Radiant Luxury: Unveiling the Transformative Power of Organic Shimmering Body Butter (2024)

{% endraw %}\"}", "bundle": {}, "labels": `{\"appstle.subscription.wg.noSubscriptionLabelTextV2\":\"No Subscription\",\"appstle.subscription.wg.cancelAnytimeLabelTextV2\":\"Cancel Anytime\",\"appstle.subscription.wg.addToShipmentErrorTextV2\":\"Error\",\"appstle.subscription.wg.weeksFrequencyTextV2\":\"Weeks\",\"appstle.subscription.wg.weeklyLabelTextV2\":\"Weekly\",\"appstle.subscription.wg.displayAddToExistingSubscriptionButtonForNotLoggedInV2\":\"false\",\"appstle.subscription.wg.addToShipmentProcessingV2\":\"Processing...\",\"appstle.subscription.wg.deliveryEveryFrequencyTextV2\":\"Delivery Every\",\"appstle.subscription.wg.subscribeAndSaveInitalV2\":\"Subscribe & save\",\"appstle.subscription.wg.cartHiddenAttributesSelectorV2\":\"\",\"appstle.subscription.wg.prepaidLabelTextV2\":\"Prepaid\",\"appstle.subscription.wg.daysFrequencyTextV2\":\"Days\",\"appstle.subscription.wg.monthlyLabelTextV2\":\"Monthly\",\"appstle.subscription.wg.subscribeAndSaveSuccessV2\":\"Subscribe success\",\"appstle.subscription.wg.addToShipmentSuccessTextV2\":\"Success\",\"appstle.subscription.wg.monthFrequencyTextV2\":\"Month\",\"appstle.subscription.wg.addToShipmentButtonTextV2\":\"Add to Shipment\",\"appstle.subscription.wg.displayAddToExistingSubscriptionButtonToSubscribersOnlyV2\":\"false\",\"appstle.subscription.wg.yearsFrequencyTextV2\":\"Years\",\"appstle.subscription.wg.onetimeDescriptionTextV2\":\"\",\"appstle.subscription.wg.addToShipmentTooltipTextV2\":\"Please avoid double delivery charges! Login to add this product to an upcoming delivery.\",\"appstle.subscription.wg.weekFrequencyTextV2\":\"Week\",\"appstle.subscription.wg.oneTimePurchaseTextV2\":\"One Time Purchase\",\"appstle.subscription.wg.loyaltyPerkDescriptionTextV2\":\"{{#isDiscountTypeFreeProduct}}

Radiant Luxury: Unveiling the Transformative Power of Organic Shimmering Body Butter (1)<\/img><\/div>

After {{{billingCycleBlock}}} orders, get a FREE {{freeProductName}} <\/span><\/div>

{{\/isDiscountTypeFreeProduct}}{{#isDiscountTypePercentage}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get {{{discount}}}% OFF your entire order<\/span><\/span>.{{\/isDiscountTypePercentage}}{{#isDiscountTypeShipping}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get shipping at {{{formatDiscountedPrice}}}<\/span><\/span>.{{\/isDiscountTypeShipping}}{{#isDiscountTypeFixed}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get {{{formatDiscountedPrice}}} OFF your entire order<\/span><\/span>.{{\/isDiscountTypeFixed}}\",\"appstle.subscription.wg.unsubscribeFrequencyTextV2\":\"unsubscribe\",\"appstle.subscription.wg.widgetVariantChangeListenerSelectorV2\":\"\",\"appstle.subscription.wg.atcButtonTextSelectorV2\":\"\",\"appstle.subscription.wg.atcButtonTextSelectorObserverV2\":\"\",\"appstle.subscription.wg.oneTimeFrequencyTextV2\":\"One Time\",\"appstle.subscription.wg.dayFrequencyTextV2\":\"day\",\"appstle.subscription.wg.allowFulfilmentCountViaPropertiesV2\":\"false\",\"appstle.subscription.wg.valdiateFormSelectorV2\":\"\",\"appstle.subscription.wg.monthsFrequencyTextV2\":\"Months\",\"appstle.subscription.wg.prepaidSaveBadgeTextV2\":\"SAVE {{selectedDiscountPercentage}}\",\"appstle.subscription.wg.manageSubscriptionButtonTextV2\":\"Manage Subscription\",\"appstle.subscription.wg.offFrequencyTextV2\":\"Off\",\"appstle.subscription.wg.yearFrequencyTextV2\":\"Year\",\"appstle.subscription.wg.prepayLabelTextV2\":\"Prepay\",\"appstle.subscription.wg.productPageUnitPriceSelectorV2\":\"\",\"appstle.subscription.wg.widgetPriceChangeListenerSelectorV2\":\"\",\"appstle.subscription.wg.selectDeliverOptionV2\":\"select deliver option\",\"appstle.subscription.wg.atcButtonTextV2\":\"\",\"appstle.subscription.wg.yearlyLabelTextV2\":\"Yearly\"}`, "css": { "appstle_subscription_widget": { "margin-top": "" , "margin-bottom": "", }, "appstle_subscription_wrapper": { "border-width": "", "border-color": "", }, "appstle_circle": { "border-color": "", }, "appstle_dot": { "background-color": "", }, "appstle_select": { "padding-top": "", "padding-bottom": "", "padding-left": "", "padding-right": "", "border-width": "", "border-style": "", "border-color": "", "border-radius": "", }, "tooltip_subscription_svg": { "fill": "", }, "appstle_tooltip": { "color": "", "background-color": "", }, "appstle_tooltip_border_top_color": { "border-top-color": "", }, "appstle_subscription_final_price": { "color": "", }, "appstle_widget_text_color": { "color": "", }, "appstle_selected_background": { "background": "transparent", }, "elementCSS": "[]", "customCSS": ".appstle-save-badge {\r\n background: black;\r\n color: white;\r\n transform: unset;\r\n border-radius: 5px;\r\n border-top-right-radius: 5px;\r\n border-bottom-right-radius: 5px;\r\n text-align: center;\r\n font: inherit;\r\n font-size: 0.7rem;\r\n padding: 5px;\r\n}\r\n\r\n.appstle-save-badge:before {\r\nbackground: unset;\r\n}\r\n\r\n@media screen and (max-width: 600px) {\r\n.appstle-save-badge {\r\n font: inherit;\r\n font-size: 0.7rem;\r\n padding: 2px;\r\n width: fit-content;\r\n margin-left: 0.15rem;\r\n}\r\n}", "customerPortalCss": "", "externalStyleTag": "", "themeCss": "", } }; sessionStorage['appstleSubscriptionConfig'] = JSON.stringify(RS.Config); var _RSConfig = _RSConfig || {}; _RSConfig.shop = 'simply-radiant-beauty.myshopify.com'; _RSConfig.shopMoneyFormat = '€{{amount_with_comma_separator}}'; _RSConfig.shopMoneyFormatWithCurrencyFormat = '€{{amount_with_comma_separator}} EUR'; }

