fahadmahmood8 / stock-locations-for-woocommerce

This plugin will help you manage WooCommerce Products stocks through locations and also different traditional barcodes.
https://pt.wordpress.org/plugins/stock-locations-for-woocommerce/
GNU General Public License v3.0
22 stars 14 forks source link

Stock locations not being updated on order when status is changed #117

Closed gferguson78 closed 9 months ago

gferguson78 commented 2 years ago

Hi there,

I've noticed an issue on our site that happens whenever I manually change the status of an order - the stock locations are not automatically updated. I'll try and explain the issue - this has only been tested with auto-allocate enabled as that is what we use.

If an order is already in status 'processing' and stock has been automatically allocated - when I then change the status to 'pending' then stock allocations are automatically removed. This works correctly - exactly as it should.

If I then change the status back to 'processing' without making any changes to the allocations I get a message saying 'Stock in locations updated successfully!' - however the locations are not updated. The fields to allow me to manually update the allocations are still visible and when I move to another page I then get the message saying 'Partial or total stock in locations is missing in this order. Please fill the remaining stock.'

I would expect that whenever I change the status of the order from 'pending' or 'on-hold' or 'cancelled' back to 'processing' that the location data should be auto-allocated again - is this not correct?

We also use the Klarna payment plugin on our site and I've noticed that when a Klarna payment fails or is declined the order that is created sits on the backend as 'pending payment' - however the stock still sits as having been allocated. This is more of less the reverse of the issue I've listed above! I would assume that when the status goes to pending-payment then the stock allocation should be removed from the order in the same was as it does when I change the status manually. This means that when a Klarna order fails the items on the order can no longer be purchased until I manually go in to change the pending order and remove the stock allocation.

I can provide access to our dev site for testing these issues if required.

Many thanks, Gordon

fahadmahmood8 commented 2 years ago

Dear Gordon,

I will start working on the issues related to stock locations plugin soon. I appreciate that you offered the dev site access for testing the reported issues. Please wait a little more as I am completing another task and soon will be with you.

On Thu, Dec 2, 2021 at 4:15 AM gferguson78 @.***> wrote:

Hi there,

I've noticed an issue on our site that happens whenever I manually change the status of an order - the stock locations are not automatically updated. I'll try and explain the issue - this has only been tested with auto-allocate enabled as that is what we use.

If an order is already in status 'processing' and stock has been automatically allocated - when I then change the status to 'pending' then stock allocations are automatically removed. This works correctly - exactly as it should.

If I then change the status back to 'processing' without making any changes to the allocations I get a message saying 'Stock in locations updated successfully!' - however the locations are not updated. The fields to allow me to manually update the allocations are still visible and when I move to another page I then get the message saying 'Partial or total stock in locations is missing in this order. Please fill the remaining stock.'

I would expect that whenever I change the status of the order from 'pending' or 'on-hold' or 'cancelled' back to 'processing' that the location data should be auto-allocated again - is this not correct?

We also use the Klarna payment plugin on our site and I've noticed that when a Klarna payment fails or is declined the order that is created sits on the backend as 'pending payment' - however the stock still sits as having been allocated. This is more of less the reverse of the issue I've listed above! I would assume that when the status goes to pending-payment then the stock allocation should be removed from the order in the same was as it does when I change the status manually. This means that when a Klarna order fails the items on the order can no longer be purchased until I manually go in to the pending order

I can provide access to our dev site for testing these issues if required.

Many thanks, Gordon

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP5CRHWTM3PHVVGDSKDUO2UAJANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

gferguson78 commented 2 years ago

Thanks Fahad,

That's great to hear. If I can help at all please let me know. I've already setup a fairly basic 'smart' order allocation system for the plugin that checks stock availability over both our branches and it can then allocate stock to a single branch if they have everything in the order in stock.

Gordon

gferguson78 commented 2 years ago

Just a quick update on the issue I'm having with stock being allocated to orders which are pending payment. It seems that stock is being allocated to orders too early in the sales process. Stock is allocated and reduced using the 'woocommerce_new_order_item' hook which is triggered whenever an order is created. I believe the default behaviour for WooCommerce orders is that stock is allocated and deducted whenever an order has moved to either on-hold or processing status. I've tried disabling the SLW plugin and that does seem to be the way that it works normally.

