Merge pull request #12821 from woocommerce/fix-12713
Don’t erase payment details w/ ‘update_checkout’
This commit is contained in:
commit
173543ba82
|
@ -290,6 +290,20 @@ jQuery( function( $ ) {
|
|||
|
||||
var termsCheckBoxChecked = $( '#terms' ).prop( 'checked' );
|
||||
|
||||
// Save payment details to a temporary object
|
||||
var paymentDetails = {};
|
||||
$( '.payment_box input' ).each( function() {
|
||||
var ID = $( this ).attr( 'id' );
|
||||
|
||||
if ( ID ) {
|
||||
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
|
||||
paymentDetails[ ID ] = $( this ).prop( 'checked' );
|
||||
} else {
|
||||
paymentDetails[ ID ] = $( this ).val();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Always update the fragments
|
||||
if ( data && data.fragments ) {
|
||||
$.each( data.fragments, function ( key, value ) {
|
||||
|
@ -303,6 +317,21 @@ jQuery( function( $ ) {
|
|||
$( '#terms' ).prop( 'checked', true );
|
||||
}
|
||||
|
||||
// Fill in the payment details if possible
|
||||
if ( ! $.isEmptyObject( paymentDetails ) ) {
|
||||
$( '.payment_box input' ).each( function() {
|
||||
var ID = $( this ).attr( 'id' );
|
||||
|
||||
if ( ID ) {
|
||||
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
|
||||
$( this ).prop( 'checked', paymentDetails[ ID ] ).change();
|
||||
} else {
|
||||
$( this ).val( paymentDetails[ ID ] ).change();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check for error
|
||||
if ( 'failure' === data.result ) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue