Stock reduced twice
-
Hi,
There is a problem when stock is reduced twice. I believe you need to replace:
wc_reduce_stock_levels($order_id);
with
wc_maybe_reduce_stock_levels( $order_id );
on line 267 in your class-wc-paysera-gateway.php file.
-
Hi,
I see that there is new version of the plugin released, but it looks like you didn’t address the issue there. Let me try to explain what problem we are having here: let’s say customer starts the payment process with Paysera, but doesn’t finish it. Then he goes back and changes payment method to something else (e.g. “Cash on delivery”). As you are calling
wc_reduce_stock_levels()
and notwc_maybe_reduce_stock_levels()
, I believe, stock is reduced twice then (because WooCommerce doesn’t mark order as_order_stock_reduced
). Could you please take a look?Hello,
When do you plan to solve this issue?
Thanks.
Dear customer,
as we already discussed before, we can not change this part, because our plugins are ready for the biggest part of the customers, in case you want to make some changes, you can do it.
When the customer comes back he may still pay for the product using Paysera and in most cases, customers want to have enough items to sell, that’s why they have stock control.
The stock level can be recovered with the status change of order, check the automatic status change in the Admin.
If you have additional questions, how you should update the code, you may write to [email protected].
Have a nice day!
Hi @paysera,
Thank you for the reply.
First of all – I don’t think you’ve discussed it with me before ??
Now regarding the issue itself. I’m not sure if you are correct. If you use
wc_maybe_reduce_stock_levels()
instead ofwc_reduce_stock_levels()
, stock still will be reduced, but in addition, order will be marked as “stock reduced”, and if some other gateway will try to reduce stock again, it won’t happen and stock won’t be reduced twice. So I don’t think that replacing this function will hurt any of your other users…Anyway, if you insist on leaving the
wc_reduce_stock_levels()
in your code, maybe you could at least add some filters and actions, so I wouldn’t have to make my changes directly in your plugin’s code? For example, if you could replace (line 267 in your class-wc-paysera-gateway.php file):wc_reduce_stock_levels($order_id);
with something like this:
if ( apply_filters( 'paysera_do_reduce_stock_levels', true, $order_id ) ) { wc_reduce_stock_levels( $order_id ); } do_action( 'paysera_after_reduce_stock_levels', $order_id );
then it wouldn’t change anything for your other users, and I wouldn’t have to change your plugin’s code after each update.
Please let me know what you think.
- This reply was modified 4 years ago by Algoritmika.
Dear customer,
Paysera is offering prepared integrations that open-sourced and we allow editing the code as you wish.
There cases that would affect our current users, just to make one integration compatible with some other needs.
We advise either to update the code for yourself, either just use automatic stock recovery, as such changes are not planned in near future, your offer is noted.
If you have additional questions, you may contact us directly [email protected].
Have a nice day!
Hey,
I can see that in 2.5.9 update changes were made to wc_maybe_reduce_stock_levels($order_id) instead of wc_reduce_stock_levels($order_id) at 267 in class-wc-paysera-gateway.php.
@algoritmika does stock reduction work fine for you after this update?
I previously had some workarounds, which kind of worked but are no longer working after current update.
How are you handling stock reduction? What are your paysera woocommerce settings under “u?sakymo būsena” tab?
Do you have custom code to handle stock reduction?
Because I have some issues, where customers abandon cart and I still get stock reduction, which is not automatically incremented back and has to be manually reset.
Also, sometimes when order is successfully completed, stock is reduced twice.
Hope you can help out,
Lukas
Hi @lukasjan123,
@algoritmika does stock reduction work fine for you after this update?
Yes, it looks like the latest release fixed it for us. At least at a first glance, I may need to test it more though…
What are your paysera woocommerce settings under “u?sakymo būsena” tab?
Our settings are:
New Order Status: Pending payment
Paid Order Status: Processing
Pending checkout: Pending paymentDo you have custom code to handle stock reduction?
The only thing we had was
wc_maybe_reduce_stock_levels()
instead ofwc_reduce_stock_levels()
. So now after the last plugin update, there is no more custom code left.Because I have some issues, where customers abandon cart and I still get stock reduction, which is not automatically incremented back and has to be manually reset.
We had similar problem (i.e. because of
wc_reduce_stock_levels()
), but now the issue is gone.As far as I know, for stock to be restored after
wc_maybe_reduce_stock_levels()
was called, order status must change to either “cancelled” or “pending”. There are two hooks forwc_maybe_increase_stock_levels()
in WooCommerce (it’s inwoocommerce\includes\wc-stock-functions.php
):add_action( 'woocommerce_order_status_cancelled', 'wc_maybe_increase_stock_levels' ); add_action( 'woocommerce_order_status_pending', 'wc_maybe_increase_stock_levels' );
Also, sometimes when order is successfully completed, stock is reduced twice.
Actually I don’t think we had anything like that, even before the latest plugin update, so I’m not really sure what’s happening there.
Hope that helps.
Thank you! Will try with your settings and see how it goes.
Sure, happy to help ?? One note though – regarding:
Also, sometimes when order is successfully completed, stock is reduced twice.
I’m now thinking that this could be related to
wc_reduce_stock_levels()
vswc_maybe_reduce_stock_levels()
issue as well. For example, if your customer starts paying with Paysera, then switches to another method, and then back to Paysera again. Not sure though… Anyway, this should be fixed already in the latest version.
- The topic ‘Stock reduced twice’ is closed to new replies.