Change stock deduction to on completion

  • Posts: 8
  • Thank you received: 0
12 years 3 months ago #60068

Hi,

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.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
12 years 2 months ago #60130

Hi,

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.

  • Posts: 8
  • Thank you received: 0
12 years 2 months ago #60146

Hi,

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.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
12 years 2 months ago #60227

Why not simply do everything in the onAfterOrderUpdate event ? You still have the product in the $object after it has been added in the db.

Please Log in or Create an account to join the conversation.

  • Posts: 66
  • Thank you received: 0
12 years 2 months ago #60438

Hi, I am after the same thing, I want to be able to only reduce my stock when the order has been paid for, I have a read on the posts above but can't understand what was done, is there any chance of some clarification please?

Daniel, would you be able to share the plugin?

Many thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
12 years 2 months ago #60492

Hi,

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.

  • Posts: 167
  • Thank you received: 8
  • Hikashop Essential
11 years 11 months ago #77160

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

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 11 months ago #77269

Hi Ian,

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: ianspeed

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 2
11 years 5 months ago #105035

Ian said:

"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.

  • Posts: 167
  • Thank you received: 8
  • Hikashop Essential
11 years 5 months ago #105037

Hi Melisari,
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

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 2
11 years 5 months ago #105038

But is not working for me :( I dont know why.

Please Log in or Create an account to join the conversation.

  • Posts: 167
  • Thank you received: 8
  • Hikashop Essential
11 years 5 months ago #105040

Is PayPal actually sending a response back? Would you normally get a confirmation of order payed, or does just stay at created when the order is created and payed for?

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 2
11 years 5 months ago #105041

At first, the problem appeared only when a client closed the paypal window, i asked for help, and nicolas recommend this:

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.

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #105210

Hi,

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 ?

The following user(s) said Thank You: melisari

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 2
11 years 5 months ago #105480

Thank you Xavier! Jerome already helped me with this. He enter my site and fixed everything. You guys have the best support in the joomla word, thank you so much for your efforts and keep going!

Please Log in or Create an account to join the conversation.

Time to create page: 0.106 seconds
Powered by Kunena Forum