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

1 line
6.3 KiB
JavaScript
Raw Normal View History

2012-07-20 12:46:05 +00:00
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();if(e("#shiptobilling input").is(":checked")||e("#shiptobilling input").size()==0)var u=i,a=s,f=o;else var u=e("#shipping_country").val(),a=e("#shipping_state").val(),f=e("input#shipping_postcode").val();e("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var l={action:"woocommerce_update_order_review",security:woocommerce_params.update_order_review_nonce,shipping_method:t,payment_method:n,country:i,state:s,postcode:o,s_country:u,s_state:a,s_postcode:f,post_data:e("form.checkout").serialize()};r=e.ajax({type:"POST",url:woocommerce_params.ajax_url,data:l,success:function(t){e("#order_review").after(t).remove();e("#order_review input[name=payment_method]:checked").click();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(".payment_methods input.input-radio").live("click",function(){e("div.payment_box").filter(":visible").slideUp(250);e(this).is(":checked")&&e("div.payment_box."+e(this).attr("ID")).slideDown(250)});e("#order_review input[name=payment_method]:checked").click();e("select#shipping_method, input[name=shipping_method], #shiptobilling input, .update_totals_on_change select").live("change",function(){clearTimeout(t);e("body").trigger("update_checkout")});e(".update_totals_on_change input").live("change",function(){if(n){clearTimeout(t);e("body").trigger("update_checkout")}});e(".update_totals_on_change input").live("keydown",function(e){var r=e.keyCode||e.which;if(r=="9")return;n=!0;clearTimeout(t);t=setTimeout(s,"1000")});woocommerce_params.is_checkout==1&&e("body").trigger("update_checkout");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.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",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});e("form.checkout").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.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});e.ajax({type:"POST",url:woocommerce_params.checkout_url,data:n.serialize(),success:function(t){try{result=e.parseJ