- Posts: 8
- Thank you received: 0
Change stock deduction to on completion
I need to change the way stock is deducted when an order goes through, at the moment stock is deducted on order creation but I need to deduct stock on order completion. I have created a plugin and used the trigger onBeforeOrderUpdate and onAfterOrderUpdate. I have successfully changed the stock deduction to happen when the order is completed, but I am having trouble getting it to work correctly with order modifications (Add an existing product). The order is modified before I can catch it in the onBeforeOrderUpdate trigger.
Your help would be appreciated.
Kind Regards
Dan
Please Log in or Create an account to join the conversation.
Orders are never modified before the onBeforeOrderUpdate trigger. So that's not possible.
However, the product is added to the order before the order information is updated. Is that what you're talking about ?
Please Log in or Create an account to join the conversation.
Yes, what I wanted to do was use onBeforeOrderUpdate to catch the product before it was added to the order then in the onAfterOrderUpdate deduct the stock from the added product using a database call. Is there any way this can be done?
Kind Regards
Dan
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Daniel, would you be able to share the plugin?
Many thanks
Please Log in or Create an account to join the conversation.
You would have to update back the quantity of the products in the onAfterOrderCreate event so that the stock is left unchanged using a MySQL query on the hikashop_product table.
And then you would have to update the stock in the onAfterOrderUpdate event after loading the order data with the loadFullOrder function of the class.order file of HikaShop. That will also require using a MySQL query on the hikashop_product table.
These would have to be implemented in a hikashop plugin.
Please Log in or Create an account to join the conversation.
Hope you are well.
Just had to ask,is there going to be a "order confirmed" stock deduction option as apposed to a "order created" stock deduction, as my customer had two one off items go out of stock when the customer failed to pay at paypal...
Thanks
Ian
Please Log in or Create an account to join the conversation.
We have put your request in our TODO list for the next HikaShop release.
Best regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
"Hi Nicolas,
Hope you are well.
Just had to ask,is there going to be a "order confirmed" stock deduction option as apposed to a "order created" stock deduction, as my customer had two one off items go out of stock when the customer failed to pay at paypal...
Thanks
Ian"
This is what is happening to me. Is still in the "to do´s" list, or is something that its suppouse to be working now? A lot of people go to paypal and doesnt pay.
Please Log in or Create an account to join the conversation.
This is actually implemented now. If you look under the configuration and main, then look at Product options you'll see the "Update the product stock on confirmed status" Radio box...
Hope this helps.
Ian
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
There are two solutions in HikaShop to help you here:
1. You use the "order auto cancel" plugin (you need to setup the cron task of the configuration for that) in order to cancel automatically orders after X hours without payment.
2. You remove the stock only when the order is confirmed, and not when the order is created. You can toggle the option "Update the product stock on confirmed status" of the configuration for that.
I already had the 2 option implemented and still had the problem, so, i did number 1. And now, the stock is removed always when the client goes to paypal, even when the client click on "cancel and return".
Thank you so much for your help, my client have some unique products that can be sold only 4 times and some of them, just once, so, i need to solve this.
Please Log in or Create an account to join the conversation.
And you have the latest version of HikaShop ? v2.1.3 ?
Can yuou give us a backend access and a ftp access too in order to debug ?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.