Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random items added to order after v2 -> v3 upgrade #15671

Closed
elliotcondon opened this issue Jun 18, 2017 · 44 comments
Closed

Random items added to order after v2 -> v3 upgrade #15671

elliotcondon opened this issue Jun 18, 2017 · 44 comments
Labels
needs: author feedback The issue/PR needs a response from any of the parties involved in the issue.

Comments

@elliotcondon
Copy link

elliotcondon commented Jun 18, 2017

EXPLANATION OF THE ISSUE

Hi guys,
Elliot here from Advanced Custom Fields.

I'm experiencing a really strange issue and have tried my best to debug it, but am at a loss.
I've just upgraded WC to 3.0.8 (from 2.6.9) and now each order that gets created (during checkout) contains an extra random product.

I've dug through the source code and can provide these findings:

  1. The order object looks correct during the WC_Checkout->create_order()
  2. During the save process of the order, an extra random product is added to the order
  3. This random product is being added via the WC_Abstract_Order->add_item() function

I have deactivated all plugins and swapped to the default WP theme to test, and the issue persists!
I have a feeling this issue must be related to the upgrade and some 'legacy' or 'compatibility' code is tripping itself up.

I'm happy to do any code debugging, please let me know if you have any thoughts on how I can fix this.

SYSTEM STATUS

``` ` ### WordPress Environment ###

Home URL: https://www.advancedcustomfields.com
Site URL: https://advancedcustomfields
WC Version: 3.0.8
Log Directory Writable: ✔
WP Version: 4.8
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: ✔
WP Cron: ✔
Language: en_US

Server Environment

Server Info: Apache
PHP Version: 5.6.25
PHP Post Max Size: 32 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.50.0
OpenSSL/1.0.2h

SUHOSIN Installed: –
MySQL Version: 5.6.28
Max Upload Size: 32 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 2.6.9
WC Database Prefix: wp_
woocommerce_sessions: ✔
woocommerce_api_keys: ✔
woocommerce_attribute_taxonomies: ✔
woocommerce_downloadable_product_permissions: ✔
woocommerce_order_items: ✔
woocommerce_order_itemmeta: ✔
woocommerce_tax_rates: ✔
woocommerce_tax_rate_locations: ✔
woocommerce_shipping_zones: ✔
woocommerce_shipping_zone_locations: ✔
woocommerce_shipping_zone_methods: ✔
woocommerce_payment_tokens: ✔
woocommerce_payment_tokenmeta: ✔

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (7)

Advanced Custom Fields PRO: by Elliot Condon – 5.5.14
Disable Password Change Email: by Andrej Pavlovic – 1.0.0
Limit Login Attempts: by Johan Eenfeldt – 1.7.1
My Dashboard: by Elliot Condon – 1.0.0
WooCommerce Stripe Gateway: by WooCommerce – 3.2.0
WooCommerce: by Automattic – 3.0.8
Yoast SEO: by Team Yoast – 4.9

Settings

API Enabled: –
Force SSL: –
Currency: AUD ($)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
featured (featured-2)
outofstock (outofstock)
outofstock (outofstock-2)
rated-1 (rated-1)
rated-1 (rated-1-2)
rated-2 (rated-2)
rated-3 (rated-3)
rated-3 (rated-3-2)
rated-4 (rated-4)
rated-4 (rated-4-2)
rated-5 (rated-5)
rated-5 (rated-5-2)

WC Pages

Shop base: ❌ Page not set
Cart: #1483 - /cart/
Checkout: #1484 - /checkout/
My account: #1485 - /my-account/

Theme

Name: Advanced Custom Fields
Version: 3.1.0
Author URL:
Child Theme: ❌ – If you're modifying WooCommerce on a parent theme you didn't build personally
then we recommend using a child theme. See: How to create a child theme

WooCommerce Support: ✔

Templates

Overrides: acf/.DS_Store
acf/woocommerce/checkout/form-billing.php
acf/woocommerce/checkout/form-checkout.php
acf/woocommerce/checkout/form-coupon.php
acf/woocommerce/checkout/thankyou.php
acf/woocommerce/emails/customer-completed-order.php
acf/woocommerce/emails/customer-new-account.php
acf/woocommerce/emails/email-footer.php
acf/woocommerce/emails/email-header.php
acf/woocommerce/emails/email-styles.php
acf/woocommerce/myaccount/dashboard.php
acf/woocommerce/myaccount/my-account.php
acf/woocommerce/myaccount/my-orders.php
acf/woocommerce/myaccount/navigation.php
acf/woocommerce/myaccount/view-order.php
acf/woocommerce/order/order-details.php

