co-cart / co-cart

πŸ›’ CoCart is a free REST API with all you need to decouple your WooCommerce store, build in any web framework, literally everything can be customized and saves you countless hours.
https://cocartapi.com
Other
373 stars 64 forks source link

ISBAT Load Cart from Session with redirect. Does not work when logged out #205

Closed ricokahler closed 3 years ago

ricokahler commented 3 years ago

Prerequisites

Steps to reproduce the issue

  1. Ensure logged out of WordPress instance
  2. Create a cart with a cart key
  3. Navigate to /?cocart-load-cart=<cart_key>&redirect=true
  4. Observe: For our site, this does not populate the cart.
  5. Login into the WordPress instance
  6. Navigate to /?cocart-load-cart=<cart_key>&redirect=true again
  7. Observe a populated cart

Expected/actual behaviour

I expect that the cart to be loaded with redirect=true regardless if there the user is logged in or not.

When I follow those steps, I see...

A cart with 0 items

I was expecting to see...

A cart with items.

Here is a video demo of a similar reproduction.

CleanShot 2021-01-24 at 10 17 40

In this GIF, I try loading the cart from the session with redirect=true (does not work) and then I try it without the redirect param (works)

Isolating the problem

WordPress Environment

``` Go to "WooCommerce > System Status then copy and paste the system status report here. ` ### WordPress Environment ### WordPress address (URL): http://bloomwoo.bloomscape.com Site address (URL): https://bloomwoo.bloomscape.com WC Version: 4.9.1 REST API Version: βœ” 4.9.1 WC Blocks Version: βœ” 4.0.0 Action Scheduler Version: βœ” 3.1.6 WC Admin Version: βœ” 1.8.3 Log Directory Writable: βœ” WP Version: 5.6 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: – Language: en_US External object cache: βœ” ### Server Environment ### Server Info: Apache PHP Version: 7.4.13 PHP Post Max Size: 100 MB PHP Time Limit: 3600 PHP Max Input Vars: 10000 cURL Version: 7.58.0 OpenSSL/1.1.1 SUHOSIN Installed: – MySQL Version: 5.7.32-35-log Max Upload Size: 50 MB Default Timezone is UTC: βœ” fsockopen/cURL: βœ” SoapClient: βœ” DOMDocument: βœ” GZip: βœ” Multibyte String: βœ” Remote Post: βœ” Remote Get: βœ” ### Database ### WC Database Version: 4.9.1 WC Database Prefix: wp_ Total Database Size: 5.16MB Database Data Size: 3.03MB Database Index Size: 2.13MB 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.22MB + Index: 0.14MB + 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_adtribes_my_conversions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_cocart_carts: Data: 0.03MB + Index: 0.02MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.06MB + Index: 0.09MB + Engine InnoDB wp_email_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_ms_snippets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_options: Data: 1.22MB + Index: 0.06MB + Engine InnoDB wp_pimwick_gift_card: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_pimwick_gift_card_activity: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_postmark_log: Data: 0.06MB + Index: 0.00MB + Engine InnoDB wp_postmeta: Data: 0.31MB + Index: 0.34MB + Engine InnoDB wp_posts: Data: 0.06MB + Index: 0.06MB + Engine InnoDB wp_snippets: Data: 0.02MB + Index: 0.00MB + 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.05MB + 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_meta_lookup: Data: 0.02MB + Index: 0.09MB + 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 wp_wfls_2fa_secrets: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wfls_settings: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_yoast_indexable: Data: 0.02MB + Index: 0.08MB + Engine InnoDB wp_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_yoast_seo_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yoast_seo_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB ### Post Type Counts ### attachment: 11 nav_menu_item: 35 page: 8 post: 3 product: 5 product_variation: 2 shop_coupon: 8 shop_order: 66 shop_order_refund: 1 ### Security ### Secure connection (HTTPS): βœ” Hide errors from visitors: βœ” ### Active Plugins (2) ### CoCart Lite: by SΓ©bastien Dumont – 2.9.0-RC.2 WooCommerce: by Automattic – 4.9.1 ### Inactive Plugins (8) ### Klarna On-Site Messaging for WooCommerce: by krokedil klarna – 1.4.3 Klarna Order Management for WooCommerce: by klarna krokedil – 1.6.5 Klarna Payments for WooCommerce: by krokedil klarna automattic – 2.1.4 Postmark (Official): by Andrew Yates & Matt Gibbs – 1.13.3 Variation Swatches for WooCommerce: by Emran Ahmed – 1.1.5 WooCommerce AvaTax: by SkyVerge – 1.11.1 WooCommerce Smart Coupons: by StoreApps – 4.15.0 WooCommerce Stripe Gateway: by WooCommerce – 4.7.0 ### Dropin Plugins (2) ### advanced-cache.php: advanced-cache.php object-cache.php: Memcached Redux ### Must Use Plugins (4) ### Force Strong Passwords - WPE Edition: by Jason Cosper – 1.6.4 WP Engine Seamless Login Plugin: by WP Engine – 1.5.5 WP Engine Security Auditor: by wpengine – 1.0.9 WP Engine System: by WP Engine – 4.1.0 ### Settings ### API Enabled: – Force SSL: βœ” Currency: USD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: composite (composite) external (external) grouped (grouped) pw gift card (pw-gift-card) simple (simple) variable (variable) woosb (woosb) yith_bundle (yith_bundle) 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: – ### WC Pages ### Shop base: # 6 - /shop/ Cart: # 7 - /cart/ Checkout: # 8 - /checkout/ My account: # 9 - /my-account/ Terms and conditions: ❌ Page visibility should be public ### Theme ### Name: Storefront Version: 3.3.0 Author URL: https://woocommerce.com/ 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: – ### CoCart ### Version: 2.9.0-RC.2 Database Version: 2.9.0-RC.2 Install Date: January 24 2021 Carts in Session: 15 Carts Expiring Soon: 0 out of 15 in session. Carts Expired: 0 out of 15 in session. ### Action Scheduler ### Complete: 4 Oldest: 2021-01-05 08:54:05 -0500 Newest: 2021-01-24 09:59:03 -0500 Pending: 1 Oldest: 2021-01-24 10:02:45 -0500 Newest: 2021-01-24 10:02:45 -0500 ` ```
seb86 commented 3 years ago

