Hi @qwik3r
Payment gateways are not responsible for the order creation logic. That is all handled by WooCommerce and WooCommerce provides the order to the payment gateway when it’s time to process the payment.
Here is how the WC order creation logic works in the WC_Checkout::create_order
method:
1. check if there is an existing order stored in the order_awaiting_payment
session variable.
2. If session variable exists, verify order’s has equals the cart hash. The has is an md5 hash of the cart contents and total. If the hash doesn’t match, a new order is created.
3. Verify that the order’s status is ‘pending’ or ‘failed’.
If any of those conditions does not pass, a new order is created.
You could also be using a plugin that hooks into the woocommerce_create_order
filter and provides its own order creation logic.
Kind Regards
Thread Starter
qwik3r
(@qwik3r)
I’m aware that payment gateways are not responsible for the order status, but let’s follow some logic.
-Installs Payment Gateway for PayPal Plugin
-Gets duplicate orders
Obviously there is something going on that maybe the order doesn’t complete or something else causing the duplicate orders.
The conclusion is that after installing the plugin this has been occuring.
@qwik3r
Here is a good thread showing how a merchant was convinced that our Stripe plugin was causing duplicate orders. Turns out it was their server configuration.
https://wordpress.org/support/topic/duplicate-orders-help/
The cause for a duplicate order can be varied but what I can confirm is that it is in all likelihood not related at all to the PayPal plugin. There isn’t any logic in the PayPal plugin that would affect WooCommerce’s determination logic for creating a new order.
Further evidence for that is the fact that your duplicate orders have a pending
status meaning that payment for them was not even attempted. So it appears your duplication is happening before the payment logic is called.
Thanks,
Thread Starter
qwik3r
(@qwik3r)
Is there a debug mode or something that can be utilized to try to figure this out?
All logs are stored within WooCommerce > Status > Logs.
You can enable this plugin’s debug log via the API Settings page. However, this plugin logs failed API requests which isn’t you’re issue so not sure how much assistance that will be for this particular case.
Thanks,