[2.6] Fire tokenisation event on load for pay page.

Fixes #12047
This commit is contained in:
Mike Jolley 2016-10-14 12:39:19 +01:00
parent c93486ccc7
commit c893bf34aa
4 changed files with 9 additions and 8 deletions

View File

@ -3,10 +3,11 @@ jQuery( function( $ ) {
$( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' );
$( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' );
$( 'body' )
.on( 'updated_checkout', function() {
$( document.body )
.on( 'updated_checkout wc-credit-card-form-init', function() {
$( '.wc-credit-card-form-card-number' ).payment( 'formatCardNumber' );
$( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' );
$( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' );
});
} );
})
.trigger( 'wc-credit-card-form-init' );
} );

View File

@ -1 +1 @@
jQuery(function(a){a(".wc-credit-card-form-card-number").payment("formatCardNumber"),a(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),a(".wc-credit-card-form-card-cvc").payment("formatCardCVC"),a("body").on("updated_checkout",function(){a(".wc-credit-card-form-card-number").payment("formatCardNumber"),a(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),a(".wc-credit-card-form-card-cvc").payment("formatCardCVC")})});
jQuery(function(a){a(".wc-credit-card-form-card-number").payment("formatCardNumber"),a(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),a(".wc-credit-card-form-card-cvc").payment("formatCardCVC"),a(document.body).on("updated_checkout wc-credit-card-form-init",function(){a(".wc-credit-card-form-card-number").payment("formatCardNumber"),a(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),a(".wc-credit-card-form-card-cvc").payment("formatCardCVC")}).trigger("wc-credit-card-form-init")});

View File

@ -42,7 +42,7 @@
// Check that the field is shown in the form - some plugins and force create account remove it
if ( $( 'input#createaccount' ).length && ! $('input#createaccount').is( ':checked' ) ) {
$wcTokenizationForm.hideSaveNewCheckbox();
}
}
};
@ -74,7 +74,7 @@
return wcTokenizationForm;
})();
$( document.body ).on( 'updated_checkout', function() {
$( document.body ).on( 'updated_checkout wc-credit-card-form-init', function() {
// Loop over gateways with saved payment methods
var $saved_payment_methods = $( 'ul.woocommerce-SavedPaymentMethods' );

View File

@ -1 +1 @@
!function(a){a(function(){var b=function(){function b(b){var c=a(b),d=c.closest(".payment_box"),e=this;this.onTokenChange=function(){"new"===a(this).val()?(e.showForm(),e.showSaveNewCheckbox()):(e.hideForm(),e.hideSaveNewCheckbox())},this.onCreateAccountChange=function(){a(this).is(":checked")?e.showSaveNewCheckbox():e.hideSaveNewCheckbox()},this.onDisplay=function(){0===a(":input.woocommerce-SavedPaymentMethods-tokenInput:checked",c).length&&a(":input.woocommerce-SavedPaymentMethods-tokenInput:last",c).prop("checked",!0),0===c.data("count")&&a(".woocommerce-SavedPaymentMethods-new",c).hide(),a(":input.woocommerce-SavedPaymentMethods-tokenInput:checked",c).trigger("change"),a("input#createaccount").length&&!a("input#createaccount").is(":checked")&&e.hideSaveNewCheckbox()},this.hideForm=function(){a(".wc-payment-form",d).hide()},this.showForm=function(){a(".wc-payment-form",d).show()},this.showSaveNewCheckbox=function(){a(".woocommerce-SavedPaymentMethods-saveNew",d).show()},this.hideSaveNewCheckbox=function(){a(".woocommerce-SavedPaymentMethods-saveNew",d).hide()},a(":input.woocommerce-SavedPaymentMethods-tokenInput",c).change(this.onTokenChange),a("input#createaccount").change(this.onCreateAccountChange),this.onDisplay()}return b}();a(document.body).on("updated_checkout",function(){var c=a("ul.woocommerce-SavedPaymentMethods");c.each(function(){new b(this)})})})}(jQuery);
!function(a){a(function(){var b=function(){function b(b){var c=a(b),d=c.closest(".payment_box"),e=this;this.onTokenChange=function(){"new"===a(this).val()?(e.showForm(),e.showSaveNewCheckbox()):(e.hideForm(),e.hideSaveNewCheckbox())},this.onCreateAccountChange=function(){a(this).is(":checked")?e.showSaveNewCheckbox():e.hideSaveNewCheckbox()},this.onDisplay=function(){0===a(":input.woocommerce-SavedPaymentMethods-tokenInput:checked",c).length&&a(":input.woocommerce-SavedPaymentMethods-tokenInput:last",c).prop("checked",!0),0===c.data("count")&&a(".woocommerce-SavedPaymentMethods-new",c).hide(),a(":input.woocommerce-SavedPaymentMethods-tokenInput:checked",c).trigger("change"),a("input#createaccount").length&&!a("input#createaccount").is(":checked")&&e.hideSaveNewCheckbox()},this.hideForm=function(){a(".wc-payment-form",d).hide()},this.showForm=function(){a(".wc-payment-form",d).show()},this.showSaveNewCheckbox=function(){a(".woocommerce-SavedPaymentMethods-saveNew",d).show()},this.hideSaveNewCheckbox=function(){a(".woocommerce-SavedPaymentMethods-saveNew",d).hide()},a(":input.woocommerce-SavedPaymentMethods-tokenInput",c).change(this.onTokenChange),a("input#createaccount").change(this.onCreateAccountChange),this.onDisplay()}return b}();a(document.body).on("updated_checkout wc-credit-card-form-init",function(){var c=a("ul.woocommerce-SavedPaymentMethods");c.each(function(){new b(this)})})})}(jQuery);