[v3.1] When updating individual item in cart, the product data is not passed when validating the quantity.
seb86 opened this issue · comments
Describe the bug
Same as the issue title: When updating individual item in cart, the product data is not passed when validating the quantity.
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 (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
- Update any item in the cart.
- I used the application Postman.
- Make sure you have debug enabled.
Expected/actual behaviour
When I follow those steps, I see...
Fatal error: Uncaught Error: Call to a member function get_min_purchase_quantity() on null in /home/customer/www/domain.me/public_html/wp-content/plugins/cart-rest-api-for-woocommerce/includes/api/cocart/v2/cart/class-cocart-cart-controller.php:346
Stack trace: #0 /home/customer/www/domain.me/public_html/wp-content/plugins/cart-rest-api-for-woocommerce/includes/api/cocart/v2/cart/class-cocart-update-item-controller.php(79): CoCart_Cart_V2_Controller->validate_quantity(2)
#1 /home/customer/www/domain.me/public_html/wp-includes/rest-api/class-wp-rest-server.php(1141): CoCart_Update_Item_v2_Controller->update_item(Object(WP_REST_Request))
#2 /home/customer/www/domain.me/public_html/wp-includes/rest-api/class-wp-rest-server.php(988): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/cocart/v2/cart...', Array, NULL)
#3 /home/customer/www/domain.me/public_html/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request))
#4 /home/cu in /home/customer/www/domain.me/public_html/wp-content/plugins/cart-rest-api-for-woocommerce/includes/api/cocart/v2/cart/class-cocart-cart-controller.php on line 346
I was expecting to see the cart resposne returned.
Screenshots
None, shared error response instead.
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.
Additional context
None
This issue was reported by Rahul in live chat.