woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.43k stars 10.77k forks source link

Closing Paypal payment gateway quickly adds variable product parent to cart #38396

Open Evaske opened 1 year ago

Evaske commented 1 year ago

Prerequisites

Describe the bug

I have a client who was seeing issues occasionally with customers checking out with the parent of a variable product added, which had no variable product SKU and sometimes allowed the customer to checkout with the cheapest price of a variable product.

I have now found what was causing this issue and it is the Paypal Smart Button (Paypal checkout button) on the single product page however this may also happen with other smart button gateways that can appear on the single product page and open a popup window.

Expected behavior

Either when the window is closed, the cart should be emptied or the variable product only should be added to the cart and this shown as 1 in cart (it currently shows as 0 unless you refresh the page).

Actual behavior

On closing the Paypal window quickly, the cart shows as 0 items. If the page is refreshed after closing the Paypal window then the parent item is in the cart. If the "Add To Cart" button is pressed without refreshing then the variation item gets added to the cart as well as the parent item.

If you let the Paypal window fully load and then close it, this adds the correct variation item to the cart but again doesn't update the cart value unless the page is refreshed so you can end up with 2 of the same variation item in the cart on pressing the "Add To Cart" button.

Steps to reproduce

  1. Have a variable product and be on the product page with Paypal Gateway plugin available and showing on the single product page
  2. Select a variable product item variance
  3. Press the Paypal button to open the PayPal window and quickly close it
  4. Press the add to cart button
  5. The parent and the variation both are in the cart or just refreshing the page and the parent item is in the cart

WordPress Environment

WordPress address (URL): 
Site address (URL): 
WC Version: 6.0.1
REST API Version: ✔ 6.0.1
WC Blocks Version: ✔ 6.3.3
Action Scheduler Version: ✔ 3.5.4
WC Admin Version: ✔ 2.9.4
Log Directory Writable: ✔
WP Version: ❌ 6.2.1 - There is a newer version of WordPress available (6.2.2)
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: ✔
WP Cron: ✔
Language: en_GB
External object cache: ✔

### Server Environment ###

Server Info: nginx/1.18.0
PHP Version: 7.4.18
PHP Post Max Size: 500 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.68.0
OpenSSL/1.1.1f

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

### Database ###

WC Database Version: 6.0.0
WC Database Prefix: Li1LAEc_
Total Database Size: 640.73MB
Database Data Size: 407.44MB
Database Index Size: 233.29MB
Li1LAEc_woocommerce_sessions: Data: 2.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
Li1LAEc_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_woocommerce_order_items: Data: 9.37MB + Index: 4.69MB + Engine MyISAM
Li1LAEc_woocommerce_order_itemmeta: Data: 74.86MB + Index: 50.05MB + Engine MyISAM
Li1LAEc_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
Li1LAEc_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_woocommerce_shipping_zone_locations: Data: 0.19MB + Index: 0.30MB + Engine InnoDB
Li1LAEc_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_acfw_loyalprog_entries: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_acfw_store_credits: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_acfw_virtual_coupons: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_actionscheduler_actions: Data: 1.02MB + Index: 0.94MB + Engine InnoDB
Li1LAEc_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_actionscheduler_logs: Data: 1.02MB + Index: 0.47MB + Engine InnoDB
Li1LAEc_commentmeta: Data: 0.17MB + Index: 0.13MB + Engine MyISAM
Li1LAEc_comments: Data: 23.86MB + Index: 8.54MB + Engine MyISAM
Li1LAEc_duplicator_pro_packages: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_dynamic_widgets: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_et_bloom_stats: Data: 10.52MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_ewwwio_images: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_ewwwio_queue: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_gf_entry: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_gf_entry_meta: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
Li1LAEc_gf_entry_notes: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_gf_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_gf_form_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_gf_form_revisions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_gf_form_view: Data: 0.08MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_iLi1LAEc_backup_status: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_iconic_was_fees: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_iconic_woo_linked_variations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_itsec_lockouts: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_itsec_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_itsec_temp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_links: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_options: Data: 10.04MB + Index: 1.56MB + Engine MyISAM
Li1LAEc_pmxe_exports: Data: 0.11MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxe_google_cats: Data: 0.39MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxe_posts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxe_templates: Data: 0.20MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxi_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxi_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxi_imports: Data: 0.06MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxi_posts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_pmxi_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_postmeta: Data: 169.76MB + Index: 102.57MB + Engine MyISAM
Li1LAEc_posts: Data: 11.79MB + Index: 4.36MB + Engine MyISAM
Li1LAEc_redirection_404: Data: 30.06MB + Index: 13.55MB + Engine InnoDB
Li1LAEc_redirection_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_redirection_items: Data: 0.11MB + Index: 0.09MB + Engine InnoDB
Li1LAEc_redirection_logs: Data: 9.52MB + Index: 3.44MB + Engine InnoDB
Li1LAEc_revslider_css: Data: 0.13MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_revslider_layer_animations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_revslider_navigations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_revslider_sliders: Data: 0.05MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_revslider_slides: Data: 0.33MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_revslider_static_slides: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_rg_form: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_rg_form_meta: Data: 0.01MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_rg_form_view: Data: 0.01MB + Index: 0.01MB + Engine MyISAM
Li1LAEc_rg_incomplete_submissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_rg_lead: Data: 0.09MB + Index: 0.01MB + Engine MyISAM
Li1LAEc_rg_lead_detail: Data: 0.15MB + Index: 0.17MB + Engine MyISAM
Li1LAEc_rg_lead_detail_long: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_rg_lead_meta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_rg_lead_notes: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
Li1LAEc_stock_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_swp_cf: Data: 0.30MB + Index: 0.47MB + Engine InnoDB
Li1LAEc_swp_index: Data: 1.52MB + Index: 2.02MB + Engine InnoDB
Li1LAEc_swp_log: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
Li1LAEc_swp_tax: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
Li1LAEc_swp_terms: Data: 0.19MB + Index: 0.30MB + Engine InnoDB
Li1LAEc_term_relationships: Data: 0.27MB + Index: 0.22MB + Engine InnoDB
Li1LAEc_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine MyISAM
Li1LAEc_termmeta: Data: 0.08MB + Index: 0.09MB + Engine InnoDB
Li1LAEc_terms: Data: 0.03MB + Index: 0.07MB + Engine MyISAM
Li1LAEc_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_usermeta: Data: 23.33MB + Index: 15.03MB + Engine MyISAM
Li1LAEc_users: Data: 1.54MB + Index: 1.55MB + Engine MyISAM
Li1LAEc_wc_admin_note_actions: Data: 0.06MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_wc_admin_notes: Data: 0.09MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wc_customer_lookup: Data: 4.52MB + Index: 4.03MB + Engine InnoDB
Li1LAEc_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_wc_order_coupon_lookup: Data: 0.06MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_wc_order_product_lookup: Data: 9.52MB + Index: 8.98MB + Engine InnoDB
Li1LAEc_wc_order_stats: Data: 4.52MB + Index: 5.53MB + Engine InnoDB
Li1LAEc_wc_order_tax_lookup: Data: 2.52MB + Index: 3.03MB + Engine InnoDB
Li1LAEc_wc_product_meta_lookup: Data: 0.13MB + Index: 0.17MB + Engine InnoDB
Li1LAEc_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
Li1LAEc_woocommerce_bundled_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_woocommerce_bundled_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
Li1LAEc_woocommerce_shipping_table_rates: Data: 1.52MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_admin_notices: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_categories: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_category_maps: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_circles: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_image_overlays: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_maps: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_point_labels: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_polygon: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_polylines: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpgmza_rectangles: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpmelon_advbedit_temp: Data: 0.06MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_wpmm_subscribers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
Li1LAEc_yith_wcan_filter_sessions: Data: 0.02MB + Index: 0.05MB + Engine InnoDB

