co-cart / co-cart

🛒 CoCart makes it easy to decouple your WooCommerce store via a customizable REST API that takes the pain out of developing – allowing you to build fast and flexible headless stores.

Home Page:https://cocartapi.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Products disappear when you restore cart

voodoobg opened this issue · comments

Describe the bug

I have a problem that did not existed a while back or at least we didn't know about it. We have problem with disappearing products from the cart itself. Lets say you add 6 different products to the cart and after that shutdown the app. After relaunch 2 of those products disappear. I have the requests that shows this, if you want to check them out, but the thing is we don't clear the cart on exit and removed_items are present also. By logic if a product is in removed_items and you add it again to the cart it should stay in the cart, but in our case the product disappears from cart after you add another product and in the same time stays in the removed_items. Can you help me out with this one? I'm not sure if it was working OK, or we missed something when we did QA.

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest trunk branch of CoCart on GitHub.
  • The issue still exists against the latest dev branch of CoCart on GitHub (this is not the same version as on WordPress.org!).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional)
  • I have installed the requirements to run this plugin.

Steps to reproduce the issue

  1. Add 6 products to cart
  2. Close app and open it again, products are now 4
  3. Missing products are in the removed_items in response but not in the items

Expected/actual behavior

When I follow those steps, I see... Missing products in the cart when you restore it

I was expecting to see... All added products in the cart when you restore it

Screenshots

Isolating the problem

  • This bug happens with only WooCommerce and CoCart plugin are active.
  • This bug happens with a default WordPress theme active.
  • This bug happens with the WordPress theme Storefront active.
  • This bug happens with the latest release of WooCommerce active.
  • This bug happens only when I authenticate as a customer.
  • This bug happens only when I authenticate as administrator.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