Thank you for your detailed report @ricokahler

It is a known issue and one I am doing my best to figure out how to solve. No eta at this time.

seb86 commented 3 years ago

This release should solve this issue @ricokahler Please test and provide feedback.

Thank you.

ricokahler commented 3 years ago

Hi @seb86 thanks for the follow-up! However, I am still getting this issue.

Here's a video reproduction on the new version

CleanShot 2021-01-29 at 07 55 51

Here I:

  1. Ensure CoCart v2.9.0-rc.3 and WooComerce are the only plugins active
  2. Grab a CartKey
  3. Open a new incognito window for a fresh logged-out/unauthenticated session
  4. Navigate to ?cocart-load-cart=<key>&redirect=true. See empty cart (bug)
  5. Navigate to ?cocart-load-cart=<key> (without redirect=true) and it works.

The only case that doesn't work is if you're logged out and redirect=true is applied when trying to load cart from session

seb86 commented 3 years ago

Thank you for the feedback. I will run some more tests to see what is still missing.

seb86 commented 3 years ago

Just to give you a small update @ricokahler I'm re-writing this feature with the support of the changes I had made the day before. Hopefully it will be more affective and cleaner in the background. Thank you for your patience.

ricokahler commented 3 years ago

Hey, thanks for the great support!

seb86 commented 3 years ago

Moving this issue to be completed for v3.0.0

seb86 commented 3 years ago

Related issues: #209 , #208

seb86 commented 3 years ago

Deprecating the redirect option after many failed attempts. Better to just load the cart in session on the page you wish to be on.