public function createEmptyCart(CartCreateEvent $cartCreateEvent)
    {
        $cart = new CartModel();

        $cart->setCurrency($this->getSession()->getCurrency(true));

        /** @var CustomerModel $customer */
        if (null !== $customer = $this->getSession()->getCustomerUser()) {
            $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId()));
        }

        $this->getSession()->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->getSession()->set("cart_use_cookie", "");
        }

        $cartCreateEvent->setCart($cart);
    }
public function createEmptyCart(CartCreateEvent $cartCreateEvent)
    {
        $cart = new CartModel();

        $cart->setCurrency($this->getSession()->getCurrency(true));

        /** @var CustomerModel $customer */
        if (null !== $customer = $this->getSession()->getCustomerUser()) {
            $cart->setCustomer(CustomerQuery::create()->findPk($customer->getId()));
        }

        $this->getSession()->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->getSession()->set("cart_use_cookie", "");
        }

        $cartCreateEvent->setCart($cart);
    }
public function createEmptyCart ( CartCreateEvent $ cartCreateEvent ) { $ cart = new CartModel ( ) ; $ cart -> setCurrency ( $ this -> getSession ( ) -> getCurrency ( true ) ) ; /** @var CustomerModel $customer */ if ( null !== $ customer = $ this -> getSession ( ) -> getCustomerUser ( ) ) { $ cart -> setCustomer ( CustomerQuery :: create ( ) -> findPk ( $ customer -> getId ( ) ) ) ; } $ this -> getSession ( ) -> 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 -> getSession ( ) -> set ( "cart_use_cookie" , "" ) ; } $ cartCreateEvent -> setCart ( $ cart ) ; }
Create a new, empty cart object, and assign it to the current customer, if any.

@param CartCreateEvent $cartCreateEvent
Create a new empty cart object and assign it to the current customer if any .