Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 44e0904

Browse files
oprsenadir
authored andcommitted
Fix bug with server errors not showing in Cart/Checkout (#6268)
* Add correct context to checkout and cart errors from API * Correct typo in add-to-cart context * Add correct context in add to cart form * Add correct context in add to cart form * Add correct context in Checkout State
1 parent d181d21 commit 44e0904

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

assets/js/base/context/providers/add-to-cart-form/form-state/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ export const AddToCartFormStateContextProvider = ( {
178178
response.forEach(
179179
( { errorMessage, validationErrors } ) => {
180180
if ( errorMessage ) {
181-
createErrorNotice(
182-
errorMessage,
183-
'wc/add-to-cart'
184-
);
181+
createErrorNotice( errorMessage, {
182+
context: 'wc/add-to-cart',
183+
} );
185184
}
186185
if ( validationErrors ) {
187186
setValidationErrors( validationErrors );

assets/js/base/context/providers/add-to-cart-form/form/submit/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ const FormSubmit = () => {
106106
'woo-gutenberg-products-block'
107107
),
108108
{
109-
id: 'dadd-to-cart',
109+
id: 'add-to-cart',
110+
context: `woocommerce/single-product/${
111+
product?.id || 0
112+
}`,
110113
}
111114
);
112115
}

assets/js/base/context/providers/cart-checkout/checkout-processor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,13 @@ const CheckoutProcessor = () => {
235235
}
236236
createErrorNotice(
237237
formatStoreApiErrorMessage( response ),
238-
{ id: 'checkout' }
238+
{ id: 'checkout', context: 'wc/checkout' }
239239
);
240240
response?.additional_errors?.forEach?.(
241241
( additionalError ) => {
242242
createErrorNotice( additionalError.message, {
243243
id: additionalError.error_code,
244+
context: 'wc/checkout',
244245
} );
245246
}
246247
);
@@ -260,7 +261,7 @@ const CheckoutProcessor = () => {
260261
'woo-gutenberg-products-block'
261262
)
262263
),
263-
{ id: 'checkout' }
264+
{ id: 'checkout', context: 'wc/checkout' }
264265
);
265266
}
266267
dispatchActions.setHasError( true );

assets/js/base/context/providers/cart-checkout/checkout-state/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export const CheckoutStateProvider = ( {
174174
if ( Array.isArray( response ) ) {
175175
response.forEach(
176176
( { errorMessage, validationErrors } ) => {
177-
createErrorNotice( errorMessage );
177+
createErrorNotice( errorMessage, {
178+
context: 'wc/checkout',
179+
} );
178180
setValidationErrors( validationErrors );
179181
}
180182
);
@@ -277,6 +279,7 @@ export const CheckoutStateProvider = ( {
277279
);
278280
createErrorNotice( message, {
279281
id: 'checkout',
282+
context: 'wc/checkout',
280283
} );
281284
}
282285

assets/js/blocks/cart/inner-blocks/filled-cart-block/frontend.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const FrontendBlock = ( {
3030
createErrorNotice( decodeEntities( error.message ), {
3131
isDismissible: true,
3232
id: error.code,
33+
context: 'wc/cart',
3334
} );
3435
} );
3536
}, [ createErrorNotice, cartItemErrors ] );

0 commit comments

Comments
 (0)