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

Express checkout, StoreAPI add-to-cart, and booking product compatibility #3871

Open
annemirasol opened this issue Feb 11, 2025 · 0 comments

Comments

@annemirasol
Copy link
Contributor

In #3865, we switched booking products back to the non-StoreAPI add-to-cart method for express checkout, as a quick fix to resolve an issue about missing data.

We need to investigate how to move it back to StoreAPI, and pass the missing data.

The issue seems to be that Bookings assumes that the data is in $_POST when an item is added to the cart, and it performs some validation code: https://github.com/woocommerce/woocommerce-bookings/blob/cd978fe375354dd5c5a872b96d27d6ff7c146cb8/includes/class-wc-booking-cart-manager.php#L88

This is the stack trace for when that part of the code is run, and we are using StoreAPI to add items to the cart:

[11-Feb-2025 17:56:10 UTC] #0 /var/www/html/wp-content/plugins/woocommerce-bookings/includes/class-wc-booking-cart-manager.php(371): wc_bookings_get_posted_data(Array, Object(WC_Product_Booking))
#1 /var/www/html/wp-includes/class-wp-hook.php(326): WC_Booking_Cart_Manager->add_cart_item_data(Array, 59)
#2 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)
#3 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Utilities/CartController.php(1217): apply_filters('woocommerce_add...', Array, 59, 0, NULL)
#4 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Utilities/CartController.php(105): Automattic\WooCommerce\StoreApi\Utilities\CartController->filter_request_data(Array)
#5 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/CartAddItem.php(127): Automattic\WooCommerce\StoreApi\Utilities\CartController->add_to_cart(Array)
#6 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/AbstractRoute.php(119): Automattic\WooCommerce\StoreApi\Routes\V1\CartAddItem->get_route_post_response(Object(WP_REST_Request))
#7 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/AbstractCartRoute.php(125): Automattic\WooCommerce\StoreApi\Routes\V1\AbstractRoute->get_response_by_request_method(Object(WP_REST_Request))
#8 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1292): Automattic\WooCommerce\StoreApi\Routes\V1\AbstractCartRoute->get_response(Object(WP_REST_Request))
#9 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wc/store/v1/ca...', Array, NULL)
#10 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch(Object(WP_REST_Request))
#11 /var/www/html/wp-includes/rest-api.php(449): WP_REST_Server->serve_request('/wc/store/v1/ca...')
#12 /var/www/html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#13 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#14 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#15 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#16 /var/www/html/wp-includes/class-wp.php(813): WP->parse_request('')
#17 /var/www/html/wp-includes/functions.php(1336): WP->main('')
#18 /var/www/html/wp-blog-header.php(16): wp()
#19 /var/www/html/index.php(17): require('/var/www/html/w...')
#20 {main}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant