Files
kupshop/bundles/External/HannahBundle/View/CartView.php
2025-08-02 16:30:27 +02:00

37 lines
827 B
PHP

<?php
declare(strict_types=1);
namespace External\HannahBundle\View;
use KupShop\KupShopBundle\Exception\RedirectException;
class CartView extends \KupShop\ContentBundle\View\CartView
{
public function getBodyVariables()
{
$this->activateCartByShareLink();
return parent::getBodyVariables();
}
private function activateCartByShareLink(): void
{
if (!($share = $this->request->get('share'))) {
return;
}
$data = json_decode(base64_decode($share), true);
foreach ($data['coupons'] as $coupon) {
$this->applyDiscountCoupon($coupon);
}
$this->cartImporter->importFromString(implode(PHP_EOL, $data['items']));
throw new RedirectException(
path('kupshop_content_cart_cart_1')
);
}
}