diff --git a/assets/js/frontend/checkout.js b/assets/js/frontend/checkout.js index 4e6814f09d9..041b0aa69f1 100644 --- a/assets/js/frontend/checkout.js +++ b/assets/js/frontend/checkout.js @@ -370,6 +370,7 @@ jQuery(document).ready(function($) { var $postcodefield = thisform.find('#billing_postcode_field, #shipping_postcode_field'); var $cityfield = thisform.find('#billing_city_field, #shipping_city_field'); + var $statefield = thisform.find('#billing_state_field, #shipping_state_field'); // Re-order postcode/city if ( thislocale['postcode_before_city'] ) { @@ -379,7 +380,7 @@ jQuery(document).ready(function($) { } else { $postcodefield.removeClass('form-row-wide').addClass('form-row-last'); $cityfield.removeClass('form-row-first').addClass('form-row-wide'); - $postcodefield.insertAfter( $cityfield ); + $postcodefield.insertAfter( $statefield ); } }) diff --git a/assets/js/frontend/checkout.min.js b/assets/js/frontend/checkout.min.js index 1cd6c98a2ea..154f259a338 100644 --- a/assets/js/frontend/checkout.min.js +++ b/assets/js/frontend/checkout.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){function i(){r&&r.abort();if(e("select#shipping_method").size()>0)var t=e("select#shipping_method").val();else var t=e("input[name=shipping_method]:checked").val();var n=e("#order_review input[name=payment_method]:checked").val(),i=e("#billing_country").val(),s=e("#billing_state").val(),o=e("input#billing_postcode").val(),u=e("input#billing_city").val(),a=e("input#billing_address_1").val(),f=e("input#billing_address_2").val();if(e("#shiptobilling input").is(":checked")||e("#shiptobilling input").size()==0)var l=i,c=s,h=o,p=u,d=a,v=f;else var l=e("#shipping_country").val(),c=e("#shipping_state").val(),h=e("input#shipping_postcode").val(),p=e("input#shipping_city").val(),d=e("input#shipping_address_1").val(),v=e("input#shipping_address_2").val();e("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var m={action:"woocommerce_update_order_review",security:woocommerce_params.update_order_review_nonce,shipping_method:t,payment_method:n,country:i,state:s,postcode:o,city:u,address:a,address_2:f,s_country:l,s_state:c,s_postcode:h,s_city:p,s_address:d,s_address_2:v,post_data:e("form.checkout").serialize()};r=e.ajax({type:"POST",url:woocommerce_params.ajax_url,data:m,success:function(t){if(t){e("#order_review").after(t).remove();e("body").trigger("updated_checkout")}}})}function s(){n=!1;e("body").trigger("update_checkout")}var t,n=!1,r;e("body").bind("update_checkout",function(){clearTimeout(t);i()});e("p.password, form.login, .checkout_coupon, div.shipping_address").hide();e("input.show_password").change(function(){e("p.password").slideToggle()});e("a.showlogin").click(function(){e("form.login").slideToggle();return!1});e("a.showcoupon").click(function(){e(".checkout_coupon").slideToggle();return!1});e("#shiptobilling input").change(function(){e("div.shipping_address").hide();e(this).is(":checked")||e("div.shipping_address").slideDown()}).change();if(woocommerce_params.option_guest_checkout=="yes"){e("div.create-account").hide();e("input#createaccount").change(function(){e("div.create-account").hide();e(this).is(":checked")&&e("div.create-account").slideDown()}).change()}e("form.checkout").on("click",".payment_methods input.input-radio",function(){if(e(".payment_methods input.input-radio").length>1){e("div.payment_box").filter(":visible").slideUp(250);e(this).is(":checked")&&e("div.payment_box."+e(this).attr("ID")).slideDown(250)}else e("div.payment_box").show()}).on("change","select#shipping_method, input[name=shipping_method], #shiptobilling input, .update_totals_on_change select",function(){clearTimeout(t);e("body").trigger("update_checkout")}).on("change",".update_totals_on_change input",function(){if(n){clearTimeout(t);e("body").trigger("update_checkout")}}).on("keydown",".update_totals_on_change input.input-text",function(e){var r=e.keyCode||e.which;if(r=="9")return;n=!0;clearTimeout(t);t=setTimeout(s,"1000")}).on("blur change",".input-text, select",function(){var t=e(this),n=t.closest(".form-row"),r=!0;if(n.is(".validate-required")&&t.val()==""){n.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-required-field");r=!1}if(n.is(".validate-email")&&t.val()){var i=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);if(!i.test(t.val())){n.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-email");r=!1}}r&&n.removeClass("woocommerce-invalid woocommerce-invalid-required-field").addClass("woocommerce-validated")}).submit(function(){clearTimeout(t);var n=e(this);if(n.is(".processing"))return!1;if(n.triggerHandler("checkout_place_order")!==!1&&n.triggerHandler("checkout_place_order_"+e("#order_review input[name=payment_method]:checked").val())!==!1){n.addClass("processing");var r=n.data();r["blockUI.isBlocked"]!=1&&n.block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});e.ajax({type:"POST",url:woocommerce_params.checkout_url,data:n.serialize(),success:function(t){try{var t=t.split("")[0],r=e.parseJSON(t);if(r.result=="success")window.location=decodeURI(r.redirect);else{if(r.result!="failure")throw"Invalid response";e(".woocommerce-error, .woocommerce-message").remove();n.prepend(r.messages);n.removeClass("processing").unblock();n.find(".input-text, select").blur();r.refresh=="true"&&e("body").trigger("update_checkout");e("html, body").animate({scrollTop:e("form.checkout").offset().top-100},1e3)}}catch(i){e(".woocommerce-error, .woocommerce-message").remove();n.prepend(t);n.removeClass("processing").unblock();n.find(".input-text, select").blur();e("html, body").animate({scrollTop:e("form.checkout").offset().top-100},1e3)}},dataType:"html"})}return!1}).find("#order_review input[name=payment_method]:checked").click();e("form.checkout_coupon").submit(function(){var t=e(this);if(t.is(".processing"))return!1;t.addClass("processing").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var n={action:"woocommerce_apply_coupon",security:woocommerce_params.apply_coupon_nonce,coupon_code:t.find("input[name=coupon_code]").val()};e.ajax({type:"POST",url:woocommerce_params.ajax_url,data:n,success:function(n){e(".woocommerce-error, .woocommerce-message").remove();t.removeClass("processing").unblock();if(n){t.before(n);t.slideUp();e("body").trigger("update_checkout")}},dataType:"html"});return!1});var o=woocommerce_params.locale.replace(/"/g,'"'),u=e.parseJSON(o),a=' *';e("body").bind("country_to_state_changing",function(t,n,r){var i=r;if(u[n])var s=u[n];else var s=u["default"];var o={address_1:"#billing_address_1_field, #shipping_address_1_field",address_2:"#billing_address_2_field, #shipping_address_2_field",state:"#billing_state_field, #shipping_state_field",postcode:"#billing_postcode_field, #shipping_postcode_field",city:"#billing_city_field, #shipping_city_field"};e.each(o,function(e,t){var n=i.find(t);if(s[e]){s[e].label&&n.find("label").html(s[e].label);s[e].placeholder&&n.find("input").attr("placeholder",s[e].placeholder);n.find("label abbr").remove();(typeof s[e]["required"]=="undefined"||s[e]["required"]==1)&&n.find("label").append(a);e!=="state"&&(s[e]["hidden"]==1?n.hide().find("input").val(""):n.show())}else if(u["default"][e]){u["default"][e]["required"]==1&&n.find("label abbr").size()==0&&n.find("label").append(a);e!=="state"&&(typeof u["default"][e]["hidden"]=="undefined"||u["default"][e]["hidden"]==0)&&n.show()}});var f=i.find("#billing_postcode_field, #shipping_postcode_field"),l=i.find("#billing_city_field, #shipping_city_field");if(s.postcode_before_city){f.removeClass("form-row-last").addClass("form-row-wide");l.removeClass("form-row-wide").addClass("form-row-first");f.insertBefore(l)}else{f.removeClass("form-row-wide").addClass("form-row-last");l.removeClass("form-row-first").addClass("form-row-wide");f.insertAfter(l)}}).bind("init_checkout",function(){e("#billing_country, #shipping_country, .country_to_state").change();e("body").trigger("update_checkout")});woocommerce_params.is_checkout==1&&e("body").trigger("init_checkout")}); \ No newline at end of file +jQuery(document).ready(function(e){function i(){r&&r.abort();if(e("select#shipping_method").size()>0)var t=e("select#shipping_method").val();else var t=e("input[name=shipping_method]:checked").val();var n=e("#order_review input[name=payment_method]:checked").val(),i=e("#billing_country").val(),s=e("#billing_state").val(),o=e("input#billing_postcode").val(),u=e("input#billing_city").val(),a=e("input#billing_address_1").val(),f=e("input#billing_address_2").val();if(e("#shiptobilling input").is(":checked")||e("#shiptobilling input").size()==0)var l=i,c=s,h=o,p=u,d=a,v=f;else var l=e("#shipping_country").val(),c=e("#shipping_state").val(),h=e("input#shipping_postcode").val(),p=e("input#shipping_city").val(),d=e("input#shipping_address_1").val(),v=e("input#shipping_address_2").val();e("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var m={action:"woocommerce_update_order_review",security:woocommerce_params.update_order_review_nonce,shipping_method:t,payment_method:n,country:i,state:s,postcode:o,city:u,address:a,address_2:f,s_country:l,s_state:c,s_postcode:h,s_city:p,s_address:d,s_address_2:v,post_data:e("form.checkout").serialize()};r=e.ajax({type:"POST",url:woocommerce_params.ajax_url,data:m,success:function(t){if(t){e("#order_review").after(t).remove();e("body").trigger("updated_checkout")}}})}function s(){n=!1;e("body").trigger("update_checkout")}var t,n=!1,r;e("body").bind("update_checkout",function(){clearTimeout(t);i()});e("p.password, form.login, .checkout_coupon, div.shipping_address").hide();e("input.show_password").change(function(){e("p.password").slideToggle()});e("a.showlogin").click(function(){e("form.login").slideToggle();return!1});e("a.showcoupon").click(function(){e(".checkout_coupon").slideToggle();return!1});e("#shiptobilling input").change(function(){e("div.shipping_address").hide();e(this).is(":checked")||e("div.shipping_address").slideDown()}).change();if(woocommerce_params.option_guest_checkout=="yes"){e("div.create-account").hide();e("input#createaccount").change(function(){e("div.create-account").hide();e(this).is(":checked")&&e("div.create-account").slideDown()}).change()}e("form.checkout").on("click",".payment_methods input.input-radio",function(){if(e(".payment_methods input.input-radio").length>1){e("div.payment_box").filter(":visible").slideUp(250);e(this).is(":checked")&&e("div.payment_box."+e(this).attr("ID")).slideDown(250)}else e("div.payment_box").show()}).on("change","select#shipping_method, input[name=shipping_method], #shiptobilling input, .update_totals_on_change select",function(){clearTimeout(t);e("body").trigger("update_checkout")}).on("change",".update_totals_on_change input",function(){if(n){clearTimeout(t);e("body").trigger("update_checkout")}}).on("keydown",".update_totals_on_change input.input-text",function(e){var r=e.keyCode||e.which;if(r=="9")return;n=!0;clearTimeout(t);t=setTimeout(s,"1000")}).on("blur change",".input-text, select",function(){var t=e(this),n=t.closest(".form-row"),r=!0;if(n.is(".validate-required")&&t.val()==""){n.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-required-field");r=!1}if(n.is(".validate-email")&&t.val()){var i=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);if(!i.test(t.val())){n.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-email");r=!1}}r&&n.removeClass("woocommerce-invalid woocommerce-invalid-required-field").addClass("woocommerce-validated")}).submit(function(){clearTimeout(t);var n=e(this);if(n.is(".processing"))return!1;if(n.triggerHandler("checkout_place_order")!==!1&&n.triggerHandler("checkout_place_order_"+e("#order_review input[name=payment_method]:checked").val())!==!1){n.addClass("processing");var r=n.data();r["blockUI.isBlocked"]!=1&&n.block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});e.ajax({type:"POST",url:woocommerce_params.checkout_url,data:n.serialize(),success:function(t){try{var t=t.split("")[0],r=e.parseJSON(t);if(r.result=="success")window.location=decodeURI(r.redirect);else{if(r.result!="failure")throw"Invalid response";e(".woocommerce-error, .woocommerce-message").remove();n.prepend(r.messages);n.removeClass("processing").unblock();n.find(".input-text, select").blur();r.refresh=="true"&&e("body").trigger("update_checkout");e("html, body").animate({scrollTop:e("form.checkout").offset().top-100},1e3)}}catch(i){e(".woocommerce-error, .woocommerce-message").remove();n.prepend(t);n.removeClass("processing").unblock();n.find(".input-text, select").blur();e("html, body").animate({scrollTop:e("form.checkout").offset().top-100},1e3)}},dataType:"html"})}return!1}).find("#order_review input[name=payment_method]:checked").click();e("form.checkout_coupon").submit(function(){var t=e(this);if(t.is(".processing"))return!1;t.addClass("processing").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var n={action:"woocommerce_apply_coupon",security:woocommerce_params.apply_coupon_nonce,coupon_code:t.find("input[name=coupon_code]").val()};e.ajax({type:"POST",url:woocommerce_params.ajax_url,data:n,success:function(n){e(".woocommerce-error, .woocommerce-message").remove();t.removeClass("processing").unblock();if(n){t.before(n);t.slideUp();e("body").trigger("update_checkout")}},dataType:"html"});return!1});var o=woocommerce_params.locale.replace(/"/g,'"'),u=e.parseJSON(o),a=' *';e("body").bind("country_to_state_changing",function(t,n,r){var i=r;if(u[n])var s=u[n];else var s=u["default"];var o={address_1:"#billing_address_1_field, #shipping_address_1_field",address_2:"#billing_address_2_field, #shipping_address_2_field",state:"#billing_state_field, #shipping_state_field",postcode:"#billing_postcode_field, #shipping_postcode_field",city:"#billing_city_field, #shipping_city_field"};e.each(o,function(e,t){var n=i.find(t);if(s[e]){s[e].label&&n.find("label").html(s[e].label);s[e].placeholder&&n.find("input").attr("placeholder",s[e].placeholder);n.find("label abbr").remove();(typeof s[e]["required"]=="undefined"||s[e]["required"]==1)&&n.find("label").append(a);e!=="state"&&(s[e]["hidden"]==1?n.hide().find("input").val(""):n.show())}else if(u["default"][e]){u["default"][e]["required"]==1&&n.find("label abbr").size()==0&&n.find("label").append(a);e!=="state"&&(typeof u["default"][e]["hidden"]=="undefined"||u["default"][e]["hidden"]==0)&&n.show()}});var f=i.find("#billing_postcode_field, #shipping_postcode_field"),l=i.find("#billing_city_field, #shipping_city_field"),c=i.find("#billing_state_field, #shipping_state_field");if(s.postcode_before_city){f.removeClass("form-row-last").addClass("form-row-wide");l.removeClass("form-row-wide").addClass("form-row-first");f.insertBefore(l)}else{f.removeClass("form-row-wide").addClass("form-row-last");l.removeClass("form-row-first").addClass("form-row-wide");f.insertAfter(c)}}).bind("init_checkout",function(){e("#billing_country, #shipping_country, .country_to_state").change();e("body").trigger("update_checkout")});woocommerce_params.is_checkout==1&&e("body").trigger("init_checkout")}); \ No newline at end of file