public function add($id, $name, $price, $quantity, $options = [])
    {
        $cartItem = new CartItem($id, $name, $price, $quantity, $options);
        $uniqueId = $cartItem->getUniqueId();

        if ($this->content->has($uniqueId)) {
            $cartItem->quantity += $this->content->get($uniqueId)->quantity;
        }

        $this->content->put($uniqueId, $cartItem);

        return $cartItem;
    }
public function add($id, $name, $price, $quantity, $options = [])
    {
        $cartItem = new CartItem($id, $name, $price, $quantity, $options);
        $uniqueId = $cartItem->getUniqueId();

        if ($this->content->has($uniqueId)) {
            $cartItem->quantity += $this->content->get($uniqueId)->quantity;
        }

        $this->content->put($uniqueId, $cartItem);

        return $cartItem;
    }
public function add ( $ id , $ name , $ price , $ quantity , $ options = [ ] ) { $ cartItem = new CartItem ( $ id , $ name , $ price , $ quantity , $ options ) ; $ uniqueId = $ cartItem -> getUniqueId ( ) ; if ( $ this -> content -> has ( $ uniqueId ) ) { $ cartItem -> quantity += $ this -> content -> get ( $ uniqueId ) -> quantity ; } $ this -> content -> put ( $ uniqueId , $ cartItem ) ; return $ cartItem ; }
Add an item to the shopping cart.

If an item is already in the shopping cart then we simply update its
quantity.

@param string|int $id
@param string     $name
@param int|float  $price
@param int        $quantity
@param array      $options

@return CartItem
Add an item to the shopping cart .