/** * Create a new, empty cart object, and assign it to the current customer, if any. * * @param CartCreateEvent $cartCreateEvent */ public function createEmptyCart(CartCreateEvent $cartCreateEvent) { $cart = new CartModel(); $cart->setCurrency($this->session->getCurrency(true)); if (null !== ($customer = $this->session->getCustomerUser())) { $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId())); } $cartCreateEvent->setCart($cart); }
/** * Create a new, empty cart object, and assign it to the current customer, if any. * * @param CartCreateEvent $cartCreateEvent */ public function createEmptyCart(CartCreateEvent $cartCreateEvent) { $cart = new CartModel(); $cart->setCurrency($this->session->getCurrency(true)); if (null !== ($customer = $this->session->getCustomerUser())) { $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId())); } $this->session->setSessionCart($cart); if (ConfigQuery::read("cart.use_persistent_cookie", 1) == 1) { // set cart_use_cookie to "" to remove the cart cookie // see Thelia\Core\EventListener\ResponseListener $this->session->set("cart_use_cookie", ""); } $cartCreateEvent->setCart($cart); }