Jump to content

Avoid decrease of product quantity when the order status is still "Process"


winresh24

Recommended Posts

How to avoid decreasing of a product quantity when it's still in the "Process" and update when

the order was shipped or delivered? Anyone Could help me with this?

 

Right now I add this


$id_order_state != Configuration::get('PS_OS_PREPARATION')

 in the statement of checkProductStock in OrderDetail.php and yes it doesn't decrease the quantity but when the order

was shipped and delivered it doesn't change too.

 




  


protected function checkProductStock($product, $id_order_state)
    {
        if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_PREPARATION')) {
            $update_quantity = true;
            if (!StockAvailable::dependsOnStock($product['id_product'])) {
                $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']);
            }


            if ($update_quantity) {
                $product['stock_quantity'] -= $product['cart_quantity'];
            }


            if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
                $this->outOfStock = true;
            }
            Product::updateDefaultAttribute($product['id_product']);
        }
    }


Thanks

Edited by winresh24 (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...