### Post Type Counts ###

acf-field: 2
acf-field-group: 1
attachment: 1272
custom_css: 1
nav_menu_item: 253
page: 14
post: 1
product: 401
product_variation: 555
product-feed: 1
revision: 353
rvp: 2944
shop_coupon: 20
shop_order: 40903
shop_order_refund: 377
sidebar: 4
yith_wcan_preset: 1
ywar_reviews: 2

### Security ###

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

### Active Plugins (45) ###

Gravity Forms: by Gravity Forms – 2.4.17.25
Advanced Coupons for WooCommerce Free: by Rymera Web Co – 4.5.4.2
Advanced Coupons for WooCommerce Premium: by Rymera Web Co – 3.5.4
Advanced Custom Fields PRO: by WP Engine – 6.1.6
Product Feed Manager for WooCommerce: by RexTheme – 7.2.31
Bloom: by Elegant Themes – 1.3.12
Category Checklist Tree: by scribu – 1.3.2
Classic Editor: by WordPress Contributors – 1.6.3
Disable Comments: by WPDeveloper – 2.4.3
Dynamic Widgets: by Qurl – 1.5.16
Enable Media Replace: by ShortPixel – 4.1.2
Genesis Columns Advanced: by Nick Diego – 2.0.5
Homepage Control: by WooThemes – 2.0.3
WooCommerce Attribute Swatches by Iconic: by Iconic  – 1.14.2
PW WooCommerce Copy Coupon: by Pimwick
LLC – 1.25

Recently Viewed Products: by Rajnish Arora – 1.0.0
Redirection: by John Godley – 5.3.10
Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.5
Slider Revolution: by ThemePunch – 5.4.8.1
ShiftNav Pro - Responsive Mobile Menu: by Chris Mavricos
SevenSpark – 1.6.3

Storefront Powerpack: by WooCommerce – 1.4.13
UberMenu 3 - The Ultimate WordPress Mega Menu: by Chris Mavricos
SevenSpark – 3.8.1

