コード例 #1
0
ファイル: CartWrapper.php プロジェクト: hd-deman/elcodi
 /**
  * Return cart from session
  *
  * If session has a cart, retrieves it and checks if exists
  * If exists, returns it
  * Otherwise, creates new one
  * If session has not a cart, creates a new one and returns it
  *
  * @return CartInterface|null Cart
  */
 public function getCartFromSession()
 {
     $cartIdInSession = $this->cartSessionManager->get();
     if (!$cartIdInSession) {
         return null;
     }
     return $this->cartRepository->findOneBy(['id' => $cartIdInSession, 'ordered' => false]);
 }
コード例 #2
0
ファイル: CartSessionWrapper.php プロジェクト: axelvnk/elcodi
 /**
  * Get cart from session
  *
  * @return CartInterface|null Cart loaded from session
  */
 protected function loadCartFromSession()
 {
     $cartIdInSession = $this->cartSessionManager->get();
     if (!$cartIdInSession) {
         return null;
     }
     $cart = $this->cartRepository->findOneBy(['id' => $cartIdInSession, 'ordered' => false]);
     return $cart instanceof CartInterface ? $cart : null;
 }
コード例 #3
0
 /**
  * Stores cart id in HTTP session when this is saved
  *
  * @param CartOnLoadEvent $event Event
  */
 public function saveCartInSession(CartOnLoadEvent $event)
 {
     $this->cartSessionManager->set($event->getCart());
 }
コード例 #4
0
 /**
  * Stores cart id in HTTP session when this is saved
  *
  * @param CartOnLoadEvent $event Event
  */
 public function onCartLoad(CartOnLoadEvent $event)
 {
     $this->cartSessionManager->set($event->getCart());
 }