woocommerce/assets/js/frontend/tokenization-form.min.js

1 line
1.3 KiB
JavaScript

!function(a,b){a(function(){var c=function(){function c(c){var d=a(c),e=d.closest(".payment_box"),f=this;this.onTokenChange=function(){"new"===a(this).val()?(f.showForm(),f.showSaveNewCheckboxForLoggedInOnly()):(f.hideForm(),f.hideSaveNewCheckbox())},this.onCreateAccountChange=function(){a(this).is(":checked")?f.showSaveNewCheckbox():f.hideSaveNewCheckbox()},this.onDisplay=function(){0===a(":input.wc-gateway-payment-token:checked",d).length&&a(":input.wc-gateway-payment-token:last",d).prop("checked",!0),0!==d.data("count")&&b.userLoggedIn||a(".wc-payment-form-new-checkbox-wrap",d).hide(),a(":input.wc-gateway-payment-token:checked",d).trigger("change")},this.hideForm=function(){a(".wc-payment-form",e).hide()},this.showForm=function(){a(".wc-payment-form",e).show()},this.showSaveNewCheckbox=function(){a(".wc-new-payment-method-wrap",e).show()},this.hideSaveNewCheckbox=function(){a(".wc-new-payment-method-wrap",e).hide()},this.showSaveNewCheckboxForLoggedInOnly=function(){b.userLoggedIn?f.showSaveNewCheckbox():f.hideSaveNewCheckbox()},a(":input.wc-gateway-payment-token",d).change(this.onTokenChange),a("input#createaccount").change(this.onCreateAccountChange),this.onDisplay()}return c}();a(document.body).on("updated_checkout",function(){var b=a("ul.wc-saved-payment-methods");b.each(function(){new c(this)})})})}(jQuery,woocommerceTokenizationParams);