-
Notifications
You must be signed in to change notification settings - Fork 221
Disable "Place order" button in Checkout block if any errors are visible and add explicitDismiss option when throwing API errors #7783
Conversation
Move snackbar hiding filter before notice creation Implements showApplyCouponNotice Refactor context providers Use STORE_NOTICE_CONTEXTS use refs to track notice containers Refactor ref usage Use existing noticeContexts
Co-authored-by: Thomas Roberts <[email protected]>
* Update API type defs * Move create notice utils * Replace useCheckoutNotices with new contexts * processCheckoutResponseHeaders should check headers are defined * Scroll to error notices only if we're not editing a field * Error handling utils * processErrorResponse when pushing changes * processErrorResponse when processing checkout * remove formatStoreApiErrorMessage * Add todo for cart errors * Remove unused deps * unused imports * Fix linting warnings * Unused dep * Update assets/js/types/type-defs/api-response.ts Co-authored-by: Thomas Roberts <[email protected]> * Add todo * Use generic * remove const * Update array types * Phone should be in address blocks Co-authored-by: Thomas Roberts <[email protected]>
The release ZIP for this PR is accessible via:
|
@@ -100,11 +100,9 @@ const updateCustomerData = debounce( (): void => { | |||
} | |||
|
|||
if ( Object.keys( customerDataToUpdate ).length ) { | |||
removeAllNotices(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures error notices are removed before trying to update the customer data. If we want to prevent pushing to the API if errors exist, we need to ensure there is a clean slate before trying.
Script Dependencies ReportThe
This comment was automatically generated by the |
TypeScript Errors ReportFiles with errors: 434
assets/js/atomic/blocks/product-elements/category-list/index.ts
assets/js/base/components/cart-checkout/address-form/address-form.tsx assets/js/base/context/hooks/use-checkout-extension-data.ts assets/js/base/context/providers/cart-checkout/checkout-events/index.tsx assets/js/base/utils/create-notice.ts assets/js/data/cart/resolvers.ts assets/js/data/cart/test/resolvers.js assets/js/data/checkout/types.ts assets/js/data/checkout/utils.ts assets/js/data/index.ts assets/js/data/payment/types.ts assets/js/data/shared-controls.ts assets/js/data/validation/actions.ts assets/js/data/validation/reducers.ts assets/js/data/validation/test/reducers.ts assets/js/data/validation/test/selectors.ts packages/checkout/components/store-notices-container/snackbar-notices.tsx packages/checkout/components/store-notices-container/store-notices.tsx packages/checkout/components/store-notices-container/test/index.tsx |
Size Change: +167 B (0%) Total Size: 966 kB
ℹ️ View Unchanged
|
Please see my comment here: #5972 (comment) And refer to the post on woocheckout p2 regarding in which I wrote about “Blocking” Events (the idea that we allow extensions to prevent checkout just before the request is submitted), and:
Which would show cart-state-related errors before the checkout is displayed. I'm not convinced blocking the button is good UX for the presence of errors, namely because:
If we're talking specifically about cart state errors like in the screenshots, we could throw the error again. And we should probably offer a CTA to fix the issue without leaving checkout! |
I see some other conversations from last week which is probably related to this. Still catching up. |
3530786
to
fc95e40
Compare
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
5f4f70f
to
fc66f01
Compare
1c4ca05
to
0f3bf98
Compare
6aacbfc
to
c47265f
Compare
This PR is based on #7711 and will prevent the "Place order" button from being pressed if any notices of type
error
are present in any of the notice contexts related to WC Blocks.It also adds the option to specify an
explicitDismiss
property in the additional data of an API error, this will in turn pass the value onto the snackbar notice displayed.Fixes #5972
Screenshots
Testing
Automated Tests
User Facing Testing
Note, there is currently a bug so an actual checkout won't work, so no need to report that. It has been noted here: #7711 (review)
WooCommerce Visibility
Changelog