Jump to content

Avoid increasing of product quantity if the order status changed to “CANCEL”?


trace

Recommended Posts

Where is it edited? And how?
OrderDetail.php or OrderHistory.php?
 

Necessary:
 
If  product has feature_id == 2 && feature_value == 1 (This has already been created and applied to certain products) , do not update quantity, if status changed to "CANCEL" (but not "ERROR").
Edited by trace (see edit history)
Link to comment
Share on other sites

You post misses your prestashop version in use. Up to V 1.6. the corresponding function is part of orderhistory.php. The corresponding lines look like this one

StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);

You just needed to enhance the pre-existing if statements with your attribut and feature ids.

If you use PS 1.7 the story might be completely different.

  • Like 1
Link to comment
Share on other sites

Have you read my post #2 ? It points you to the place where you have to implement the enhancement.

I mean I don't know how to do that. I am not a php Developer.

I trying to do something, but not enough knowledge.

Link to comment
Share on other sites

Then it could be an option to get yourself familiar with php - at least trying to get in. But trying to change prestashop core without any PHP knowledge might end in troubles.

 

The culprit for your scenario is the following:

The feature itself isn't stored on the products table. You needed to scan the feature table for the product first. If your feature is connected to the product which is cancelled, do not perform the stock action. In my opinion, it's not a good idea to hook up the change on an attribute value. Instead I would as example create a invisible "virtual" category and put in the related products to this category. Or flag it somehow else.

 

Long story in short:

it's a bit more than 10 minutes to achieve this - even for an experienced developer.

The option might be to ask and pay a developer to do it for you.

  • Like 1
Link to comment
Share on other sites

The culprit for your scenario is the following:

The feature itself isn't stored on the products table. You needed to scan the feature table for the product first. If your feature is connected to the product which is cancelled, do not perform the stock action. In my opinion, it's not a good idea to hook up the change on an attribute value. Instead I would as example create a invisible "virtual" category and put in the related products to this category. Or flag it somehow else.

Fully understood. If it's too complicated, then maybe it's worth trying with status?

 

When the buyer makes an order using the module, the order is assigned a new status "Preorder" in config "PS_OS_PREORDER" (It already works.)

 

New question: 

How to edit the file OrderHistory.php? If the order was "PS_OS_PREORDER" and changed to "PS_OS_CANCEL" do not increase the quantity of the products?

 

P.S: Sorry for my English

Link to comment
Share on other sites

An order may have several products - so order status is also not the way I would handle this. On the other hand: I don't understand what your issue is. If an order is placed, the stock decreases. If an order is cancelled, the stock increases with the same quantity. That's the way it should work.

Link to comment
Share on other sites

An order may have several products - so order status is also not the way I would handle this. On the other hand: I don't understand what your issue is. If an order is placed, the stock decreases. If an order is cancelled, the stock increases with the same quantity. That's the way it should work.

I has module for preorder. In my case, buyers can pre-order only one product. This module is activated if the quantity of the product has 1 unit and the product has the feature "Pre-order". And this orders in admin panel has status PS_OS_PREORDER. If buyer do pre-order, then the quantity of products does not decrease. 

Just one problem - If I changed status to "CANCEL" it increases the quantity of product.

 

P.S: Once again, sorry for my English.

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

I got it now. So if it is a bug (according to your detailled description it looks like) you might search the forum for others who have encountered the same problem. Or find somebody to do the change for you by fixing orderhistory.php. Or try to delete the product from the order before you cancel the order. This handling is done somehow different from the direct cancel actions.

Edited by Scully (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year 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...