User Menus: by Code Atlantic – 1.3.1
W3 Total Cache: by BoldGrid – 2.3.2
WebP Express: by Bjørn Rosell – 0.25.6
WooCommerce Search by Product SKU: by Clayton Kriesel [Three Remain Production] – 1.0
WooCommerce Extended Coupon Features FREE: by Soft79 – 3.3.3
WooCommerce Conditional Shipping and Payments: by SomewhereWarm – 1.8.5
WooCommerce EU VAT Number: by WooCommerce – 2.3.23
WooCommerce SagePay Form and SagePay Direct Gateway: by Andrew Benbow – 3.12.4
WooCommerce Google Analytics Integration: by WooCommerce – 1.8.1
WooCommerce PayPal Payments: by WooCommerce – 2.0.4
WooCommerce Print Invoices/Packing Lists: by SkyVerge – 3.6.1
WooCommerce Product Bundles: by SomewhereWarm – 6.3.5
WooCommerce Table Rate Shipping: by WooCommerce – 3.0.29
WooCommerce Ultimate Multi Currency Suite: by Dev49.net – 1.9.1
WooCommerce: by Automattic – 6.0.1 (update to version 7.7.0 is available)
WP All Export Pro: by Soflyy – 1.8.3
WP Go Maps (formerly WP Google Maps): by WP Go Maps – 9.0.19
WP Mail SMTP: by WP Mail SMTP – 3.8.0
WP All Export - WooCommerce Export Add-On Pro: by Soflyy – 1.0.6
YITH WooCommerce Ajax Product Filter Premium: by YITH – 4.21.0
YITH WooCommerce Brands Add-On Premium: by YITH – 2.12.0
YITH WooCommerce Bulk Product Editing Premium: by YITH – 2.8.0

### Inactive Plugins (1) ###

WooCommerce PayPal Checkout Gateway: by WooCommerce – 2.1.3

### Dropin Plugins (4) ###

advanced-cache.php: advanced-cache.php
db.php: db.php
maintenance.php: maintenance.php
object-cache.php: object-cache.php

### Settings ###

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

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-filtered (exclude-from-filtered)
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: –

### WC Pages ###

Shop base: #4 - /shop/
Basket: #5 - /basket/
Checkout: #6 - /checkout/
My account: #7 - /my-account/
Terms and conditions: ❌ Page ID is set
but the page does not exist

### Theme ###

Name: Removed
Version: 1.0
Author URL: 
Child Theme: ✔
Parent Theme Name: Storefront
Parent Theme Version: 2.8.0 – 4.3.0 is available
Parent Theme Author URL: https://woocommerce.com/
WooCommerce Support: ✔

### Templates ###

Overrides: */woocommerce/checkout/form-login.php
*/woocommerce/content-single-product.php
*/woocommerce/emails/email-header.php
*/woocommerce/emails/email-styles.php
*/woocommerce/global/breadcrumb.php
*/woocommerce/global/form-login.php
*/woocommerce/global/quantity-input.php
*/woocommerce/myaccount/form-login.php
*/woocommerce/product-searchform.php
*/woocommerce/single-product/add-to-cart/external.php
*/woocommerce/single-product/add-to-cart/grouped.php version 4.0.0 is out of date. The core version is 4.8.0
*/woocommerce/single-product/add-to-cart/simple.php
*/woocommerce/single-product/add-to-cart/variable.php
*/woocommerce/single-product/add-to-cart/variation-add-to-cart-button.php
*/woocommerce/single-product/add-to-cart/variation.php
*/woocommerce/single-product/meta.php
*/woocommerce/single-product/price.php
*/woocommerce/single-product/product-attributes.php
*/woocommerce/single-product/share.php
*/woocommerce/single-product/tabs/additional-information.php
*/woocommerce/single-product/up-sells.php

Outdated Templates: ❌

                        Learn how to update

### sagepay ###

MCrypt: ❌ No
OpenSSL: ✔ Yes
OpenSSL Methods: ❌ No
PHP Max_Input_Vars: ❌ Your php_max_inpit_vars value is 1000. If you experience any issues during checkout then increase this value to 5000.

### Product Bundles ###

Database Version: 6.3.5
Loopback Test: –
Template Overrides: –

### WooCommerce PayPal Payments ###

Onboarded: ✔
Shop country code: GB
WooCommerce currency supported: ✔
Advanced Card Processing available in country: ✔
Pay Later messaging available in country: ✔
Webhook status: ✔
Vault enabled: –
Logging enabled: –
Reference Transactions: –
Used PayPal Checkout plugin: ✔
Tracking enabled: –

### Action Scheduler ###

Complete: 2,981
Oldest: 2023-04-21 15:36:36 +0100
Newest: 2023-05-22 14:30:02 +0100

Failed: 4
Oldest: 2023-05-18 15:19:37 +0100
Newest: 2023-05-19 10:22:30 +0100

Pending: 1
Oldest: 2023-05-22 14:30:27 +0100
Newest: 2023-05-22 14:30:27 +0100

### Status report information ###

Generated at: 2023-05-22 14:30:33 +01:00

Isolating the problem

Evaske commented 1 year ago

I got to the bottom of what was causing this. The attributes that were being applied to variable product had slugs that contained an " character. It was obviously throwing something off with the variation selection once the Paypal window was closed. Removing the " character from all the attribute slugs has fixed the issue.

Maybe add something to stop illegal character from being added in to attribute slugs?

vbelolapotkov commented 1 year ago

@woocommerce/quark could you please prioritize this?