') }; if( window.wsaio_involved != undefined && window.wsaio_involved == true && WSAIO.app_mode_applied){ WSAIO.showCheckoutLoader() } window.addEventListener("load", function(){ var $ = jQuery; if(typeof WSAIO != 'undefined'){ WSAIO.loginLink(); if(typeof window.ZapietCheckoutEnabled != 'undefined'){ var valid_chk = false; setInterval(function(){ if(window.ZapietCheckoutEnabled && valid_chk == false){ if(typeof WSAIO.checkoutEventListner != 'undefined'){WSAIO.checkoutEventListner()} valid_chk =true; }else if(!window.ZapietCheckoutEnabled && valid_chk == true){ valid_chk =false; } },100) } if("function"===typeof WSAIO.initAddons){ WSAIO.initAddons(jQuery || $); } if(typeof current_product != 'undefined' && current_product != null){ $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').css('cssText','display:inline-block !important') } try{WSAIO.buyNowEventListener()}catch(e){} if( window.wsaio_involved != undefined && window.wsaio_involved == true && WSAIO.app_mode_applied){ WSAIO.cart_qty_change_event(); } setTimeout(function(){ if((typeof WSAIO != 'undefined' && typeof WSAIO.cartDrawer === 'function' && WSAIO.template === "cart") || (typeof WSAIO != 'undefined' && window.location.pathname.indexOf('pages/net-term-order') > -1 )){ if(!jQuery.isEmptyObject(WSAIO.discount_response)){ WSAIO.preCheckoutResponse(WSAIO.discount_response) WSAIO.callback(WSAIO.discount_response) if(typeof WSAIO.loadcartQuantityControllers != 'undefined' && typeof WSAIO.load_checkout_restriction != 'undefined'){ WSAIO.load_checkout_restriction(); WSAIO.loadcartQuantityControllers([],function(e){WSAIO.run_checkout()});}else{WSAIO.run_checkout()} }else{ WSAIO.preCheckout(); } } if(WSAIO.agreement_checkout_selector != '' && $(WSAIO.agreement_checkout_selector).length != 0 && window.wsaio_involved != undefined && window.wsaio_involved == true && WSAIO.app_mode_applied){ if($(WSAIO.agreement_checkout_selector).is(':checked')){ window.isAgree = true; WSAIO.run_checkout() }else{ window.isAgree = false; WSAIO.run_checkout() } $(document).on('click', WSAIO.agreement_checkout_selector, function (e) { if($(WSAIO.agreement_checkout_selector).is(':checked')){ window.isAgree = true; WSAIO.run_checkout() }else{ window.isAgree = false; WSAIO.run_checkout() } }) } setTimeout(function(){ try{ if(WSAIO != undefined && !WSAIO.main_liquid_file_included && (typeof WSAIO.isShowCheckout == 'undefined')){ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeClass('wsaio_hideCheckout') $('.wsaio_coupon_group, .wsaio_coupon_link').css('cssText','display:block !important') } }catch(e){} try{ if((WSAIO != undefined || WSAIO.main_liquid_file_included) && (typeof WSAIO.isShowCheckout == 'undefined')){ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeClass('wsaio_hideCheckout') $('.wsaio_coupon_group, .wsaio_coupon_link').css('cssText','display:block !important') } }catch(e){} try{ if(WSAIO == undefined || !WSAIO.isWholesaleCustomer() && (typeof WSAIO.isShowCheckout == 'undefined')){ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeClass('wsaio_hideCheckout') $('.wsaio_coupon_group, .wsaio_coupon_link').css('cssText','display:block !important') } }catch(e){} if(WSAIO.buy_now_btn_replace == false || typeof WSAIO.buyNowEventListener == 'undefined' ){ $('.shopify-payment-button .shopify-payment-button__button').css('cssText','display:inline-block !important') } $('.wsaio_loader_checkout').hide(); },1000); if(typeof current_product != 'undefined' && current_product != null){ $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').css('cssText','display:inline-block !important') if(WSAIO.buy_now_btn_replace == false){ $(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').remove() $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.shopify-payment-button .shopify-payment-button__button').css('cssText','display:inline-block !important') } } },1050) }else{ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeClass('wsaio_hideCheckout') $('.wsaio_loader_checkout').hide(); $('.shopify-payment-button .shopify-payment-button__button').css('cssText','display:inline-block !important') } }); WSAIO.run_checkout = function(){ if(WSAIO.app_mode_applied){ $('.wsaio_coupon_group, .wsaio_coupon_link').css('cssText','display:block !important') WSAIO.checkoutAlert = $('

    ') if(WSAIO.replace_checkout){ $(WSAIO.replace_checkout_button).replaceWith(WSAIO.duplicate_checkout_html) if(typeof WSAIO.checkoutEventListner != 'undefined' && typeof WSAIO.isWholesaleCustomer != 'undefined' && WSAIO.isWholesaleCustomer() !== false){ WSAIO.checkoutEventListner() }else{ if(WSAIO.replace_checkout){ $(document).on('click',WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector, function (e) { e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); window.location.href = '/checkout'; }); } } } WSAIO.order_control();WSAIO.disableCheckout() if(WSAIO.default_limit){ if(typeof WSAIO.allow_normal_checkout__OC == 'undefined' || WSAIO.allow_normal_checkout__OC == false){ WSAIO.checkoutAlert.append('

  1. ' + WSAIO.checkout_message + "
  2. "); }else{ WSAIO.checkoutAlert.append('

  3. ' + WSAIO.checkout_message + "
  4. "); WSAIO.checkoutAlert.append('

  5. Fulfill minimum order requirements to avail discount
  6. '); } } if(WSAIO.applied_shipping != undefined && WSAIO.applied_shipping.apply_shipping_charges && $('.Shipping_msg').length == 0 && WSAIO.shipping_message_applied){ WSAIO.checkoutAlert.after('

    ' + WSAIO.applied_shipping.final_ship_rule.message + "

    "); } if(typeof WSAIO.isShowCheckout == 'undefined'){ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeClass('wsaio_hideCheckout') }else{ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).addClass('wsaio_hideCheckout') } $('.wsaio_coupon_group, .wsaio_coupon_link').css('cssText','display:block !important') $('.wsaio-alerts').remove(); $('.waio_agree_message').remove() if(typeof window.MOQ_alert != 'undefined' && window.MOQ_alert!=''){ WSAIO.checkoutAlert = window.MOQ_alert; }else{ if($('.wsaio-alerts').length == 0 && WSAIO.checkoutAlert != undefined){ $(WSAIO.checkout_message_selector).after(WSAIO.checkoutAlert); } } WSAIO.cartLevelUpSell(); $('.wsaioUsellMessage,.Shipping_msg').remove(); if(WSAIO.wsaioUpSell_msg != undefined && WSAIO.wsaioUpSell_msg!= '' && $('.wsaioUsellMessage').length == 0){ if(typeof WSAIO.cart_level_upsell_message_select == 'undefined' || WSAIO.cart_level_upsell_message_select == ''){ $(WSAIO.checkout_message_selector).before('

    ' + WSAIO.wsaioUpSell_msg + "

    "); }else{ $(WSAIO.cart_level_upsell_message_select).before('

    ' + WSAIO.wsaioUpSell_msg + "

    "); } } if(WSAIO.applied_shipping != undefined && WSAIO.applied_shipping.apply_shipping_charges && $('.Shipping_msg').length == 0 && WSAIO.shipping_message_applied){ $(WSAIO.checkout_message_selector).after('

    ' + WSAIO.applied_shipping.final_ship_rule.message + "

    "); } if($('.wsaio-alerts').length == 0 && WSAIO.checkoutAlert != undefined && typeof window.MOQ_alert != 'undefined' && WSAIO.checkoutAlert.indexOf('

    • -1){ $(WSAIO.checkout_message_selector).after(WSAIO.checkoutAlert); } if(WSAIO.disable_checkout || window.disable_checkout_MOQ || window.isAgree == false){ if(WSAIO.agrrement_alert_message != '' && $('.waio_agree_message').length == 0 && typeof window.isAgree != 'undefined' && window.isAgree == false){ $(WSAIO.checkout_message_selector).after('

      '+WSAIO.agrrement_alert_message+'

      '); } if((typeof WSAIO.allow_normal_checkout__OC != 'undefined' && WSAIO.allow_normal_checkout__OC) && ((!window.disable_checkout_MOQ || $('.moq_error').length == 0) && (typeof window.isAgree == 'undefined' || window.isAgree))){ $(WSAIO.netTerm_checkout_selector).addClass('checkout-disabled').attr('disabled','disabled').css({'pointer-events': 'none','cursor': 'default'}) }else{ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).addClass('checkout-disabled').attr('disabled','disabled').css({'pointer-events': 'none','cursor': 'default'}) } }else{ $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).removeClass('checkout-disabled').removeAttr('disabled').css({'pointer-events': 'auto','cursor': 'pointer'}) } $('.wsaio_loader_checkout').hide(); } } window.addEventListener("load",function(){ if(typeof WSAIO != 'undefined' && window.wsaio_involved != undefined && window.wsaio_involved == true && typeof WSAIO.preCheckout == 'undefined' && WSAIO.app_mode_applied){ WSAIO.preloadCheckout = function (){ WSAIO.showCheckoutLoader(); try { "undefined" === typeof window.waioMOC && (window.waioMOC = {}); "undefined" === typeof waioMOC.cart && (waioMOC.cart = {}); try { window.cart_data = WSAIO.cart_object; waioMOC.cart["item_count"] = WSAIO.cart_object.item_count; waioMOC.cart["original_total_price"] = WSAIO.cart_object.original_total_price; WSAIO.order_control() setTimeout(function(){ if(typeof WSAIO.loadcartQuantityControllers != 'undefined' && typeof WSAIO.load_checkout_restriction != 'undefined'){ WSAIO.load_checkout_restriction(); WSAIO.loadcartQuantityControllers([],function(e){setTimeout(function(){WSAIO.run_checkout()},1000)});}else{WSAIO.run_checkout()} },1000) } catch (e) {} } catch (e) {} }; WSAIO.preCheckout = function (){ if(typeof WSAIO.run_checkout != 'undefined'){ WSAIO.showCheckoutLoader() $.getJSON(WSAIO.local_param +'cart',function(e){ window.cart_data = e; try { "undefined" === typeof window.waioMOC && (window.waioMOC = {}); "undefined" === typeof waioMOC.cart && (waioMOC.cart = {}); try { waioMOC.cart["item_count"] = e.item_count; waioMOC.cart["original_total_price"] = e.original_total_price; WSAIO.order_control() if(typeof WSAIO.cartQuantityControllers != 'undefined' && typeof WSAIO.checkout_restriction != 'undefined'){ WSAIO.checkout_restriction(); WSAIO.cartQuantityControllers([],function(e){setTimeout(function(){WSAIO.run_checkout()},500)});}else{WSAIO.run_checkout()} } catch (e) {} } catch (e) {} }) } }; WSAIO.preloadCheckout(); } }) }; window.WSAIO_MODULE(jQuery)

    '); jqWrapped.find('.money').filter((i, x)=>/%compare_at_price%/gi.test(x.innerText) ).removeClass('money'); return jqWrapped.html(); }catch(e){ console.log(e); return html; } } WSAIO.checkAppliesTo = function (params) { if (WSAIO.debugger) debugger; switch (params.type) {case "products": params.rule["priority"] = 1; applies_to_products(); break;case "collections": params.rule["priority"] = 2; applies_to_collections(); break;case "entire_store": var excluded = false; if (params.rule.exclude_products && params.rule.exclude_products.findIndex(function (x) {return x.handle == $ws.selected_product.handle }) > -1) {excluded = true; } if (params.rule.exclude_collections && params.rule.exclude_collections.length > 0) {for (var xzy = 0; xzy < $ws.product_in_collects.length; xzy++) { var item = $ws.product_in_collects[xzy]; if (-1 < params.rule.exclude_collections.findIndex(function (x) {return x.id == item.collection_id })) {if ($ws.selected_product.id == item.product_id) { excluded = true;} }} } if (!excluded) {params.rule["priority"] = 3;if (params.module === "regular_discount") { $ws.productRd.push(params.rule);} else { $ws.productVd.push(params.rule);} } break;default: params.rule["priority"] = 3; if (params.module === "regular_discount") {$ws.productRd.push(params.rule); } else {$ws.productVd.push(params.rule); } break; } function applies_to_products() {if (WSAIO.debugger) debugger;// Apply only if selected_product_id was defined.if ('undefined' !== typeof $ws.selected_product.handle || 'undefined' !== typeof $ws.selected_product.id) { var isFound = params.rule.products.findIndex(function (x) {return (x.handle === $ws.selected_product.handle || x.id == $ws.selected_product.id) }) if (isFound > -1) {if (params.module === "regular_discount") {// if (params.rule.products[isFound].variant_level === true) {// $ws.productRd = [];// } $ws.productRd.push(params.rule);} else {// if (params.rule.products[isFound].variant_level === true) {// $ws.productVd = [];// } $ws.productVd.push(params.rule);} }} else { isError("Selected product handle is not defined.");} } function applies_to_collections() {if (WSAIO.debugger) debugger;var isFound = [false];// if selected_product_id is definedif ($ws.selected_product.handle) { var excluded = false; if (params.rule.exclude_products && params.rule.exclude_products.findIndex(function (x) {return x.handle == $ws.selected_product.handle }) > -1) {excluded = true; } if (!excluded) {isFound = params.rule.collections.map(function (collection, i) { return -1 < ($ws.product_in_collects.findIndex(function (x) {return (x.product_handle == $ws.selected_product.handle || x.product_id == $ws.selected_product.id) && x.collection_id == collection.id }))});if (isFound.indexOf(true) > -1) { if (params.module === "regular_discount") {$ws.productRd.push(params.rule); } else {$ws.productVd.push(params.rule); }} }}// if only selected_collection.id is defined.else if ($ws.template === "collection" && $ws.selected_collection.id) { // $ws.selected_collection.id (if template is collection then this id contains current collection id, otherwise null). for other case isFound = params.rule.collections.map(function (collection, i) {return collection.id == $ws.selected_collection.id; }); if (isFound.indexOf(true) > -1) {if (params.module === "regular_discount") { $ws.productRd.push(params.rule);} else { $ws.productVd.push(params.rule);} }} else { isError("Missing either product's id or collection's id or template is not set for collections");} } if (params.module === "regular_discount") {if ($ws.productRd && $ws.productRd.length > 1) { if (-1 < $ws.productRd.findIndex(function (z) {return z.individual_product === true })) {$ws.productRd = $ws.productRd.filter(function (x) { return x.individual_product === true}); } else if (-1 < $ws.productRd.findIndex(function (z) {return z.customer_group === 'has_tag' })) {$ws.productRd = $ws.productRd.filter(function (x) { return x.customer_group === 'has_tag'}); } else if (-1 < $ws.productRd.findIndex(function (z) {return z.customer_group === 'has_tag' })) {$ws.productRd = $ws.productRd.filter(function (x) { return x.customer_group === 'has_tag'}); } else if (-1 < $ws.productRd.findIndex(function (z) {return z.customer_group === 'has_account' })) {$ws.productRd = $ws.productRd.filter(function (x) { return x.customer_group === 'has_account'}); } else if (-1 < $ws.productRd.findIndex(function (z) {return z.customer_group === 'no_account' })) {$ws.productRd = $ws.productRd.filter(function (x) { return x.customer_group === 'no_account'}); }} } else {if ($ws.productVd && $ws.productVd.length > 1) { if (-1 < $ws.productVd.findIndex(function (z) {return z.individual_product === true })) {$ws.productVd = $ws.productVd.filter(function (x) { return x.individual_product === true}); } else if (-1 < $ws.productVd.findIndex(function (z) {return z.customer_group === 'has_tag' })) {$ws.productVd = $ws.productVd.filter(function (x) { return x.customer_group === 'has_tag'}); } else if (-1 < $ws.productVd.findIndex(function (z) {return z.customer_group === 'has_account' })) {$ws.productVd = $ws.productVd.filter(function (x) { return x.customer_group === 'has_account'}); } else if (-1 < $ws.productVd.findIndex(function (z) {return z.customer_group === 'no_account' })) {$ws.productVd = $ws.productVd.filter(function (x) { return x.customer_group === 'no_account'}); }} }}; WSAIO.price_with_unit = function(price){ if(typeof WSAIO.country_currency_code != 'undefined' && typeof WSAIO.customer.default_address.country_code != 'undefined'){price = price+' '+WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[0]; }else{price = price+' '+Shopify.currency.active; } return price; }; WSAIO.change_currency_sign = function(price){ if(typeof WSAIO.country_currency_code != 'undefined' && typeof WSAIO.customer.default_address.country_code != 'undefined' && typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1 && typeof WSAIO.market_selected != 'undefined' && typeof WSAIO.customer.default_address.country_code != 'undefined' && (WSAIO.market_selected != WSAIO.customer.default_address.country_code)){ var character = null; price = price.toString(); character= price.replace( /(<([^>]+)>)/ig, '');character= character.replace(/\d.+/g, '');character= character.replace(/\d,+/g, '') price = price.replace(character,WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[1]) } return price; }WSAIO.volumeDiscount = function (params, callback) { if (WSAIO.debugger) debugger; if (typeof params === 'function') callback = params; if(!params){isError("No params provided for volume discount");return false; } if(!params.item_price_selector){isError("Item price selector is undefined");return false; } if (WSAIO.isWholesaleCustomer() === false) {if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } var WSAIO_variant_sku_are_same = true; if($(params.item_price_selector).attr('class') != undefined){if($(params.item_price_selector).attr('class').indexOf('wsaio_') == -1){ $(params.item_price_selector).addClass('wsaio_'+params.product_id)} } if (typeof params.template !== 'undefined' && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){var _id = params.product_id;if(WSAIO.template != 'cart' && typeof WSAIO.product_in_collects != 'undefined' && WSAIO.product_in_collects.length != 0){ var _indx = WSAIO.product_in_collects.findIndex(function(e,r){ return e.product_id == _id; }); if(typeof WSAIO.product_in_collects[_indx] != 'undefined' && typeof WSAIO.product_in_collects[_indx].product_variants != 'undefined'){ var current_product_variant = WSAIO.product_in_collects[_indx].product_variants; var _indx_of_variant = current_product_variant.findIndex(function(d,t){ return d.id == params.variant_id; }) WSAIO.selected_variant_taxable = current_product_variant[_indx_of_variant].taxable; // if Price set in price adjustment, then no tax include function run if(typeof WSAIO.tax_settings != 'undefined' && WSAIO.tax_settings.presentment != null && WSAIO.tax_settings.presentment.price_adjustments != null && typeof WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids != 'undefined' && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.length && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.indexOf(current_product_variant[_indx_of_variant].id) > -1){WSAIO.selected_variant_taxable = false;} } }else if(typeof WSAIO.products_with_collections != 'undefined' && WSAIO.products_with_collections.length != 0){ var _indx = WSAIO.products_with_collections.findIndex(function(e,r){ return e.product_id == _id; }); if(typeof WSAIO.products_with_collections[_indx] != 'undefined' && typeof WSAIO.products_with_collections[_indx].product_variants != 'undefined'){ var current_product_variant = WSAIO.products_with_collections[_indx].product_variants; var _indx_of_variant = current_product_variant.findIndex(function(d,t){ return d.id == params.variant_id; }) WSAIO.selected_variant_taxable = current_product_variant[_indx_of_variant].taxable; // if Fixed Price set in price adjustment, then no tax include function run if(typeof WSAIO.tax_settings != 'undefined' && WSAIO.tax_settings.presentment != null && WSAIO.tax_settings.presentment.price_adjustments != null && typeof WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids != 'undefined' && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.length && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.indexOf(current_product_variant[_indx_of_variant].id) > -1){WSAIO.selected_variant_taxable = false;} } } } $ws.output = true; $ws.remove_duplicate_table = false; $ws.selected_variant = JSON.parse(JSON.stringify($ws.current_variant)); // current variant obj should not change $ws.selected_product = JSON.parse(JSON.stringify($ws.current_product)); // current product obj should not change $ws.selected_collection = JSON.parse(JSON.stringify($ws.current_collection)); // current collection obj should not change if (typeof params === 'object') {if (typeof params.product_id !== 'undefined' && params.product_id !== "default") $ws.selected_product.id = params.product_id;if (typeof params.product_handle !== 'undefined' && params.product_handle !== "default") $ws.selected_product.handle = params.product_handle;if (typeof params.variant_id !== 'undefined' && params.variant_id !== "default") $ws.selected_variant.id = params.variant_id;if (typeof params.variant_sku !== 'undefined' && params.variant_sku !== "default") $ws.selected_variant.sku = params.variant_sku;if (typeof params.variant_price !== 'undefined' && params.variant_price !== "default") $ws.selected_variant.price = params.variant_price;if (typeof params.variant_compare_at_price !== 'undefined' && params.variant_compare_at_price !== "default") $ws.selected_variant.compare_at_price = params.variant_compare_at_price;if (typeof params.collection_id !== 'undefined' && params.collection_id !== "default") $ws.selected_collection.id = params.collection_id;if (typeof params.output !== 'undefined' && params.output !== "default") $ws.output = params.output;if (typeof params.product_parent_grid_selector !== 'undefined' && params.product_parent_grid_selector !== "default") $ws.product_qb_table_selector = params.qb_table_selector;if (typeof params.remove_duplicate_table !== 'undefined' && params.remove_duplicate_table !== "default") $ws.remove_duplicate_table = params.remove_duplicate_table;if (typeof params.template !== 'undefined' && params.template !== "default") $ws.landingTemplate = params.template; } if ($ws.selected_variant && typeof $ws.selected_variant.price === "string" && $ws.selected_variant.price.indexOf(".") > -1) {$ws.selected_variant.price = $ws.selected_variant.price.replace('.', ''); } if ($ws.selected_variant && typeof $ws.selected_variant.compare_at_price === "string" && $ws.selected_variant.compare_at_price.indexOf(".") > -1) {$ws.selected_variant.compare_at_price = $ws.selected_variant.compare_at_price.replace('.', ''); } $ws.productVd = []; var hasImportRule = $ws.volume_discounts.some(function(item){return item.applies_to == "products" && item.products.length && item.products[0].id == item.products[0].handle; }); if(hasImportRule){ $ws.volume_discounts.sort(function (a, b) { // Shifting import rule to end if(b.applies_to == "products" || a.applies_to == "products"){ if(a.products.length && (a.products[0].id == a.products[0].handle)){ return 1; } if(b.products.length && (b.products[0].id == b.products[0].handle)){ return -1; } } return 0; }); } $ws.applied_tag_array = []; // for loop for (var i = 0, len_i = $ws.volume_discounts.length; i < len_i; i++) {var volume_discount = $ws.volume_discounts[i];if (volume_discount.state !== 'published') continue;if ($ws.checkCustomer(volume_discount.customer_group, volume_discount.tags, volume_discount.tags_excluded) === false) continue;if (volume_discount.schedule_active) { var _schedule = $ws.getSchedule(volume_discount.schedule); log("_schedule", _schedule); if (_schedule.ends_in) {if ( Number(_schedule.ends_in.years) <= 0 && Number(_schedule.ends_in.months) <= 0 && Number(_schedule.ends_in.days) <= 0 && Number(_schedule.ends_in.hours) <= 0 && Number(_schedule.ends_in.minutes) <= 0 && Number(_schedule.ends_in.seconds) <= 0) { log("This rule was expired", _schedule); continue;}if ( Number(_schedule.started.years) >= 0 && Number(_schedule.started.months) >= 0 && Number(_schedule.started.days) >= 0 && Number(_schedule.started.hours) >= 0 && Number(_schedule.started.minutes) >= 0 && Number(_schedule.started.seconds) >= 0) { log("This rule was schedules and will be started in", _schedule); continue;} }}$ws.checkAppliesTo({ "type": volume_discount.applies_to, "rule": volume_discount, "module": "volume_discount"}); } // end for loop if ($ws.productVd.length > 0) {// sort array by priority$ws.productVd.sort(function (a, b) { return Number(a.priority) - Number(b.priority)});// if this array contains multiple applies to, then filter by products or by collection, to exclude extra rules.if (-1 < $ws.productVd.findIndex(function (x) { return x.applies_to == "products"})) { $ws.productVd = $ws.productVd.filter(function (x) {return x.applies_to === "products" });} else if (-1 < $ws.productVd.findIndex(function (x) { return x.applies_to == "collections"})) { $ws.productVd = $ws.productVd.filter(function (y) {return y.applies_to === "collections" });} } $ws.product_qb = []; $ws.product_volume_discount = {}; $ws.vd_has_discount = false; // assume this has if ($ws.productVd && $ws.productVd.length > 1) { var rule_date_found = $ws.productVd.some(function(e,r){ return typeof e.created_at !== "undefined"}); if(rule_date_found){ var update_sorted_rule = JSON.parse(JSON.stringify($ws.productVd)); try{var check_if_individual = $ws.productVd.find(function(w,y){return w.individual_product }) if(!check_if_individual){ update_sorted_rule.sort(function(a,b){ if(typeof a.created_at === 'undefined' || typeof b.created_at === 'undefined'){ return 0; }else{ if(new Date(a.created_at) > new Date(b.created_at)){ return -1; }else{ return 1; } } });} } catch(e){ update_sorted_rule = []; } if(update_sorted_rule.length > 0){ $ws.productVd = JSON.parse(JSON.stringify(update_sorted_rule)); } }$ws.productVd = [$ws.productVd[0]]; } var hasImported_Rule = $ws.productVd.some(function(item){ return item.applies_to == "products" && item.products.length && item.products[0].id == item.products[0].handle; }); if(hasImported_Rule || WSAIO.variant_sku_are_same == false){WSAIO_variant_sku_are_same = false; } // Checking priority of volume discount. $ws.volumeDiscountPriority(); if ($ws.productVd && $ws.productVd.length > 0) {$ws.vd_has_discount = true;// for loopfor (var j = 0, len_j = $ws.productVd.length; j < len_j; j++) { var vd_rule = $ws.productVd[j]; if ("products" === vd_rule.applies_to && vd_rule.individual_product === true) {for (var kk = 0; kk < vd_rule.products.length; kk++) { var product = vd_rule.products[kk], pIndex = kk; if (product.handle === $ws.selected_product.handle || product.id == $ws.selected_product.id) {if ($ws.product_volume_discount.handle !== product.handle) { $ws.product_volume_discount = JSON.parse(JSON.stringify(vd_rule)); $ws.product_volume_discount["product"] = product;}if (product.variant_level) { for (var ll = 0; ll < product.variants.length; ll++) {var variant = product.variants[ll],vIndex = ll;var check_tag = false;var vIn = variant.tag_options.findIndex(function (apt) {$ws.applied_tag_array.findIndex(function (single_tag){if(apt.name.toString().toLowerCase() == single_tag.toString().toLowerCase()){check_tag = true;}})if(check_tag){return true;}});if (vIn > -1 && (variant.id == $ws.selected_variant.id) || ((variant.sku == $ws.selected_variant.sku && hasImported_Rule) && !WSAIO_variant_sku_are_same)) { var v_tag_option = variant.tag_options[vIn]; $ws.product_qb.push({name: v_tag_option.name,value: v_tag_option.value,type: v_tag_option.type,qty: variant.quantity });} }} else {var check_tag = false;var pIn = product.tag_options.findIndex(function (apt) { $ws.applied_tag_array.findIndex(function (single_tag){ if(apt.name.toString().toLowerCase() == single_tag.toString().toLowerCase()) { check_tag = true; } }) if(check_tag){ return true; }}); if (pIn > -1) {var tag_option = product.tag_options[pIn];$ws.product_qb.push({ name: tag_option.name, value: tag_option.value, type: tag_option.type, qty: product.quantity}); }} }} } else {for (var pp = 0; pp < vd_rule.volume_discount.length; pp++) { var vd = vd_rule.volume_discount[pp], vdIndex = pp; $ws.product_qb.push({name: vd_rule.applies_to,value: vd.value,type: vd_rule.discount_type,qty: vd.qty }); }$ws.product_volume_discount = JSON.parse(JSON.stringify(vd_rule));if (vd_rule.applies_to === "collections") { $ws.product_volume_discount["collections"] = $ws.product_volume_discount.collections.filter(function (c) {return c.id == $ws.selected_collection.id });} }} } $ws.product_volume_discount["volume_discount"] = JSON.parse(JSON.stringify($ws.product_qb)); // if TRUE, app will alter prices. our app will output price and compare at price if ($ws.output && $ws.vd_has_discount && (typeof $ws.product_volume_discount.display_option != 'undefined' && $ws.product_volume_discount.display_option != 'no_volume_table')) {if ($ws.landingTemplate === "product" || (window.location.href.indexOf('/pages/') > -1 && $ws.landingTemplate === "collection")) { // Remove the table, also check for the quick view if ($ws.remove_duplicate_table) {$(".wholesale-table").remove(); } if (typeof $ws.product_volume_discount === 'undefined') isError("Volume discount table could not created. Because the rule is empty or not defined. Reference variable is WSAIO.product_volume_discount."); switch ($ws.product_volume_discount.display_option) {case "detailed_grid": $ws.detailed_grid_table($ws.product_volume_discount, params); break;case "basic_grid": $ws.basic_grid_table($ws.product_volume_discount, params); break;case "grid_range": $ws.grid_range_table($ws.product_volume_discount, params); break;case "detailed_grid_percent": $ws.detailed_grid_percent_table($ws.product_volume_discount, params); break;case "percent_grid": $ws.percent_grid_table($ws.product_volume_discount, params); break;case "grid_range_alternate": $ws.grid_range_alternate_table($ws.product_volume_discount, params); break;default: $ws.grid_range_alternate_table($ws.product_volume_discount, params); break; }} else { // This is used for collection listing page var value_range = []; for (var ee = 0; ee < $ws.product_volume_discount.volume_discount.length; ee++) {var v = $ws.product_volume_discount.volume_discount[ee];value_range.push(Number(v.value)); } var min = Math.min.apply(null, value_range); var max = Math.max.apply(null, value_range); log("Min discount: " + min); log("Max discount: " + max); var max_discount_index = $ws.product_volume_discount.volume_discount.findIndex(function (b) {return b.value == max }); if (max_discount_index > -1) {var max_discount = $ws.product_volume_discount.volume_discount[max_discount_index];var price = Number($ws.mF($ws.selected_variant.price));var discount = $ws.get_discount(price, max_discount.type, max_discount.value);if (Number(discount) == 0 || (Number(price) == 0)) { $ws.vd_has_discount = false;}if ($ws.vd_has_discount) { var compare_at_price = Number($ws.mF($ws.selected_variant.price)); if ($ws.general_settings.show_compare_at_price) {compare_at_price = Number($ws.mF($ws.selected_variant.compare_at_price)); } if (isNaN($ws.selected_variant.compare_at_price) || (Number($ws.selected_variant.compare_at_price) <= Number($ws.selected_variant.price))) {compare_at_price = 0;if ((Number(price) - Number(discount)) < Number(price)) { compare_at_price = Number(price).toFixed(2);} } var regular_price = $ws.formatMoney((Number(price) - Number(discount)).toFixed(2)); compare_at_price = $ws.formatMoney(Number(compare_at_price).toFixed(2)); if (Number(compare_at_price) < 1) {compare_at_price = ""; } if (!$ws.general_settings.compare_at_price) {compare_at_price = ""; } var html = ''; if ($ws.template === 'product') {html = $ws.product_price_html; } else {html = $ws.hcsr_qb_price_html; } if (!$ws.general_settings.compare_at_price) {compare_at_price = "";html = WSAIO.remove_comparePrice(html); } try {compare_at_price = compare_at_price.replace("$", "$@");regular_price = regular_price.replace("$", "$@"); } catch (e) {log(e) } html = html .replace(new RegExp("%regular_price%", "gi"), $ws.Lang.from + " " + regular_price) .replace(new RegExp("%compare_at_price%", "gi"), compare_at_price); try {html = html.replace(/@/g, ''); } catch (e) {log(e); } if (params.item_price_selector && $ws.selected_product.id) {$(params.item_price_selector).html(html) } else {isError("Item price selector is undefined"); } } }}$ws.saleClock($ws.product_volume_discount, $ws.selected_product, "vd"); } if (typeof $ws.callback === 'function') {$ws.callback({ product_volume_discount: $ws.product_volume_discount, quantity_breaks: $ws.product_qb, product: $ws.selected_product, variant: $ws.selected_variant}); } // response back if (typeof callback === 'function') {callback({ product_volume_discount: $ws.product_volume_discount, quantity_breaks: $ws.product_qb, product: $ws.selected_product, variant: $ws.selected_variant}); } // end for loop}; WSAIO.regularDiscount = function (params, callback) { if (WSAIO.debugger) debugger; if (typeof params === 'function') callback = params; if(!params){isError("No params provided for regular discount");return false; } if(!params.item_price_selector){isError("Item price selector is undefined");return false; } if (WSAIO.isWholesaleCustomer() === false) {if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } if($(params.item_price_selector).attr('class') != undefined){if($(params.item_price_selector).attr('class').indexOf('wsaio_') == -1){ $(params.item_price_selector).addClass('wsaio_'+params.product_id)} } var WSAIO_variant_sku_are_same = true; if (typeof params.template !== 'undefined' && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){ var _id = params.product_id; if(WSAIO.template != 'cart' && typeof WSAIO.product_in_collects != 'undefined' && WSAIO.product_in_collects.length != 0){var _indx = WSAIO.product_in_collects.findIndex(function(e,r){return e.product_id == _id;});if(typeof WSAIO.product_in_collects[_indx] != 'undefined' && typeof WSAIO.product_in_collects[_indx].product_variants != 'undefined'){ var current_product_variant = WSAIO.product_in_collects[_indx].product_variants;var _indx_of_variant = current_product_variant.findIndex(function(d,t){return d.id == params.variant_id;});WSAIO.selected_variant_taxable = current_product_variant[_indx_of_variant].taxable;// if Price set in price adjustment, then no tax include function runif(typeof WSAIO.tax_settings != 'undefined' && WSAIO.tax_settings.presentment != null && WSAIO.tax_settings.presentment.price_adjustments != null && typeof WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids != 'undefined' && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.length && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.indexOf(current_product_variant[_indx_of_variant].id) > -1){WSAIO.selected_variant_taxable = false;}}}else if(typeof WSAIO.products_with_collections != 'undefined' && WSAIO.products_with_collections.length != 0){var _indx = WSAIO.products_with_collections.findIndex(function(e,r){return e.product_id == _id;});if(typeof WSAIO.products_with_collections[_indx] != 'undefined' && typeof WSAIO.products_with_collections[_indx].product_variants != 'undefined'){var current_product_variant = WSAIO.products_with_collections[_indx].product_variants;var _indx_of_variant = current_product_variant.findIndex(function(d,t){return d.id == params.variant_id;})WSAIO.selected_variant_taxable = current_product_variant[_indx_of_variant].taxable;// if Price set in price adjustment, then no tax include function runif(typeof WSAIO.tax_settings != 'undefined' && WSAIO.tax_settings.presentment != null && WSAIO.tax_settings.presentment.price_adjustments != null && typeof WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids != 'undefined' && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.length && WSAIO.tax_settings.presentment.price_adjustments.fixed_variant_ids.indexOf(current_product_variant[_indx_of_variant].id) > -1){WSAIO.selected_variant_taxable = false;}}} } $ws.output = true; $ws.selected_variant = JSON.parse(JSON.stringify($ws.current_variant)); // current variant obj should not change $ws.selected_product = JSON.parse(JSON.stringify($ws.current_product)); // current product obj should not change $ws.selected_collection = JSON.parse(JSON.stringify($ws.current_collection)); // current collection obj should not change if (typeof params === 'object') {if (typeof params.product_id !== 'undefined' && params.product_id !== "default") $ws.selected_product.id = params.product_id;if (typeof params.product_handle !== 'undefined' && params.product_handle !== "default") $ws.selected_product.handle = params.product_handle;if (typeof params.variant_id !== 'undefined' && params.variant_id !== "default") $ws.selected_variant.id = params.variant_id;if (typeof params.variant_sku !== 'undefined' && params.variant_sku !== "default") $ws.selected_variant.sku = params.variant_sku;if (typeof params.variant_price !== 'undefined' && params.variant_id !== "default") $ws.selected_variant.price = params.variant_price;if (typeof params.variant_compare_at_price !== 'undefined' && params.variant_sku !== "default") $ws.selected_variant.compare_at_price = params.variant_compare_at_price;if (typeof params.collection_id !== 'undefined' && params.collection_id !== "default") $ws.selected_collection.id = params.collection_id;if (typeof params.output !== 'undefined' && params.output !== "default") $ws.output = params.output;if (typeof params.template !== 'undefined' && params.template !== "default") $ws.landingTemplate = params.template; } if ($ws.selected_variant && typeof $ws.selected_variant.price === "string" && $ws.selected_variant.price.indexOf(".") > -1) {$ws.selected_variant.price = $ws.selected_variant.price.replace('.', ''); } if ($ws.selected_variant && typeof $ws.selected_variant.compare_at_price === "string" && $ws.selected_variant.compare_at_price.indexOf(".") > -1) {$ws.selected_variant.compare_at_price = $ws.selected_variant.compare_at_price.replace('.', ''); } $ws.productRd = []; var hasImportRule = $ws.regular_discounts.some(function(item){ return item.applies_to == "products" && item.products.length && item.products[0].id == item.products[0].handle; }); if(hasImportRule){$ws.regular_discounts.sort(function (a, b) {// Shifting import rule to endif(b.applies_to == "products" || a.applies_to == "products"){if(a.products.length && (a.products[0].id == a.products[0].handle)){return 1;}if(b.products.length && (b.products[0].id == b.products[0].handle)){return -1;}}return 0;});} $ws.applied_tag_array = []; // for loop for (var i = 0, len_i = $ws.regular_discounts.length; i < len_i; i++) {var regular_discount = $ws.regular_discounts[i];if (regular_discount.state !== 'published') continue;if ($ws.checkCustomer(regular_discount.customer_group, regular_discount.tags, regular_discount.tags_excluded) === false) continue;if (regular_discount.schedule_active) { var _schedule = $ws.getSchedule(regular_discount.schedule); log("_schedule", _schedule); if (_schedule.ends_in) {if ( Number(_schedule.ends_in.years) <= 0 && Number(_schedule.ends_in.months) <= 0 && Number(_schedule.ends_in.days) <= 0 && Number(_schedule.ends_in.hours) <= 0 && Number(_schedule.ends_in.minutes) <= 0 && Number(_schedule.ends_in.seconds) <= 0) { log("This rule was expired", _schedule); continue;}if ( Number(_schedule.started.years) >= 0 && Number(_schedule.started.months) >= 0 && Number(_schedule.started.days) >= 0 && Number(_schedule.started.hours) >= 0 && Number(_schedule.started.minutes) >= 0 && Number(_schedule.started.seconds) >= 0) { log("This rule was schedules and will be started in", _schedule); continue;} }}$ws.checkAppliesTo({ "type": regular_discount.applies_to, "rule": regular_discount, "module": "regular_discount"}); } // end for loop if ($ws.productRd.length > 0) {// sort array by priority$ws.productRd.sort(function (a, b) { return Number(a.priority) - Number(b.priority)});// if this array contains multiple applies to, then filter by products or by collection, to exclude extra rules.if (-1 < $ws.productRd.findIndex(function (x) { return x.applies_to == "products"})) { $ws.productRd = $ws.productRd.filter(function (x) {return x.applies_to === "products" });} else if (-1 < $ws.productRd.findIndex(function (x) { return x.applies_to == "collections"})) { $ws.productRd = $ws.productRd.filter(function (y) {return y.applies_to === "collections" });} } $ws.product_rd_obj = []; $ws.product_regular_discount = {}; $ws.rd_has_discount = false; // assume this has if ($ws.productRd && $ws.productRd.length > 1) { var rule_date_found = $ws.productRd.some(function(e,r){ return typeof e.created_at !== "undefined"}); if(rule_date_found){ var update_sorted_rule = JSON.parse(JSON.stringify($ws.productRd)); try{var check_if_individual = $ws.productRd.find(function(w,y){return w.individual_product }) if(check_if_individual){ update_sorted_rule.sort(function(a,b){ if(typeof a.created_at === 'undefined' || typeof b.created_at === 'undefined'){ return 0; }else{ if(new Date(a.created_at) > new Date(b.created_at)){ return -1; }else{ return 1; } } });} } catch(e){ update_sorted_rule = []; } if(update_sorted_rule.length > 0){ $ws.productRd = JSON.parse(JSON.stringify(update_sorted_rule)); } }$ws.productRd = [$ws.productRd[0]]; } var hasImported_Rule = $ws.productRd.some(function(item){ return item.applies_to == "products" && item.products.length && item.products[0].id == item.products[0].handle; }); if(hasImported_Rule || WSAIO.variant_sku_are_same == false){WSAIO_variant_sku_are_same = false; } if ($ws.productRd.length > 0) {$ws.rd_has_discount = true;// for loopfor (var j = 0, len_j = $ws.productRd.length; j < len_j; j++) { var rd_rule = $ws.productRd[j]; if ("products" === rd_rule.applies_to && rd_rule.individual_product === true) {for (var tt = 0; tt < rd_rule.products.length; tt++) { var product = rd_rule.products[tt], pIndex = tt; if (product.handle === $ws.selected_product.handle || product.id == $ws.selected_product.id) {if ($ws.product_regular_discount.handle !== product.handle) { $ws.product_regular_discount = JSON.parse(JSON.stringify(rd_rule)); $ws.product_regular_discount["product"] = product;}if (product.variant_level) { for (var nn = 0; nn < product.variants.length; nn++) {var variant = product.variants[nn],vIndex = nn;var check_tag = false;var vIn = variant.tag_options.findIndex(function (apt) {$ws.applied_tag_array.findIndex(function (single_tag){if(apt.name.toString().toLowerCase() == single_tag.toString().toLowerCase()){check_tag = true;}})if(check_tag){return true;}});if (vIn > -1 && (variant.id == $ws.selected_variant.id || ((variant.sku == $ws.selected_variant.sku && hasImported_Rule) && (!WSAIO_variant_sku_are_same)))) { var v_tag_option = variant.tag_options[vIn]; $ws.product_rd_obj.push({name: v_tag_option.name,value: v_tag_option.value,type: v_tag_option.type });} }} else {var check_tag = false;var pIn = product.tag_options.findIndex(function (apt) { $ws.applied_tag_array.findIndex(function (single_tag){ if(apt.name.toString().toLowerCase() == single_tag.toString().toLowerCase()) { check_tag = true; } }) if(check_tag){ return true; }}); if (pIn > -1) {var tag_option = product.tag_options[pIn];$ws.product_rd_obj.push({ name: tag_option.name, value: tag_option.value, type: tag_option.type}); }} }} } else {product_rd_obj = { name: rd_rule.applies_to, type: rd_rule.discount_type, value: rd_rule.discount_value}$ws.product_regular_discount = JSON.parse(JSON.stringify(rd_rule));if (rd_rule.applies_to === "collections") { $ws.product_regular_discount["collections"] = $ws.product_regular_discount.collections.filter(function (c) {return c.id == $ws.selected_collection.id });} }} } $ws.product_regular_discount["volume_discount"] = JSON.parse(JSON.stringify($ws.product_rd_obj)); // if TRUE, app will alter prices. our app will output price and compare at price var price = Number($ws.mF($ws.selected_variant.price)); // if customer exampt true, then subtract international tax from original price if(WSAIO.customer.id != null && WSAIO.customer.tax_exempt && WSAIO.selected_variant_taxable){if(typeof WSAIO.tax_settings !== "undefined" && WSAIO.tax_settings && typeof WSAIO.tax_settings.taxes_included !== "undefined" && WSAIO.tax_settings.taxes_included === true && typeof WSAIO.tax_settings.auto_configure_tax_inclusivity != 'undefined' && WSAIO.tax_settings.auto_configure_tax_inclusivity && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){ price = Number($ws.mF($ws.selected_variant.price))/(1+WSAIO.tax_settings.presentment.tax); } } if ($ws.product_regular_discount["volume_discount"].length > 0) {$ws.product_regular_discount.discount_type = $ws.product_regular_discount["volume_discount"][0].type;$ws.product_regular_discount.discount_value = $ws.product_regular_discount["volume_discount"][0].value; } if (typeof $ws.product_regular_discount.discount_type === 'undefined') {$ws.rd_has_discount = !1; } if (typeof $ws.product_regular_discount.discount_value === 'undefined') {$ws.rd_has_discount = !1; } var discount = $ws.get_discount(price, $ws.product_regular_discount.discount_type, $ws.product_regular_discount.discount_value); if (Number(discount) == 0 || (Number(price) == 0)) {$ws.rd_has_discount = !1; } if ($ws.rd_has_discount && $ws.output) {var regular_price = (Number(price) - Number(discount)).toFixed(2);var compare_at_price = Number($ws.mF($ws.selected_variant.price));if ($ws.general_settings.show_compare_at_price) { compare_at_price = Number($ws.mF($ws.selected_variant.compare_at_price));}if (isNaN($ws.selected_variant.compare_at_price) || (Number($ws.selected_variant.compare_at_price) <= Number($ws.selected_variant.price))) { compare_at_price = 0; if ((Number(price) - Number(discount)) < Number(price)) {compare_at_price = Number(price).toFixed(2); }}var html = $ws.hcsr_price_html;var saved_price_html = $ws.saved_price_in_grid_html;if ($ws.template === 'product') { html = $ws.product_price_html, saved_price_html = $ws.saved_price_html;}if(html.indexOf('%compare_at_price%') == -1){ html = '%compare_at_price%' + html; }var total_saved = $ws.saved_amount(compare_at_price, regular_price);saved_price_html = saved_price_html.replace(new RegExp("%saved_amount:price%", "gi"), $ws.formatMoney(Number(total_saved.price))).replace(new RegExp("%saved_amount:percentage%", "gi"), total_saved.percentage);$ws.alterHTML(saved_price_html, $ws.product_saved_amount_selector.replace("%id%", $ws.selected_product.id));$ws.product_regular_discount.total_saved = total_saved;$ws.product_regular_discount.regular_price = (Number(price) - Number(discount)).toFixed(2);$ws.product_regular_discount.compare_at_price = Number(compare_at_price).toFixed(2);var actual_regularPrice = 0; var excluded_actual_regularPrice = 0;if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()){ var exclude_value = (WSAIO.exclude_VAT/100) + 1; if(typeof QOF_page !== 'undefined' && QOF_page && (typeof WSAIO.QOF_version == 'undefined' || WSAIO.QOF_version == 1)){ regular_price = $ws.formatMoney(((Number(price) - Number(discount))/exclude_value)*100); compare_at_price = $ws.formatMoney(((Number(compare_at_price))/exclude_value)*100); excluded_actual_regularPrice = $ws.formatMoney(((Number(price) - Number(discount))/exclude_value)*100); actual_regularPrice = $ws.formatMoney((Number(price) - Number(discount))*100) }else{ regular_price = $ws.formatMoney(((Number(price) - Number(discount))/exclude_value)); compare_at_price = $ws.formatMoney(((Number(compare_at_price))/exclude_value));excluded_actual_regularPrice = $ws.formatMoney(((Number(price) - Number(discount))/exclude_value));actual_regularPrice = $ws.formatMoney(Number(price) - Number(discount)) } }else{ if(typeof QOF_page !== 'undefined' && QOF_page && (typeof WSAIO.QOF_version == 'undefined' || WSAIO.QOF_version == 1)){ regular_price = $ws.formatMoney((Number(price) - Number(discount))*100); compare_at_price = $ws.formatMoney(Number(compare_at_price)*100); }else{ regular_price = $ws.formatMoney((Number(price) - Number(discount))); compare_at_price = $ws.formatMoney(Number(compare_at_price)); } }if (Number(compare_at_price) < 1) { compare_at_price = "";}if (!$ws.general_settings.compare_at_price) { compare_at_price = "";}try { compare_at_price = compare_at_price.replace("$", "$@"); regular_price = regular_price.replace("$", "$@");} catch (e) { log(e)}if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ regular_price = regular_price+' '+Shopify.currency.active; actual_regularPrice = actual_regularPrice+' '+Shopify.currency.active; excluded_actual_regularPrice = excluded_actual_regularPrice+' '+Shopify.currency.active; if(compare_at_price != ""){ compare_at_price = compare_at_price+' '+Shopify.currency.active; } }html = html.replace(new RegExp("%regular_price%", "gi"), regular_price).replace(new RegExp("%compare_at_price%", "gi"), compare_at_price);if ($ws.landingTemplate !== "product" && $ws.landingTemplate !== "cart") { html = html .replace(new RegExp("%regular_price%", "gi"), regular_price) .replace(new RegExp("%compare_at_price%", "gi"), compare_at_price);}try { $(params.item_price_selector).removeClass("empty");} catch (e) {}try { html = html.replace(/@/g, '');} catch (e) { log(e);}if($(params.item_price_selector).hasClass("wsdapp")){ log("Discount already has been applied on this item");}else{ if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && typeof WSAIO.excludePrice_design != 'undefined' && WSAIO.excludePrice_design == 'without-crossout'){ if (!$ws.general_settings.compare_at_price) { actual_regularPrice = "" } html = '

    '+actual_regularPrice+'

    '+excluded_actual_regularPrice+'(Excl. Tax)

    ' $(params.item_price_selector).html(html); }else{ $(params.item_price_selector).html(html); } $(params.item_price_selector).addClass("wsdapp");}$ws.saleClock($ws.product_regular_discount, $ws.selected_product, "rd"); } // response back if (typeof callback === 'function') {callback({ product_regular_discount: $ws.product_regular_discount, regular_discounts: $ws.product_rd_obj, product: $ws.selected_product, variant: $ws.selected_variant, ws_discount: discount}); } if (typeof $ws.callback === 'function') {$ws.callback({ product_regular_discount: $ws.product_regular_discount, regular_discounts: $ws.product_rd_obj, product: $ws.selected_product, variant: $ws.selected_variant, ws_discount: discount}); }}; WSAIO.cartLevelDiscount = function () { var is_cld = false; if (WSAIO.cart_ld_discounts && WSAIO.cart_ld_discounts.length) {for (var cld_index = 0; cld_index < WSAIO.cart_ld_discounts.length; cld_index++) { var rule_item = WSAIO.cart_ld_discounts[cld_index]; if (rule_item.state != 'published') continue; if ($ws.checkCustomer(rule_item.customer_group, rule_item.tags, rule_item.tags_excluded) === false) continue; is_cld = true; break;} } return is_cld;} WSAIO.Volume_disocunted_price = function(qty){ if(typeof current_product != 'undefined' && current_product != null){ var selected_variant_index = current_product.variants.findIndex(function (a) {return a.id == selected_variant_id }); var Total_quantity = qty; var compare_row = 0; try{ WSAIO.productDiscount({template:'product',item_price_selector: $('.demo'),product_id: current_product.id,product_handle: current_product.handle,variant_id: current_product.variants[selected_variant_index].id,variant_sku: current_product.variants[selected_variant_index].sku,variant_price: current_product.variants[selected_variant_index].price,variant_compare_at_price: current_product.variants[selected_variant_index].compare_at_price },function(ee){var volume_applied = ee.volume_discount.quantity_breaks.length;var volume_table_Values = []; if(volume_applied > 0){ volume_table_Values = ee.volume_discount.quantity_breaks; volume_table_Values = volume_table_Values.filter(function(elem,i){return elem.value != '' || elem.value != 0; }); if(Total_quantity >= Number(volume_table_Values[0].qty)){$(volume_table_Values).each(function(e){if(Total_quantity >= Number(volume_table_Values[e].qty) && Number(volume_table_Values[e].value) != 0 && Number(volume_table_Values[e].value) != ''){ compare_row = e;}}) var compare = 0;var Volume_applied_price = 0;var actual_regularPrice = 0;var excluded_actual_regularPrice = 0; var check_compare = 0, check_applied_discount = 0; if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()){ var exclude_value = (WSAIO.exclude_VAT/100) + 1; Volume_applied_price = $ws.formatMoney(((Number(current_product.variants[selected_variant_index].price/100)-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value)))/exclude_value)); compare = $ws.formatMoney(((current_product.variants[selected_variant_index].price)/exclude_value)/100); check_compare = ((current_product.variants[selected_variant_index].price)/exclude_value)/100; check_applied_discount = (Number(current_product.variants[selected_variant_index].price/100)-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value)))/exclude_value; actual_regularPrice = $ws.formatMoney(((Number(current_product.variants[selected_variant_index].price/100)-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value))))) excluded_actual_regularPrice = $ws.formatMoney(((Number(current_product.variants[selected_variant_index].price/100)-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value)))/exclude_value)) }else{var price = Number(current_product.variants[selected_variant_index].price/100);// if customer exampt true, then subtract international tax from original priceif(WSAIO.customer.id != null && WSAIO.customer.tax_exempt && WSAIO.selected_variant_taxable){if(typeof WSAIO.tax_settings !== "undefined" && WSAIO.tax_settings && typeof WSAIO.tax_settings.taxes_included !== "undefined" && WSAIO.tax_settings.taxes_included === true && typeof WSAIO.tax_settings.auto_configure_tax_inclusivity != 'undefined' && WSAIO.tax_settings.auto_configure_tax_inclusivity && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){price = price/(1+WSAIO.tax_settings.presentment.tax);}}Volume_applied_price = $ws.formatMoney((price-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value)))); compare = $ws.formatMoney((current_product.variants[selected_variant_index].price)/100); check_compare = (current_product.variants[selected_variant_index].price)/100; check_applied_discount = (Number(current_product.variants[selected_variant_index].price/100)-Number(WSAIO.get_discount(current_product.variants[selected_variant_index].price/100,volume_table_Values[compare_row].type,volume_table_Values[compare_row].value))); if(Volume_applied_price == compare && current_product.variants[selected_variant_index].compare_at_price != undefined){ compare = $ws.formatMoney(((current_product.variants[selected_variant_index].compare_at_price)/100).toFixed(2)); check_compare = (current_product.variants[selected_variant_index].compare_at_price)/100; } } var html = WSAIO.product_price_html; if (!$ws.general_settings.compare_at_price || Volume_applied_price == compare || check_applied_discount > check_compare) { compare = ""; html = WSAIO.remove_comparePrice(html); }if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ Volume_applied_price = Volume_applied_price+' '+Shopify.currency.active; actual_regularPrice = actual_regularPrice+' '+Shopify.currency.active; excluded_actual_regularPrice = excluded_actual_regularPrice+' '+Shopify.currency.active; if(compare != ""){ compare = compare+' '+Shopify.currency.active; } }html = html.replace(new RegExp("%regular_price%", "gi"), Volume_applied_price).replace(new RegExp("%compare_at_price%", "gi"), compare); if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && typeof WSAIO.excludePrice_design != 'undefined' && WSAIO.excludePrice_design == 'without-crossout'){ if (!$ws.general_settings.compare_at_price) { actual_regularPrice = "" } html = '

    '+actual_regularPrice+'

    '+excluded_actual_regularPrice+'(Excl. Tax)

    ' $('.wsaio_'+current_product.id).html(html); }else{ $('.wsaio_'+current_product.id).html(html) } }else{ if(ee.regular_discount.ws_discount != 0){var compare = 0;var Volume_applied_price = 0; var actual_regularPrice = 0; var excluded_actual_regularPrice = 0;var html = WSAIO.product_price_html;var check_compare = 0, check_applied_discount = 0;if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()){ var exclude_value = (WSAIO.exclude_VAT/100) + 1; Volume_applied_price = $ws.formatMoney(((ee.regular_discount.product_regular_discount.regular_price)/exclude_value)); compare = $ws.formatMoney((((current_product.variants[selected_variant_index].price)/100)/exclude_value)); check_compare = (((current_product.variants[selected_variant_index].price)/100)/exclude_value); check_applied_discount = ((ee.regular_discount.product_regular_discount.regular_price)/exclude_value); actual_regularPrice = $ws.formatMoney(((ee.regular_discount.product_regular_discount.regular_price))) excluded_actual_regularPrice = $ws.formatMoney(((ee.regular_discount.product_regular_discount.regular_price)/exclude_value)) }else{ Volume_applied_price = $ws.formatMoney((ee.regular_discount.product_regular_discount.regular_price)); compare = $ws.formatMoney(((current_product.variants[selected_variant_index].price)/100)); check_compare = (current_product.variants[selected_variant_index].price)/100; check_applied_discount = (ee.regular_discount.product_regular_discount.regular_price);}if (!$ws.general_settings.compare_at_price || Volume_applied_price == compare || check_compare < check_applied_discount) { compare = ""; html = WSAIO.remove_comparePrice(html);}if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){Volume_applied_price = Volume_applied_price+' '+Shopify.currency.active; actual_regularPrice = actual_regularPrice+' '+Shopify.currency.active; excluded_actual_regularPrice = excluded_actual_regularPrice+' '+Shopify.currency.active; if(compare != ""){compare = compare+' '+Shopify.currency.active;} } html = html.replace(new RegExp("%regular_price%", "gi"), Volume_applied_price) .replace(new RegExp("%compare_at_price%", "gi"), compare); if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && typeof WSAIO.excludePrice_design != 'undefined' && WSAIO.excludePrice_design == 'without-crossout'){ if (!$ws.general_settings.compare_at_price) { actual_regularPrice = "" } html = '

    '+actual_regularPrice+'

    '+excluded_actual_regularPrice+'(Excl. Tax)

    ' $('.wsaio_'+current_product.id).html(html); }else{ $('.wsaio_'+current_product.id).html(html) }}else{ var compare = 0; var Volume_applied_price = 0; var html = WSAIO.product_price_original_html;Volume_applied_price = $ws.formatMoney(((ee.regular_discount.variant.price)/100).toFixed(2));compare = $ws.formatMoney(((current_product.variants[selected_variant_index].compare_at_price)/100).toFixed(2));if (!$ws.general_settings.compare_at_price || current_product.variants[selected_variant_index].compare_at_price == null || current_product.variants[selected_variant_index].compare_at_price == 0 || Volume_applied_price == compare) {compare = ""; html = WSAIO.remove_comparePrice(html);}if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){Volume_applied_price = Volume_applied_price+' '+Shopify.currency.active;if(compare != ""){compare = compare+' '+Shopify.currency.active;}} html = html.replace(new RegExp("%regular_price%", "gi"), Volume_applied_price) .replace(new RegExp("%compare_at_price%", "gi"), compare); $('.wsaio_'+current_product.id).html(html)} }} });}catch(e){} }} WSAIO.variantOriginalPrice = function () { if (WSAIO.debugger) debugger; var regular_price = $ws.formatMoney($ws.selected_variant.price/100); var compare_at_price = $ws.formatMoney($ws.selected_variant.compare_at_price/100); var html = $ws.hcsr_price_original_html; if ($ws.template === 'product') {html = $ws.product_price_original_html; } if (Number($ws.selected_variant.price) > Number($ws.selected_variant.compare_at_price)) {compare_at_price = ""; } if ($ws.selected_variant.compare_at_price == null) {compare_at_price = ""; } if (Number($ws.selected_variant.compare_at_price) < 1) {compare_at_price = ""; } if (!$ws.general_settings.compare_at_price) {compare_at_price = ""; html = WSAIO.remove_comparePrice(html); } if(Number($ws.selected_variant.price) == Number($ws.selected_variant.compare_at_price)){compare_at_price = ""; } if (compare_at_price == "") {try { $($ws.product_price_selector).addClass("empty"); html = WSAIO.remove_comparePrice(html);} catch (e) {} } else {try { $($ws.product_price_selector).removeClass("empty");} catch (e) {} } try {compare_at_price = compare_at_price.replace("$", "$@");regular_price = regular_price.replace("$", "$@"); } catch (e) {log(e) } if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ regular_price = regular_price+' '+Shopify.currency.active; if(compare_at_price != ""){ compare_at_price = compare_at_price+' '+Shopify.currency.active; } } html = html.replace(new RegExp("%regular_price%", "gi"), regular_price).replace(new RegExp("%compare_at_price%", "gi"), compare_at_price); try {html = html.replace(/@/g, ''); } catch (e) {log(e); } if ($ws.product_price_selector && $ws.selected_product) {$(WSAIO.product_price_selector).html(html); } else {isError("Selected variant price was not defined. Reference: WSAIO.selected_variant.price"); }}; WSAIO.get_discount = function (price, type, value) { if (WSAIO.debugger) debugger; if(type == 'fixed_price' && (value == '' || value == 'NaN')) value = price; if(type != "percentage") value = WSAIO.calculate_tax_price_adjustments(value); if (type !== "percentage" && value && $ws.Currency && ($ws.Currency.rates && $ws.Currency.storeCurrency)) {if ($ws.ccr && !isNaN($ws.ccr)) { value = Number(Number(Number(value) * Number($ws.ccr)).toFixed(2));} else { value = $ws.Currency.convert(value, $ws.Currency.storeCurrency, $ws.Currency.selectedCurrency);} } var d = 0; switch (type) {case "percentage":d = ((Number(price) * Number(value)) / 100).toFixed(2); break;case "price_discount": if (Number(price) < Number(value)) {d = Number(price); } else {d = Number(value); } break;case "fixed_price": if (Number(price) <= Number(value)) {d = 0; } else {d = Number(price) - Number(value); } break;default: log("Invalid discount type. Valid values are percentage, price_discount and fixed_price."); break; } return Number(d).toFixed(2);}; window.HandleQty=function(){ /* Selector of qty */var selector = WSAIO.current_product_qty_input_selector;/* Callback: for native change event */var changeListener=function(e){ // Trigger change callback HandleQty.change(e.target);};/* Setup an observer */var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");var originalSet = descriptor.set;/* define our own setter (Will call default setter) */descriptor.set = function(input) { originalSet.apply(this,arguments); // Trigger change callback HandleQty.change(this);}/* Will add listerners */ var init_module=function(){ /* Attach event to every selector */ var elements = document.querySelectorAll(selector); if(elements.length > 0){$(elements).each(function(i){ var el = elements[i]; /* Will capture 60% of the events (mostly trigger upon exec "el.val({value})" ) */ el.removeEventListener("change", changeListener); el.addEventListener("change", changeListener); /* Will capture remaining 40% of the events (mostly trigger by "el.value={value}" ) */ Object.defineProperty(el, "value", descriptor);}); }}return { /* Main Callback */ change:function(el){WSAIO.Volume_disocunted_price(el.value) }, // So it can be called dynamically init:init_module} }() HandleQty.init(); WSAIO.check_eligible_customer = function(){ var check_tag = false; var tagss = WSAIO.exclude_VAT_for.toLowerCase().split(','); if(WSAIO.exclude_VAT_for != ''){$(tagss).each(function(e){ $(WSAIO.customer.tags).each(function(ee){var customer_tag = WSAIO.customer.tags[ee].toLowerCase();if(customer_tag == tagss[e]){ check_tag = true;} })}) }else{check_tag = true; } return check_tag;} WSAIO.get_price = function (rule, vd) { if (WSAIO.debugger) debugger; if ($ws.selected_variant.price) {var price = Number($ws.mF($ws.selected_variant.price));var discount = $ws.get_discount(price, vd.type, vd.value);// if customer exampt true, then subtract international tax from original priceif(WSAIO.customer.id != null && WSAIO.customer.tax_exempt && WSAIO.selected_variant_taxable){if(typeof WSAIO.tax_settings !== "undefined" && WSAIO.tax_settings && typeof WSAIO.tax_settings.taxes_included !== "undefined" && WSAIO.tax_settings.taxes_included === true && typeof WSAIO.tax_settings.auto_configure_tax_inclusivity != 'undefined' && WSAIO.tax_settings.auto_configure_tax_inclusivity && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){price = Number($ws.mF($ws.selected_variant.price))/(1+WSAIO.tax_settings.presentment.tax);}}var wholesale_price = Number(price) - Number(discount);try { wholesale_price = Number(wholesale_price).toFixed(2);} catch (e) { isError(e)}if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()){ var exclude_value = (WSAIO.exclude_VAT/100) + 1; wholesale_price = (wholesale_price/exclude_value);}if(typeof QOF_page !== 'undefined' && QOF_page && (typeof WSAIO.QOF_version == 'undefined' || WSAIO.QOF_version == 1)){ return $ws.formatMoney(wholesale_price*100, $ws.shopInfo.money_format); }else{ return $ws.formatMoney(wholesale_price, $ws.shopInfo.money_format); } } else {isError("Selected variant price was not defined. Reference: WSAIO.selected_variant.price"); }}; WSAIO.get_price_in_percent = function (rule, vd) { if (WSAIO.debugger) debugger; if ($ws.selected_variant.price) {var price = Number($ws.mF($ws.selected_variant.price));var discount = $ws.get_discount(price, vd.type, vd.value);var perc = Math.round(100 - ((Number(price) - Number(discount)) / Number(price)) * 100);return perc.toString() + '%'; } else {isError("Selected variant price was not defined. Reference: WSAIO.selected_variant.price") }}; WSAIO.saved_amount = function (original_price, discount_price) { if (WSAIO.debugger) debugger; if (original_price === null || discount_price === null || isNaN(original_price) || isNaN(discount_price)) {return { percentage: "0%", price: "0"}; }; var price = original_price - discount_price, percentage = 100 - (discount_price / original_price) * 100; return {percentage: Math.round(percentage) + "%",price: Number(price).toFixed(2) };}; WSAIO.volumeDiscountPriority = function () { if ($ws.productRd && $ws.productRd.length && $ws.productVd && $ws.productVd.length) {try { if ($ws.productRd.findIndex(function (x) {return x.customer_group === 'has_tag' }) > -1 && $ws.productVd.findIndex(function (x) {return x.customer_group == 'has_tag' }) === -1) {$ws.productVd = []; }} catch (e) { isError(e);}try { if ($ws.productRd.length > 0 && $ws.productRd.findIndex(function (x) {return x.customer_group === 'all' }) === -1 && $ws.productVd.findIndex(function (x) {return x.customer_group == 'all' }) > -1) {$ws.productVd = []; }} catch (e) { isError(e);} }}; // Product page Tables gridWSAIO.detailed_grid_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = "";try{table_description = ""; // Quantity can be mix of different variants}catch(e){console.warn('Volume string formate not supported');}for (var ff = 0; ff < rule.volume_discount.length; ff++) { var vd = rule.volume_discount[ff]; if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price(rule, vd) != undefined ) {table_rows += '

    ' + '' + vd.qty + '' + '' + $ws.get_price(rule, vd) + $ws.Lang.each_item + '' + '

    '; }}if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.buy + ' ' + $ws.Lang.quantity + '' + $ws.Lang.price + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.basic_grid_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = "";try{table_description = ""; // Quantity can be mix of different variants}catch(e){console.warn('Volume string formate not supported');}rule.volume_discount.forEach(function (vd, i) {if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price(rule, vd) != undefined) {table_rows += '

    ' + '' + vd.qty + '' + '' + $ws.get_price(rule, vd) + $ws.Lang.each_item + '' + '

    '; }});if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.quantity + '' + $ws.Lang.price + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.grid_range_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = "";try{table_description = ""; // Quantity can be mix of different variants}catch(e){console.warn('Volume string formate not supported');}rule.volume_discount.forEach(function (vd, i) {if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price(rule, vd) != undefined) {var next_qty = $ws.Lang.range_so_on;if (rule.volume_discount[i + 1]) { next_qty = Number(rule.volume_discount[i + 1].qty) - 1;}table_rows += '

    ' + '' + vd.qty + '' + '' + next_qty + '' + '' + $ws.get_price(rule, vd) + $ws.Lang.each_item + '' + '

    '; }});if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.minimum_quantity + '' + $ws.Lang.maximum_quantity + '' + $ws.Lang.price + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.detailed_grid_percent_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = ""; try{ table_description = ""; // Quantity can be mix of different variants }catch(e){console.warn('Volume string formate not supported');}rule.volume_discount.forEach(function (vd, i) {if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price(rule, vd) != undefined) {table_rows += '

    ' + '' + vd.qty + '' + '' + $ws.get_price(rule, vd) + $ws.Lang.each_item + '' + '' + $ws.get_price_in_percent(rule, vd) + ' ' + $ws.Lang.off + '' + '

    '; }}); if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.quantity + '' + $ws.Lang.price + '' + $ws.Lang.discount + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.percent_grid_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = ""; try{ table_description = ""; // Quantity can be mix of different variants }catch(e){console.warn('Volume string formate not supported');}rule.volume_discount.forEach(function (vd, i) {if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price_in_percent(rule, vd) != undefined) { table_rows += '

    ' +'' + $ws.Lang.buy + ' ' + vd.qty + '' +'' + $ws.get_price_in_percent(rule, vd) + ' ' + $ws.Lang.off + '' +'

    ';}}); if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.quantity + '' + $ws.Lang.discount + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.grid_range_alternate_table = function (rule, params) { if (WSAIO.debugger) debugger; if ('undefined' !== typeof rule.volume_discount && rule.volume_discount.length > 0) {var table_rows = "",table_description = ""; try{ table_description = ""; // Quantity can be mix of different variants }catch(e){console.warn('Volume string formate not supported');}rule.volume_discount.forEach(function (vd, i) {if (Number(vd.qty) > 0 && vd.value != '' && $ws.get_price(rule, vd) != undefined) {var next_qty = $ws.Lang.range_so_on;if (rule.volume_discount[i + 1]) { next_qty = Number(rule.volume_discount[i + 1].qty) - 1;}table_rows += '

    ' + '' + vd.qty + $ws.Lang.range_seperator + next_qty + '' + '' + $ws.get_price(rule, vd) + $ws.Lang.each_item + '' + '

    '; }}); if(table_description != ''){ table_rows += '

    ' + ''+'Note : ' + table_description +'' + '

    '; }var table = '

    ' +'' +'' +'' +'' +'' + table_rows + '' +'
    ' + $ws.Lang.quantity + '' + $ws.Lang.price + '

    ';if (table_rows != "") { if($('#Quick-order-form').length == 0){$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).siblings('.wholesale-table').remove()$('.wsaio_'+params.product_id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_inner_qb_table_selector).after(table) }else{ $ws.displayTable(table, '.wsaio-qt-'+params.product_id+':same', !0) $ws.displayTable(table, '.wsaio-vqt-'+params.variant_id+':same', !0) }} else { if($('#Quick-order-form').length == 0){$(".wholesale-table").remove(); }} } else {$(".wholesale-table").remove();isError("Volume discount was not configured."); }}; WSAIO.fetchCart = function (callback) { var url_string = WSAIO.local_param+"cart.js"; if(typeof Shopify.currency.active != 'undefined' && Shopify.currency.active != null && Shopify.currency.active != ''){url_string = url_string+'?currency='+Shopify.currency.active; } $ws.ajax({type: 'GET',url: url_string,cache: false,dataType: 'json',success: function (cart_obj) { var ws_cart_items = []; if (cart_obj && cart_obj.items && cart_obj.items.length > 0) {cart_obj.items.forEach(function (item, i) { try {delete item.product_description;delete item.featured_image;delete item.url;delete item.options_with_values;delete item.variant_options;delete item.product_description; } catch (error) {log(error); } ws_cart_items.push(item);});cart_obj.items = ws_cart_items; } try {"undefined" === typeof window.waioMOC && (window.waioMOC = {});"undefined" === typeof waioMOC.cart && (waioMOC.cart = {});try { waioMOC.cart["item_count"] = cart_obj.item_count; waioMOC.cart["total_weight"] = cart_obj.total_weight;} catch (e) {} } catch (e) {} if ("function" === typeof callback) {callback(null, cart_obj); }},error: function (err) { if ("function" === typeof callback) {callback(err, null); }} });}; WSAIO.checkout = function () { if (WSAIO.debugger) debugger; if(WSAIO.isWholesaleCustomer() === false || (window.ZapietCheckoutEnabled === false && typeof ZapietWidgetConfig != 'undefined' && Object.keys(ZapietWidgetConfig).length != 0)){if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } sessionStorage.setItem('isCheckoutvisited', 'true'); $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).addClass('checkout-disabled').attr('disabled','disabled').css({'pointer-events': 'none','cursor': 'progress'}) $ws.fetchCart(function (error, cart) {if (error) return isError(error);else { if(WSAIO.subscription_selector != 'false' || WSAIO.subscription_selector != ''){var isAllow = true;try{ $(cart.items).each(function(ee){if(WSAIO.subscription_selector.indexOf(',') == -1){ var _item = cart.items[ee]; if(_item[WSAIO.subscription_selector] != undefined || _item[WSAIO.subscription_selector] != null){isAllow = false;return $ws.redirectToURL('/checkout'); }}else{ var selct1 = WSAIO.subscription_selector.split(',')[0] var selct2 = WSAIO.subscription_selector.split(',')[1] var _item1 = cart.items[ee]; _item1 = _item1[selct1] if(_item1[selct2] != undefined || _item1[selct2] != null){isAllow = false;return $ws.redirectToURL('/checkout'); }} }).promise().done(function(){if(isAllow && (parseFloat(WSAIO.discount_response.wholesale_total_discount) > 0 || (typeof WSAIO.discount_response.shipping != 'undefined' && WSAIO.discount_response.shipping.apply_shipping_charges))){go_checkout() }else{ return $ws.redirectToURL('/checkout'); } })}catch(eee){log(eee)} } else{ if(parseFloat(WSAIO.discount_response.wholesale_total_discount) > 0 || (typeof WSAIO.discount_response.shipping != 'undefined' && WSAIO.discount_response.shipping.apply_shipping_charges)){ go_checkout() }else{ return $ws.redirectToURL('/checkout'); } } function go_checkout(){ if((WSAIO.disable_checkout && (typeof WSAIO.allow_normal_checkout__OC != 'undefined' && WSAIO.allow_normal_checkout__OC))){ return $ws.redirectToURL('/checkout'); } var note_attr = [];$.map( cart.attributes, function( val, i ) {note_attr.push({"name": i,"value":val});})if(WSAIO.PO_field_enable && $('.po_field').val() != ''){var po_value = $('.po_field').val();if(typeof po_value == 'undefined' || po_value == null) po_value = ''; note_attr.push({"name": 'Purchase Order (PO) Number',"value": $('.po_field').val() }); } var shopify_discounts = '';cart.items.findIndex(function(indx,count){if(indx.discounts != undefined && indx.discounts != null && indx.discounts.length > 0){$(indx.discounts).each(function(discount_itr){if(shopify_discounts.indexOf(indx.discounts[discount_itr].title) == -1){if(shopify_discounts != '') shopify_discounts = shopify_discounts + ' , ';shopify_discounts = shopify_discounts + indx.discounts[discount_itr].title;}})}}) if(shopify_discounts != '') {note_attr.push({"name": 'Shopify Automatic Discount',"value": shopify_discounts });}var reqdata = { // custom_tax_lines: [], // custom_shipping_line: {}, note_attributes:note_attr, custom_line_items: [], cart: cart, shopInfo: $ws.shopInfo, customer: $ws.customer, user_mode: $ws.user_mode, currency: $ws.shopInfo.currency, discount_code_application: WSAIO.DiscountCode.application, products_with_collections: (WSAIO.product_collections || []),};if (WSAIO.all_discount_tags && WSAIO.all_discount_tags.length > 0) { try {if(typeof WSAIO.wholesale_app_tags == 'undefined' || (typeof WSAIO.wholesale_app_tags != 'undefined' && WSAIO.wholesale_app_tags.indexOf('app') > -1) ){ WSAIO.all_discount_tags.push("wsaio-app"); }reqdata["tags"] = WSAIO.all_discount_tags.toString(); } catch (e) {log(e) }} else {if(typeof WSAIO.wholesale_app_tags == 'undefined' || (typeof WSAIO.wholesale_app_tags != 'undefined' && WSAIO.wholesale_app_tags.indexOf('app') > -1) ){ reqdata["tags"] = "wsaio-app"; } }if (cart.note == null) {reqdata["note"] = $("[name=note]").val(); }if ($ws.variant_sku_are_same) { reqdata["variant_sku_are_same"] = $ws.variant_sku_are_same;}if ($ws.coupon_expires_after_hours) { reqdata["coupon_expires_after_hours"] = $ws.coupon_expires_after_hours;}if ($ws.auto_delete_api) { if (localStorage.getItem("draft_order_info") != null) {try { reqdata["prev_draft_order_info"] = JSON.parse(localStorage.getItem("draft_order_info"));} catch (e) { log(e)} } if (localStorage.getItem("price_rule_info") != null) {try { reqdata["prev_price_rule_info"] = JSON.parse(localStorage.getItem("price_rule_info"));} catch (e) { log(e)} }}if(typeof WSAIO.shopify_markets_pro_enabled != 'undefined' && WSAIO.shopify_markets_pro_enabled && (typeof Shopify !== "undefined" && typeof Shopify.currency !== "undefined" && Shopify.currency.active != WSAIO.shopInfo.currency)){if(WSAIO.customer.addresses[0] == undefined){$ws.customer = { "addresses": [{ "country": WSAIO.shop_country }] }}if ($ws.customer && $ws.customer.addresses && $ws.customer.addresses[0]) {reqdata["shipping_address"] = $ws.customer.addresses[0]; } if($ws.customer && $ws.customer.addresses && $ws.customer.addresses[0]){ reqdata["billing_address"] = $ws.customer.addresses[0]; }}if ($ws.ccr) { reqdata["ccr"] = $ws.ccr;}$ws.checkoutRequest(reqdata, function (error, response) {if(typeof response != 'undefined' && response.isError && response.error != null && response.error && response.error.errors){var error_msg = response.error.errors[0].message;if(typeof error_msg != 'undefined' && error_msg != null && error_msg != '' && error_msg.indexOf('Managed Markets orders') > -1){WSAIO.shopify_markets_pro_enabled = true;if(recheckout_marketPro < 1){recheckout_marketPro++;WSAIO.checkout();return false;}}}if(typeof response.wholesale_errors != 'undefined' && response.wholesale_errors.length > 0){for(var error_key = 0; error_key < response.wholesale_errors.length; error_key++){if(response.wholesale_errors[error_key].key == 'email'){if($('.wsaioserver_error').length == 0){$(WSAIO.checkout_message_selector).after('

    Email contains an invalid domain name. Retry to place an order without a discount.

    ');$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).removeClass('checkout-disabled').removeAttr('disabled').css({'pointer-events': 'auto','cursor': 'pointer'}) return false;}else{return $ws.redirectToURL('/checkout');}}} }if(typeof response != 'undefined' && response.checkout_url == null) return $ws.redirectToURL('/checkout?wholesale=error');if (error) {log(error);$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).removeClass('checkout-disabled').removeAttr('disabled').css({'pointer-events': 'auto','cursor': 'pointer'})return $ws.redirectToURL('/checkout?wholesale=error');} else {if (typeof $ws.callback === 'function') { $ws.callback(response);}var concate_parameter = '/?';try{if(response.checkout_url.indexOf('/?') > -1){concate_parameter = '&'}if(Shopify.locale != '' && typeof response.discount_code == 'undefined'){ response.checkout_url = response.checkout_url+concate_parameter+'locale='+Shopify.locale;}if(Shopify.locale != '' && typeof response.discount_code != 'undefined'){ response.checkout_url = response.checkout_url.replace('?discount=','?locale='+Shopify.locale+'&discount=')} }catch(er){console.warn(er)}try{if($ws.customer.id == null && (window.ZapietCheckoutEnabled && typeof ZapietWidgetConfig != 'undefined' && Object.keys(ZapietWidgetConfig).length != 0)){var checkout_params = Zapiet.Widget.getCheckoutParams();response.checkout_url = response.checkout_url+'/?'+new URLSearchParams(checkout_params); }}catch(err){console.warn(err)}if(response.checkout_url.indexOf('/?') > -1){concate_parameter = '&'} if (response && response.checkout_url) { try{if(response.draft_order_info){response.checkout_url = response.checkout_url+concate_parameter+'step=contact_information';} }catch(e){console.warn(e)} try{ response.checkout_url = (response.checkout_url).replace((response.checkout_url).split('//')[1].split('/')[0],window.location.hostname) }catch(e){console.warn(e)} return $ws.redirectToURL(response.checkout_url);} else {$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).removeClass('checkout-disabled').removeAttr('disabled').css({'pointer-events': 'auto','cursor': 'pointer'}) return $ws.redirectToURL('/checkout?wholesale=error');} }}); }} });};WSAIO.getDiscountCode = function (callback) { if (WSAIO["debugger"]) {debugger; } WSAIO.fetchCart(function (error, cart) {if (error) { return log(error);}var note_attr = [];var dcreqdata = { note_attributes: note_attr, cart: cart, tags: "wsaio-app", note: $("[name=note]").val(), shopInfo: WSAIO.shopInfo, customer: WSAIO.customer, user_mode: WSAIO.user_mode, currency: WSAIO.shopInfo.currency, custom_line_items: [], discount_code_application: WSAIO.DiscountCode.application, products_with_collections: (WSAIO.product_collections || [])};if ($ws.variant_sku_are_same) { dcreqdata["variant_sku_are_same"] = $ws.variant_sku_are_same;}if ($ws.coupon_expires_after_hours) { dcreqdata["coupon_expires_after_hours"] = $ws.coupon_expires_after_hours;}if ($ws.auto_delete_api) { if (localStorage.getItem("draft_order_info") != null) {try { dcreqdata["prev_draft_order_info"] = JSON.parse(localStorage.getItem("draft_order_info"));} catch (e) { log(e)} } if (localStorage.getItem("price_rule_info") != null) {try { dcreqdata["prev_price_rule_info"] = JSON.parse(localStorage.getItem("price_rule_info"));} catch (e) { log(e)} }}if ($ws.ccr) { dcreqdata["ccr"] = $ws.ccr;}WSAIO.checkoutRequest(dcreqdata, callback); });};WSAIO.preloadCheckout = function () { if (WSAIO.debugger) debugger; if (WSAIO.isWholesaleCustomer() === false) {if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } window.cart_data = WSAIO.cart_object; var cart = WSAIO.cart_object; var preqdata = {cart: cart,shopInfo: $ws.shopInfo,customer: $ws.customer,user_mode: $ws.user_mode,discount_code_application: WSAIO.DiscountCode.application,products_with_collections: (WSAIO.product_collections || []) }; if ($ws.variant_sku_are_same) {preqdata["variant_sku_are_same"] = $ws.variant_sku_are_same; } if(typeof WSAIO.wholesale_app_tags != 'undefined' && WSAIO.wholesale_app_tags.indexOf('all') > -1){ preqdata["fields"] = 'all'; } if ($ws.auto_delete_api) {if (localStorage.getItem("draft_order_info") != null) { try {preqdata["prev_draft_order_info"] = JSON.parse(localStorage.getItem("draft_order_info")); } catch (e) {log(e) }}if (localStorage.getItem("price_rule_info") != null) { try {preqdata["prev_price_rule_info"] = JSON.parse(localStorage.getItem("price_rule_info")); } catch (e) {log(e) }} } $ws.preCheckoutRequest(preqdata, function (error, response) {if (error) { log(error);} else { if (typeof $ws.callback === 'function') {$ws.callback(response); } $ws.discount_response=response; try{ if(typeof WSAIO.pre_response != 'undefined' && typeof WSAIO.pre_response === 'function'){ WSAIO.pre_response(response);} }catch(e){} serverLogging(response);} });};WSAIO.preCheckout = function () {$('.wsaio_coupon_box,.wsaio_coupon_link,.wsaio--Cart_ld__Message,.wsaio_loader_checkout').remove();$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).addClass('wsaio_hideCheckout') $(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector).after('

    ') window.preDiscountData = []; if (WSAIO.debugger) debugger; if (WSAIO.isWholesaleCustomer() === false) {if(typeof WSAIO.run_checkout != 'undefined'){ WSAIO.run_checkout(); }if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } $ws.fetchCart(function (error, cart) {if (error) return isError(error);else {window.cart_data = cart; var preqdata = {cart: cart,shopInfo: $ws.shopInfo,customer: $ws.customer,user_mode: $ws.user_mode,discount_code_application: WSAIO.DiscountCode.application,products_with_collections: (WSAIO.product_collections || []) }; if ($ws.variant_sku_are_same) {preqdata["variant_sku_are_same"] = $ws.variant_sku_are_same; } if(typeof WSAIO.wholesale_app_tags != 'undefined' && WSAIO.wholesale_app_tags.indexOf('all') > -1){ preqdata["fields"] = 'all'; } if ($ws.auto_delete_api) {if (localStorage.getItem("draft_order_info") != null) { try {preqdata["prev_draft_order_info"] = JSON.parse(localStorage.getItem("draft_order_info")); } catch (e) {log(e) }}if (localStorage.getItem("price_rule_info") != null) { try {preqdata["prev_price_rule_info"] = JSON.parse(localStorage.getItem("price_rule_info")); } catch (e) {log(e) }} } $ws.preCheckoutRequest(preqdata, function (error, response) {if (error) {log(error);if(typeof WSAIO.cartQuantityControllers != 'undefined' && typeof WSAIO.checkout_restriction != 'undefined'){ WSAIO.checkout_restriction(); WSAIO.cartQuantityControllers([],function(e){setTimeout(function(){WSAIO.run_checkout()},1000)});}else{WSAIO.run_checkout()} } else { if (typeof $ws.callback === 'function') {$ws.callback(response); } $ws.discount_response=response; $ws.preCheckoutResponse(response); if(typeof WSAIO.cartQuantityControllers != 'undefined' && typeof WSAIO.checkout_restriction != 'undefined'){ WSAIO.checkout_restriction(); WSAIO.cartQuantityControllers([],function(e){setTimeout(function(){WSAIO.run_checkout()},1000)});}else{WSAIO.run_checkout()} serverLogging(response);} });} });}; WSAIO.preCheckoutResponse = function (response) { window.preDiscountData = response; try{ if(typeof WSAIO.pre_response != 'undefined' && typeof WSAIO.pre_response === 'function'){ WSAIO.pre_response(response) } }catch(e){} if (WSAIO.debugger) debugger; if($(".po_field_div").length > 0){ $('.po_field_div').remove(); } try{ if(WSAIO.PO_field_enable){ if(WSAIO.PO_field_selector == ''){ if( $ws.discount_code_field_selector == ''){ WSAIO.PO_field_selector = WSAIO.subtotal_selector.split(':')[0]; }else{ WSAIO.PO_field_selector = $ws.discount_code_field_selector.split(':')[0]; } }$('.Net_PO_field').show(); $(WSAIO.PO_field_selector).before('

    '); } }catch(e){} var i = 0; if (response && response.final_discounted_products) {try { for (i = 0; i < response.final_discounted_products.length; i++) {try { WSAIO.all_discount_tags.push(response.final_discounted_products[i].appRule.applied_included_tag);} catch (e) {} }} catch (e) {} } WSAIO.shipping_message_applied = false; if (response && response.shipping) {$ws.applied_shipping = response.shipping;if ($ws.applied_shipping.apply_shipping_charges) { //check if shipping appliedWSAIO.shipping_message_applied = true; $ws.alterHTML($ws.shipping_message_html.replace('%message%', $ws.applied_shipping.final_ship_rule.message), $ws.shipping_message_selector);} } if (response) { if(typeof WSAIO.discount_response != 'undefined' && typeof WSAIO.discount_response.wholesale_total_discount != 'undefined' && parseFloat(WSAIO.discount_response.wholesale_total_discount) == 0){ WSAIO.exclude_VAT = 0; }$ws.setCartSubtotal(response.original_total_price, response.checkout_price_from_total_price);if (response.line_items) { $ws.setCartItemsPrice(response.line_items,response.checkout_price_from_total_price);}if (Number(response.wholesale_total_discount) > 0) { var total_saving = $ws.cart_bulk_saving_html .replace("%saved_amount%", $ws.formatMoney(response.wholesale_total_discount)); $ws.alterHTML(total_saving, $ws.cart_bulk_saving_selector);} } if (response.original_total_price) {$ws.cart_total = response.original_total_price;$ws.cart_discounted_total = response.checkout_price_from_total_price; } if (response && response.cart_level_discount) {if (Number(response.cart_level_discount.cart_discount_amount) > 0) { var cld_msg = $ws.cart_ld_html .replace(new RegExp("%discount%", "gi"), ($ws.formatMoney(response.cart_level_discount.cart_discount_amount) || "")) .replace(new RegExp("%discount%", "gi"), ""); $('.wsaio--Cart_ld__Message').remove(); if($ws.cart_ld_selector == ''){ $(WSAIO.checkout_message_selector).after(cld_msg); }else{ $ws.alterHTML(cld_msg, $ws.cart_ld_selector); }} }}; WSAIO.redirectToURL = function (url) { if (WSAIO.debugger) debugger; if (url) {window.location.href = url; } else {isError("Redirect URL was not found!"); }}; WSAIO.checkoutRequest = function (data, callback) {try{ /* send presentment_currency if enabled */ if(WSAIO.selectedCurrency() != '' && WSAIO.selectedCurrency() !== 'undefined'){var presentment_currency_rate = 0; if(typeof Shopify.currency !== "undefined" && (WSAIO.selectedCurrency() == Shopify.currency.active)){ presentment_currency_rate = parseFloat(Shopify.currency.rate) || 1; }else{ presentment_currency_rate = parseFloat(window.Currency.rates[WSAIO.shopInfo.currency]/window.Currency.rates[WSAIO.selectedCurrency()]) || 1; } /* Append rate in payload to use in server */data['presentment_currency'] = {code: WSAIO.selectedCurrency(),rate: presentment_currency_rate}; } else{if(typeof Shopify !== "undefined" && typeof Shopify.currency !== "undefined"){var presentment_currency_rate = parseFloat(Shopify.currency.rate) || 1;/* Append rate in payload to use in server */data['presentment_currency'] = {code: Shopify.currency.active,rate: presentment_currency_rate};}}if(typeof Shopify !== "undefined" && typeof Shopify.country !== "undefined"){ /* Append country in payload to use in server */ data['presentment_country'] = Shopify.country; } if(typeof WSAIO.tax_settings !== "undefined" && typeof WSAIO.auto_vat_enable !== "undefined" && WSAIO.auto_vat_enable){ /* Append tax setting in payload to use in server */ data['tax_settings'] = WSAIO.tax_settings; }if((WSAIO.market_selected!= undefined && typeof WSAIO.customer.default_address.country_code != 'undefined' && WSAIO.market_selected != WSAIO.customer.default_address.country_code) && WSAIO.country_currency_code != undefined && typeof WSAIO.Currency.rates[WSAIO.shopInfo.currency] != 'undefined'){var rate = 0;var customer_currency = WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[0];if(customer_currency == WSAIO.shopInfo.currency){data['presentment_currency'] = {code: WSAIO.shopInfo.currency,rate: 1};data['presentment_country'] = WSAIO.customer.default_address.country_code;}else{ if(WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[0] == Shopify.currency.active){ rate = Shopify.currency.rate;} else{ if(WSAIO.shopInfo.currency == 'USD'){ conversion_fee = 1.015; }else{ conversion_fee = 1.02; } rate = ((WSAIO.Currency.rates[WSAIO.shopInfo.currency]/WSAIO.Currency.rates[customer_currency])*conversion_fee) } data['presentment_currency'] = { code: customer_currency, rate: rate }; data['presentment_country'] = WSAIO.customer.default_address.country_code;}}}catch(e){console.log('WSAIO currency rates undefined')} $ws.ajax({type: 'POST',url: $ws.App.checkoutURL + $ws.checkout_version,cache: false,data: data,success: function (result) { log(result); $($ws.checkout_selector).prop('disabled', false); try {if (result && result.price_rule_info) { try {localStorage.setItem("price_rule_info", JSON.stringify(result.price_rule_info)) } catch (e) {log(e) }}if (result && result.draft_order_info) { try {localStorage.setItem("draft_order_info", JSON.stringify(result.draft_order_info)) } catch (e) {log(e) }} } catch (e) {log(e) } if ("function" === typeof callback) {callback(null, result); }},error: function (err) { if ("function" === typeof callback) {callback(err, null); }} });}; WSAIO.preCheckoutRequest = function (data, callback) { try{ /* send presentment_currency if enabled */ if(WSAIO.selectedCurrency() != '' && WSAIO.selectedCurrency() !== 'undefined'){var presentment_currency_rate = 0; if(typeof Shopify.currency !== "undefined" && (WSAIO.selectedCurrency() == Shopify.currency.active)){ presentment_currency_rate = parseFloat(Shopify.currency.rate) || 1; }else{ presentment_currency_rate = parseFloat(window.Currency.rates[WSAIO.shopInfo.currency]/window.Currency.rates[WSAIO.selectedCurrency()]) || 1; } /* Append rate in payload to use in server */data['presentment_currency'] = {code: WSAIO.selectedCurrency(),rate: presentment_currency_rate}; } else{ if(typeof Shopify !== "undefined" && typeof Shopify.currency !== "undefined"){ var presentment_currency_rate = parseFloat(Shopify.currency.rate) || 1; /* Append rate in payload to use in server */ data['presentment_currency'] = { code: Shopify.currency.active, rate: presentment_currency_rate }; } }if(typeof Shopify !== "undefined" && typeof Shopify.country !== "undefined"){ /* Append country in payload to use in server */ data['presentment_country'] = Shopify.country; } if(typeof WSAIO.tax_settings !== "undefined" && typeof WSAIO.auto_vat_enable != 'undefined' && WSAIO.auto_vat_enable){ /* Append tax setting in payload to use in server */ data['tax_settings'] = WSAIO.tax_settings; }if((WSAIO.market_selected!= undefined && typeof WSAIO.customer.default_address.country_code != 'undefined' && WSAIO.market_selected != WSAIO.customer.default_address.country_code) && WSAIO.country_currency_code != undefined && typeof WSAIO.Currency.rates[WSAIO.shopInfo.currency] != 'undefined'){var rate = 0;var customer_currency = WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[0];if(customer_currency == WSAIO.shopInfo.currency){data['presentment_currency'] = {code: WSAIO.shopInfo.currency,rate: 1};data['presentment_country'] = WSAIO.customer.default_address.country_code;}else{ if(WSAIO.country_currency_code[WSAIO.customer.default_address.country_code].split('_')[0] == Shopify.currency.active){ rate = Shopify.currency.rate;} else{ if(WSAIO.shopInfo.currency == 'USD'){ conversion_fee = 1.015; }else{ conversion_fee = 1.02; } rate = ((WSAIO.Currency.rates[WSAIO.shopInfo.currency]/WSAIO.Currency.rates[customer_currency])*conversion_fee) } data['presentment_currency'] = { code: customer_currency, rate: rate }; data['presentment_country'] = WSAIO.customer.default_address.country_code;}} }catch(e){console.log('WSAIO currency rates undefined')} $ws.ajax({type: 'POST',url: $ws.App.checkoutURL + $ws.checkout_version + '/pre',cache: false,data: data,success: function (result) { log(result); if ("function" === typeof callback) {callback(null, result); }},error: function (err) { if ("function" === typeof callback) {callback(err, null); }} });}; WSAIO.checkoutEventListner = function (params) {if(WSAIO.isWholesaleCustomer() === false || (window.ZapietCheckoutEnabled === false && typeof ZapietWidgetConfig != 'undefined' && Object.keys(ZapietWidgetConfig).length != 0)){return "Invalid customer"; } $($ws.checkout_selector+','+WSAIO.duplicate_checkout_selector).removeAttr("disabled"); $(document).on('click', $ws.checkout_selector+','+WSAIO.duplicate_checkout_selector, function (e) {e.preventDefault();e.stopImmediatePropagation();e.stopPropagation();$(this).attr("disabled");$(this).find('[name="discount"], [name="clear_discount"]').remove();// $(this).parents('form').find('[name="discount"], [name="clear_discount"]').remove();log("Wholesale All In One checkout is working.");$ws.checkout(); });}; WSAIO.setCartSubtotal = function (items_subtotal_price, checkout_subtotal) { if (WSAIO.debugger) debugger; if (typeof items_subtotal_price === 'undefined' || typeof checkout_subtotal === 'undefined') {return; } if (Number(items_subtotal_price) < 0 || Number(checkout_subtotal) < 0) {return; } var regular_price = $ws.formatMoney(Number(checkout_subtotal), $ws.shopInfo.money_format); var compare_at_price = ""; if (Number(items_subtotal_price) > Number(checkout_subtotal)) {compare_at_price = $ws.formatMoney(Number(items_subtotal_price), $ws.shopInfo.money_format); } try {compare_at_price = compare_at_price.replace("$", "$@");regular_price = regular_price.replace("$", "$@"); } catch (e) {log(e) } // change currency sign forcely based on market regular_price = WSAIO.change_currency_sign(regular_price); compare_at_price = WSAIO.change_currency_sign(compare_at_price); function show_Additional_Processing_fee(subtotal){var fee = 0;if(WSAIO.general_settings.additionalFee_value_type == 'fixed'){subtotal = subtotal + parseFloat(WSAIO.general_settings.additionalFee_value);fee = WSAIO_formatMoney(parseFloat(WSAIO.general_settings.additionalFee_value));}else{var p = ((parseFloat(WSAIO.general_settings.additionalFee_value)/100)*subtotal).toFixed(2);fee = WSAIO_formatMoney(parseFloat(p));subtotal = subtotal + parseFloat(p);}return subtotal;} try {if (typeof WSAIO.enable_netTerm != 'undefined' && WSAIO.enable_netTerm) {if (WSAIO.NetTerm_version > 1 || $('.net_address_fields').length == 0) {try {var net_regular = $ws.formatMoney(Number(checkout_subtotal));if(WSAIO.general_settings.additionalFee_enabled){var subt = show_Additional_Processing_fee(Number(checkout_subtotal));net_regular = $ws.formatMoney(Number(subt));}} catch (c) {k(c);} if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ net_regular = WSAIO.change_currency_sign(net_regular); } $('.net_prices.net--subtotal').html(''+net_regular+'');if ($('.NetTerm_div .net_cartLevel_div').length == 0 && !jQuery.isEmptyObject(cart_level)) {$('.NetTerm_div .applied_coupon_line').after('

    Additional Discount

    -' + $ws.formatMoney(Number(window.preDiscountData.cart_level_discount.cart_discount_amount) * 100) + '

    ')}if ($('.net_mobile_div .net_cartLevel_div').length == 0 && !jQuery.isEmptyObject(cart_level)) {$('.net_mobile_div .applied_coupon_line').after('

    Additional Discount

    -' + $ws.formatMoney(Number(window.preDiscountData.cart_level_discount.cart_discount_amount) * 100) + '

    ')}} else {try {var net_regulars = $ws.formatMoney(Number(checkout_subtotal) * 100, $ws.shopInfo.money_format);var net_regular = net_regulars.replace(/@/g, ""); var net_value = net_regular; if(WSAIO.general_settings.additionalFee_enabled){var subt = show_Additional_Processing_fee(Number(checkout_subtotal) * 100);net_regular = $ws.formatMoney(Number(subt) * 100, $ws.shopInfo.money_format);net_value = Number(subt);}} catch (c) {console.log(c);} if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ net_regular = WSAIO.change_currency_sign(net_regular); } $('.net_prices.net--subtotal').html(''+net_regular+'')}}} catch (w) { } var html = $ws.cart_subtotal_price_html; if (!$ws.general_settings.compare_at_price) {compare_at_price = ""; html = WSAIO.remove_comparePrice(html); } if(html.indexOf('%compare_at_price%') == -1){ html = '%compare_at_price%' +html ; } if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ regular_price = WSAIO.price_with_unit(regular_price) if(compare_at_price != ""){ compare_at_price = WSAIO.price_with_unit(compare_at_price) } } if(compare_at_price == ''){ html = WSAIO.remove_comparePrice(html); } html = html.replace("%regular_price%", regular_price) .replace("%compare_at_price%", compare_at_price); try {html = html.replace(/@/g, ''); } catch (e) {log(e);} $ws.alterHTML(html, $ws.subtotal_selector); }; WSAIO.setCartItemsPrice = function (line_items,_subtotal) {if (WSAIO.debugger) debugger; $ws.cart_items_each_selector = $ws.cart_items_each_selector+',.net_item';var reg_single_price = 0, com_single_price = 0,reg_total_price = 0, com_total_price = 0, vat_subtotal = 0; var actual_regularPrice = 0; var excluded_actual_regularPrice = 0;for (var itr = 0 ; itr < $ws.cart_items_each_selector.split(',').length; itr++) {shuffle_cart_grid_loop($ws.cart_items_each_selector.split(',')[itr])}function shuffle_cart_grid_loop(_select){ try{ var Sorted_line_items = []; $(_select).each(function(index, item){var _this = $(this);var Vid = _this.find('[href*="variant="]').attr('href')if(typeof Vid != 'undefined'){ Vid = Vid.split('variant=')[1] Vid = parseInt(Vid.split('&')[0]); $(line_items).each(function(_indx){if(line_items[_indx].id == Vid){ line_items[_indx].line = index; if(-1 == Sorted_line_items.findIndex(function(e){return Vid == e.id})){ Sorted_line_items.push(line_items[_indx]) }} })} }); if(Sorted_line_items.length > 0){ line_items=Sorted_line_items}}catch(ee){console.warn(ee)}}var vat_subtotal = 0;var vat_applied = false;$('.vat_div').remove();for(var itr = 0 ; itr < $ws.cart_items_each_selector.split(',').length; itr++){ cart_grid_loop($ws.cart_items_each_selector.split(',')[itr])}function cart_grid_loop(_selector){actual_regularPrice = 0;excluded_actual_regularPrice = 0; $(_selector).each(function(index, item){ if(line_items && line_items.length > 0){ var lineItemIndex = -1; try {lineItemIndex = line_items.findIndex(function(x){ return x.line == index}); } catch (e) {} log("lineItemIndex",lineItemIndex); if(item){if(lineItemIndex > -1){ // wholesale line item, price and discount info var wsLineItem = line_items[lineItemIndex]; //cart line item whoes price gonna changed var cart_item_total_selector = $(item).find($ws.cart_item_total_selector); var cart_item_price_selector = $(item).find($ws.cart_item_price_selector); var cart_item_saved_price_selector = $(item).find($ws.cart_item_saved_price_selector); log("cart_item_total_selector",cart_item_total_selector); log("cart_item_price_selector",cart_item_price_selector); if (typeof wsLineItem.wholesale !== 'undefined') {var wholesale = wsLineItem.wholesale;try { wholesale.item_subtotal_price = wholesale.item_subtotal_price.replace("$", "$@"); wholesale.item_subtotal_compare_at_price = wholesale.item_subtotal_compare_at_price.replace("$", "$@");} catch (e) { log(e)}if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()){var exclude_value = (WSAIO.exclude_VAT/100) + 1;vat_applied = true;reg_total_price = (wholesale.item_subtotal_price / exclude_value);com_total_price = (wholesale.item_subtotal_compare_at_price / exclude_value);vat_subtotal = vat_subtotal+parseFloat(reg_total_price); actual_regularPrice = $ws.formatMoney( Number(wholesale.item_subtotal_price)) excluded_actual_regularPrice = $ws.formatMoney(Number(wholesale.item_subtotal_price / exclude_value))}else{reg_total_price = wholesale.item_subtotal_price;com_total_price = wholesale.item_subtotal_compare_at_price;vat_subtotal = vat_subtotal+parseFloat(wholesale.item_subtotal_price); actual_regularPrice = $ws.formatMoney( Number(wholesale.item_subtotal_price));excluded_actual_regularPrice = 0;} try {if (typeof WSAIO.enable_netTerm != 'undefined' && WSAIO.enable_netTerm) {if (WSAIO.NetTerm_version > 1 || $('.net_address_fields').length == 0) {try {var net_regular = reg_total_price;var net_compare = com_total_price;var net_selector = '.net-item-total-price-' + wsLineItem.key.replace(":", "_");net_regular = $ws.formatMoney(Number(net_regular));net_compare = $ws.formatMoney(Number(net_compare));} catch (c) {k(c);}} else {try {var net_regular = reg_total_price;var net_compare = com_total_price;var net_selector = '.net-item-total-price-' + wsLineItem.key.replace(":", "_");net_regular = $ws.formatMoney(net_regular * 100);net_compare = $ws.formatMoney(net_compare * 100);} catch (c) {console.log(c);}}if (!$ws.general_settings.compare_at_price || net_compare == net_regular) {net_compare = "";} if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){ net_regular = WSAIO.change_currency_sign(net_regular); if(net_compare != ""){ net_compare = WSAIO.change_currency_sign(net_compare); } } $(net_selector).html('

    ' + net_compare + '

    ' + net_regular + '')}} catch (w) { }if (!$ws.general_settings.compare_at_price) {com_total_price = "";}var regular_price = $ws.formatMoney(Number(reg_total_price)); var compare_at_price = $ws.formatMoney(Number(com_total_price));if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){regular_price = WSAIO.change_currency_sign(regular_price);actual_regularPrice = WSAIO.change_currency_sign(actual_regularPrice);excluded_actual_regularPrice = WSAIO.change_currency_sign(excluded_actual_regularPrice); if(compare_at_price != ""){compare_at_price = WSAIO.change_currency_sign(compare_at_price);}regular_price = WSAIO.price_with_unit(regular_price);actual_regularPrice = WSAIO.price_with_unit(actual_regularPrice);excluded_actual_regularPrice = WSAIO.price_with_unit(excluded_actual_regularPrice); if(compare_at_price != ""){compare_at_price = WSAIO.price_with_unit(compare_at_price);}} var total_html = '';if (Number(reg_total_price) < Number(com_total_price)) {if($ws.cart_item_total_price_html.indexOf('%compare_at_price%') == -1){ $ws.cart_item_total_price_html = '%compare_at_price%' +$ws.cart_item_total_price_html ; } total_html = $ws.cart_item_total_price_html; if (!$ws.general_settings.compare_at_price) {total_html = WSAIO.remove_comparePrice(total_html);}total_html = total_html.replace("%regular_price%", regular_price) .replace("%compare_at_price%", compare_at_price); } else { $ws.cart_item_total_price_html = WSAIO.remove_comparePrice($ws.cart_item_total_price_html);total_html = $ws.cart_item_total_price_html.replace("%regular_price%",regular_price).replace("%compare_at_price%", '');} try { total_html = total_html.replace(/@/g, '');} catch (e) { log(e);}try { if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && typeof WSAIO.excludePrice_design != 'undefined' && WSAIO.excludePrice_design == 'without-crossout' && excluded_actual_regularPrice != 0){ if (!$ws.general_settings.compare_at_price) { actual_regularPrice = "" } total_html = '

    '+actual_regularPrice+'

    '+excluded_actual_regularPrice+'(Excl. Tax)

    ' cart_item_total_selector.html(total_html); }else{ cart_item_total_selector.html(total_html); }} catch (e) { isError(e)} try { wholesale.regular_price = wholesale.regular_price.replace("$", "$@"); wholesale.original_price = wholesale.original_price.replace("$", "$@");} catch (e) { log(e)}if (WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer()) {var exclude_value = (WSAIO.exclude_VAT / 100) + 1;reg_single_price = (wholesale.regular_price / exclude_value);com_single_price= (wholesale.original_price / exclude_value);vat_applied = true; actual_regularPrice = $ws.formatMoney(wholesale.regular_price) excluded_actual_regularPrice = $ws.formatMoney(wholesale.regular_price / exclude_value) }else{reg_single_price = wholesale.regular_price;com_single_price= wholesale.original_price; actual_regularPrice = $ws.formatMoney(wholesale.regular_price);excluded_actual_regularPrice = 0;}if (!$ws.general_settings.compare_at_price) {com_single_price = "";}var regular_price = $ws.formatMoney(Number(reg_single_price)); var compare_at_price = $ws.formatMoney(Number(com_single_price));if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){regular_price = WSAIO.change_currency_sign(regular_price);actual_regularPrice = WSAIO.change_currency_sign(actual_regularPrice);excluded_actual_regularPrice = WSAIO.change_currency_sign(excluded_actual_regularPrice);if(compare_at_price != ""){ compare_at_price = WSAIO.change_currency_sign(compare_at_price);}regular_price = WSAIO.price_with_unit(regular_price);actual_regularPrice = WSAIO.price_with_unit(actual_regularPrice);excluded_actual_regularPrice = WSAIO.price_with_unit(excluded_actual_regularPrice);if(compare_at_price != ""){compare_at_price = WSAIO.price_with_unit(compare_at_price);}} var single_price_html = '';if (Number(reg_single_price) < Number(com_single_price)) {if($ws.cart_item_price_html.indexOf('%compare_at_price%') == -1){ $ws.cart_item_price_html = '%compare_at_price%' +$ws.cart_item_price_html ; }single_price_html = $ws.cart_item_price_html;if (!$ws.general_settings.compare_at_price) {single_price_html = WSAIO.remove_comparePrice(single_price_html);}single_price_html = single_price_html.replace("%regular_price%", regular_price).replace("%compare_at_price%", compare_at_price);} else { $ws.cart_item_price_html = WSAIO.remove_comparePrice($ws.cart_item_price_html);single_price_html = $ws.cart_item_price_html.replace("%regular_price%", regular_price).replace("%compare_at_price%", '');} try { single_price_html = single_price_html.replace(/@/g, '');} catch (e) { log(e);}try { if(WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && typeof WSAIO.excludePrice_design != 'undefined' && WSAIO.excludePrice_design == 'without-crossout' && excluded_actual_regularPrice != 0){ if (!$ws.general_settings.compare_at_price) { actual_regularPrice = "" } single_price_html = '

    '+actual_regularPrice+'

    '+excluded_actual_regularPrice+'(Excl. Tax)

    ' cart_item_price_selector.html(single_price_html); }else{ cart_item_price_selector.html(single_price_html); }} catch (e) { isError(e)}var html = $ws.cart_item_saved_price_html.toString();var total_saved = { price: "", percentage: ""};if (wholesale && wholesale.saved_amount && wholesale.saved_amount.percentage) { total_saved.percentage = wholesale.saved_amount.percentage;}if (wholesale && wholesale.saved_amount && wholesale.saved_amount.price) { total_saved.price = wholesale.saved_amount.price;}html = html.replace(new RegExp("%saved_amount:price%", "gi"), $ws.formatMoney(total_saved.price)).replace(new RegExp("%saved_amount:percentage%", "gi"), total_saved.percentage);try { cart_item_saved_price_selector.html(html);} catch (e) { isError(e)} } }else{ log("Line item index not found. cart line number",index, "and cart item",item);} } else{isError("Item not found"); }}else{ isError("Critical Error. Precheckout line items are empty");}}).promise().done(function () {if (WSAIO.exclude_VAT != 0 && WSAIO.check_eligible_customer() && vat_applied) {if ($('.vat_div').length == 0 && $('.net_address_fields').length == 0) {if(WSAIO.customer.tax_exempt && WSAIO.auto_vat_enable){$(WSAIO.subtotal_selector.replace(':same','')).html('Subtotal(Excl. Tax) ' + WSAIO.formatMoney(vat_subtotal) + '');}else{$(WSAIO.VAT_subtotal_selector).before('

    Excluded Total ' + WSAIO.formatMoney(vat_subtotal) + '

    VAT ' + WSAIO.formatMoney((_subtotal - vat_subtotal)) + '

    ')}}else if($('.net_address_fields').length == 0 && WSAIO.NetTerm_version > 1){var netTerm_subtotal = WSAIO.formatMoney(vat_subtotal);if(typeof WSAIO.show_currenyLabel_withPrice != 'undefined' && WSAIO.show_currenyLabel_withPrice && typeof Shopify.currency != 'undefined' && Shopify.currency.active != 'undefined' && WSAIO.formatMoney('0').indexOf(Shopify.currency.active) == -1){netTerm_subtotal = WSAIO.change_currency_sign(netTerm_subtotal);netTerm_subtotal = WSAIO.price_with_unit(netTerm_subtotal);}$('.net_prices.net--subtotal').text(netTerm_subtotal);$('.net--vat_deduct').text(WSAIO.formatMoney((_subtotal - vat_subtotal)))$('.applied_vat_line').show();}}})}}; WSAIO.productDiscount = function (params, callback) { if (WSAIO.debugger) debugger; if (WSAIO.isWholesaleCustomer() === false) {if (typeof callback === "function") { return callback({error: "Invalid customer" });} else { return "Invalid customer";} } if (typeof params === 'undefined') {return isError("This action required some parameters."); } if (typeof params.product_id === 'undefined') {params.product_id = "default"; } if (typeof params.product_handle === 'undefined') {params.product_handle = "default"; } if (typeof params.variant_id === 'undefined') {params.variant_id = "default"; } if (typeof params.variant_sku === 'undefined') {params.variant_sku = "default"; } if (typeof params.variant_price === 'undefined') {params.variant_price = "default"; } if (typeof params.variant_compare_at_price === 'undefined') {params.variant_compare_at_price = "default"; } if (typeof params.collection_id === 'undefined') {params.collection_id = "default"; } if (typeof params.product_parent_grid_selector === 'undefined') {params.product_parent_grid_selector = "default"; } if (typeof params.remove_duplicate_table === 'undefined') {params.remove_duplicate_table = "default"; } if (typeof params.template === 'undefined') {params.template = "default"; } if(typeof params.template != 'undefined' && params.template === "product" ){ WSAIO.buyNowEventListener() } WSAIO.regularDiscount(params, function (regular_discount_response) {if (params.template === "product" || $ws.landingTemplate === "product" || (window.location.href.indexOf('/pages/') > -1 && $ws.landingTemplate === "collection") || params.apply_volume_discount === true) { WSAIO.volumeDiscount(params, function (volume_discount_response) {if (typeof callback === "function") { callback({regular_discount: regular_discount_response,volume_discount: volume_discount_response });} });} else if ($ws.volume_discount_on_hcsr) { WSAIO.volumeDiscount(params, function (volume_discount_response) {if (typeof callback === "function") { callback({regular_discount: regular_discount_response,volume_discount: volume_discount_response });} });} else { if (typeof callback === "function") {callback({ regular_discount: regular_discount_response, volume_discount: "Not executed"}); }} });}; WSAIO.variantChange = function (product, variant) { if (WSAIO.debugger) debugger; if (WSAIO.isWholesaleCustomer() === false) {return "Invalid customer"; } $ws.productDiscount({item_price_selector: $ws.product_price_selector,template: 'product',product_id: product.id,product_handle: product.handle,variant_id: variant.id,variant_sku: variant.sku,variant_price: variant.price,variant_compare_at_price: variant.compare_at_price }, function (response) {log("vc response",response);setTimeout(function(){ if(typeof current_product != 'undefined' && current_product != null){WSAIO.Volume_disocunted_price($('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.current_product_qty_input_selector).val()) }},10);if(response && response.regular_discount && Number(response.regular_discount.ws_discount) > 0){ log("ws discount applied on this item");}else{ log("Set original price"); $ws.variantOriginalPrice();} });}; WSAIO.selectedCurrency = function (el) { return $(el || $ws.currency_selector).val() ||'';}; WSAIO.Currency.convert = function (amount, from, to) {var rates = $ws.Currency.rates;try { if(typeof Shopify !== "undefined" && typeof Shopify.currency !== "undefined"){ return amount*Shopify.currency.rate; }else{ return (amount * rates[from]) / rates[to]; }} catch (e) { return e;} }; WSAIO.getProduct = function (handle, callback) { $.getJSON(WSAIO.local_param + 'products/' + handle + '.js', function (product) {if (typeof callback === "function") { callback(product);} }); return "Use callback function to get product";}; WSAIO.buy_it_now = function () { $($ws.buy_now_button_selector).on("click",function (event) {event.preventDefault();event.stopImmediatePropagation();$(this).prop("disabled", !0);var c = $(this).parents("form");var product_handle = c.parents(WSAIO.product_parent_grid_selector).find('[name="id"]').attr("data-handle") || current_product.handle,variant_id = c.parents(WSAIO.product_parent_grid_selector).find('[name="id"]').val(),product_quantity = c.parents(WSAIO.product_parent_grid_selector).find('[name="quantity"]').val();var variant_inventory_info = {};var inventory_issue = false;var available_qty = 0;if(typeof WSAIO.default_product_variant != 'undefined' && WSAIO.default_product_variant.length > 0){variant_inventory_info = WSAIO.default_product_variant.find(function(e,r){return e.variant_id == variant_id})}if(variant_inventory_info != undefined && Object.keys(variant_inventory_info).length){if(variant_inventory_info.variant_inventory_management != undefined && variant_inventory_info.variant_inventory_management != ''){if(variant_inventory_info.variant_inventory_policy == 'deny'){if(parseInt(product_quantity) > parseInt(variant_inventory_info.variant_inventory_quantity)){ inventory_issue = true; available_qty = variant_inventory_info.variant_inventory_quantity;}}}}if(inventory_issue){$(this).prop("disabled", false);if( $('.waioBUY_inventory_error').length == 0 ){$('.waioBUY_inventory_error').remove(); $(WSAIO.shopify_payment_button_wrapper).after('

    Only '+available_qty+' item(s) are available. Please update the quantity and try again.

    ');}setTimeout(function(){$('.waioBUY_inventory_error').remove();},4000)return false;}void 0 === product_quantity && (product_quantity = 1); $ws.getProduct(product_handle, function (pr) { $ws.buy_now_product = pr; proccedToBuyItNow();}); function proccedToBuyItNow() { sessionStorage.setItem('isCheckoutvisited', 'true'); if (typeof $ws.buy_now_product !== 'undefined' && $ws.buy_now_product !== null) {var product = $ws.buy_now_product;if (product) { var selected_variant_index = product.variants.findIndex(function (a) {return a.id == variant_id }), variant = {}; if (-1 < selected_variant_index) {variant = product.variants[selected_variant_index]; } try{ WSAIO.productDiscount({template:'product',item_price_selector: $('.demo'),product_id: WSAIO.buy_now_product.id,product_handle: WSAIO.buy_now_product.handle,variant_id: WSAIO.buy_now_product.variants[selected_variant_index].id,variant_sku: WSAIO.buy_now_product.variants[selected_variant_index].sku,variant_price: WSAIO.buy_now_product.variants[selected_variant_index].price,variant_compare_at_price: WSAIO.buy_now_product.variants[selected_variant_index].compare_at_price },function(ee){var volume_applied = ee.volume_discount.quantity_breaks.length;WSAIO.volume_values = [];if(volume_applied > 0){ WSAIO.volume_values = ee.volume_discount.quantity_breaks;}if(parseFloat(ee.regular_discount.ws_discount) > 0){ WSAIO.current_product_discountPrice = Number(variant.price)-parseFloat(ee.regular_discount.ws_discount)*100 WSAIO.regular_price = Number(variant.price);}else{ WSAIO.current_product_discountPrice = Number(variant.price); WSAIO.regular_price = Number(variant.price);} });}catch(e){} if(WSAIO.current_product_discountPrice == undefined){ WSAIO.current_product_discountPrice = Number(variant.price); } if (variant.available) {var line_price = Number(variant.price) * Number(product_quantity),cart = { attributes: {}, cart_level_discount_applications: [], currency: $ws.Currency.selectedCurrency || $ws.shopInfo.currency, item_count: product_quantity, items: [{discounted_price: variant.price,discounts: [],featured_image: product.featured_image,final_line_price: line_price,final_price: variant.price,gift_card: !1,grams: variant.weight,handle: product.handle,id: variant.id,image: product.featured_image,key: "11309472350255:a5c7b76a76a9b8da2aa5dceab2c6b7ab",line_level_discount_allocations: [],line_price: line_price,options_with_values: [],original_line_price: line_price,original_price: variant.price,price: variant.price,product_description: "",product_has_only_default_variant: !1,product_id: product.id,product_title: product.title,product_type: product.type,properties: null,quantity: product_quantity,requires_shipping: variant.requires_shipping,sku: variant.sku,taxable: variant.taxable,title: product.title + " - " + variant.title,total_discount: 0,url: WSAIO.local_param + "products/" + product_handle + "?variant=" + variant.id,variant_id: variant.id,variant_options: variant.options,variant_title: variant.title,vendor: product.vendor }], items_subtotal_price: line_price, note: null, original_total_price: line_price, requires_shipping: variant.requires_shipping, token: "3cbccfbccb5ed48c66e4ced34048082d", total_discount: 0, total_price: line_price, total_weight: Number(variant.weight) * Number(product_quantity)};var bnreqdata = { cart: cart, note: "", note_attributes: [], billing_address: {}, shipping_address: {}, shopInfo: $ws.shopInfo, customer: $ws.customer, user_mode: $ws.user_mode, currency: $ws.shopInfo.currency, custom_line_items: [], discount_code_application: WSAIO.DiscountCode.application, products_with_collections: (WSAIO.product_collections || [])};if(typeof WSAIO.wholesale_app_tags == 'undefined' || (typeof WSAIO.wholesale_app_tags != 'undefined' && WSAIO.wholesale_app_tags.indexOf('app') > -1) ){ bnreqdata["tags"] = "wsaio-app,checkout-via-buy-now-button"; }else{ bnreqdata["tags"] = "checkout-via-buy-now-button"; }if ($ws.variant_sku_are_same) { bnreqdata["variant_sku_are_same"] = $ws.variant_sku_are_same;}if ($ws.coupon_expires_after_hours) { bnreqdata["coupon_expires_after_hours"] = $ws.coupon_expires_after_hours;}if ($ws.auto_delete_api) { if (localStorage.getItem("draft_order_info") != null) {try { bnreqdata["prev_draft_order_info"] = JSON.parse(localStorage.getItem("draft_order_info"));} catch (e) { log(e)} } if (localStorage.getItem("price_rule_info") != null) {try { bnreqdata["prev_price_rule_info"] = JSON.parse(localStorage.getItem("price_rule_info"));} catch (e) { log(e)} }}if(typeof MOQ_applied != 'undefined' && MOQ_applied.length > 0){ if((Number(product_quantity)%MOQ_applied[0]._qtyInc) == 0 && Number(product_quantity) >= MOQ_applied[0]._qtyMin){if(MOQ_applied[0]._qtyMax != 0 && Number(product_quantity) <= MOQ_applied[0]._qtyMax){ $(WSAIO.buy_now_button_selector).removeClass('checkout-disabled').removeAttr('disabled') WSAIO.disable_buy_now_button_moq = false;}else{ $(WSAIO.buy_now_button_selector).removeClass('checkout-disabled').removeAttr('disabled') WSAIO.disable_buy_now_button_moq = false; } }else{if(WSAIO.buyNow_message != '' ){$('.waioMOQ_buy_message').remove(); $(WSAIO.shopify_payment_button_wrapper).after('

    Minimum Requirements not fulfilled

    ');}$(WSAIO.buy_now_button_selector).addClass('checkout-disabled').attr('disabled','disabled')WSAIO.disable_buy_now_button_moq = true; setTimeout(function(){ $(WSAIO.buy_now_button_selector).removeClass('checkout-disabled').removeAttr('disabled') $('.waio_buy_message, .waioMOQ_buy_message').remove();},2500); }}setTimeout(function(){$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').css('cssText','display:inline-block !important')},10)WSAIO.BuyNoworderControl(WSAIO.current_product_discountPrice,Number(product_quantity),$ws.buy_now_button_selector,WSAIO.volume_values,WSAIO.regular_price,variant.id);if (WSAIO.disable_buy_now_button || WSAIO.disable_buy_now_button_moq) {if(WSAIO.disable_buy_now_button && !WSAIO.disable_buy_now_button_moq && (typeof WSAIO.allow_normal_checkout__OC != 'undefined' && WSAIO.allow_normal_checkout__OC)){ return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity); }else{ return false; }}if ($ws.ccr) { bnreqdata["ccr"] = $ws.ccr;}$ws.checkoutRequest(bnreqdata, function (error, response) {if(typeof response.wholesale_errors != 'undefined' && response.wholesale_errors.length > 0){for(var error_key = 0; error_key < response.wholesale_errors.length; error_key++){if(response.wholesale_errors[error_key].key == 'email'){if($('.wsaioserver_error1').length == 0){$(WSAIO.shopify_payment_button_wrapper).after('

    Email contains an invalid domain name. Retry to place an order without a discount.

    ');$(WSAIO.buy_now_button_selector).removeClass('checkout-disabled').removeAttr('disabled');return false;}else{return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity);}}} } if (error) {log(error);return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity); } else {if (response && response.checkout_url && (response.checkout_url.indexOf("invoices") > -1)) { try{if(Shopify.routes.root.replaceAll('/','') != '' && typeof response.discount_code == 'undefined'){ response.checkout_url = response.checkout_url+'?locale='+Shopify.routes.root.replaceAll('/','');} }catch(er){console.warn('er')} return $ws.redirectToURL(response.checkout_url);} else if (response && $ws.general_settings && ($ws.general_settings.discount_method == "coupon_code" && response.discount_code)) { if(Shopify.routes.root.replaceAll('/','') != '' && typeof response.discount_code != 'undefined'){return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity + '?locale='+Shopify.routes.root.replaceAll('/','')+'&discount=' + response.discount_code); }else{return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity + '?discount=' + response.discount_code); }} else { if(Shopify.routes.root.replaceAll('/','') != ''){return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity+ '?locale='+Shopify.routes.root.replaceAll('/','')); }else{return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity); }} }}); } else {isError("Variant is not available or missing variant");if(Shopify.routes.root.replaceAll('/','') != ''){ return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity+ '?locale='+Shopify.routes.root.replaceAll('/',''));}else{ return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity);} }} else { isError("Product object is missing"); if(Shopify.routes.root.replaceAll('/','') != ''){return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity+ '?locale='+Shopify.routes.root.replaceAll('/','')); }else{return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity); }} } else {if(Shopify.routes.root.replaceAll('/','') != ''){ return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity+ '?locale='+Shopify.routes.root.replaceAll('/',''));}else{ return $ws.redirectToURL(WSAIO.local_param + 'cart/' + variant_id + ':' + product_quantity);} }} });}; WSAIO.orderControl = function (min_price, el, message, disable_checkout_btn) { "undefined" === typeof window.waioMOC && (window.waioMOC = {}); "undefined" === typeof waioMOC.cart && (waioMOC.cart = {}); if (typeof min_price !== "undefined" && min_price != null && !isNaN(min_price)) {try { waioMOC.cart["original_total_price"] = min_price;} catch (e) { isError(e);} } else {isError("min price was not provided for buy now product"); } if ("undefined" !== typeof min_price && null != min_price && !isNaN(min_price)) {try { waioMOC.cart.original_total_price = min_price;} catch (e) { isError(e);} }; if(typeof WSAIO.disableCheckout === "function"){WSAIO.disableCheckout(disable_checkout_btn, message, el); } if(typeof WSAIO.order_control === "function"){WSAIO.order_control(); } return WSAIO.disable_checkout;}; WSAIO.DiscountCode.subscribe = function () { $('.wsaio_coupon_field input').on('input',function(){var $this = $(this);$this.code = $this.val();if ($this.code && $this.code.trim() != "") { $this.parents('.wsaio_coupon_group').find("button").removeClass("ws-disabled"); $this.parents('.wsaio_coupon_group').find("button").removeAttr("disabled");}else{ $this.parents('.wsaio_coupon_group').find("button").addClass("ws-disabled"); $this.parents('.wsaio_coupon_group').find("button").attr("disabled","disabled");} }); $(document).on('click','.wsaio_coupon_button',function(e){var $this = $(this);e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation();$this.input = $this.parents('.wsaio_coupon_group').find(".wsaio_coupon_field input");$this.code = $($this.input).val();if ($this.code && $this.code.trim() != "") { $($this.input).removeClass("wsaio_error"); WSAIO.DiscountCode.apply($this.code);}else{ $($this.input).addClass("wsaio_error"); $($this.input).focus();} })}; WSAIO.DiscountCode.apply = function (_code) { if (WSAIO.debugger) debugger; $discount = this; $discount.code = _code; $('.wsaio_coupon_box').addClass('wsaio_loading') $ws.fetchCart(function (error, cart) {$('.wsaio_coupon_box').removeClass('wsaio_success').removeClass('wsaio_error');try { WSAIO.cart_object = cart;} catch (e) {}if (error) { return isError(error);} else { var post_data = {cart: cart,shopInfo: $ws.shopInfo,customer: $ws.customer,coupon_code: _code,products_with_collections: (WSAIO.product_collections || []) }; $ws.ajax({type: "POST",url: $ws.App.checkoutURL + '/discount-code',data: post_data,dataType: "json",success: function (result) { $('.wsaio_coupon_box').removeClass('wsaio_loading') log(result); try {delete result.log; } catch (e) {log(e) } if (typeof $ws.callback === 'function') {$ws.callback(result); } if (result && result.status === 1) {if (typeof result.wholesale_key !== 'undefined') { $discount.application = result; try{$('[href$="/pages/net-term-order"]').attr('href','/pages/net-term-order?coupon='+_code) } catch (e) { log(e) } var wsac = {code: _code,shop: $ws.shopInfo.shop, }; if ($ws.customer.id) {wsac["customer_id"] = $ws.customer.id; } localStorage.setItem("ws-applied-coupon", JSON.stringify(wsac));} else { $discount.application = undefined;}$('.wsaio_coupon_box').addClass('wsaio_success'); } else {localStorage.removeItem("ws-applied-coupon");if((result && result.status === 0 && result.message == 'Not found') || (WSAIO.customer.id != null)){ $('.wsaio_error_msg').text('Enter a valid discount code'); $('.wsaio_coupon_box').addClass('wsaio_error'); }else{ $('.wsaio_error_msg').html('Login to apply discount code'); $('.wsaio_coupon_box').addClass('wsaio_error'); } }} });} });}; WSAIO.signUpForm = function () { if (WSAIO.debugger) debugger; if (typeof $ws.signup_form !== 'undefined') {try { 0 < $($ws.signup_form_selector).length ? ($($ws.signup_form_selector).html($ws.signup_form.form_html)) : log("Sign Up form selector not found");} catch (e) { isError(e)} } else {log("We could not found Signup Form. Save signup form in the wholesale applicatipn dashboard and then refresh this page") }}; WSAIO.removeAllEvents = function (el) { try {for (var i = 0; i < document.querySelectorAll(el).length; i++) { var a = document.querySelectorAll(el)[i]; a.parentNode.replaceChild(a.cloneNode(true), a);} } catch (e) {log(e) }}; WSAIO.registerEvent = function (el, type, callback) { try {for (var i = 0; i < document.querySelectorAll(el).length; i++) { var a = document.querySelectorAll(el)[i]; a.addEventListener(type, callback);} } catch (e) {log(e) }}; WSAIO.buyNowEventListener = function () {if (WSAIO.isWholesaleCustomer() === false && waioMOC.rules.length === 0) {return "Invalid customer"; } $ws.addBuyNowBtnHTML();}; WSAIO.addBuyNowBtnHTML = function () {var selected_variant_availablity = true; if(typeof current_product != 'undefined' && current_product != null){ current_product.variants.find(function(e){ if(jQ('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('[name="id"]').val() == e.id){ selected_variant_availablity = e.available; } }); } var is_replace = false; if(WSAIO.buy_now_btn_replace){ is_replace = true; } if((WSAIO.subscription_variant_selector != '' || WSAIO.subscription_variant_selector != 'false') && WSAIO.buy_now_btn_replace){if($(WSAIO.subscription_variant_selector).is(':checked')){ is_replace = false;}else{ is_replace = true;} } if(!selected_variant_availablity){is_replace = false} var is_append = setInterval(function(){if(typeof current_product != 'undefined' && current_product != null){if(WSAIO.isWholesaleCustomer() === false){ $(WSAIO.product_price_selector).addClass('wsaio_'+current_product.id)}if( is_replace == false){$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').remove()} if($('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find(WSAIO.buy_now_button_selector).length > 0){$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).hide()if($('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').length == 0 && is_replace){$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find(WSAIO.buy_now_button_selector).addClass('wsaio_hide_btn').css('cssText','display:none !important') $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find('.shopify-payment-button__more-options').addClass('wsaio_hide_btn').css('cssText','display:none !important') $(WSAIO.shopify_payment_button_wrapper).append(WSAIO.buy_now_button_html);$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').css('cssText','display:inline-block !important') }else{if((WSAIO.buy_now_btn_replace == false || is_replace == false) && selected_variant_availablity){$(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').remove(); $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find(WSAIO.buy_now_button_selector).removeClass('wsaio_hide_btn') $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find('.shopify-payment-button__more-options').removeClass('wsaio_hide_btn') $('.shopify-payment-button .shopify-payment-button__button').css('cssText','display:inline-block !important') }}$ws.buy_it_now();if(typeof WSAIO.showBuy != 'undefined'){WSAIO.showBuy()}if($('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('.wsaio_buynow').length != 0){$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find('button').siblings('div').find(WSAIO.buy_now_button_selector).addClass('wsaio_hide_btn').css('cssText','display:none !important')$('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).find('button').siblings('div').find(WSAIO.buy_now_button_selector).siblings('button').addClass('wsaio_hide_btn').css('cssText','display:none !important')}clearInterval(is_append) }}else{ clearInterval(is_append)} },100) }; $(document).ready(function(){ setTimeout(function(){WSAIO.buyNowEventListener();var selected_variant_availablity = true;if(typeof current_product != 'undefined' && current_product != null){ current_product.variants.find(function(e){ if(jQ('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find('[name="id"]').val() == e.id){ selected_variant_availablity = e.available; } }); } if(selected_variant_availablity){ setTimeout(function(){ try{ $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).show() }catch(e){} WSAIO.showBuyevent = function(){ WSAIO.showBuy = function(){ $('.wsaio_'+current_product.id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.shopify_payment_button_wrapper).show() } } if(typeof WSAIO.showBuyevent != 'undefined'){WSAIO.showBuyevent()} },500)} },100) }) WSAIO.DiscountCode.add = function () {if (true === WSAIO.general_settings.enable_additional_coupon_code) { $ws.DiscountCode.addForm(); $ws.DiscountCode.subscribe(); // subscribe on click event} }; WSAIO.cartDrawer = function (time) {$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).addClass('wsaio_hideCheckout')$(WSAIO.checkout_selector+','+WSAIO.duplicate_checkout_selector+','+WSAIO.netTerm_checkout_selector).addClass('checkout-disabled').attr('disabled','disabled')setTimeout(function(){ $ws.checkoutEventListner(); // Subscribe checkout button on click event $ws.preCheckout(); // Get wholesale price from server on window load},time) }; $(document).on('click','a[href*="quantity=0"]',function(){WSAIO.cartDrawer(1500) }) if ('undefined' === typeof WSAIO.Currency.rates) {WSAIO.Currency.rates = {}; } if ('undefined' === typeof WSAIO.Currency.selectedCurrency) {WSAIO.Currency.selectedCurrency = $ws.selectedCurrency(); } WSAIO.Currency.storeCurrency = $ws.shopInfo.currency; if ("undefined" !== typeof window.Currency) {WSAIO.Currency.rates = window.Currency.rates; } WSAIO.estTime = function () {var tN = new Date();tN.setTime(tN.getTime() + tN.getTimezoneOffset() * 60 * 1000);var offset = -300,estDate = new Date(tN.getTime() + offset * 60 * 1000);return estDate.getTime(); }; WSAIO.getSchedule = function (schedule) {function est_time_now() { var tN = new Date(); tN.setTime(tN.getTime() + tN.getTimezoneOffset() * 60 * 1000); var offset = -300, estDate = new Date(tN.getTime() + offset * 60 * 1000); return estDate.getTime();} function getTimezoneOffset() { function z(n) {return (n < 10 ? '0' : '') + n } var offset = new Date().getTimezoneOffset(); var sign = offset < 0 ? '+' : '-'; offset = Math.abs(offset); return sign + z(offset / 60 | 0) + z(offset % 60);} function date_time_value(date, time) { // Parsing date to YYYY/MM/DD HH:MM:SS from YYYY-MM-DD HH:MM:SSvar prevDate = date; if(typeof date === "string")date = date.replace(/-/g, "/"); var dateTimeValue = new Date(date); if(dateTimeValue == 'Invalid Date'){dateTimeValue = new Date(prevDate); } if (typeof dateTimeValue === 'object') {try { dateTimeValue = dateTimeValue.toString(); if (typeof dateTimeValue === 'string') {dateTimeValue = dateTimeValue.replace(getTimezoneOffset(), '+0000'); }} catch (e) { log(e);} } try {dateTimeValue = new Date(dateTimeValue).toISOString(); } catch (e) {log(e); } try {dateTimeValue = dateTimeValue.split('T')[0] + " " + time; } catch (e) {log(e); } return dateTimeValue;} function diff_in_schedule(date1, date2) { // Parsing date to YYYY/MM/DD HH:MM:SS from YYYY-MM-DD HH:MM:SS if(typeof date1 === "string")date1 = date1.replace(/-/g, "/"); if(typeof date2 === "string")date2 = date2.replace(/-/g, "/"); date1 = new Date(date1); date2 = new Date(date2); if (date1 === 'Invalid Date' || date2 === 'Invalid Date') {return 0; } if (!date1 || !date2) return 0; if (typeof date1 !== 'object' || typeof date2 !== 'object') {return 0; } if (date1 > date2) {var result = diff_in_schedule(date2, date1);result.years = -result.years;result.months = -result.months;result.days = -result.days;result.hours = -result.hours;result.minutes = -result.minutes;result.seconds = -result.seconds;return result; } result = {years: date2.getYear() - date1.getYear(),months: date2.getMonth() - date1.getMonth(),days: date2.getDate() - date1.getDate(),hours: date2.getHours() - date1.getHours(),minutes: date2.getMinutes() - date1.getMinutes(),seconds: date2.getSeconds() - date1.getSeconds() }; if (result.seconds < 0) {result.minutes--;result.seconds += 60; } if (result.minutes < 0) {result.hours--;result.minutes += 60; } if (result.hours < 0) {result.days--;result.hours += 24; } if (result.days < 0) {result.months--;var copy1 = new Date(date1.getTime());copy1.setDate(32);result.days = 32 - date1.getDate() - copy1.getDate() + date2.getDate(); } if (result.months < 0) {result.years--;result.months += 12; } return result;}var end_schedule_difference = { "years": 1, "months": 1, "days": 1, "hours": 1, "minutes": 1, "seconds": 1},start_schedule_difference = { "years": -1, "months": -1, "days": -1, "hours": -1, "minutes": -1, "seconds": -1},_est = est_time_now();if (schedule) { if (schedule.start_date && schedule.start_time_est) {var schedule_started = date_time_value(schedule.start_date, schedule.start_time_est);start_schedule_difference = diff_in_schedule(_est, schedule_started);log("start_schedule_difference", start_schedule_difference); } if (schedule.end_date && schedule.end_time_est) {var schedule_started = date_time_value(schedule.end_date, schedule.end_time_est);end_schedule_difference = diff_in_schedule(_est, schedule_started);log("end_schedule_difference", end_schedule_difference); }}return { ends_in: end_schedule_difference, started: start_schedule_difference, est_time_now: _est} }; WSAIO.saleClock = function (rule, product, mod) { //module -> rd OR vdif (rule && rule.schedule_active && rule.schedule) { var _sch = $ws.getSchedule(rule.schedule), _show_clock = false; if (_sch.ends_in) {if ( Number(_sch.ends_in.years) > 0 || Number(_sch.ends_in.months) > 0 || Number(_sch.ends_in.days) > 0 || Number(_sch.ends_in.hours) > 0 || Number(_sch.ends_in.minutes) > 0 || Number(_sch.ends_in.seconds) > 0) { _show_clock = true;} } if (_show_clock && _sch.ends_in) {try { _show_clock = $ws.general_settings.sale_clock.show_sale_clock || false;} catch (e) {}if (_show_clock) { $ws.runClock(rule.schedule, product.id, mod);} else { $ws.removeClock(product.id);} } else {$ws.removeClock(product.id);log("Sale clock was disabled"); }} else { log("No schedule found");} }; WSAIO.removeClock = function (id) {$('.wsaio_sale_'+id).remove(); }; WSAIO.runClock = function (schedule, id, mod) {var _type = 1;try { _type = $ws.general_settings.sale_clock.sale_clock_type;} catch (e) { log(e);} function _runClock() { var _ends = $ws.getSchedule(schedule); if (_ends.ends_in) {if ( Number(_ends.ends_in.years) > 0 || Number(_ends.ends_in.months) > 0 || Number(_ends.ends_in.days) > 0 || Number(_ends.ends_in.hours) > 0 || Number(_ends.ends_in.minutes) > 0 || Number(_ends.ends_in.seconds) > 0) { function getStyledClock(msg) {var sty = $ws.general_settings.sale_clock.style,__css = '';if (sty.font_size) { __css += 'font-size:' + sty.font_size + 'px;';}if (sty.border_radius) { __css += 'border-radius:' + sty.border_radius + 'px;';}if (sty.hex_bg_color) { __css += 'background-color:' + sty.hex_bg_color + ';';}if (sty.hex_fg_color) { __css += 'color:' + sty.hex_fg_color + ';';}if (sty.padding) { __css += 'padding:' + sty.padding + ';';}if (sty.text_align) { __css += 'text-align:' + sty.text_align + ';';}return '

    ' + msg + '

    ' } var _msg = $ws.getClockTextByType(_ends.ends_in, schedule, _type), show_time = ""; try {show_time = $ws.general_settings.sale_clock.sale_clock_text1 + " " + _msg + " " + $ws.general_settings.sale_clock.sale_clock_text2; } catch (e) {log(e); } if (show_time == "") {show_time = _msg; } $ws.removeClock(id); if(WSAIO.product_saleClock_selector == ''){ WSAIO.product_saleClock_selector = WSAIO.product_inner_qb_table_selector; } $('.wsaio_'+id).parents(WSAIO.product_parent_grid_selector).find(WSAIO.product_saleClock_selector).after('

    '+getStyledClock(show_time)+'

    ') } else { $ws.removeClock(id);} } else {$ws.removeClock(id); }}if (_type == 1 || _type == 8 || _type == 9) {setInterval(function() { _runClock();}, 1000); } else {_runClock(); } }; WSAIO.getClockTextByType = function (ends_in, schedule, type) {function get_date_time_value(date, time) { // Parsing date to YYYY/MM/DD HH:MM:SS from YYYY-MM-DD HH:MM:SS if(typeof date === "string")date = date.replace(/-/g, "/"); var d = new Date(date), year = d.getFullYear(), month = d.getMonth() + 1, dat = d.getDate(); return year + "-" + month + "-" + dat + " " + time;}var ends_message = '';try { switch (type) {case "1": if (ends_in.days > 0) {ends_message += ends_in.days + (ends_in.days == 1 ? 'day, ' : 'days, '); } if (ends_in.hours > 0) {ends_message += ends_in.hours + (ends_in.hours == 1 ? 'hour, ' : 'hours, '); } if (ends_in.minutes > 0) {var minutes = ends_in.minutes;if (minutes < 10) { minutes = '0' + minutes;}ends_message += minutes + (ends_in.minutes == 1 ? 'minute, ' : 'minutes, '); } if (ends_in.seconds >= 0) {var seconds = ends_in.seconds;if (seconds < 10) { seconds = '0' + seconds;}ends_message += '' + seconds + '' + (ends_in.seconds <= 1 ? 'second' : 'seconds'); } break;case '2': if (ends_in.days > 0) {ends_message += ends_in.days + (ends_in.days == 1 ? ' day' : ' days'); } else if (ends_in.days == 0) {if (ends_in.hours > 0) { ends_message += ends_in.hours + (ends_in.hours == 1 ? 'hour' : 'hours');} } else {ends_message += ""; } break;case '3': var options = {timeZone: 'America/New_York',weekday: 'long',year: 'numeric',month: 'long',day: 'numeric',hour: 'numeric',minute: 'numeric',second: 'numeric' }; ends_message += new Date(get_date_time_value(schedule.end_date, schedule.end_time_est)).toLocaleDateString('en-UK', options); break;case '4': var options = {timeZone: 'America/New_York',weekday: 'long',year: 'numeric',month: 'long',day: 'numeric' }; ends_message += new Date(get_date_time_value(schedule.end_date, schedule.end_time_est)).toLocaleDateString('en-UK', options); break;case '5': var options = {timeZone: 'America/New_York',year: 'numeric',month: 'long',day: 'numeric' }; ends_message += new Date(get_date_time_value(schedule.end_date, schedule.end_time_est)).toLocaleDateString('en-UK', options); break;case '6': var options = {timeZone: 'America/New_York',year: 'numeric',month: 'short',day: 'numeric',hour: 'numeric',minute: 'numeric',second: 'numeric' }; ends_message += new Date(get_date_time_value(schedule.end_date, schedule.end_time_est)).toLocaleDateString('en-UK', options); break;case '7': var options = {timeZone: 'America/New_York',year: 'numeric',month: 'short',day: 'numeric' }; ends_message += new Date(get_date_time_value(schedule.end_date, schedule.end_time_est)).toLocaleDateString('en-UK', options); break;case '8': if (ends_in.days > 0) {ends_message += ends_in.days + 'd:'; } if (ends_in.hours > 0) {ends_message += ends_in.hours + 'h:'; } if (ends_in.minutes > 0) {var minutes = ends_in.minutes;if (minutes < 10) { minutes = '0' + minutes;}ends_message += minutes + 'm:'; } if (ends_in.seconds >= 0) {var seconds = ends_in.seconds;if (seconds < 10) { seconds = '0' + seconds;}ends_message += '' + seconds + '' + 's'; } break;case '9': if (ends_in.days > 0) {ends_message += ends_in.days + (ends_in.days == 1 ? 'day ' : 'days '); } if (ends_in.hours > 0) {ends_message += ends_in.hours + (ends_in.hours == 1 ? 'hour ' : 'hours '); } if (ends_in.minutes > 0) {var minutes = ends_in.minutes;if (minutes < 10) { minutes = '0' + minutes;}ends_message += minutes + (ends_in.minutes == 1 ? 'minute ' : 'minutes '); } if (ends_in.seconds >= 0) {var seconds = ends_in.seconds;if (seconds < 10) { seconds = '0' + seconds;}ends_message += '' + seconds + '' + (ends_in.seconds <= 1 ? 'second' : 'seconds'); } break;default: break; }} catch (e) { log(e);}return ends_message; }; WSAIO.isCustomerLoggedIn = function () {var is_logged = false;if (WSAIO.customer && WSAIO.customer.id) { is_logged = true;}return is_logged; }; WSAIO.isWholesaleCustomer = function () {var is_vd_applied = false;var is_rd_applied = false;var is_cart_ld_applied = $ws.cartLevelDiscount() ? true : false;var is_ships_applied = WSAIO.ships_exists ? false : true;if (WSAIO.regular_discounts && WSAIO.regular_discounts.length > 0) { // for loop for (var i = 0, len_i = $ws.regular_discounts.length; i < len_i; i++) {var regular_discount = $ws.regular_discounts[i];if (regular_discount.state !== 'published') continue;if ($ws.checkCustomer(regular_discount.customer_group, regular_discount.tags, regular_discount.tags_excluded) === false) continue;if (regular_discount.schedule_active) { var _schedule = $ws.getSchedule(regular_discount.schedule); log("_schedule", _schedule); if (_schedule.ends_in) {if ( Number(_schedule.ends_in.years) <= 0 && Number(_schedule.ends_in.months) <= 0 && Number(_schedule.ends_in.days) <= 0 && Number(_schedule.ends_in.hours) <= 0 && Number(_schedule.ends_in.minutes) <= 0 && Number(_schedule.ends_in.seconds) <= 0) { log("This rule was expired", _schedule); continue;}if ( Number(_schedule.started.years) >= 0 && Number(_schedule.started.months) >= 0 && Number(_schedule.started.days) >= 0 && Number(_schedule.started.hours) >= 0 && Number(_schedule.started.minutes) >= 0 && Number(_schedule.started.seconds) >= 0) { log("This rule was schedules and will be started in", _schedule); continue;} }}is_rd_applied = true; } // end for loop}if (!is_rd_applied && WSAIO.volume_discounts && WSAIO.volume_discounts.length > 0) { // for loop for (var i = 0, len_i = $ws.volume_discounts.length; i < len_i; i++) {var volume_discount = $ws.volume_discounts[i];if (volume_discount.state !== 'published') continue;if ($ws.checkCustomer(volume_discount.customer_group, volume_discount.tags, volume_discount.tags_excluded) === false) continue;if (volume_discount.schedule_active) { var _schedule = $ws.getSchedule(volume_discount.schedule); log("_schedule", _schedule); if (_schedule.ends_in) {if ( Number(_schedule.ends_in.years) <= 0 && Number(_schedule.ends_in.months) <= 0 && Number(_schedule.ends_in.days) <= 0 && Number(_schedule.ends_in.hours) <= 0 && Number(_schedule.ends_in.minutes) <= 0 && Number(_schedule.ends_in.seconds) <= 0) { log("This rule was expired", _schedule); continue;}if ( Number(_schedule.started.years) >= 0 && Number(_schedule.started.months) >= 0 && Number(_schedule.started.days) >= 0 && Number(_schedule.started.hours) >= 0 && Number(_schedule.started.minutes) >= 0 && Number(_schedule.started.seconds) >= 0) { log("This rule was schedules and will be started in", _schedule); continue;} }}is_vd_applied = true; } // end for loop}if (!is_rd_applied && !is_vd_applied && WSAIO.app_shipping && WSAIO.app_shipping.length > 0) { for (var kktt = 0; kktt < WSAIO.app_shipping.length; kktt++) {var temp_app_shipping = WSAIO.app_shipping[kktt];if (temp_app_shipping.status === "active") { switch (temp_app_shipping.customer_group) {case "all": if (temp_app_shipping.except_logged_in) {if (WSAIO.isCustomerLoggedIn() === false) { is_ships_applied = true;} } else {is_ships_applied = true; } break;case "logged_in": is_ships_applied = true; break;case "tag_based": if (WSAIO.isCustomerLoggedIn()) {if (WSAIO.customer.tags && WSAIO.customer.tags.length > 0) { for (var ctk = 0; ctk < WSAIO.customer.tags.length; ctk++) {var dfes = WSAIO.customer.tags[ctk];if (temp_app_shipping.customer_tags.findIndex(function (t) { return t.toLowerCase() == dfes.toLowerCase()}) > -1) { is_ships_applied = true; break;} }} } break;default: break; }} }}if (!is_vd_applied) { log("WSAIO: volume discount not found");}if (!is_rd_applied) { log("WSAIO: regular discount not found");}if (!is_ships_applied) { log("WSAIO: shipping not found");}if (!is_cart_ld_applied) { log("WSAIO: cart level discount not found");}if (is_vd_applied || is_rd_applied || is_ships_applied || is_cart_ld_applied) { return true;} else { return false;} }; WSAIO.buyNowEventListener() WSAIO.ajax = function (params) { if (params) { $.ajax({ url: params.url, type: params.type, data: params.data, dataType: 'json', success: function(responseTxt) { return params.success(responseTxt); }, error: function(error){ return params.error(error); } }) }else{ throw Error("Ajax parameters can't be null. required parameters are type and url. Optional parameters are success and error functions"); } } if (isNaN(WSAIO.buy_now_btn_interval)) {WSAIO.buy_now_btn_interval = 1000; } function serverLogging(pre_checkout) {var logging_data = { is_wholesale: WSAIO.isWholesaleCustomer(), customer: {id: WSAIO.customer.id,email: WSAIO.customer.email,tags: WSAIO.customer.tags }, template: WSAIO.landingTemplate, shop: {url: WSAIO.shopInfo.url,shop: WSAIO.shopInfo.shop }, cart: WSAIO.cart_object, date: new Date(), pre_checkout: pre_checkout || {}};localStorage.setItem("wsaio_logging", JSON.stringify(logging_data)); } serverLogging(); WSAIO.run_app = function () {if (window.Currency && window.Currency.rates) { WSAIO.Currency.rates = window.Currency.rates;}if ($ws.general_settings.discount_method === 'line_items' && true === WSAIO.general_settings.enable_additional_coupon_code) { $ws.DiscountCode.addForm(); $ws.DiscountCode.subscribe(); // subscribe on click event}if ($ws.landingTemplate === "cart") { $ws.checkoutEventListner(); // Subscribe checkout button on click event $ws.preloadCheckout(); // Get wholesale price from server on window load}$ws.signUpForm();try { if (typeof window.wsaio_execute_custom_code === 'function') {window.wsaio_execute_custom_code($) }} catch (e) { log(e);} }; window.wsaioClosePreview = function () {WSAIO.removeQueryString("test-mode", WSAIO.getParameterByName("test-mode")[0]);localStorage.removeItem("wsaio-app-mode");WSAIO.user_mode = "live";setTimeout(function () { window.location.replace('https://' + Shopify.shop);}, 500); } window.wsaioHidePreview = function () {$(".wholesaleAllInOnePreview").remove();$("html").css("padding-bottom", ""); } WSAIO.addPreviewBar = function () {var previewBar = '

    '+'

    '+'Wholesale All In One Preview: '+'Wholesale pricing are only visible to you. Learn More

    '+'

    '+''+''+'

    '+'

    ';0 == $(".wholesaleAllInOnePreview").length && $("body").append(previewBar);$("html").css("padding-bottom", "60px"); } WSAIO.store = {get: function (key) { return sessionStorage.getItem(key);},set: function (key, value) { return sessionStorage.setItem(key, value);},del: function (key) { return sessionStorage.removeItem(key);} } WSAIO.handleBrowserURL = function () {function $track_overriding(product, variant, selector, trackClass) { var counter = 1; function $check(counter) {log("$tracking variant change...");counter++;if($(selector).hasClass(trackClass)){ // log("$tracking variant changed! Discount did not override");}else{ log("$tracking Discount has been overrided by another function. Let's change it according to WSAIO"); WSAIO.variantChange(product, variant); counter = 3000;}if(counter < 3000){ setTimeout(function () {$check(counter); }, 1);} } $check(counter);}function $handle_variant_change(variant_id) { var pt_index = -1; try {pt_index = WSAIO.product_details.variants.findIndex(function (x) { return x.id == variant_id}); } catch (e) {} if($(WSAIO.product_price_selector).hasClass("wsdapp")){$(WSAIO.product_price_selector).removeClass("wsdapp") } if (pt_index > -1) {$ws.selected_variant = WSAIO.product_details.variants[pt_index];var variant = WSAIO.product_details.variants[pt_index];WSAIO.variantChange(WSAIO.product_details, variant);$track_overriding(WSAIO.product_details, variant, WSAIO.product_price_selector, "wsdapp"); }}var selected_variant_id = WSAIO.getParameterByName("variant")[0];if(selected_variant_id){ log("Got variant id from browser url"); $handle_variant_change(selected_variant_id);}else{ setTimeout(function () {selected_variant_id = $('[name="id"]').val();if(selected_variant_id){ log("Got variant id from name=id attribute"); $handle_variant_change(selected_variant_id);}else{ isError("Error 404! Variant ID not found");} }, 1000);} }; WSAIO.listenLocationChange = (function () {var pushState = history.pushState;var replaceState = history.replaceState;history.pushState = function() { pushState.apply(history, arguments); window.dispatchEvent(new Event('pushstate')); window.dispatchEvent(new Event('locationchange'));};history.replaceState = function() { replaceState.apply(history, arguments); window.dispatchEvent(new Event('replacestate')); window.dispatchEvent(new Event('locationchange'));};window.addEventListener('popstate', function() { window.dispatchEvent(new Event('locationchange'))});// window.addEventListener('locationchange', WSAIO.handleBrowserURL); })(); if ($ws.app_auto_start) {$ws.run_app(); } setTimeout(function(){WSAIO.autoInstallScript($wsj); },200); }; //end WSAIO.init function ws_load_app(jQuery) {if (WSAIO.db_config == 'database') { jQuery.ajax({type: 'GET',url: WSAIO.App.url + '/api/2021-03/get-rules?shop=' + WSAIO.shopInfo.shop,cache: false,success: function (rules) { if (rules) {if (rules.volume_discounts) { WSAIO.volume_discounts = rules.volume_discounts;}if (rules.regular_discounts) { WSAIO.regular_discounts = rules.regular_discounts;}if (rules.cart_discounts) { WSAIO.cart_ld_discounts = WSAIO.cart_discounts;}WSAIO.init(jQuery); }},error: function (error) { if(!WSAIO.no_logs){console.error('WSAIO could not be initialized.', error); }} });} else { WSAIO.init(jQuery);} } WSAIO.removeQueryString = function (a, d) {var b = document.location.href,c = location.search;"" != a ? (d = encodeURIComponent(d), a = a + "=" + d, "-1" != c.indexOf("?" + a + "&") ? b = b.replace("?" + a + "&", "?") : "-1" != c.indexOf("&" + a + "&") ? b = b.replace("&" + a + "&", "&") : "-1" != c.indexOf("?" + a) ? b = b.replace("?" + a, "") : "-1" != c.indexOf("&" + a) && (b = b.replace("&" + a, ""))) : (c = location.search, b = b.replace(c, ""));history.pushState({ state: 1, rand: Math.random()}, "", b) }; WSAIO.getParameterByName = function (e) {for (var b = [], c = window.location.search.substring(1).split("&"), a = 0; a < c.length; a++) { var d = c[a].split("="); d[0] == e && b.push(decodeURIComponent(d[1]))}return b }; var waioLoadScript = function (c, b) {var a = document.createElement("script");a.type = "text/javascript";a.readyState ? a.onreadystatechange = function () { if ("loaded" == a.readyState || "complete" == a.readyState) a.onreadystatechange = null, b()} : a.onload = function () { b()};a.src = c;document.getElementsByTagName("head")[0].appendChild(a) }; if ("yes" === WSAIO.getParameterByName("test-mode")[0]) {WSAIO.user_mode = "test";localStorage.setItem("wsaio-app-mode", "test");WSAIO.show_preview_bar = true; } if (localStorage.getItem("wsaio-app-mode") === "yes") {WSAIO.show_preview_bar = true; } if (WSAIO.app_mode === 'live' && WSAIO.disable_logs_when_live === true) {WSAIO.log = '';WSAIO.errorLog = ''; } if (WSAIO.app_mode === "live" || (WSAIO.app_mode === WSAIO.user_mode)) {var jQ = typeof window.WSAIO_GET_JQUERY === "function" ? window.WSAIO_GET_JQUERY() : jQuery; if(jQ)ws_load_app(jQ); } else {if(!WSAIO.no_logs){ console.warn("%c'Wholesale All In One' is disabled", "font-size: 20px");}WSAIO_is_disabled = true; } WSAIO.autoInstallScript = function($){var $wsj = $;if(typeof window.token_enable != 'undefined' && window.token_enable == true){ // ====================Custom function define========================= if(localStorage.getItem('product_in_collects') == null || (localStorage.getItem('store_products') != null && typeof WSAIO.store_products != 'undefined' && parseInt(localStorage.getItem('store_products')) != parseInt(WSAIO.store_products))){ try{ $wsj('.col_clct').each(function(){ var clctn_dta = JSON.parse($(this).attr("clct"));for(var ii = 0 ; ii < clctn_dta.length; ii++){WSAIO.product_in_collects.push(clctn_dta[ii]);WSAIO.products_with_collections.push(clctn_dta[ii]);WSAIO.products_in_collection.push(clctn_dta[ii]);WSAIO.product_collections.push(clctn_dta[ii]); } }); }catch(e){console.log(e)} } if(Object.keys(WSAIO.product_in_collects).length != 0){ localStorage.setItem('product_in_collects', JSON.stringify(WSAIO.product_in_collects)); localStorage.setItem('store_products', WSAIO.store_products); } else{ WSAIO.product_in_collects = JSON.parse(localStorage.getItem('product_in_collects')); WSAIO.products_with_collections = JSON.parse(localStorage.getItem('product_in_collects')); WSAIO.products_in_collection = JSON.parse(localStorage.getItem('product_in_collects')); WSAIO.product_collections = JSON.parse(localStorage.getItem('product_in_collects')); } function _apply_discount( current_template, product, parent_selector, price_selector, index, discount_type, collection_price_selector ) { var selector = ""; if (discount_type == "specific_product") { selector = $wsj(parent_selector).find(price_selector); } else { selector = collection_price_selector; } try { WSAIO.productDiscount({ item_price_selector: selector, template: current_template, product_id: product.id, product_handle: product.handle, variant_id: product.variants[index].id, variant_sku: product.variants[index].sku, variant_price: product.variants[index].price, variant_compare_at_price: product.variants[index].compare_at_price, }); } catch (error) { // console.warn(error); } } WSAIO.custom_discount_function = function (t, v, h) { var discount_type = t, default_product = "", Vid = ""; if (discount_type == "specific_product") { if(typeof HandleQty != 'undefined'){HandleQty.init()} if (v == null) { Vid = $wsj(WSAIO.Default_variant_id_selector).val(); } else { Vid = v; } if (h == null && WSAIO.product_details.handle != null) { prepare_data(WSAIO.product_details); } else { if(typeof h != 'undefined'){ $wsj.getJSON(WSAIO.local_param + "products/" + h + ".js", function (product) { prepare_data(product); }); } } function prepare_data(product) { if (typeof product.handle != "undefined") { $wsj(WSAIO.product_parent_grid_selector) .find(WSAIO.product_price_selector) .removeClass("wsdapp"); $wsj(WSAIO.product_parent_grid_selector) .find(WSAIO.product_price_selector) .removeClass("empty"); var _indx = product.variants.findIndex(function (x) { return x.id == Vid; }); window.selected_variant_id = product.variants[_indx].id; WSAIO.variantChange(product, product.variants[_indx]); _apply_discount( "product", product, WSAIO.product_parent_grid_selector, WSAIO.product_price_selector, _indx, discount_type ); } } } else if (discount_type == "specific_collection") { $wsj(WSAIO.collection_items_each_selector).each(function (index, item) { if (item.querySelector("a[href]") == null) { return false; } var handle = null; if (h == null) { handle = item.querySelector("a[href]").getAttribute("href"); } var itemSelector = item.querySelector( WSAIO.collection_item_price_selector ); if (handle) { var product_handle = null, productIndex = -1; try { product_handle = handle.split('/products/')[1]; product_handle = product_handle.split('?')[0]; } catch (e) {} jQuery.getJSON(WSAIO.local_param + "products/" + product_handle+".js", function (product) { _apply_discount( "collection", product, null, null, 0, discount_type, itemSelector ); }).always(function () { $('.price--on-sale.wsdapp').parents('.card-wrapper').find('.card__badge').remove() }); } }); } }; // =====================Call function================ WSAIO.custom_discount_function("specific_product"); // ===================variant change================= $wsj(WSAIO.Default_variant_selector).on("change", function () { setTimeout(function () { WSAIO.custom_discount_function("specific_product"); }, 2000); }); // ===================Quick View===================== function quickViewDiscount() { if(typeof HandleQty != 'undefined'){HandleQty.init()} var Vid = $wsj(WSAIO.quickView_parent_Selector).find('[name="id"]').val(); var handle = null; handle = $wsj(WSAIO.quickView_parent_Selector) .find(WSAIO.quickView_handleSelector) .attr("href"); if (handle) { var product_handle = null, productIndex = -1; try { product_handle = handle.split("?")[0].split("/")[ handle.split("/").length - 1 ]; } catch (e) {} } jQuery.getJSON(WSAIO.local_param + "products/" + product_handle + ".js", function (product) { window.current_product = product; prepare_data(product); }); function prepare_data(product) { if (typeof product.handle != "undefined") { $wsj(WSAIO.quickView_parent_Selector) .find(WSAIO.product_price_selector) .removeClass("wsdapp"); $wsj(WSAIO.quickView_parent_Selector) .find(WSAIO.product_price_selector) .removeClass("empty"); var _indx = product.variants.findIndex(function (x) { return x.id == Vid; }); window.selected_variant_id = product.variants[_indx].id; WSAIO.variantChange(product, product.variants[_indx]); _apply_discount( "product", product, WSAIO.quickView_parent_Selector, WSAIO.product_price_selector, _indx, "specific_product" ); } } } var isQuickViewOpen = false; var _intv = setInterval(function () { if ( $wsj(WSAIO.quickView_parent_Selector).length > 0 && isQuickViewOpen == false ) { isQuickViewOpen = true; setTimeout(function () { quickViewDiscount(); }, 1000); //Quick Variant change $wsj(WSAIO.quickView_variantSelector).on("change", function () { setTimeout(function () { quickViewDiscount(); }, 1500); }); } else if ( !$wsj(WSAIO.quickView_parent_Selector).length > 0 && isQuickViewOpen == true ) { isQuickViewOpen = false; } }, 500); // ==============collection discount function======== WSAIO.custom_discount_function("specific_collection"); if (WSAIO.template == "collection" || WSAIO.template == "search") { $wsj(document).bind("DOMNodeInserted", function (e) { var element = e.target; var elm = $wsj(element).attr("class"); if (typeof elm != "undefined") { if ( elm.indexOf("collection page-width") > -1 || elm.indexOf( "mobile-facets__open-label button-label medium-hide large-up-hide" ) > -1 ) { setTimeout(function () { WSAIO.custom_discount_function("specific_collection"); }, 500); } } }); } var Recentlyviewedd = false; var _intv = setInterval(function() { if ($wsj('product-recommendations .grid__item').length > 0 && Recentlyviewedd == false) { Recentlyviewedd = true; setTimeout(function() { WSAIO.custom_discount_function("specific_collection"); clearInterval(_intv) ; }, 500) } else if (!$wsj('product-recommendations .grid__item').length > 0 && Recentlyviewedd == true) { Recentlyviewedd = false; } }, 500); $wsj('[type="search"]').keyup(function() { setTimeout(function() { WSAIO.custom_discount_function("specific_collection"); }, 1500) }) //=================== cart discount fucntion========= try {if($wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').length == 0){$wsj('td.cart-item__details a.cart-item__name').siblings('.cart-item__discounted-prices').addClass('singlepricee') }else{$wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').addClass('singlepricee') } } catch (error) {} if (typeof WSAIO.cartDrawer != 'undefined'){WSAIO.cartDrawer(100)} // ================== cart quantity change ========== $wsj(document).on("change", WSAIO.cart_qty_input_selector, function () { setTimeout(function () { try {if($wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').length == 0){$wsj('td.cart-item__details a.cart-item__name').siblings('.cart-item__discounted-prices').addClass('singlepricee') }else{$wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').addClass('singlepricee') } } catch (error) {} }, 1500); if (typeof WSAIO.cartDrawer != 'undefined'){WSAIO.cartDrawer(1500)} }); $wsj(document).on("click", WSAIO.cart_qty_btn_selector, function () { setTimeout(function () { try {if($wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').length == 0){$wsj('td.cart-item__details a.cart-item__name').siblings('.cart-item__discounted-prices').addClass('singlepricee') }else{$wsj('td.cart-item__details a.cart-item__name').siblings('div.product-option').addClass('singlepricee') } } catch (error) {} }, 1500); if (typeof WSAIO.cartDrawer != 'undefined'){WSAIO.cartDrawer(1500)} }); //==================== cart drawer =============== var cartdrawerr = false; var _intv = setInterval(function () { if ($wsj(".drawer").hasClass("active") && cartdrawerr == false) { cartdrawerr = true; try { $wsj("td.cart-item__details a.cart-item__name") .siblings("div.product-option") .addClass("singlepricee"); } catch (error) {} if (typeof WSAIO.cartDrawer != 'undefined'){WSAIO.cartDrawer(100)} } else if (!$wsj(".drawer").hasClass("active") && cartdrawerr == true) { cartdrawerr = false; } }, 200); } }

    Radiant Luxury: Unveiling the Transformative Power of Organic Shimmering Body Butter (2024)

    References

    Top Articles
    Latest Posts
    Recommended Articles
    Article information

    Author: Tyson Zemlak

    Last Updated:

    Views: 5682

    Rating: 4.2 / 5 (43 voted)

    Reviews: 90% of readers found this page helpful

    Author information

    Name: Tyson Zemlak

    Birthday: 1992-03-17

    Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

    Phone: +441678032891

    Job: Community-Services Orchestrator

    Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

    Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.