コード例 #1
0
 public function addItem(CartItemInterface $item)
 {
     if ($item->getCartItemId() == null) {
         $this->items[] = $item;
     } else {
         $this->items[$item->getCartItemId()] = $item;
     }
     return $this;
 }
コード例 #2
0
ファイル: CartService.php プロジェクト: nclundsten/SpeckCart
 public function addItemToCart(CartItemInterface $item, CartInterface $cart = null)
 {
     if ($cart === null) {
         $cart = $this->getSessionCart(true);
     }
     $item->setCartId($cart->getCartId())->setAddedTime(new \DateTime());
     $this->itemMapper->persist($item);
     $this->persistCartItemChildren($item->getItems(), $item, $cart);
     $cart->addItem($item);
     return $this;
 }
コード例 #3
0
 public function persist(CartItemInterface $item)
 {
     if ($item->getCartItemId() > 0) {
         $where = new Where();
         $where->equalTo($this->itemIdField, $item->getCartItemId());
         $this->update($item, $where, $this->tableName);
     } else {
         $result = $this->insert($item, $this->tableName);
         $item->setCartItemId($result->getGeneratedValue());
     }
     return $item;
 }