Make coupon errors properly refresh the checkout page
This commit is contained in:
parent
2a639fd459
commit
4ad3709859
|
@ -294,7 +294,7 @@ jQuery( function( $ ) {
|
||||||
var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' );
|
var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' );
|
||||||
|
|
||||||
// Reload the page if requested
|
// Reload the page if requested
|
||||||
if ( 'true' === data.reload ) {
|
if ( true === data.reload ) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -448,26 +448,26 @@ jQuery( function( $ ) {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function( result ) {
|
success: function( result ) {
|
||||||
try {
|
try {
|
||||||
if ( result.result === 'success' ) {
|
if ( 'success' === result.result ) {
|
||||||
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
|
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
|
||||||
window.location = result.redirect;
|
window.location = result.redirect;
|
||||||
} else {
|
} else {
|
||||||
window.location = decodeURI( result.redirect );
|
window.location = decodeURI( result.redirect );
|
||||||
}
|
}
|
||||||
} else if ( result.result === 'failure' ) {
|
} else if ( 'failure' === result.result ) {
|
||||||
throw 'Result failure';
|
throw 'Result failure';
|
||||||
} else {
|
} else {
|
||||||
throw 'Invalid response';
|
throw 'Invalid response';
|
||||||
}
|
}
|
||||||
} catch( err ) {
|
} catch( err ) {
|
||||||
// Reload page
|
// Reload page
|
||||||
if ( result.reload === 'true' ) {
|
if ( true === result.reload ) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger update in case we need a fresh nonce
|
// Trigger update in case we need a fresh nonce
|
||||||
if ( result.refresh === 'true' ) {
|
if ( true === result.refresh ) {
|
||||||
$( document.body ).trigger( 'update_checkout' );
|
$( document.body ).trigger( 'update_checkout' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ jQuery( function( $ ) {
|
||||||
},
|
},
|
||||||
submit_error: function( error_message ) {
|
submit_error: function( error_message ) {
|
||||||
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
||||||
wc_checkout_form.$checkout_form.prepend( '<div class="woocommerce-NoticeGroup-updateOrderReview">' + error_message + '</div>' );
|
wc_checkout_form.$checkout_form.prepend( error_message );
|
||||||
wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock();
|
wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock();
|
||||||
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).blur();
|
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).blur();
|
||||||
$( 'html, body' ).animate({
|
$( 'html, body' ).animate({
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue