public function updateOrderItemQuantity(OrderItem $item, $quantity = 1, $filter = [])
    {
        $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.'));
        }

        $buyable = $item->Buyable();
        // If an extension throws an exception, error out
        try {
            $order->extend('beforeSetQuantity', $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item->Quantity = $quantity;

        // If an extension throws an exception, error out
        try {
            $order->extend('afterSetQuantity', $item, $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item->write();
        $this->message(_t(__CLASS__ . '.QuantitySet', 'Quantity has been set.'));

        return true;
    }
public function updateOrderItemQuantity(OrderItem $item, $quantity = 1, $filter = [])
    {
        $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.'));
        }

        $buyable = $item->Buyable();
        // If an extension throws an exception, error out
        try {
            $order->extend('beforeSetQuantity', $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item->Quantity = $quantity;

        // If an extension throws an exception, error out
        try {
            $order->extend('afterSetQuantity', $item, $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item->write();
        $this->message(_t(__CLASS__ . '.QuantitySet', 'Quantity has been set.'));

        return true;
    }
public function updateOrderItemQuantity ( OrderItem $ item , $ quantity = 1 , $ filter = [ ] ) { $ 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.' ) ) ; } $ buyable = $ item -> Buyable ( ) ; // If an extension throws an exception, error out try { $ order -> extend ( 'beforeSetQuantity' , $ buyable , $ quantity , $ filter ) ; } catch ( Exception $ exception ) { return $ this -> error ( $ exception -> getMessage ( ) ) ; } $ item -> Quantity = $ quantity ; // If an extension throws an exception, error out try { $ order -> extend ( 'afterSetQuantity' , $ item , $ buyable , $ quantity , $ filter ) ; } catch ( Exception $ exception ) { return $ this -> error ( $ exception -> getMessage ( ) ) ; } $ item -> write ( ) ; $ this -> message ( _t ( __CLASS__ . '.QuantitySet' , 'Quantity has been set.' ) ) ; return true ; }
Update quantity of a given order item

@param  OrderItem $item
@param  int       $quantity the new quantity to use
@param  array     $filter
@return boolean success/failure
Update quantity of a given order item