Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
174 stars 69 forks source link

Cart contents cleared when logging in at checkout w/ WCPay and JP active #5491

Closed maxlaf closed 9 months ago

maxlaf commented 1 year ago

Describe the bug

When both WooCommerce Payments and Jetpack are activated, carts created as a guest are cleared when logging in on the checkout page.

Deactivating either plugin fixes the issue.

To Reproduce

  1. Install and connect Jetpack.
  2. Install WCPay and start the onboarding. An account doesn't need to finish onboarding, it just needs to connect with Jetpack.
  3. Allow customers to log in at checkout under WooCommerce > Settings > Accounts & Privacy.
  4. Visit the store while logged out and add some products to your cart
  5. Go to checkout, log in, cart is cleared.
  6. Deactivate WCPay or JP and clear your carts.
  7. Make a new guest cart, log in at checkout, cart contents persist after logging in.

Actual behavior

Logging in at checkout clears the cart and both the woocommerce_cart_hash and woocommerce_items_in_cart cookies.

Expected behavior

I expected the cart contents to persist after logging in at checkout.

Additional context

System Status

``` ### WordPress Environment ### WordPress address (URL): https://welcome-seal.jurassic.ninja Site address (URL): https://welcome-seal.jurassic.ninja WC Version: 7.3.0 REST API Version: ✔ 7.3.0 WC Blocks Version: ✔ 9.1.5 Action Scheduler Version: ✔ 3.4.0 Log Directory Writable: ✔ WP Version: 6.1.1 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: ✔ WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.55 (Unix) OpenSSL/1.0.2g PHP Version: 7.4.33 PHP Post Max Size: 1 GB PHP Time Limit: 30 PHP Max Input Vars: 5000 cURL Version: 7.47.0 OpenSSL/1.0.2g SUHOSIN Installed: – MySQL Version: 5.7.33-0ubuntu0.16.04.1-log Max Upload Size: 512 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 7.3.0 WC Database Prefix: wp_ Total Database Size: 4.87MB Database Data Size: 3.38MB Database Index Size: 1.49MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.02MB + Index: 0.11MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 2.48MB + Index: 0.08MB + Engine InnoDB wp_postmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_posts: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB ### Post Type Counts ### attachment: 1 page: 7 post: 3 product: 1 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ❌Error messages should not be shown to visitors. ### Active Plugins (6) ### Companion Plugin: by Osk – 1.29 Jetpack: by Automattic – 11.7.1 WooCommerce Payments Dev Tools: by Automattic – WooCommerce Payments: by Automattic – 5.3.0 WooCommerce: by Automattic – 7.3.0 WP Rollback: by GiveWP.com – 1.7.3 ### Inactive Plugins (3) ### Akismet Anti-Spam: by Automattic – 5.0.1 Hello Dolly: by Matt Mullenweg – 1.7.2 WooCommerce Shipping & Tax: by WooCommerce – 2.2.1 ### Settings ### API Enabled: – Force SSL: – Currency: USD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) subscription (subscription) variable (variable) variable subscription (variable-subscription) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – Enforce Approved Product Download Directories: ✔ Order datastore: WC_Order_Data_Store_CPT ### WC Pages ### Shop base: #5 - /shop/ Cart: #6 - /cart/ Checkout: #7 - /checkout/ My account: #8 - /my-account/ Terms and conditions: ❌ Page not set ### Theme ### Name: Twenty Twenty-Three Version: 1.0 Author URL: https://wordpress.org Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ✔ ### Templates ### Overrides: – ### Subscriptions ### WCS_DEBUG: ✔ No Subscriptions Mode: ✔ Live Subscriptions Live URL: https://welcome-seal.jurassic.ninja Subscription Statuses: – WooCommerce Account Connected: ❌ No ### Store Setup ### Country / State: United States (US) — California ### Payment Gateway Support ### ### Admin ### Enabled Features: activity-panels analytics coupons customer-effort-score-tracks experimental-products-task experimental-import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing multichannel-marketing mobile-app-banner navigation onboarding onboarding-tasks remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices woo-mobile-welcome wc-pay-promotion wc-pay-welcome-page Disabled Features: minified-js new-product-management-experience settings Daily Cron: ✔ Next scheduled: 2023-02-01 00:23:38 +00:00 Options: ✔ Notes: 39 Onboarding: - ### WooCommerce Payments ### Version: 5.3.0 Connected to WPCOM: Yes Blog ID: 215089087 Account ID: acct_1MW7isFdW2Ksbbdy ### Action Scheduler ### Complete: 9 Oldest: 2023-01-31 00:26:39 +0000 Newest: 2023-01-31 00:38:38 +0000 Pending: 2 Oldest: 2023-01-31 01:28:12 +0000 Newest: 2023-02-01 00:24:52 +0000 ### Status report information ### Generated at: 2023-01-31 01:27:48 +00:00 ```

Found in 5913108-zen This may be related to the enhancement request here: https://github.com/Automattic/jetpack/issues/25479 This is also likely the root issue in this forum thread and potentially others: https://wordpress.org/support/topic/cart-clears-when-customer-logins/

pehaa commented 1 year ago

I was testing in parallel and observed the very same behavior.

csmcneill commented 1 year ago

Similar issue reported on the WC repo here: https://github.com/woocommerce/woocommerce/issues/34464

senff commented 1 year ago

Reported in 5940335-zen

GFARID64 commented 1 year ago

Hello, is there a solution to this problem without disabling jetpack? THANKS

boxingkoala commented 1 year ago

