示例#1
0
文件: Cart.php 项目: falkbizz/cart
 /**
  * Add an item to the cart.
  *
  * @param CartItem $cartItem
  */
 public function add(CartItem $cartItem)
 {
     $itemId = $cartItem->getId();
     // if item already exists in the cart, just update the quantity,
     // otherwise add it as a new item
     if ($this->has($itemId)) {
         $existingItem = $this->find($itemId);
         $existingItem->quantity += $cartItem->quantity;
     } else {
         $this->items[] = $cartItem;
     }
 }
示例#2
0
 public function testGettingIdPropertyReturnsItemId()
 {
     $item = new CartItem();
     $this->assertSame($item->getId(), $item->id);
 }