Jump to content

Don't decrease quantities on certain order statuses


Recommended Posts

Hi

 

as per title of the post, could someone address me to files or functions where I can set exceptions, that is: on certain status changes or creation of orders from BO with certain statuses, the quantity of the products of the order is not decreased.

 

I guess it is a matter of some if-else in some PHP controller. As I am pretty skilled, I think to manage to have it, but I have no idea, by now, in which file to put my hands :)

 

Thanks a lot!

Fabio

Link to comment
Share on other sites

First of all, thank you for your kindness!

 

In AdminOrdersController.php (and this should cover both the cases where I set the order for the first time and updating its status, right?) I find indeed these lines

// Update product available quantity
StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id, ($old_quantity - $order_detail->product_quantity), $order->id_shop);

So, I could have it like

// Update product available quantity
StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id, ($old_quantity), $order->id_shop);

and quantity should not then decrease.

 

Now, I noticed that this is in the function

 

public function ajaxProcessEditProductOnOrder()

 

where I don't think I can have the current order status id by querying order details. Should I query the DB directly?

After all, in this function I know the order id and could ask the ps_order_history to give me the last state for that order and perform some if-else statement in the lines above.

 

What do you think? Is the right approach? :)

 

Most of all, I was asking myself... Prestashop must have somewhere coded that upon some state changes the quantity does not decrease. For example, if I change from "preparing" to "sent" (just guessing the english names...) the quantity does not decrease. Do you know where this is actually decided? In the table ps_orders_state I do not see any column stating this (logable, shipped, paid, etc.)

 

Thank you very much!

 

Fabio

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...