| 1 |
(j=>{function e(){var t=j(".merchant-flexible-content-control.volume-discounts-style").find(".layout.active"),e=j(".merchant-field-offers_display_style input:checked").val(),a=t.find(".merchant-field-table_title input").val(),n=t.find(".merchant-field-title_text_color input").val(),c=t.find(".merchant-field-title_font_size input").val(),r=t.find(".merchant-field-title_font_weight select").val(),i=t.find(".merchant-field-table_item_bg_color input").val(),o=t.find(".merchant-field-table_item_bg_color_hover input").val(),l=t.find(".merchant-field-table_item_border_color input").val(),d=t.find(".merchant-field-table_item_border_color_hover input").val(),u=t.find(".merchant-field-table_item_text_color input").val(),s=t.find(".merchant-field-table_item_text_color_hover input").val(),h=t.find(".merchant-field-table_label_bg_color input").val(),m=t.find(".merchant-field-table_label_text_color input").val(),p=t.find(".merchant-field-discount_type input:checked").val(),f=+t.find(".merchant-field-discount input").val(),v=t.find(".merchant-field-discount input"),_=t.find(".merchant-field-save_label input").val(),g=t.find(".merchant-field-buy_text input").val(),y=+t.find(".merchant-field-quantity input").val(),b=t.find(".merchant-group-field-cart_page .merchant-field-title input").val(),x=t.find(".merchant-group-field-checkout_page .merchant-field-title input").val(),w=t.find(".merchant-group-field-checkout_page .merchant-field-discount_text input").val(),k=t.find(".merchant-group-field-checkout_page .merchant-field-button_text input").val(),C=t.find(".merchant-group-field-thank_you_page .merchant-field-title input").val(),q=t.find(".merchant-group-field-thank_you_page .merchant-field-discount_text input").val(),z=t.find(".merchant-group-field-thank_you_page .merchant-field-button_text input").val(),t=t.find(".merchant-group-field-cart_page .merchant-field-button_text input").val(),e=(console.log(e),"standard"===e?(j(".tiered-radio,.standard-style").removeClass("show"),j(".standard-style").addClass("show")):"radio"===e&&(j(".tiered-radio,.standard-style").removeClass("show"),j(".tiered-radio").addClass("show")),j(".merchant-volume-discounts-title").css({color:n,"font-size":c+"px","font-weight":r}).html(a),j(".merchant-volume-discounts-item").css({"--merchant-item-text-color":u,"--merchant-item-text-color-hover":s||u,"--merchant-item-bg-color":i,"--merchant-item-bg-color-hover":o||i,"--merchant-item-border-color":l,"--merchant-item-border-color-hover":d||l}),j(".merchant-volume-discounts-item-label")),n=j(".merchant-volume-discounts-buy-label .inner-text"),c=(e.find("span:first").css({"--merchant-label-text-color":m,"--merchant-label-bg-color":h}),e.closest(".mrc-preview-right-column").attr("data-currency")),r="fixed_discount"===p?"".concat(c).concat(f):"".concat(f,"%"),a="fixed_discount"===p?"".concat(c).concat(f*y):"".concat(f,"%"),_=_.replace(/{amount}|{percent}/g,a);e.find("span:first").text(_),g=g.replace(/{discount}|{percent}/g,"<strong>".concat(r,"</strong>")).replace(/{quantity}|{amount}/g,"<strong>".concat(y,"</strong>")),n.html(g),j(".merchant-cart-preview .my-cart .cart-table .cart-item .product .product-info .upsell-offer").text(b.replace("{quantity}","3").replace("{discount}","20%")),j(".merchant-cart-preview .my-cart .cart-table .cart-item .product .product-info .upsell-product .upsell-info .add-to-cart").text(t),j(".merchant-checkout-preview .offer-title").text(x.replace("{quantity}","3").replace("{discount}","10%")),j(".merchant-checkout-preview .product-details .product-info p").html(w.replace("{discount}","10%").replace("{product_price}",merchant_volume_discounts.mock_item_price)),j(".merchant-checkout-preview .product-details .product-info .add-to-order").text(k),j(".merchant-thank-you-preview .offer-title").text(C.replace("{quantity}","3").replace("{discount}","15%").replace("{total_quantity}","5")),j(".merchant-thank-you-preview .product-details .product-info p").html(q.replace("{product_price}",merchant_volume_discounts.mock_item_price).replace("{discount}","10%")),j(".merchant-thank-you-preview .product-details .product-info .add-to-order").text(z),"percentage_discount"===p?(v.attr("max",100),100<v.val()&&v.val(100)):v.removeAttr("max")}function a(){j(".merchant-single-product-preview").addClass("show")}function n(){j(".merchant-single-product-preview").removeClass("show")}function c(){j(".merchant-cart-preview").removeClass("show")}function r(){j(".merchant-thank-you-preview").removeClass("show")}function i(){j(".merchant-checkout-preview").removeClass("show")}j(document).on("click",".merchant-flexible-content-control.volume-discounts-style .layout",function(){var t=j(this);t.closest(".merchant-flexible-content-control.volume-discounts-style").find(".layout").removeClass("active"),t.addClass("active"),e()}),j(document).on("change.merchant keyup",function(){e()}),j(".merchant-flexible-content-control.volume-discounts-style .layout:first-child").addClass("active").trigger("click"),j(document).on("change",'input[type="radio"]',function(){var a=j(this).val();"percentage_discount"!==a&&"fixed_discount"!==a||j(this).closest(".layout").find('input[type="text"], textarea').each(function(){var t="percentage_discount"===a?"{percent}":"{amount}",e=j(this).val(),e=(j(this).attr("name").includes("buy_text")&&(t="{quantity}"),e.replace(/{amount}|{percent}/g,t));j(this).val(e)})}),j(".merchant-module-page-setting-box").on("click",function(t){t=j(t.target);(0<t.closest(".merchant-group-field-cart_page").length||t.hasClass("merchant-group-field-cart_page")?(j(".merchant-cart-preview").addClass("show"),n(),r(),i):0<t.closest(".merchant-group-field-thank_you_page").length||t.hasClass("merchant-group-field-thank_you_page")?(j(".merchant-thank-you-preview").addClass("show"),n(),c(),i):0<t.closest(".merchant-group-field-checkout_page").length||t.hasClass("merchant-group-field-checkout_page")?(j(".merchant-checkout-preview").addClass("show"),n(),c(),r):(a(),c(),r(),i))()}),a()})(jQuery); |