The main issue with stock being allocated so early is that if the customers payment fails or if they cancel the payment process, the order has already been created and the stock has been allocated to it and will no longer be purchaseable by anyone else. Payment plugins like Klarna or other finance plugins have to create the order in WooCommerce with 'pending payment' status before the customer goes to complete the application process.

Is it possible to modify the behaviour of the plugin so that stock only gets allocated and deducted after the order status changes to on-hold or processing? This would solve the issue we are currently experiencing.

Many thanks, Gordon

fahadmahmood8 commented 2 years ago

Dear Gordon,

I have tested the plugin, you are right about the stock allocation but in case of failed or canceled status, stock gets restored for sure. And I have recently made two more options visible in the bottom of the settings page, please check those and let me know if you are synchronized with me?

On Tue, Dec 7, 2021 at 2:58 AM gferguson78 @.***> wrote:

Just a quick update on the issue I'm having with stock being allocated to orders which are pending payment. It seems that stock is being allocated to orders too early in the sales process. Stock is allocated and reduced using the 'woocommerce_new_order_item' hook which is triggered whenever an order is created. I believe the default behaviour for WooCommerce orders is that stock is allocated and deducted whenever an order has moved to either on-hold or processing status. I've tried disabling the SLW plugin and that does seem to be the way that it works normally.

The main issue with stock being allocated so early is that if the customers payment fails or if they cancel the payment process, the order has already been created and the stock has been allocated to it and will no longer be purchaseable by anyone else. Payment plugins like Klarna or other finance plugins have to create the order in WooCommerce with 'pending payment' status before the customer goes to complete the application process.

Is it possible to modify the behaviour of the plugin so that stock only gets allocated and deducted after the order status changes to on-hold or processing? This would solve the issue we are currently experiencing.

Many thanks, Gordon

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-987270818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP7ZMBYAQ7BYWFHZC7DUPUWZFANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

JReeeee commented 2 years ago

Hey, We are having this same exact problem. We need to manually re-stock the stocks after failed payment. That new update didn't help. It still doesnt automatically re-stock.

fahadmahmood8 commented 2 years ago

In the latest version, there is a help section and an urgent help option. We can schedule a screen sharing session through Google meeting to understand this issue better. Are you comfortable with this?

On Sun, Dec 12, 2021 at 2:33 PM JReeeee @.***> wrote:

Hey, We are having this same exact problem. We need to manually re-stock the stocks after failed payment. That new update didn't help. It still doesnt automatically re-stock.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-991863393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP2LSVCDJ6J3K3ZRELLUQRT7FANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

JReeeee commented 2 years ago

In the latest version, there is a help section and an urgent help option. We can schedule a screen sharing session through Google meeting to understand this issue better. Are you comfortable with this? On Sun, Dec 12, 2021 at 2:33 PM JReeeee @.***> wrote: Hey, We are having this same exact problem. We need to manually re-stock the stocks after failed payment. That new update didn't help. It still doesnt automatically re-stock. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#117 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP2LSVCDJ6J3K3ZRELLUQRT7FANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. -- Thanks, Fahad

Hey, this sounds good. If we just could get this fixed otherwise the plugin is working like a charm.

fahadmahmood8 commented 2 years ago

Just let me know whenever you're comfortable, I will be in the meeting room.

On Sun, Dec 12, 2021 at 7:19 PM JReeeee @.***> wrote:

In the latest version, there is a help section and an urgent help option. We can schedule a screen sharing session through Google meeting to understand this issue better. Are you comfortable with this? … <#m-2403839052763481890> On Sun, Dec 12, 2021 at 2:33 PM JReeeee @.***> wrote: Hey, We are having this same exact problem. We need to manually re-stock the stocks after failed payment. That new update didn't help. It still doesnt automatically re-stock. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#117 (comment) https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-991863393>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP2LSVCDJ6J3K3ZRELLUQRT7FANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . -- Thanks, Fahad

