Refresh checkout totals after validation if needed

Refreshing the totals the same way as WC does this.
This commit is contained in:
Alex P 2023-04-04 11:35:16 +03:00
parent c03b3d86b5
commit 3c557907f2
No known key found for this signature in database
GPG key ID: 54487A734A204D71
5 changed files with 47 additions and 11 deletions

View file

@ -62,6 +62,11 @@ class CheckoutActionHandler {
);
} else {
errorHandler.clear();
if (data.data.refresh) {
jQuery( document.body ).trigger( 'update_checkout' );
}
if (data.data.errors?.length > 0) {
errorHandler.messages(data.data.errors);
} else if (data.data.details?.length > 0) {

View file

@ -23,6 +23,10 @@ export default class FormValidator {
const data = await res.json();
if (!data.success) {
if (data.data.refresh) {
jQuery( document.body ).trigger( 'update_checkout' );
}
if (data.data.errors) {
return data.data.errors;
}