Hello, is there a solution to this problem without disabling jetpack? THANKS

I have not seen a fix yet. I have jetpack permanently disabled in order to not have annoyed customers spending an hour adding products to see cleared when logging in!!

GFARID64 commented 1 year ago

Hello, is there a solution to this problem without disabling jetpack? THANKS

I have not seen a fix yet. I have jetpack permanently disabled in order to not have annoyed customers spending an hour adding products to see cleared when logging in!!

Same for me, did you find a replacement jet pack extension that would do the same job?

boxingkoala commented 1 year ago

I am using WPStatistics for the stats and have left it at that.

marissaexplores commented 1 year ago

6047834-zen

This bug is particularly an issue when purchasing subscription products using Apple Pay/Google Pay.

maxlaf commented 1 year ago

6059843-zen. This bug is forcing the user to choose between using WCPay or WCS&T for automated taxes. They will likely be removing WCPay.

csmcneill commented 1 year ago

6374348-zen

SmartHomeAu commented 1 year ago

It is crazy this is not fixed yet. This is costing our company money by (forcing) cart abandonment! Please fix asap.

boxingkoala commented 1 year ago

I had to disable jetpack to remove the issue of the cart clearing when a customer logs in. Had customers spend an hour or more selecting items only to have the cart content removed when they logged in. Very annoying and no fix to be seen in a year since i reported it.

I use WP Statistics for the stats. would prefer it was fixed but this works with disabling jetpack at least!

Mxchael commented 1 year ago

6402206-zen

csmcneill commented 1 year ago

The issue is caused by cookie conflict between WCPay and Jetpack Sync. The Jetpack team is working on a fix here: https://github.com/Automattic/jetpack/pull/31423

In the meantime, the sites experiencing the issue can be fixed by contacting support at https://woocommerce.com/my-account/create-a-ticket/ and asking a Happiness Engineer to disable Dedicated Sync. Please note that it might take a bit of time for the change to take effect.

Sent out comms for reports. Details here: p1687120161354979/1687117159.732829-slack-CB37YNEH1

jessy-p commented 1 year ago

The Jetpack fix was reverted, context: p1688500124456809/1686285707.645099-slack-CBG1CP4EN Blocked and moved to next Sprint.

namiokuzono commented 1 year ago

6603839-zd-woothemes - Disabled dedicated sync.

nicdwilson commented 1 year ago

6754710-zen. Replicated on Jetpack v12.6-a.3. Disabling Jetpack dedicated sync did the trick.

fgiannar commented 1 year ago

Jetpack fix under review once more. Full update: p9dueE-7zI-p2#comment-10096

fgiannar commented 1 year ago

Jetpack fix is now part of the 1.59.0 Sync package version and will be also included in the upcoming Jetpack 10.8 release.

Please feel free to test and update the corresponding Sync package version dependency accordingly.

Full update: p9dueE-7zI-p2#comment-10117

fgiannar commented 1 year ago

Another update as a certain edge case was brought to our attention so we need to fully validate the impact and possibly might need to revert the fix once again :(

For now, please don't update the Sync package dependency to 1.59.0 yet, apologies for this.

Slack discussion: p1697623116284589-slack-C02JQ08G0

rezzap commented 11 months ago

Similar report here: 7330851-zd-a8c. We've disabled dedicated sync as a workaround for the time being.

maxlaf commented 10 months ago

7479044-zen

shrutimoorthy commented 10 months ago

7563128-zen

pierorocca commented 9 months ago

Noting that I'd expect the carts to be merged, and for the shopper to decide which if any items should be removed. I've tested this out on Target.com and the carts are combined, giving the shoppers a reminder of their previous cart contents (which many shoppers uses as a wishlist).

glagonikas commented 9 months ago

Noting that I'd expect the carts to be merged, and for the shopper to decide which if any items should be removed.

in an ideal world, you'd show a warning saying something along the lines of "We found some products from a previous sessions. do you want to add them?" and let them decide accordingly rather than merging the carts automatically, because customers will start complaining that you tricked them into adding more items, etc. This is how IKEA does it on their site and provides great UX.

This thread however has to do with carts getting emptied when you log in on checkout, meaning there is a bug affecting conversions that needs fixing urgently, rather than hoping for an improvement with the UX which would take ages to implement.

pierorocca commented 9 months ago

Thanks George for the additional example. I tried Ikea's approach and it's ok and the most complicated. There are a few options each with their own pros/cons. The key concern I have is that a very high amount of shoppers use the cart as a way to save items for consideration for days, weeks, or months. https://baymard.com/premium/guideline-collections/wvcimm/2157. Here's a summary of the approaches I've observed:

Of these patterns Home Depot was my favorite as it strikes a good balance between respecting the cart as a bookmarking tool and a shopper's current purchase intentions. Next is Shopify's approach but it falls apart if the cart can't be cookied/stored. It took effort to circumvent their efforts so they've done a pretty good job.

htdat commented 9 months ago

This PR https://github.com/Automattic/woocommerce-payments/pull/8084 would fix the issue in WooPayments 7.2.0, will be released on Feb 14th, 2024.

In case someone wants to test it in advance, please use this test zip file with a note that this zip IS NOT READY for production: NOT-READY-FOR-PRODUCTION___woocommerce-payments_7.2.0-dev_fix_losing_cart_content.zip

I am going to close this issue for now, too. In case this fix causes any other issue with your site, please create a new issue in https://github.com/Automattic/woocommerce-payments/issues, then we can have a look at them.