Skip to content
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

Unable to remove item from cart #25

Closed
Janie20 opened this issue Apr 5, 2018 · 25 comments
Closed

Unable to remove item from cart #25

Janie20 opened this issue Apr 5, 2018 · 25 comments
Assignees
Labels
type: bug The issue is a confirmed bug.

Comments

@Janie20
Copy link

Janie20 commented Apr 5, 2018

Sorry, if this is the right place to post this, but I have no idea where to reach help.
i'm creating an ios application for woocommerce website and I was able to use this plugin to add product to cart , view cart , and clear cart , but I could not get through with the delete request to remove an item from cart , below is the screen short I used postman to test out

------ GET request
screen shot 2018-04-05 at 3 11 12 pm
------ DELETE request
screen shot 2018-04-05 at 3 05 31 pm

@Janie20 Janie20 changed the title Delete request SUCCESS with status 500 Delete request , response: SUCCESS with status 500 Apr 5, 2018
@seb86
Copy link
Member

seb86 commented Apr 8, 2018

When you say the delete request was SUCCESS with status 500 does that mean it is deleting the item but still returns an error response?

@Janie20 Janie20 changed the title Delete request , response: SUCCESS with status 500 Delete request , response: status 500 Apr 9, 2018
@Janie20
Copy link
Author

Janie20 commented Apr 9, 2018

@seb86 Sorry for my english and No it did not delete the item in the cart.

@seb86
Copy link
Member

seb86 commented Apr 10, 2018

OK I will look into the issue. Could you please provide me with your WooCommerce system status report. Thank you.

@seb86 seb86 changed the title Delete request , response: status 500 Unable to remove item from cart Apr 10, 2018
@seb86 seb86 self-assigned this Apr 10, 2018
@seb86
Copy link
Member

seb86 commented Apr 10, 2018

@Janie20 I have not been able to replicate your issue. I was able to remove an item using Postman with no problems.

Did you add the item via Postman first or did you add the item via the site first then try to remove it via Postman because it can not see your browser session?

Steps I took to remove item in Postman.

  1. View cart - cart is empty
  2. Add an item - cart returned with item
  3. View cart - cart returns with item
  4. Delete item - item is removed
  5. View cart - cart is empty

@Janie20
Copy link
Author

Janie20 commented Apr 11, 2018

