Fix nonce issues when adding product to cart from All Products (https://github.com/woocommerce/woocommerce-blocks/pull/3598)
* Products extend cart route * load cart in products
This commit is contained in:
parent
84f83f840c
commit
3d92a61102
|
@ -55,6 +55,7 @@ export const controls = {
|
|||
} );
|
||||
} )
|
||||
.catch( ( errorResponse ) => {
|
||||
triggerFetch.setNonce( errorResponse.headers );
|
||||
if ( typeof errorResponse.json === 'function' ) {
|
||||
// Parse error response before rejecting it.
|
||||
errorResponse
|
||||
|
|
|
@ -8,7 +8,7 @@ use Automattic\WooCommerce\Blocks\StoreApi\Utilities\CartController;
|
|||
*
|
||||
* @internal This API is used internally by Blocks--it is still in flux and may be subject to revisions.
|
||||
*/
|
||||
class CartCoupons extends AbstractRoute {
|
||||
class CartCoupons extends AbstractCartRoute {
|
||||
/**
|
||||
* Get the path of this REST route.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,7 @@ use Automattic\WooCommerce\Blocks\StoreApi\Utilities\CartController;
|
|||
*
|
||||
* @internal This API is used internally by Blocks--it is still in flux and may be subject to revisions.
|
||||
*/
|
||||
class CartCouponsByCode extends AbstractRoute {
|
||||
class CartCouponsByCode extends AbstractCartRoute {
|
||||
/**
|
||||
* Get the path of this REST route.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,7 @@ use Automattic\WooCommerce\Blocks\StoreApi\Utilities\CartController;
|
|||
*
|
||||
* @internal This API is used internally by Blocks--it is still in flux and may be subject to revisions.
|
||||
*/
|
||||
class CartItemsByKey extends AbstractRoute {
|
||||
class CartItemsByKey extends AbstractCartRoute {
|
||||
/**
|
||||
* Get the path of this REST route.
|
||||
*
|
||||
|
|
|
@ -44,6 +44,8 @@ class Products extends AbstractRoute {
|
|||
* @return \WP_REST_Response
|
||||
*/
|
||||
protected function get_route_response( \WP_REST_Request $request ) {
|
||||
// we load so that we have the same session, this is done so that Add to Cart can function.
|
||||
$this->maybe_load_cart();
|
||||
$response = new \WP_REST_Response();
|
||||
$product_query = new ProductQuery();
|
||||
|
||||
|
|
Loading…
Reference in New Issue