!function(){var e,t;window.germanized=window.germanized||{},e=jQuery,(t=window.germanized).cart_voucher={params:{},vouchers:{},init:function(){this.params=wc_gzd_cart_voucher_params,this.vouchers=wc_gzd_cart_voucher_params.vouchers,e(".woocommerce-checkout").length&&this.manipulate_checkout_totals(),e(".woocommerce-cart-form").length&&this.manipulate_cart_totals(),e(document.body).on("updated_cart_totals",this.manipulate_cart_totals),e(document.body).on("updated_checkout",this.manipulate_checkout_totals),e(document.body).on("applied_coupon",this.refresh_cart_vouchers),e(document.body).on("removed_coupon",this.refresh_cart_vouchers)},refresh_cart_vouchers:function(){var o=t.cart_voucher;setTimeout((function(){e.ajax({type:"POST",url:o.params.wc_ajax_url.toString().replace("%%endpoint%%","gzd_refresh_cart_vouchers"),data:{security:o.params.refresh_cart_vouchers_nonce},success:function(e){o.vouchers=e.vouchers,o.manipulate_cart_totals()},dataType:"json"})}),75)},manipulate_checkout_totals:function(o,r){var c=t.cart_voucher,a=e(".woocommerce-checkout #order_review table");(r=void 0===r?{}:r).hasOwnProperty("fragments")&&r.fragments.hasOwnProperty(".gzd-vouchers")&&(c.vouchers=r.fragments[".gzd-vouchers"]),c.params.display_prices_including_tax||c.move_vouchers_before_total_checkout(),c.manipulate_coupons(a)},manipulate_cart_totals:function(){var o=e(".cart_totals table"),r=o.find("tr.order-total"),c=t.cart_voucher;c.params.display_prices_including_tax||(c.move_vouchers_before_total(o,r),e(".woocommerce-checkout").length&&c.move_vouchers_before_total_checkout()),c.manipulate_coupons(o)},manipulate_coupons:function(o){var r=t.cart_voucher;e.each(r.vouchers,(function(e,t){var c=r.get_voucher_coupon(t,o),a=r.get_voucher_fee(t,o);if(c.hide(),a.length>0&&c.length>0){var n=c.find("a.woocommerce-remove-coupon");n.length>0&&(a.find("td:last").append(" "),a.find("td:last").append(n))}}))},move_vouchers_before_total_checkout:function(){var o=e(".woocommerce-checkout #order_review table"),r=o.find("tr.order-total");t.cart_voucher.move_vouchers_before_total(o,r)},get_voucher_fee:function(t,o){var r=!1;return o.find("tr.fee").each((function(){$tr=e(this);var o=$tr.find("th").text();o.substr(o.length-t.code.length)===t.code&&(r=$tr)})),r||(r=o.find('tr.fee th:contains("'+t.name+'")').parents("tr")),r},get_voucher_coupon:function(e,t){return t.find("tr."+e.coupon_class)},move_vouchers_before_total:function(o,r){var c=t.cart_voucher;e.each(c.vouchers,(function(e,t){var a=c.get_voucher_fee(t,o);a.length>0&&a.insertBefore(r)}))}},e(document).ready((function(){t.cart_voucher.init()})),((window.germanized=window.germanized||{}).static=window.germanized.static||{})["cart-voucher"]={}}();