Hey, this sounds good. If we just could get this fixed otherwise the plugin is working like a charm.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-991906540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCPYE6HVKM3CCX4ZESX3UQSVNZANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

JReeeee commented 2 years ago

Let's meet in 1 hour if thats good for you.

fahadmahmood8 commented 2 years ago

Sure, drop another email whenever you open the meeting room and I will add you to start meeting.

On Sun, Dec 12, 2021 at 7:24 PM JReeeee @.***> wrote:

Let's meet in 1 hour if thats good for you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-991907271, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP7K7CBYT4BWFTHCD5DUQSWAFANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

JReeeee commented 2 years ago

Alright, lets go

JReeeee commented 2 years ago

Im here, on the waiting room

JReeeee commented 2 years ago

Hey,

Since you didnt join. Shall we book good time thats suitable for you?

fahadmahmood8 commented 2 years ago

I am available.

On Sun, Dec 12, 2021 at 9:16 PM JReeeee @.***> wrote:

Hey,

Sice you didnt join. Shall we book good time thats suitable for you?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-991926055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP7NNDLVZHJSD5TFFDTUQTDFZANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

JReeeee commented 2 years ago

Here i am

gferguson78 commented 2 years ago

Hi there,

I have tested this this morning but the issue is still the same. Stock is being deducted too early in the order process. It's being deducted as soon as the order is created, not when the order goes to status 'processing'. When I create a test order using Klarna or finance an order is created on the system as status 'pending payment'. Stock is being deducted by the plugin at this point when it shouldn't be. If the customer then abandons the checkout process for Klarna/finance then the order sits on our system as 'pending payment' and the stock remains deducted and can't be purchsed by anyone else. It won't go back into stock until we manually update the order status to cancelled or failed. We have no order hold time setup on our system.

You can find out more info about the Klarna order flow here: https://krokedil.com/new-flow-in-klarna-checkout-for-woocommerce/

The main issue we have is this:

If a customer is buying a one-off product from our site using Klarna or finance but their application gets rejected they can't then go back to try a different method of payment as the stock in their cart has now been allocated to their previous order attempt and is now out of stock and unable to be purchased.

I would recommend that the stock should only be deducted by the plugin when payment has been completed by the customer and the status of the order is moved to 'processing'. This would mean changing the 'newOrderItemAllocateStock' hook from 'woocommerce_new_order_item' to run instead at 'woocommerce_order_status_processing' - this is more in line with the way that WooCommerce allocates stock in general. It would however have to be hooked in before order emails are processed to be able to send out emails to each location stock location.

I have done some experimenting with this so feel free to contact me directly and I can explain how far I got with this. I also have an idea for smart order allocation - to allow the order to be allocated to a single location if they have all of the order items in stock.

Many thanks, Gordon

fahadmahmood8 commented 2 years ago

Dear Gordon,

We appreciate the detailed email. We are not sure if you are aware or not but sometimes it becomes hard to test the things when we don't have the same setup as clients/users are having on their websites. So we request them to join us on Google meetings or Skype for better understanding. If you are comfortable, please schedule a meeting with us through the help section, urgent help link.

Stock is being updated/deducted on the product page once you use the add to cart button. You are right, it is performing this action earlier. But we cannot immediately change something without having the ripple effects in our minds.

You were manually updating the status back but for 3 order statuses we have made sure with the checkbox available on settings page including failed, pending and canceled order that location stock should be restored. And you don't need to manually restore it, did you notice those new changes on the settings page? Please give it a try.

We appreciate your findings about changing the 'newOrderItemAllocateStock' hook from 'woocommerce_new_order_item' to run instead at 'woocommerce_order_status_processing'.

About smart allocation, we would love to know about it and as you have experimented with the above mentioned hook change, please give me an opportunity to learn it from you. We are available according to your convenient time.

On Mon, Dec 13, 2021 at 5:18 PM gferguson78 @.***> wrote:

Hi there,

