2019-03-15 12:21:51 +00:00
|
|
|
jQuery(function(n){if("undefined"==typeof wc_cart_params)return!1;var r=function(t){return wc_cart_params.wc_ajax_url.toString().replace("%%endpoint%%",t)},i=function(t){return t.is(".processing")||t.parents(".processing").length},a=function(t){i(t)||t.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},s=function(t){t.removeClass("processing").unblock()},c=function(t,e){var o=n.parseHTML(t),c=n(".woocommerce-cart-form",o),i=n(".cart_totals",o),r=n(".woocommerce-error, .woocommerce-message, .woocommerce-info",o);if(0!==n(".woocommerce-cart-form").length){if(e||n(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),0===c.length){if(n(".woocommerce-checkout").length)return void window.location.reload();var a=n(".cart-empty",o).closest(".woocommerce");n(".woocommerce-cart-form__contents").closest(".woocommerce").replaceWith(a),0<r.length&&m(r),n(document.body).trigger("wc_cart_emptied")}else n(".woocommerce-checkout").length&&n(document.body).trigger("update_checkout"),n(".woocommerce-cart-form").replaceWith(c),n(".woocommerce-cart-form").find(':input[name="update_cart"]').prop("disabled",!0),0<r.length&&m(r),p(i);n(document.body).trigger("updated_wc_div")}else window.location.reload()},p=function(t){n(".cart_totals").replaceWith(t),n(document.body).trigger("updated_cart_totals")},m=function(t,e){e||(e=n(".woocommerce-notices-wrapper:first")||n(".cart-empty").closest(".woocommerce")||n(".woocommerce-cart-form")),e.prepend(t)},t={init:function(){this.update_cart_totals=this.update_cart_totals.bind(this),this.input_keypress=this.input_keypress.bind(this),this.cart_submit=this.cart_submit.bind(this),this.submit_click=this.submit_click.bind(this),this.apply_coupon=this.apply_coupon.bind(this),this.remove_coupon_clicked=this.remove_coupon_clicked.bind(this),this.quantity_update=this.quantity_update.bind(this),this.item_remove_clicked=this.item_remove_clicked.bind(this),this.item_restore_clicked=this.item_restore_clicked.bind(this),this.update_cart=this.update_cart.bind(this),n(document).on("wc_update_cart",function(){t.update_cart.apply(t,[].slice.call(arguments,1))}),n(document).on("click",".woocommerce-cart-form :input[type=submit]",this.submit_click),n(document).on("keypress",".woocommerce-cart-form :input[type=number]",this.input_keypress),n(document).on("submit",".woocommerce-cart-form",this.cart_submit),n(document).on("click","a.woocommerce-remove-coupon",this.remove_coupon_clicked),n(document).on("click",".woocommerce-cart-form .product-remove > a",this.item_remove_clicked),n(document).on("click",".woocommerce-cart .restore-item",this.item_restore_clicked),n(document).on("change input",".woocommerce-cart-form .cart_item :input",this.input_changed),n('.woocommerce-cart-form :input[name="update_cart"]').prop("disabled",!0)},input_changed:function(){n('.woocommerce-cart-form :input[name="update_cart"]').prop("disabled",!1)},update_cart:function(e){var t=n(".woocommerce-cart-form");a(t),a(n("div.cart_totals")),n.ajax({type:t.attr("method"),url:t.attr("action"),data:t.serialize(),dataType:"html",success:function(t){c(t,e)},complete:function(){s(t),s(n("div.cart_totals")),n.scroll_to_notices(n('[role="alert"]'))}})},update_cart_totals:function(){a(n("div.cart_totals")),n.ajax({url:r("get_cart_totals"),dataType:"html",success:function(t){p(t)},complete:function(){s(n("div.cart_totals"))}})},input_keypress:function(t){if(13===t.keyCode){var e=n(t.currentTarget).parents("form");try{e[0].checkValidity()&&(t.preventDefault(),this.cart_submit(t))}catch(o){t.preventDefault(),this.cart_submit(t)}}},cart_submit:function(t){var e=n(document.activeElement),o=n(":input[type=submit][clicked=true]"),c=n(t.currentTarget);if(c.is("form")||(c=n(t.currentTarget).parents("form")),0!==c.find(".woocommerce-cart-form__contents").length)return!i(c)&&void(o.is(':input[name="update_cart"]')||e.is("input.qty")?(t.preventDefault(),this.quantity_update(c)):(o.is(':input[name="apply_coupon"]')||e.is("#coupon_code"))&&(t.preventDefault(),this.apply_coupon(c)))},submit_click:function(t){n(":input[type=s
|