I did the same steps that you took , but i would still get the error on step 4.
I'm new to woocommerce , is this the system report you are looking for ?
`

WordPress Environment

Home URL: http://localhost/wordpress
Site URL: http://localhost/wordpress
WC Version: 3.3.4
Log Directory Writable: ✔
WP Version: 4.9.5
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US

Server Environment

Server Info: Apache/2.2.32 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.1.8 mod_ssl/2.2.32 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
PHP Version: 7.1.8
PHP Post Max Size: 32 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.52.1
OpenSSL/1.0.2j

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

Database

WC Database Version: 3.3.4
WC Database Prefix: wp_
MaxMind GeoIP Database: ✔
Total Database Size: 2.68MB
Database Data Size: 1.81MB
Database Index Size: 0.87MB
wp_woocommerce_sessions: Data: 0.17MB + 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: 1.05MB + Index: 0.02MB
wp_postmeta: Data: 0.05MB + Index: 0.03MB
wp_posts: Data: 0.02MB + Index: 0.06MB
wp_termmeta: Data: 0.02MB + Index: 0.03MB
wp_terms: Data: 0.02MB + Index: 0.03MB
wp_term_relationships: Data: 0.02MB + Index: 0.02MB
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
wp_yoast_seo_links: Data: 0.02MB + Index: 0.02MB
wp_yoast_seo_meta: Data: 0.02MB + Index: 0.00MB

Post Type Counts

attachment: 3
customize_changeset: 2
nav_menu_item: 10
page: 8
post: 1
product: 2
revision: 5
shop_order: 3

Security

Secure connection (HTTPS): ❌Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: ✔

Active Plugins (7)

AiCS ipay88 Woocommerce: by AiCS – 1.1.0 – Not tested with the active version of WooCommerce
Cart REST API for WooCommerce: by Sébastien Dumont – 1.0.2
Ocean Extra: by OceanWP – 1.4.9
WP REST API: by WP REST API Team – 2.0-beta15
WooCommerce PayPal Express Checkout Gateway: by WooCommerce – 1.5.1
WooCommerce: by Automattic – 3.3.4 – 3.3.5 is available
WP BASIC Auth: by wokamoto – 1.1.3

Settings

API Enabled: ✔
Force SSL: –
Currency: MYR (RM)
Currency Position: left
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: #4 - /
Cart: #5 - /cart/
Checkout: #6 - /checkout/
My account: #7 - /my-account/
Terms and conditions: ❌ Page not set

Theme

Name: OceanWP
Version: 1.5.9 – 1.5.10 is available
Author URL: https://oceanwp.org/about-me/
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: oceanwp/woocommerce/cart/mini-cart.php
oceanwp/woocommerce/loop/loop-start.php
oceanwp/woocommerce/single-product/title.php

@seb86
Copy link
Member

seb86 commented Apr 11, 2018

Thank you for sharing your system report. Can you tell me why you have WP REST API installed? It's already part of WordPress. That could be causing some issues. Please disable it and try again.

@Janie20
Copy link
Author

Janie20 commented Apr 11, 2018

I deactivated it and try again , but still getting the same error result.

@seb86
Copy link
Member

seb86 commented Apr 11, 2018

Are you using authentication when removing the item?

@seb86
Copy link
Member

seb86 commented Apr 11, 2018

Can you make sure the item key is also correct.

@Janie20
Copy link
Author

Janie20 commented Apr 12, 2018

No, I'm not using authentication, when removing the item. I make sure my cart is not empty as you can see in the first picture , then I tried to remove the item , I only put the cart_item_key on the body.
I can't figure out where I'm wrong , am I missing any steps here ? Really appreciate your help !

screen shot 2018-04-12 at 9 17 42 am

screen shot 2018-04-12 at 9 16 15 am

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

I see what you are doing now. You are adding the cart_item_key as form-data when you should be adding it to the parameters. Clear the form-data and click on "Params" next to the big blue "Send" button.

Then add the key and value there. Then press "Send".

@Janie20
Copy link
Author

Janie20 commented Apr 12, 2018

Oh, I did not know that , I tried what you suggest and this is my result.
screen shot 2018-04-12 at 11 24 51 am

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

Can you disable all plugins execpt for WooCommerce and the Cart REST API and try again after refreshing your permalinks to flush the rewrite rules please.

@Janie20
Copy link
Author

Janie20 commented Apr 12, 2018

still not working ...

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

Then the only thing I can think of is that there is something wrong with your Postman software because you should only get that error if the cart_item_key is not added as a parameter which you have done.

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

Are you able to run the same tests with your site online?

@Janie20
Copy link
Author

Janie20 commented Apr 12, 2018

You mean publish my website on the internet ?

I used ngrok to run my site and repeat the steps ( with only two plugin activated which is the Cart REST API and WooCommerce , sadly I'm still getting the same result.

This is the screenshot capture on the ngrok terminal
screen shot 2018-04-12 at 1 30 54 pm

screen shot 2018-04-12 at 1 37 26 pm

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

This is so weird. If the body is used to apply cart_item_key with form-data set it does not send the item key as a string so reports the error.

If posted with x-www-form-urlencoded set, it works.

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

But the best option is still to use the "Params" to apply the cart_item_key. Works every time for me so what I would like you to do is the following:

  1. View Cart - (GET) https://sebdumont.xyz/dev/wp-json/wc/v2/cart - Does it say "Cart is empty!"?
  2. Add Product - (POST) https://sebdumont.xyz/dev/wp-json/wc/v2/cart/add?product_id=60 - Does it return item data in the body response?
  3. Do step 1 again to make sure the product was added.
  4. Remove Product - (DELETE) https://sebdumont.xyz/dev/wp-json/wc/v2/cart/cart-item?cart_item_key=072b030ba126b2f4b2374f342be9ed44 - Does it remove the item?
  5. Do step 1 again to make sure the cart is empty again.

If that fails then I will look further into the issue. I would just like to see what you get after running this test.

Thank you.

@seb86
Copy link
Member

seb86 commented Apr 12, 2018

@Janie20 Let me know when you have run the tests as I asked above. Thank you.

@Janie20
Copy link
Author

Janie20 commented Apr 18, 2018

@seb86 I have founded whats the problem that causing the error , it turns out to be the cart item key that I get was the reason causing the error. I'm not sure if this is the main reason, but it works perfectly fine after I done some configuration on my site, then I go create a new product , and the key that generated become slightly different as I realize the key generated now start with a number instead of an alphabet like my previous cart item key. Now it works perfectly fine. Thank you for answering my question , really appreciate the help ^_^

previous = "c16a5320fa475530d9583c34fd356ef5"
now = "9f61408e3afb633e50cdf1b20de6f466"

@seb86
Copy link
Member

seb86 commented Apr 18, 2018

@Janie20 Can you tell me what configurations you made to your site that you think helped fix the issue?

If the issue is with the cart item key starting with a letter rather than a number then that will need to be confirmed.

Do all your products item key start with a letter or number? I will comfirm on my end to see if that is the case. So far no one else has reported this issue.

@seb86
Copy link
Member

seb86 commented Apr 18, 2018

I can confirm that products cart_item_key can start with a letter or number. When it starts with a letter it is unable to validate the value not being a 0. See line 362-364 on removing an item.

I will change this validation and put out a release soon.

@seb86 seb86 added type: bug The issue is a confirmed bug. and removed bug:unconfirmed labels Apr 18, 2018
@seb86
Copy link
Member

seb86 commented Apr 18, 2018

The same validation will be applied to restoring and updating an item.

@seb86
Copy link
Member

seb86 commented Apr 18, 2018

OK I have pushed changes @Janie20.

Can you download the update and run your tests again please to confirm.

Let me know if the issue is resolved afterwards. Thank you.

@seb86 seb86 closed this as completed Apr 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

2 participants