```

WordPress Environment

WordPress address (URL): https://store.wooop.bg
Site address (URL): https://store.wooop.bg
WC Version: 6.4.1
REST API Version: ✔ 6.4.1
WC Blocks Version: ✔ 7.2.2
Action Scheduler Version: ✔ 3.4.0
WC Admin Version: ✔ 3.3.2
Log Directory Writable: ✔
WP Version: 6.0.1
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.30
PHP Post Max Size: 250 MB
PHP Time Limit: 3600
PHP Max Input Vars: 10000
cURL Version: 7.84.0
OpenSSL/1.1.1q

SUHOSIN Installed: –
MySQL Version: 5.5.5-10.3.36-MariaDB-log
Max Upload Size: 250 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 6.5.0
WC Database Prefix: wpet_
Total Database Size: 1130.73MB
Database Data Size: 1106.25MB
Database Index Size: 24.48MB
wpet_woocommerce_sessions: Data: 0.01MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_api_keys: Data: 0.04MB + Index: 0.01MB + Engine MyISAM
wpet_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_order_items: Data: 0.06MB + Index: 0.03MB + Engine MyISAM
wpet_woocommerce_order_itemmeta: Data: 0.54MB + Index: 0.27MB + Engine MyISAM
wpet_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_woocommerce_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_actionscheduler_actions: Data: 1.06MB + Index: 0.38MB + Engine MyISAM
wpet_actionscheduler_claims: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_actionscheduler_groups: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_actionscheduler_logs: Data: 0.70MB + Index: 0.50MB + Engine MyISAM
wpet_additional_supplier_info: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_atum_export_templates: Data: 0.11MB + Index: 0.01MB + Engine MyISAM
wpet_atum_inventories: Data: 0.09MB + Index: 0.10MB + Engine MyISAM
wpet_atum_inventory_files: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_atum_inventory_locations: Data: 0.02MB + Index: 0.05MB + Engine MyISAM
wpet_atum_inventory_meta: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_atum_inventory_orders: Data: 0.77MB + Index: 0.10MB + Engine MyISAM
wpet_atum_inventory_regions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_atum_inventory_reserved_stock: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_atum_order_itemmeta: Data: 1.38MB + Index: 1.04MB + Engine MyISAM
wpet_atum_order_items: Data: 0.37MB + Index: 0.14MB + Engine MyISAM
wpet_atum_product_data: Data: 0.07MB + Index: 0.07MB + Engine MyISAM
wpet_cocart_carts: Data: 1.41MB + Index: 0.03MB + Engine MyISAM
wpet_commentmeta: Data: 0.23MB + Index: 0.07MB + Engine MyISAM
wpet_comments: Data: 0.27MB + Index: 0.11MB + Engine MyISAM
wpet_dokan_advertised_products: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wpet_dokan_announcement: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_delivery_time: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_dokan_distance_rate_shipping: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_dokan_follow_store_followers: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_dokan_orders: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wpet_dokan_product_map: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_refund: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_report_abuse_reports: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_dokan_rma_conversations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_rma_request: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_rma_request_product: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_shipping_tracking: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wpet_dokan_shipping_zone_locations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_table_rate_shipping: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wpet_dokan_vendor_balance: Data: 0.06MB + Index: 0.00MB + Engine InnoDB
wpet_dokan_withdraw: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wpet_duplicator_packages: Data: 0.02MB + Index: 0.00MB + Engine MyISAM
wpet_e_events: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_links: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_options: Data: 1046.71MB + Index: 5.36MB + Engine MyISAM
wpet_order_inventory: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_files: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_hash: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_history: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_images: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_imports: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_posts: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_pmxi_templates: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_podsrel: Data: 0.01MB + Index: 0.03MB + Engine MyISAM
wpet_postmeta: Data: 6.13MB + Index: 1.85MB + Engine MyISAM
wpet_posts: Data: 3.98MB + Index: 0.68MB + Engine MyISAM
wpet_redirection_404: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_redirection_groups: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_redirection_items: Data: 0.00MB + Index: 0.02MB + Engine MyISAM
wpet_redirection_logs: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_relevanssi: Data: 0.49MB + Index: 0.60MB + Engine MyISAM
wpet_relevanssi_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_relevanssi_stopwords: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_snippets: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_termmeta: Data: 0.05MB + Index: 0.05MB + Engine MyISAM
wpet_terms: Data: 0.02MB + Index: 0.04MB + Engine MyISAM
wpet_term_relationships: Data: 0.10MB + Index: 0.21MB + Engine MyISAM
wpet_term_taxonomy: Data: 0.01MB + Index: 0.01MB + Engine MyISAM
wpet_tm_taskmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_tm_tasks: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_usermeta: Data: 0.29MB + Index: 0.14MB + Engine MyISAM
wpet_users: Data: 0.02MB + Index: 0.02MB + Engine MyISAM
wpet_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine MyISAM
wpet_wc_admin_note_actions: Data: 0.01MB + Index: 0.00MB + Engine MyISAM
wpet_wc_category_lookup: Data: 0.01MB + Index: 0.01MB + Engine MyISAM
wpet_wc_customer_lookup: Data: 0.01MB + Index: 0.02MB + Engine MyISAM
wpet_wc_download_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_wc_order_coupon_lookup: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_wc_order_product_lookup: Data: 0.07MB + Index: 0.07MB + Engine MyISAM
wpet_wc_order_stats: Data: 0.02MB + Index: 0.03MB + Engine MyISAM
wpet_wc_order_tax_lookup: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_wc_product_attributes_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_wc_product_download_directories: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_wc_product_meta_lookup: Data: 0.09MB + Index: 0.16MB + Engine MyISAM
wpet_wc_rate_limits: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_wc_reserved_stock: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_wc_tax_rate_classes: Data: 0.00MB + Index: 0.01MB + Engine MyISAM
wpet_wc_webhooks: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
wpet_wrc_caches: Data: 36.54MB + Index: 6.89MB + Engine MyISAM
wpet_wrc_relations: Data: 4.04MB + Index: 5.01MB + Engine MyISAM
wpet_wt_iew_action_history: Data: 0.09MB + Index: 0.00MB + Engine MyISAM
wpet_wt_iew_mapping_template: Data: 0.00MB + Index: 0.00MB + Engine MyISAM

Post Type Counts

acf-field: 8
acf-field-group: 1
attachment: 1765
atum_inventory_log: 11
atum_po_delivery: 91
atum_purchase_order: 269
atum_supplier: 19
custom-css-js: 3
custom_css: 1
dokan_announcement: 1
elementor_library: 1
manufacturer: 1
page: 14
post: 7
producer: 163
product: 1281
revision: 556
shop_coupon: 14
shop_order: 25
shop_order_refund: 3
stores: 2
supplier: 1
wp_global_styles: 6
_pods_field: 32
_pods_group: 6
_pods_pod: 6

Security

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

Active Plugins (19)

Wooop Manufacturer: by Svet – 1.0
ATUM Export PRO: by Stock Management Labs™ – 1.4.9
ATUM Multi-Inventory: by Stock Management Labs™ – 1.7.3
ATUM Purchase Orders PRO: by Stock Management Labs™ – 1.0.2
ATUM Inventory Management for WooCommerce: by Stock Management Labs™ – 1.9.19.2
CoCart Lite: by Sébastien Dumont – 3.4.0
CoCart - Cart Enhanced: by Sébastien Dumont – 3.2.0
CoCart Pro: by Sébastien Dumont – 1.0.0-rc.5
Duplicator: by Snap Creek – 1.4.7.1
Hide admin menu: by Bhavin Thummar & Maulik Patel (BM Studio) – 1.1.1
Pods - Custom Content Types and Fields: by Pods Framework Team – 2.8.15
Relevanssi: by Mikko Saari – 4.16.0
REST API for Relevanssi: by Svet – 2
Simple-JWT-Login: by Nicu Micle – 3.4.2
UpdraftPlus - Backup/Restore: by UpdraftPlus.Com
DavidAnderson – 1.22.14

User Role Editor: by Vladimir Garagulya – 4.63
Order Weight for WooCommerce: by Andreas Karman – 0.5.5
WooCommerce: by Automattic – 6.4.1 (update to version 6.8.2 is available)
WP REST Cache: by Acato – 2022.1.0

Inactive Plugins (15)

Disable Gutenberg: by Jeff Starr – 2.7
Dokan: by weDevs – 3.3.9
Dokan Pro: by weDevs – 3.5.2
Elementor: by Elementor.com – 3.6.4
Essential Addons for Elementor: by WPDeveloper – 5.1.0
Maintenance: by WebFactory Ltd – 4.06
Post Meta View and Export: by Matej Kravjar – 1.0
Product CSV Import Export (BASIC): by WebToffee – 2.1.9
Redirection: by John Godley – 5.2.3
REST API Log: by Pete Nelson – 1.6.8
Search Everything: by Sovrn
zemanta – 8.1.9

Simple Custom CSS and JS: by SilkyPress.com – 3.39
WP-Optimize - Clean, Compress, Cache: by David Anderson
Ruhani Rabin
Team Updraft – 3.2.6

WP Admin Customize: by Svet – 1.0
WP Clean Admin Menu: by P. Roy – 2.0

Must Use Plugins (1)

WP REST Cache - Must-Use Plugin: by Richard Korthuis - Acato – 2021.3.0

Settings

API Enabled: –
Force SSL: –
Currency: BGN (лв.)
Currency Position: right_space
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)
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: #103 - /shop/
Cart: #104 - /cart/
Checkout: #105 - /checkout/
My account: #106 - /
Terms and conditions: ❌ Page not set

Theme

Name: Wooop Child
Version: 1.0.0
Author URL: https://wooop.bg
Child Theme: ✔
Parent Theme Name: Astra
Parent Theme Version: 3.7.9 – 3.9.1 is available
Parent Theme Author URL: https://wpastra.com/about/?utm_source=theme_preview&utm_medium=author_link&utm_campaign=astra_theme
WooCommerce Support: ✔

Templates

Overrides: /home/woopbg13/store.wooop.bg/wp-content/plugins/atum-multi-inventory/views/email-templates/email-mi-order-items.php

Action Scheduler

Complete: 4,045
Oldest: 2022-07-23 10:56:47 +0000
Newest: 2022-08-23 06:55:29 +0000

Failed: 1
Oldest: –
Newest: –

Pending: 5
Oldest: 2022-08-23 07:13:19 +0000
Newest: 2022-08-29 12:39:52 +0000

CoCart

Version: 3.4.0
Database Version: 3.6.3
Install Date: 18/03/2022
Carts in Session: 391
Carts Active: 391 out of 391 in session.
Carts Expiring Soon: 0 out of 391 in session.
Carts Expired: 0 out of 391 in session.
Carts Source (by CoCart): 389
Carts Source (by Web): 1
Carts Source (by Other): 1

Status report information

Generated at: 2022-08-23 10:13:36 +03:00

</details>

## Additional context

<!--Any additional context or details you think might be helpful.-->

Hello, i have an update. I've updated cocart and woocommerce to the latest version. The problem still persists, but we managed to narrow it down to probably a timing issue. If we add a product and immediately add another one, the second one disappears from the cart, but the strange thing is I see the requests from the backend and they look fine with status 200.
Now my question is this, do the cocart have time limitation of some kind that it cannot process requests that are received in matter of 1-2 seconds? Probably this also is affected by the hosting server specifications!?

Yes the timing issue makes sense. The reason the second item does not appear because your interrupting the first request that has not yet finished. This is because after everything has been validated it will then update the cart data which the second request will not have.

When the request is complete it will save the cart data to the database on the shutdown hook which is read the next time another request is made to add an item to the cart.

So ideally you will need like a window of time (latency) before allowing another item to be added. Maybe cache the request and then resolve it after a request is completed.

Unless there is a validation issue or an error with the request it will always return with a 200 status.

Closing issue as there has been no updates.