public function removeOrderItem(OrderItem $item, $quantity = null)
    {
        $order = $this->current();

        if (!$order) {
            return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.'));
        }

        if (!$item || $item->OrderID != $order->ID) {
            return $this->error(_t(__CLASS__ . '.ItemNotFound', 'Item not found.'));
        }

        //if $quantity will become 0, then remove all
        if (!$quantity || ($item->Quantity - $quantity) <= 0) {
            $item->delete();
            $item->destroy();
        } else {
            $item->Quantity -= $quantity;
            $item->write();
        }

        return true;
    }
public function removeOrderItem(OrderItem $item, $quantity = null)
    {
        $order = $this->current();

        if (!$order) {
            return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.'));
        }

        if (!$item || $item->OrderID != $order->ID) {
            return $this->error(_t(__CLASS__ . '.ItemNotFound', 'Item not found.'));
        }

        //if $quantity will become 0, then remove all
        if (!$quantity || ($item->Quantity - $quantity) <= 0) {
            $item->delete();
            $item->destroy();
        } else {
            $item->Quantity -= $quantity;
            $item->write();
        }

        return true;
    }
public function removeOrderItem ( OrderItem $ item , $ quantity = null ) { $ order = $ this -> current ( ) ; if ( ! $ order ) { return $ this -> error ( _t ( __CLASS__ . '.NoOrder' , 'No current order.' ) ) ; } if ( ! $ item || $ item -> OrderID != $ order -> ID ) { return $ this -> error ( _t ( __CLASS__ . '.ItemNotFound' , 'Item not found.' ) ) ; } //if $quantity will become 0, then remove all if ( ! $ quantity || ( $ item -> Quantity - $ quantity ) <= 0 ) { $ item -> delete ( ) ; $ item -> destroy ( ) ; } else { $ item -> Quantity -= $ quantity ; $ item -> write ( ) ; } return true ; }
Remove a specific order item from cart

@param  OrderItem $item
@param  int       $quantity - number of items to remove or leave `null` to remove all items (default)
@return boolean success/failure
Remove a specific order item from cart