public function setQuantity(Buyable $buyable, $quantity = 1, $filter = [])
    {
        if ($quantity <= 0) {
            return $this->remove($buyable, $quantity, $filter);
        }

        $item = $this->findOrMakeItem($buyable, $quantity, $filter);

        if (!$item || !$this->updateOrderItemQuantity($item, $quantity, $filter)) {
            return false;
        }

        return $item;
    }
public function setQuantity(Buyable $buyable, $quantity = 1, $filter = [])
    {
        if ($quantity <= 0) {
            return $this->remove($buyable, $quantity, $filter);
        }

        $item = $this->findOrMakeItem($buyable, $quantity, $filter);

        if (!$item || !$this->updateOrderItemQuantity($item, $quantity, $filter)) {
            return false;
        }

        return $item;
    }
public function setQuantity ( Buyable $ buyable , $ quantity = 1 , $ filter = [ ] ) { if ( $ quantity <= 0 ) { return $ this -> remove ( $ buyable , $ quantity , $ filter ) ; } $ item = $ this -> findOrMakeItem ( $ buyable , $ quantity , $ filter ) ; if ( ! $ item || ! $ this -> updateOrderItemQuantity ( $ item , $ quantity , $ filter ) ) { return false ; } return $ item ; }
Sets the quantity of an item in the cart.
Will automatically add or remove item, if necessary.

@param Buyable $buyable
@param int     $quantity
@param array   $filter

@return boolean|OrderItem false or the new/existing item
Sets the quantity of an item in the cart . Will automatically add or remove item if necessary .