`

</details>
@mikejolley mikejolley added the needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. label Jun 19, 2017
@mikejolley
Copy link
Member

@elliotcondon if you dump your session/cart, whats in there?

I'm not aware of any BW compat code that would add items to an order.

@cwuensche
Copy link

Hey guys, this almost sounds like the exact issue I'm experiencing and I'm attempting to debug it. Sometimes random items get added to the cart, or items get added to orders and their credit cards re being charged for items they didn't add. I'm in the process of cleaning up any items that appear in the error log, but the only endpoint I personally added to the add cart was one ajax function, and that is not being called as far as I can tell when this happens.

@cwuensche
Copy link

@mikejolley @elliotcondon Let me know if you guys find a solution while I poke around also.

@elliotcondon
Copy link
Author

Hi @mikejolley, thanks for the reply.

Here's an odd twist to the issue.
I was able to solve the problem by re-importing my DB and running the 'WC DB Update' again.

I wasn't able to find any issues with any data in the cart, and can confirm that all data was correct during the WC_Checkout->create_order().

I won't be able to do any in-depth debugging anymore as the checkout is now working as expected.
@cwuensche - might be worth reverting your DB to an older version, or chatting to mike about triggering the DB updater on the current DB?

@mikejolley
Copy link
Member

I wonder if that was just a co-incidence. I'm thinking there may have been a rogue item in the cart itself, maybe not visible.

@cwuensche
Copy link

@mikejolley I'm not sure that that is what is/was happening in my instance. I did not add those items to my cart, and other people were getting items in their cart they didn't see yet.

@elliotcondon Thanks, I will try that.

@mikejolley
Copy link
Member

Look at your sessions table once a product appears and see what is there.

The other thing it could be is caching i.e you taking someone elses session.

@cwuensche
Copy link

@mikejolley @elliotcondon I backed up the database and ran the database upgrade script. Hopefully this fixes it. When I personally experienced the problem, I was able to fix it by manually removing the products from the cart and updating everything. Ever since I did that, it didn't occur for me anymore. Before I updated the cart for myself personally, it had a random product in the cart when I would refresh the page before I even added anything.

@mikejolley
Copy link
Member

I was able to fix it by manually removing the products from the cart and updating everything. Ever since I did that, it didn't occur for me anymore. Before I updated the cart for myself personally

Really it sounds like something ended up in the cart that should not have been there.

@mikejolley
Copy link
Member

I've had no luck pinpointing a cause nor replicating this sadly. If anyone else comes across this, please dump the data in user carts and share here for review.

@elliotcondon
Copy link
Author

Hi @mikejolley. Thanks for taking a look, here's hoping it's just a random one off bug that is super rare!

@sethpjohnson
Copy link

sethpjohnson commented Aug 3, 2017

We're hitting this issue post 2.x to 3.1.1. Not even sure where to start. We've worked with WPEngine to disable caching nearly everywhere. We've gone in circles trying to track down how this happens post-checkout. How can we debug this and supply info?

@BlackWireDesigns
Copy link

I have been searching high and low for the cause of this. I recently updated from 2.6.14 and went to 3.1.1. I have made sure any plug in that has something to do with WC has been updated with 3.0+ compatibility. We keep having random items added to carts during check out. The item is not paid for. Youll see the sub total is a higher amount but the price paid is a lower amount. I am also seeing that item disappear from orders as well. Its very strange.

@apengstrom
Copy link

apengstrom commented Aug 14, 2017

Hello. I have recently experienced this issue on a client's site. I upgraded them from an older version of WooCommerce, new theme and everything. They even have a custom plugin with advanced custom fields to create rentals in their WooCommerce site. What I did was go to the Tools in WooCommerce under "Status". I ran the following:

  1. WC transients
  2. Expired transients
  3. Orphaned variations
  4. Term counts
  5. Customer sessions
  6. Reset usage tracking settings

And the issue disappeared. I do not know if this is a permanent fix, I just did this now on a staging site. Back up your DB before running this and confirm for me here if it fixes it for you guys as well.

screen shot 2017-08-14 at 11 54 45 am

@apengstrom
Copy link

@mikejolley I don't know if there is anything I can do to help you replicate, without providing you the contents of an established client's site (before the WooCommerce upgrade) which obviously I can't do for good reason. But perhaps we can add some sort of check for old data / existing data after doing an upgrade? Are there any of these options in the Status Tools that we can run on a plugin update automatically? etc. Thoughts?

@apengstrom
Copy link

apengstrom commented Aug 14, 2017

I wanted to follow up because we ran these items on the live site for this client. It did not fix the problem for anyone who was currently logged in, etc.

The client had to logout and clear their browser cache before this would be in effect.

We still do not have the custom cart item data after the checkout process. We're looking into that further.

EDIT: After some more testing it seems the client is continuing to have issues with their orders. I am going to do some more extensive testing with them over the next 12-24 hours and will post back with our findings.

@mikejolley
Copy link
Member

Ensure you have checkout/cart excluded from caching - thats often related.

@apengstrom
Copy link

apengstrom commented Aug 15, 2017

@mikejolley

This is after having WPEngine turn off Varnish caching and disabling the object cache and cleaning the regular cache, as well as our browser caches. Something is still being retained. But we're also missing additional cart data, even for users who do not have this "caching" problem.

I might almost consider this a separate issue. So I'll open a new issue for that.

The client ran some tests last night. Apparently, the client can successfully do this when creating a new account or checking out as a guest. But when they login to their original account, they get this issue where it adds random products to the order upon checkout.

@apengstrom
Copy link

image

This is what is excluded from WPEngine's Varnish Caching.

@apengstrom
Copy link

Looks like #16370
describes almost the same functionality (if not the same) as this issue.

@mikejolley
Copy link
Member

@apengstrom The common factor is WPEngine...

@apengstrom
Copy link

This worked on WPEngine before the upgrade to WooCommerce.

@mikejolley
Copy link
Member

mikejolley commented Aug 15, 2017

Right, but if there are cache exclusion rules which do not account for the changes in v3 thats not something we'd be able to patch?

I suspect regular visitors to your site are having carts assigned to them due to caching.

ac-api should be wc-api btw I notice in your screenshot.

@apengstrom
Copy link

Yeah that's what I was thinking. So Based on the rules noted in the screenshot above, is the ac-api the only wrong one currently?

I can have them add an additional one for wc-api= to exclude args and see if that helps.

@mikejolley
Copy link
Member

Hmm what about the WC session cookies? wp_woocommerce_session_ prefix.

@apengstrom
Copy link

Here is the updated exclusions as per WPengine. Just had them make this change and purge their Varnish cache. I also purged the object/regular cache via WPEngine admin panel.

I will see if the client continues to have issues and then report back.

blueskiesdrone - install config - wp engine overdrive 2017-08-15 10-56-05

@apengstrom
Copy link

apengstrom commented Aug 15, 2017

Quick somewhat unrelated question, but regarding the current issues I am experiencing, when using add_action or add_filter, referencing a hook, we need to use the defined "woocommerce_hook_name" whereas in a function call, we use "wc_hook_name()", in terms of naming conventions, is this accurate for v3.x.x+ ?

@mikejolley
Copy link
Member

@apengstrom The session one is only a prefix - does that match them correctly?

yes naming like that is correct.

@apengstrom
Copy link

@mikejolley Yes they have a custom plugin someone built for them a while back that makes some custom vars, now I'm not entirely sure they are stored there but just in case I had WPEngine add it as a prefix to the exclusions list just to cover all basis (am tired of dealing with caching issues).

They are testing now. I will let you know on this thread with the results of what happens going forward now that all these changes are made. The other issue with cart meta not coming through was due to a inconsistency in naming conventions (mentioned above) in their custom plugin, I fixed that as well.

@apengstrom
Copy link

@mikejolley Client affirms that they have been able to do the testing on their account that was having issues, without a problem. I am assuming at this point the Varnish cache exclusions you had me make yesterday attributed to this.

@guanyixi
Copy link

My client is having the same issue. When users add items to cart at the same time, users can see more than their own items. Sometimes some random items/orders. This site is also hosted on WPengine. I've asked WPengine to exclude the urls list in this ticket. Problem not solved.

@Freshclicks
Copy link

My client is having the same issue, but I am not on WPEngine. Using Nginx with fastcgi cache.
I have the following cache exclusions:

fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
add_header Fastcgi-Cache $upstream_cache_status;
set $skip_cache 0;

if ($request_method = POST) {
set $skip_cache 1;
}

if ($query_string != "") {
set $skip_cache 1;
}

if ($request_uri ~* "/wp-admin/|/deploy/|/xmlrpc.php|wp-..php|/feed/|index.php|sitemap(_index)?.xml|/shopping/|/store.|/cart.|/my-account.|/checkout.|/addons.|/ideas.*") {
set $skip_cache 1;
}

if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
}

@tcope25
Copy link

tcope25 commented Mar 7, 2019

Is anyone having this issue and using WP Rocket?

@apengstrom
Copy link

Hi @tcope25 - From what I can see, it looks like WP Rocket is fully compatible. I'd check if you have caching being done elsewhere.

https://wp-rocket.me/faq/wordpress-caching-plugins-for-woocommerce/

"WP Rocket is fully compatible. No extra configuration is needed. All WooCommerce pages are automatically detected and not cached."

@tcope25
Copy link

tcope25 commented Mar 17, 2019

I also have 'Abandoned Cart Lite for WooCommerce' plugin - could this be causing the issue?

@apengstrom
Copy link

@tcope25 There could be many issues for this, if you feel there is a plugin incompatibility what I'd do is set up a test environment and then disable any plugin(s) you feel could be causing an issue, until it either works or until you have no plugins to disable. I'd also test with a default WP theme, if you find plugins aren't an issue.

@peterfabian
Copy link
Contributor

Are you using Returns and Warranty Requests plugin by any chance? It was reported to cause some problems in #17660. Just guessing, could be something else as well.

@tcope25
Copy link

tcope25 commented Mar 19, 2019 via email

@jaykhandelwal
Copy link

If you are using https://getquick.link/ by just adding it to the head then this can cause the same issue as well, so instead of adding the script in the head you can use its plugin

https://wordpress.org/plugins/quicklink/

@DogcomeTank
Copy link

Is anyone having this issue and using WP Rocket?

I have the same issue. I’m hosted on WP Engine and use WP Rocket. I realized the “random items” are not random. It’s from other customer’s cart. They don’t know each other and they are far away from each other.

What comes worse to my site is: customer A and B, they don’t know each other and they live far away. Customer A placed an order, about few minutes later, customer B placed an order. Customer B’ shipping address shows customer A’ address. Customer B contacted me to get her address fixed.

Until now the problem still unsolved.

@peterfabian
Copy link
Contributor

Hi @DogcomeTank ,

If you manage to replicate the problem, we'd be happy to fix it. The problem is that it's very elusive and we haven't managed to find a way how this is happening. It would be great if you could test this out only with WC core plugin active to see if there is any other plugin causing this. It's possible that it's caused by some caching, but it's difficult to guess.

Also, sharing your system status report would help.

What's more important, though, is that this particular topic relates to problems customers were having when migrating from WC 2 to WC 3, so it might not be related to this issue at all, so starting a new issue could be beneficial.

@pigneedle
Copy link

pigneedle commented Jun 7, 2020

I just ran into very similar issue, and I fixed it.

We are using Sucuri & WP Rocket. We ran into an issue where items were being added to the cart when users visited the homepage without any user input. The user would then view their cart, and the items would be removed automatically with a warning from WooCommerce.

I fixed this issue by clearing Sucuri & WP Rocket cache (which I don't think did much), but most importantly, CLEARING TRANSIENTS.

This is done through Settings>WP Rocket>Database>Transients Cleanup

Check the boxes for bot Expired Transients & All Transients, then click the "Optimize" button at the bottom of the page.

Hope this helps somebody.

@DogcomeTank
Copy link

Hi @DogcomeTank ,

If you manage to replicate the problem, we'd be happy to fix it. The problem is that it's very elusive and we haven't managed to find a way how this is happening. It would be great if you could test this out only with WC core plugin active to see if there is any other plugin causing this. It's possible that it's caused by some caching, but it's difficult to guess.

Also, sharing your system status report would help.

What's more important, though, is that this particular topic relates to problems customers were having when migrating from WC 2 to WC 3, so it might not be related to this issue at all, so starting a new issue could be beneficial.

Hello peterfabian,
Thank you for your reply and sorry for posting at the wrong area. Too bad I can’t replicate the problem. But I will continue investigating and I’ll keep you posted if I found something.

@DogcomeTank
Copy link

I just ran into very similar issue, and I fixed it.

We are using Sucuri & WP Rocket. We ran into an issue where items were being added to the cart when users visited the homepage without any user input. The user would then view their cart, and the items would be removed automatically with a warning from WooCommerce.

I fixed this issue by clearing Sucuri & WP Rocket cache (which I don't think did much), but most importantly, CLEARING TRANSIENTS.

This is done through Settings>WP Rocket>Database>Transients Cleanup

Check the boxes for bot Expired Transients & All Transients, then click the "Optimize" button at the bottom of the page.

Hope this helps somebody.

Thank you. I’ll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: author feedback The issue/PR needs a response from any of the parties involved in the issue.
Projects
None yet
Development

No branches or pull requests