-
Notifications
You must be signed in to change notification settings - Fork 64
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
Delete cart return ok but nothing is deleted #37
Comments
@yaroldlord Are you able to remove it using Postman? |
I don't know how to use postman. I use a simple javascript call
I try also with a curl call. it is the same:
Update work fine but it is not possible to have a quantity of 0 so it cannot be a workaround. |
I just success to use postman. It is the same. I receive a http 200 with "Item has been removed from cart." but the product is still in the cart. |
I just tried in Postman and it works fine. Can you try without authorization applied? |
@yaroldlord Have you tried without authorization using Postman yet? |
I just try and I have a strange behavior: If I try just after refreshing the page in my browser, I get in postman "Item has been removed from cart". (but the article is not removed) !!! If I try again, I receive "Unable to remove item from cart". I'm also trying to debug the code of WC_REST_Cart_Controller::remove_item but I do not understand where the problem comes from: The code runs without error, the article is removed from the cart and yet when I ask again the cart it still contains the Article !! Another point I corrected the error that prevented the update from working with a quantity to 0 ($product_data is not defined in WC_REST_Cart_Controller :: update_item) and the behavior is the same as with remove_item: the request runs without error but the item is not removed from the cart. What's even stranger is that adding article and changing quantity work without error !!! |
I found someone with the same problem as me: |
I try with a new account (not logged as admin for the site) and the problem is still present! |
Here an other with the same probleme: https://wordpress.org/support/topic/sometimes-remove_cart_item-does-not-removeing-item |
The browser and postman do not connect so viewing the items in cart via the browser and removing them via postman will return false results. Second, the articles that you have shared are issues with WooCommerce core. Nothing to do with the REST API that I have built. Is your site or web app live or in a staging area that I can quickly examine? |
After running the API the changes are not kept in the wp_woocommerce_sessions table but only in the php session in all case (delete, update, add). This error has the effect of making the add or update of a product work, but not the delete: the get_cart_from_session function has this behavior when it retrieves the information from the table it takes the information of the session php when they exist otherwise it take that of the table. The fix is not just a call to persistent_cart_update because the current user has been invalidated by rest_cookie_check_errors which checks for the presence of _wpnonce |
So what needs to change? |
It's possible to disable persistant cart. The bug diseapear: The delete work fine. Of course I lose the persistence of the cart at the end of a session. It's just a bad workaround. It seems to me that cart-rest-api has a structural flaw complicate to fix. |
The issue you have is with WooCommerce, not the API. That filter is for the core of WooCommerce so something is wrong with your setup. I have already confirmed that the API works to remove items. I suggest that you also update your PHP version to fill the requirements WooCommerce needs. |
I'm not agree with you. The filter rest_cookie_check_errors is call when a route registered by register_rest_route is present. rest_cookie_check_errors is a general and standard protection against CSRF. To avoid blocking a _wpnonce parameter must be inserted in the call parameters. |
I am able to remove items without the need of using nonces. So this is puzzling. |
Some plugin disable persistent cart. Perhaps... I work with a fresh install of wordpress, woocommerce and cart-rest-api .and nothing else. |
I will run more tests when I have more free time to spend on this project and make adjustments. |
Fr your information, i managed to use the API with persistant cart enabled by doing these operations:
For the 1 I used the trick shown here:
|
@yaroldlord You never did confirm if you had the same issue as a guest (not logged in). |
Sorry. |
Prerequisites
master
branch of Cart REST-API for WooCommerce on Github (this is not the same version as on WordPress.org!)Steps to reproduce the issue
Expected/actual behaviour
When I follow those steps, I see: http 200 and the response is "Item has been removed from cart." but the product is still in the cart
I was expecting to see : the product diseapear from the cart
Isolating the problem
Add, update and get works fine.
WordPress Environment
WC Version: 3.4.4
Log Directory Writable: ✔
WP Version: 4.9.8
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –
Server Environment
Server Info: nginx/1.12.2
PHP Version: 5.4.16 - ❌ WooCommerce will run under this version of PHP
however
it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version
PHP Post Max Size: 8 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.29.0
NSS/3.34
SUHOSIN Installed: –
MySQL Version: 5.5.60-MariaDB
Max Upload Size: 2 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ❌ Your server does not have the SoapClient class enabled - some gateway plugins which use SOAP may not work as expected.
DOMDocument: ❌ Your server does not have the DOMDocument class enabled - HTML/Multipart emails
and also some extensions
will not work without DOMDocument.
GZip: ✔
Multibyte String: ❌ Your server does not support the mbstring functions - this is required for better character encoding. Some fallbacks will be used instead for it.
Remote Post: ✔
Remote Get: ✔
Database
WC Database Version: 3.4.4
WC Database Prefix: wp_
MaxMind GeoIP Database: ✔
Total Database Size: 10.84MB
Database Data Size: 5.80MB
Database Index Size: 5.04MB
wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB
wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB
wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB
wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB
wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB
wp_comments: Data: 0.02MB + Index: 0.09MB
wp_links: Data: 0.02MB + Index: 0.02MB
wp_options: Data: 2.03MB + Index: 0.02MB
wp_postmeta: Data: 2.02MB + Index: 4.05MB
wp_posts: Data: 1.19MB + Index: 0.20MB
wp_termmeta: Data: 0.02MB + Index: 0.03MB
wp_terms: Data: 0.02MB + Index: 0.03MB
wp_term_relationships: Data: 0.08MB + Index: 0.05MB
wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB
wp_usermeta: Data: 0.02MB + Index: 0.03MB
wp_users: Data: 0.02MB + Index: 0.05MB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB
wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB
Post Type Counts
attachment: 323
page: 26
post: 2
product: 452
revision: 31
Security
Secure connection (HTTPS): ❌
Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: ✔
Active Plugins (2)
Cart REST API for WooCommerce: by Sébastien Dumont – 1.0.4
WooCommerce: by Automattic – 3.4.4
Settings
API Enabled: –
Force SSL: –
Currency: EUR (€)
Currency Position: right
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)
WC Pages
Shop base: #5 - /shop/
Cart: #6 - /divers/cart/
Checkout: #7 - /divers/checkout/
My account: #8 - /divers/my-account/
Terms and conditions: ❌ Page not set
Theme
Name: Shop Isle
Version: 1.1.46
Author URL: https://themeisle.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: –
`
The text was updated successfully, but these errors were encountered: