How to resolve duplicate stock movement and order notifications in Woocommerce - php

I have been troubleshooting this issue for the last few weeks and have not been able to resolve.
We are experiencing the following (intermittently) when an order is placed by a customer.
Stock movement is duplicated
Order notes are duplicated
Email notifications are duplicated (to all parties)
Backorders are created (if the stock on hand is not sufficient to handle the duplicate qty). Example: initial inventory = 1 unit. 1 unit is purchased but the stock movement is duplicated which takes inventory to -1 causing a backorder, despite back orders being set to "do not allow".
Stack
Osmosis theme (+ child theme) - v4.3.6 (just updated to latest version)
Woocommerce v6.4.1
WordPress v5.9.3
PHP v7.4.28
Flywheel/5.1.0, nginx
The issue appears to have started a couple of weeks prior to a migration to a new host. A review of orders prior to the migration showed that order notes were already duplicating. After the move to the new host, it seems the stock movement started to duplicate (as well as order notification emails).
I reached out to Flywheel, they took a look but could not see anything suspicious-looking in the logs other than some fatal errors in the theme. I updated the theme. This resolved the fatal errors but not the order issue. Flywheel also adjusted the PHP memory, but no dice on the order issues. They have not provided much more help.
I updated a bunch of plugins at the same time as I migrated the site to Flywheel, so a possible conflict with a plugin may exist.
I tested in a staging environment with themes and plugins disabled but can not replicate.
It's hard to tell which plugin/theme might be causing a conflict on the staging site, as the issue is intermittent, so it's hard to narrow down which plugin, or if it is even a conflict. We also don't have the volume of orders going through the staging site, so hard to figure out. We would need to process several test orders over the course of a day. Which I guess we can do.
I did some googling and saw a bunch of posts on a similar issue relating to the payment gateway, and a possible conflict between using the hosted payment page or merchant payment page. I reached out to the developer (Windcave / Payment Express). They were not aware of any conflicts but sent me an older version of the plugin so I could roll it back. No dice. I also had the client reach out to Windcave directly to check their account was configured correctly and all appears to be as it should.
I've checked all Woocommerce settings, run all updates on plugins, reviewed the woocommerce status report, and checked logs.
I'm left with placing a bunch of test orders in the staging site over a few days until I can narrow down a possible plugin conflict, but wanted to fire this query through here first to see if anyone had come across something simiar and can help me resolve.
Would greatly appreciate some help.
Thanks
Josh

I think it can relate some of the WordPress hooks that are used for checkout page. You can check in this link "https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/" for the hooks that can possible used on checkout page (or) before order create hooks. Try to compare these hooks names and if you used these hooks in child theme > functions.php or plugins. Some of hooks can trigger 2 or 3 times so it can possible be the problem.

Related

How to track what is triggering WooCommerce to create a new order

I need to add some debug code to my WooCommerce site to figure out where new orders are being triggered (I am getting duplicates). I don't mind adding debug code to WooCommerce core temporarily. How would I go about finding where that happens? I am looking for whatever information I can gather regarding what is triggering a new order to be created, any parameters, etc.
I tried installing WP Activity Log plugin (with WooCommerce add-on) but it isn't giving me the level of detail that I need.

Strange WooCommerce database related issue

I have a strange WooCommerce issue on one of my sites. It's a popular webshop with thousands of products. Most likely the issue is there for a long time but we just noticed it.
The problem: A lot of products are not showing up on the frontend. All of those are visible in the backend, all of them are live, all of those are in stock. So they should show up. Some of the store products are visible, some of them are not. There's no logic in this. BUT... if I just edit a missing product and just simply re-save it in the backend it shows up in the frontend right away.
Most likely the issue is related to the 2.x to 3.x database upgrade: "3.0.0 instroduces a new product visibility taxonomy; catalog, search, hidden, featured, outofstock are terms. These are set on upgrade and help filter products in the catalog during frontend queries."
My theory is that this database upgrade didn't finish at that time for some reason.
So the solution would be to run it again or to find an automatic way to emulate the "save" feature that I do manually if I edit and save a missing product in the backend. But the manual way is simply not an option when I have thousands of products.
I just want all available products to appear in the frontend too. Do you have any idea how can I solve this?
P.s: I have already tried switching back to a default theme and disabling every other plugin except WooCommerce. It's clearly a database related WooCommerce issue. And yes, I have the latest WP and the latest 3.x Woo. The PHP version is 7.2.
Thank you in advance!

WordPress + WooCommerce - disabling cart AJAX (fragments) in 3.4.0?

WooCommerce has a script that runs on every page, upon every page reload, that adds 1-3 seconds to loading time. It's the "wc-ajax get_refreshed_fragments" function.
All this does is check whether the shopping cart totals have changed. Which is nice to have on the product page - but completely unnecessary on the home page or category page or any of the text-content pages.
There are manual methods (dequeue script commands to be added to functions.php) and plugins (PerfMatters, LittleBizzy's Disable Cart Fragments, etc) to remove this, which worked... right up until the latest WooCommerce update.
Is there a solution for disabling this script, in the latest version of WooCommerce?
Unfortunately your information is wrong:
PerfMatters (Brian Jackson) took their code from our GPL plugin without credit, which was originally shared by Jeff Matson on his blog back in 2016 (credited in our readme).
wp_dequeue_script('wc-cart-fragments');
Disable Cart Fragments still works fine in WC 3.4+
If it's not working on your site, most likely your theme is to blame... confirm by activating a different theme and disabling all other plugins that may be enqueuing the cart, etc.
Update: since so many people are now referring to this thread, I'd like to once again confirm that Kinsta (web host) is now promoting the stolen code from LittleBizzy plugins, and have contacted me to state they have nothing to do with PerfMatters. When I asked them when they'd be removing all the links and promotional material on their website for PerfMatters, they went silent...
P.S. Thanks to WP Engine and WP Rocket for crediting us! :)

Woocommerce cart items keep reappearing

i made a video of the woocommerce cart issue a friend of mine has with his store https://streamable.com/augha
i cannot reproduce it here, on other pc's. Nor can i reproduce it on my mobile phone.
This was yesterday... But now today the problem seems to be expanding to the moment it seems that customers from belgium are also getting this problem. In the past we have never had problems with Belgium, and yesterday we also received a Belgian order with several articles without any problems.
But another order we have to make a payment link because he did not manage to get more than 4 items in the basket.
The remarkable thing I find that the Belgian where we made a payment link initially got 15 hoodies in his shopping basket, and the next day the basket was empty and he could add up to 4.
So it seems that in certain occasions the cart will go fubar... Anyone else experienced this ?
It looks like a caching issue. You may want to try disabling all other plugins to see if that helps.

Fake bot orders Woocommerce

I've installed Wordpress with Azera Shop theme. For development time, whole page is protected with .htpasswd, but - after about a week there was few orders from bots.
It could be easy thing if we have buying functionality (captcha), BUT - all prices are Null, so in that theme - all elements like "Add to cart" etc. are
just disabled.
Orders are without any products set, with random price, date and status.
What could be the problem? First thing that make me curious is overpassing through .htpasswd, next - how the orders are set? I guess that there wasn't a SQL injection used, but, maybe some of you have ever seen similar problem.
From that moment, I've installed anti-spam plugin from webvitaly and set all products status to "unavailable" and it's propably working.
Thanks
There could be Nth number of reason.
Could you please make true the Debug and Error, so that you could troubleshoot the issue from the Code view and see the Deprecated Code and Runtime Error as well. Also make sure you have Firewall is active.
This could be the basic things that bot bypass.

Categories