Paysbuy do not reduce stock on Woocommerce

I have helped the development of e-commerce site for the client other day and Paysbuy gateway did not work as expected so I have decided to investigate about this. The platform I used was WordPress with Woocommerce plugin for e-commerce site development. My client have registered to use Paysbuy as payment gateway so I have downloaded the Paysbuy plugin that work with Woocommerce. The transaction went fine but it did not reduce the stock amount as expected. I did not know what was going on so first I went through the document and found followings…

On-Hold – Awaiting payment – stock is reduced, but you need to confirm payment
Processing – Payment received and stock has been reduced – the order is awaiting fulfillment. All product orders require processing
Completed – Order fulfilled and complete – requires no further action

So in the document it say that “On-Hold” status will reduce the stock amount. “Check Payment” and “Paypal” does reduce the stock amount as expected but Paysbuy did not so I compared three codes…

Payment Method: Check Payment

File: wp-content/plugins/woocommerce/includes/gateways/cheque/class-wc-gateway-cheque.php

Payment Method: Paypal

File: wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php

As you can see, Woocommerce default payment methods include “$order->reduce_order_stock();” which seems to me as function that reduces the stock amount. Let’s see Paysbuy code now…

Payment Method: Paysbuy

File: wp-content/plugins/woocommerce-paysbuy-payment-gateway/wc_paysbuy_payment_gateway.php

So the code do not include “$order->reduce_order_stock();”  and no wonder why the gateway plugin does not reduce the stock amount. Simple solution was just add the code.

Tested out the code and seems like everything is working as expected… I should inform the developer as the plugin is out on github now.


Developer agreed that this fix is needed so I fixed it for them. Github Issue

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.