I have tested this this morning but the issue is still the same. Stock is being deducted too early in the order process. It's being deducted as soon as the order is created, not when the order goes to status 'processing'. When I create a test order using Klarna or finance an order is created on the system as status 'pending payment'. Stock is being deducted by the plugin at this point when it shouldn't be. If the customer then abandons the checkout process for Klarna/finance then the order sits on our system as 'pending payment' and the stock remains deducted and can't be purchsed by anyone else. It won't go back into stock until we manually update the order status to cancelled or failed. We have no order hold time setup on our system.

You can find out more info about the Klarna order flow here: https://krokedil.com/new-flow-in-klarna-checkout-for-woocommerce/

The main issue we have is this:

If a customer is buying a one-off product from our site using Klarna or finance but their application gets rejected they can't then go back to try a different method of payment as the stock in their cart has now been allocated to their previous order attempt and is now out of stock and unable to be purchased.

I would recommend that the stock should only be deducted by the plugin when payment has been completed by the customer and the status of the order is moved to 'processing'. This would mean changing the 'newOrderItemAllocateStock' hook from 'woocommerce_new_order_item' to run instead at 'woocommerce_order_status_processing' - this is more in line with the way that WooCommerce allocates stock in general. It would however have to be hooked in before order emails are processed to be able to send out emails to each location stock location.

I have done some experimenting with this so feel free to contact me directly and I can explain how far I got with this. I also have an idea for smart order allocation - to allow the order to be allocated to a single location if they have all of the order items in stock.

Many thanks, Gordon

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-992422167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP3ZPTDSNSM5VTKWGALUQXP7VANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--

Thanks,

Fahad

gferguson78 commented 2 years ago

I'd be more than happy to contact you via Google Meetings. Please let me know when would suit and we can arrange this.

The new changes for cancelled/pending & failed orders are very welcome but unfortunately they don't fix the issue I have with Klarna payments or when a customers payment fails. The order always stays in 'pending payment' and doesn't change status until I manually change it or delete the order so the stock allocation is never removed until it gets changed manually.

Many thanks, Gordon

fahadmahmood8 commented 2 years ago

I will let you know the time. Please wait as I am working on other points which are in final testing phase.

On Thu, 16 Dec 2021, 8:02 pm gferguson78, @.***> wrote:

I'd be more than happy to contact you via Google Meetings. Please let me know when would suit and we can arrange this.

The new changes for cancelled/pending & failed orders are very welcome but unfortunately they don't fix the issue I have with Klarna payments or when a customers payment fails. The order always stays in 'pending payment' and doesn't change status until I manually change it or delete the order so the stock allocation is never removed until it gets changed manually.

Many thanks, Gordon

— Reply to this email directly, view it on GitHub https://github.com/fahadmahmood8/stock-locations-for-woocommerce/issues/117#issuecomment-995898758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLCP3C6MOHLNHGCDJOWBTURH5Q5ANCNFSM5JFWRAWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.*** .com>

chingologram commented 9 months ago

Hi. We are having this exact same issue. I would be glad to join a meeting to discuss workarounds. Cheers!

fahadmahmood8 commented 9 months ago

Perfect, lets connect in the next week. Let me know how would you like to connect?

chingologram commented 9 months ago

@fahadmahmood8 I can meet on Tuesday or Thursday afternoon (11AM - 3 PM UTC). Let me know when and I will set up the meeeting and send you the link and pass some minutes before.

fahadmahmood8 commented 9 months ago

Ok, you may schedule a meeting and we will connect.

chingologram commented 8 months ago

@fahadmahmood8 sorry for not reaching back to you. I can still do 11AM - 3 PM UTC any day of this week if you are still available.

fahadmahmood8 commented 8 months ago

I am still available and you can ping me on slack directly or reach me through the mail address mentioned under the help tab on the settings page of the plugin.

chingologram commented 6 months ago

@fahadmahmood8 I can meet to discuss this issue as it's still happening in our site. I'll contact you via email to send you meeting link. Also, could you please reopen this issue? So if someone is troubleshooting this problem, they can quickly see this is an active issue in the plugin?

Cheers!

fahadmahmood8 commented 6 months ago

No need to reopen this issue because this plugin is evolving with every single round of usage. I am available for support and continuously improving it. As it has multi directions and every test environment has different parameters so things are taking time to get a shape.