Home › Forums › WoodMart support forum › Duplicate orders are created.
Duplicate orders are created.
- This topic has 4 replies, 2 voices, and was last updated 1 year, 1 month ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
March 10, 2024 at 10:29 pm #547814
bitpublimediaParticipantHello,
We have create a website using woocommerce and the woodmart theme.
It is an excelent theme and very intuitive to work with.The website is a great success, having lots of orders. During discount campaigns orders reach a number of 10 per minute tops. And this is where the problems start to appear, namely orders are being duplicated when the server is very busy.
We have documented ourselves on how to fix this problem. Our conclusion is that this is a woocommerce problem and that the theme can have a part to play in this as well. We changed hosting to a Virtual Private Server and the number of duplicate orders are much lower, but not zero. Regarding this being a woocommerce problem, we have found a bug report on the woocommerce dev github – https://github.com/woocommerce/woocommerce/issues/14541
So my questions are:
1. Have you had problems with duplicate orders and how have you solved them?
2. There was a solution proposed in the https://github.com/woocommerce/woocommerce/issues/14541 that tries to fix the problem by adding an extra check to the woocommerce_after_checkout_validation using a transient to see if you ordered in the last 3 minutes, and if so disallow you to order for that period of time. Do you think it is a good idea to implement something like this? (snippet added as attachment)
Best regards,
DanMarch 10, 2024 at 10:31 pm #547815
bitpublimediaParticipant/** * Prevent duplicate order */ add_filter('woocommerce_defer_transactional_emails', '__return_true' ); add_action( 'woocommerce_after_checkout_validation', 'forbid2orders', 10, 2 ); function forbid2orders( $fields, $errors ){ $c_user_email = $fields['billing_email']; $c_transient_key = 'create_order_'.$c_user_email; $create_order = true; if(false === ($c_transient_results = get_transient($c_transient_key))){ $c_transient_results = $fields['billing_email']; set_transient($c_transient_key, $c_transient_results, 3 * MINUTE_IN_SECONDS ); }else{ if($c_transient_results == $fields['billing_email']){ $errors->add( 'validation', 'An order has already been created. Please check your <a href="/my-account/orders/">Orders</a> or wait a few minutes to place a new one.' ); } } }
I am pasting the snippet here as it didn’t let me upload a php file as an attachment
March 11, 2024 at 2:19 pm #548024
Aizaz Imtiaz AwanKeymasterHello,
Please make a full backup of your site and check how it works with some default WordPress themes like TwentyTwenty or WooCommerce Storefront to understand is it our theme issue or not?
Best Regards.
March 11, 2024 at 2:34 pm #548035
bitpublimediaParticipantHello,
I am not happy with this response at all.
I cannot do what you request because I cannot have a sale where the website looks different than what clients know it to look like. And i need to have high volume of customers and orders to be able to simulate the problem so it cannot be done on a test environment.
I asked two specific questions, that I will add here again:
1. Have you had problems with duplicate orders and how have you solved them?
2. There was a solution proposed in the https://github.com/woocommerce/woocommerce/issues/14541 that tries to fix the problem by adding an extra check to the woocommerce_after_checkout_validation using a transient to see if you ordered in the last 3 minutes, and if so disallow you to order for that period of time. Do you think it is a good idea to implement something like this?
Are you able or willing to answer them? you have 60000+ help requests on this forum, I assume that doubled orders have come up from time to time. Also I am asking what impact adding that snippet might have on the theme itself…
I have no problem if you do not answer them if you outright let me know that if the problem is not 100% related to the theme than your support doesn’t cover it and can’t be bothered to give an answer to set you in the right direction at least. Just so we know where we stand and not waste each others time.
Best Regards.
March 11, 2024 at 4:36 pm #548096
Aizaz Imtiaz AwanKeymasterHello,
The “Order” functionality is related to WooCommerce so I cannot tell you exactly. Try to contact their support team for further solutions
This thread had a a similar situation that was caused by out of memory errors during high traffic times.
https://wordpress.org/support/topic/duplicate-orders-problem/Hope this helps!
Best Regards.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register