woocommerce/assets/js/frontend/checkout.min.js

1 line
7.4 KiB
JavaScript
Raw Normal View History

jQuery(function(a){function b(){e&&e.abort();var b=[];a("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){b[a(this).data("index")]=a(this).val()});var c,d,f,g,h,i,j=a("#order_review input[name=payment_method]:checked").val(),k=a("#billing_country").val(),l=a("#billing_state").val(),m=a("input#billing_postcode").val(),n=a("#billing_city").val(),o=a("input#billing_address_1").val(),p=a("input#billing_address_2").val();a("#ship-to-different-address input").is(":checked")||0===a("#ship-to-different-address input").size()?(c=a("#shipping_country").val(),d=a("#shipping_state").val(),f=a("input#shipping_postcode").val(),g=a("#shipping_city").val(),h=a("input#shipping_address_1").val(),i=a("input#shipping_address_2").val()):(c=k,d=l,f=m,g=n,h=o,i=p),a("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+wc_checkout_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var q={action:"woocommerce_update_order_review",security:wc_checkout_params.update_order_review_nonce,shipping_method:b,payment_method:j,country:k,state:l,postcode:m,city:n,address:o,address_2:p,s_country:c,s_state:d,s_postcode:f,s_city:g,s_address:h,s_address_2:i,post_data:a("form.checkout").serialize()};e=a.ajax({type:"POST",url:wc_checkout_params.ajax_url,data:q,success:function(b){if(b){var c=a(a.parseHTML(a.trim(b)));a("#order_review").html(c.html()),a("#order_review").find("input[name=payment_method]:checked").trigger("click"),a("body").trigger("updated_checkout")}}})}function c(){var b=!0;a(f).size()&&($required_inputs=a(f).closest("div").find(".address-field.validate-required"),$required_inputs.size()&&$required_inputs.each(function(){""===a(this).find("input.input-text").val()&&(b=!1)})),b&&(f=!1,a("body").trigger("update_checkout"))}if(a.blockUI.defaults.overlayCSS.cursor="default","undefined"==typeof wc_checkout_params)return!1;var d,e,f=!1;a("body").bind("update_checkout",function(){clearTimeout(d),b()}),a("p.password, form.login, .checkout_coupon, div.shipping_address").hide(),a("input.show_password").change(function(){a("p.password").slideToggle()}),a("a.showlogin").click(function(){return a("form.login").slideToggle(),!1}),a("a.showcoupon").click(function(){return a(".checkout_coupon").slideToggle(400,function(){a("#coupon_code").focus()}),!1}),a("#ship-to-different-address input").change(function(){a("div.shipping_address").hide(),a(this).is(":checked")&&a("div.shipping_address").slideDown()}).change(),"yes"===wc_checkout_params.option_guest_checkout&&(a("div.create-account").hide(),a("input#createaccount").change(function(){a("div.create-account").hide(),a(this).is(":checked")&&a("div.create-account").slideDown()}).change()),a("#order_review").on("click",".payment_methods input.input-radio",function(){if(a(".payment_methods input.input-radio").length>1){var b=a("div.payment_box."+a(this).attr("ID"));a(this).is(":checked")&&!b.is(":visible")&&(a("div.payment_box").filter(":visible").slideUp(250),a(this).is(":checked")&&a("div.payment_box."+a(this).attr("ID")).slideDown(250))}else a("div.payment_box").show();a("#place_order").val(a(this).data("order_button_text")?a(this).data("order_button_text"):a("#place_order").data("value"))}).find("input[name=payment_method]:checked").click(),a("form.checkout").on("input change","select.shipping_method, input[name^=shipping_method], #ship-to-different-address input, .update_totals_on_change select",function(){clearTimeout(d),f=!1,a("body").trigger("update_checkout")}).on("change",".address-field input.input-text, .update_totals_on_change input.input-text",function(){f&&c()}).on("input change",".address-field select",function(){f=this,c()}).on("input keydown",".address-field input.input-text, .update_totals_on_change input.input-text",function(a){var b=a.keyCode||a.which||0;return 9===b?!0:(f=this,clearTimeout(d),void(d=setTimeout(c,"1000")))}).on("blur input change",".input-text, select",function(){var b=a(this),c=b.closest(".form-row"),d=!0;if(c.is(".validate-re