コン十ツに進む

Welcome to Our Store

零菜 ZEROSAI

カート

世界で一番農薬が使われている食料品と言われたこともある「コーヒー」

人文期間中、無農薬・無化学肥料で造られたミラクルのコーヒー。

地球にも、次世代にも、体にも優しい一杯。

Shop now

妊娠中の至福の一杯

ZEROSAIのコーヒーは、一般的なコーヒーの1/4の低カフェ宿舎。

妊娠とりわけ、カフェ宿舎の取りすぎを気にすることなく、楽しめる。

Shop now

今ならエポスカード新鮮入会で

2,000円offになる個所GET!!

コン十ツに進む

Welcome to Our Store

零菜 ZEROSAI

カート

世界で一番農薬が使われている食料品と言われたこともある「コーヒー」

人文期間中、無農薬・無化学肥料で造られたミラクルのコーヒー。

地球にも、次世代にも、体にも優しい一杯。

Shop now

妊娠中の至福の一杯

ZEROSAIのコーヒーは、一般的なコーヒーの1/4の低カフェ宿舎。

妊娠とりわけ、カフェ宿舎の取りすぎを気にすることなく、楽しめる。

Shop now

今ならエポスカード新鮮入会で

2,000円offになる個所GET!!

" + thousands), cents = parts[1] ? decimal + parts[1] : ""; return dollars + cents; } switch (formatString.match(placeholderRegex)[1]) { case "amount": value = formatWithDelimiters(cents, 2); break; case "amount_no_decimals": value = formatWithDelimiters(cents, 0, ",", ".", directionFor50); break; case "amount_with_comma_separator": value = formatWithDelimiters(cents, 2, ".", ","); break; case "amount_with_decimal_separator": value = formatWithDelimiters(cents, 2, ",", "."); break; case "amount_no_decimals_with_comma_separator": value = formatWithDelimiters(cents, 0, ".", ",", directionFor50); break; case "amount_no_decimals_with_space_separator": value = formatWithDelimiters(cents, 0, " ", ",", directionFor50); break; case "amount_with_apostrophe_separator": value = formatWithDelimiters(cents, 2, "'", "."); break; } return formatString.replace(placeholderRegex, value); } catch (e) { console.log(e.message); price = cents / 100; return price.toLocaleString(undefined, { style: "currency", currency: fallbackCurrency }); } }, convertMoney: function (value, rate, currency, round) { if (value <= 0) { return 0; } value *= rate; var roundUp = ["USD", "CAD", "AUD", "NZD", "SGD", "HKD", "GBP"]; var roundTo100 = ["JPY"]; var roundTo95 = ["EUR"]; if (round) { if (roundUp.indexOf(currency) !== -1) { value = Math.ceil(value); } else if (roundTo100.indexOf(currency) !== -1) { value = Math.ceil(value / 100) * 100; } else if (roundTo95.indexOf(currency) !== -1) { value = Math.ceil(value) - 0.05; } } return value; } }; function logProductEvent(addon,type){ $.ajax({ url: recurpay.logURL, type: 'POST', async:true, dataType: 'json', data: { module:"product_widget", level: type, payload:{ store : recurpay.domainURL, remark: addon } }, success: function(response) { console.log("event logged"); } }); } function calculatePrice(variant_id){ var variant_json = {}; var variant_price = 0; var productObj = {}; if(variant_id !== undefined && variant_id !== null){ variant_id = parseInt(variant_id); let variant_data = []; for(i=0 ; i< recurpay.productDatas.length; i++){ variant_data.push(...recurpay.productDatas[i].product.variants.filter(function(searchId) { return parseInt(searchId.id) == variant_id; })); console.log(variant_data); } if(variant_data.length >=1){ productObj.variant_price = variant_data[0].price; productObj.product_id = variant_data[0].product_id; } } else{ productObj.variant_price = recurpay.productDatas[0].product.variants[0].price; productObj.product_id = variant_data[0].product_id; } return productObj; } function formatPriceMoney(price){ var multiple_price = price*100; var formatted_price = recurpay.recurMoney.formatPrice(multiple_price); return formatted_price; } $(atcFormSelector).closest(".product__meta").find("button.product__chip").on("click", function () { var $this = $(this); setTimeout(function() { recurpay.product.selectedVariant = $this.parents(atcFormSelector).find('select[name="id"]').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); $(atcFormSelector).find(".combobox, .wetheme-dropdown__wrapper ul[id^='SingleOptionSelector-'] li, .option-values-radio .popover-list-item .form-element-radio, .single-option-selector .bcpo-image-parent, .regular-select-item, .bcpo-dd.single-option-selector ul.inner li, #clickyboxes-SingleOptionSelector-0 a, button.product__chip, .form-swatch-item, .product-variant__container .product-variant__label, .options-selection__option-value, .popout-list__option--product, .option-swatch .custom-swatch, ul.select-dropdown li, .swatch-element, .swatch_pr_item, .basel-swatch, .swatchBox label, .swatchBox span").on("click", function () { var $this = $(this); setTimeout(function() { recurpay.product.selectedVariant = $this.parents(atcFormSelector).find('select[name="id"], input[name="id"][type="radio"]:checked').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); $(atcFormSelector).closest(".product-selection").find("select.single-option-selector").on("change", function () { var $this = $(this); setTimeout(function() { recurpay.product.selectedVariant = $this.parents(atcFormSelector).find('select[name="id"]').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); $(atcFormSelector).find(".product-single__swatch__input").on("change", function () { var $this = $(this); setTimeout(function() { recurpay.product.selectedVariant = $this.parents(atcFormSelector).find('select[name="id"]').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); $(atcFormSelector).find('input#SelectedId, select.js-variant-select, input[name="id"], select[name="id"], select.single-option-selector, .zpa-single-option-selector, .select.options-selection__input-select, .form-options input.option-value-input, .variant-input input[type="radio"], .product-form__option-select, .option-selectors .selector-wrapper select, select.single-option-list-type, .product-options .option-input, select.input-reset, select.js-product-variant, select[data-single-option-selector], input[data-single-option-selector], select.single-option-selector-product-template, .single-option-selector[type="radio"], .single-option-selector-product-template[type="radio"]').on("change", function () { var $this = $(this) setTimeout(function() { console.log( $(this)); console.log($(this).parents(atcFormSelector)); recurpay.product.selectedVariant = $this.parents(atcFormSelector).find('input[name="id"], select[name="id"], input#SelectedId').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); function recurDiscountedPrice(variant){ var getVariantObj = calculatePrice(variant); var getVariantPrice = getVariantObj.variant_price; var getProductId = parseInt(getVariantObj.product_id); $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]').find(".recurpay__frequency_select option").each(function(){ var $this = $(this); console.log($this); var getDiscount = $(this).attr("data-plan-discount"); var getPlanName = $(this).attr("data-plan-name"); var getPlanShipment = $(this).attr("data-plan-shipment"); if(getPlanShipment == null || getPlanShipment == undefined || getPlanShipment == "null"){ getPlanShipment = 1; } if(getDiscount == null || getDiscount == undefined || getDiscount == "null"){ getDiscount = 0; } var discountedPrice = getVariantPrice - (getVariantPrice * getDiscount / 100); if(parseFloat(getVariantPrice) !== parseFloat(discountedPrice)){ $this.html(getPlanName+" ("+formatPriceMoney(discountedPrice*getPlanShipment)+")"); console.log( $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]')); if($this.is(':selected')){ $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_compare_price").html(""+formatPriceMoney(getVariantPrice*getPlanShipment)+""); } } else{ $this.html(getPlanName+"("+formatPriceMoney(discountedPrice*getPlanShipment)+")"); if($this.is(':selected')){ $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_compare_price").html(""); } } if($this.is(':selected')){ $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_selling_price").html(""+formatPriceMoney(discountedPrice*getPlanShipment)+""); } $('.recurpay-pdp-widget[data-product-id="'+getProductId+'"]').find(".recurpay__widget_container[data-type='onetime-purchase']").find(".recurpay__group_selling_price").html(""+formatPriceMoney(getVariantPrice)+""); }); } // PRODUCT PAGE function recurPDP(data){ var prepaidCount = 0, regularCount = 0, prepaidDiscount = [], maxPrepaidDiscount = '', getPlanDesc = '', pdpTemplate = '', GetPlans = ""; $.each(data.plans, function(key, plan) { var DiscountPercentageHtml = '', DescriptionHtml = '', PlanHtml = '', PlanDiscount = 0, PlanType = 'regular'; if(plan.type){ PlanType = plan.type; if(PlanType == 'prepaid'){ prepaidCount += prepaidCount+1; prepaidDiscount.push(plan.pricing_policy[0].discount.value); } else{ regularCount += regularCount+1; } } if(plan.pricing_policy[0].discount.type == "percentage" && plan.pricing_policy[0].discount.value != 0){ PlanDiscount = plan.pricing_policy[0].discount.value; DiscountPercentageHtml = '(' + PlanDiscount + '% Off)'; } if(plan.description) { DescriptionHtml = ''; } if(recurpay.checkout == "shopify"){ if(key == 0){ PlanHtml += '' } else{ PlanHtml += '' } } else{ if(key == 0){ PlanHtml += '' } else{ PlanHtml += '' } } GetPlans += PlanHtml; getPlanDesc += DescriptionHtml; }) if(regularCount > 0 && prepaidCount >0){ maxPrepaidDiscount = Math.max.apply(Math,prepaidDiscount); } pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '' pdpTemplate += '
' pdpTemplate += ''; pdpTemplate += ''; if(recurpay.checkout == "shopify"){ pdpTemplate += ''; } return pdpTemplate; } if($(pdpSelector).length <= 0){ if (window.location.href.indexOf("/products/") > -1) { if($(atcFormSelector).find(atcSelector).filter(':visible').length){ if($(atcFormSelector).find(atcSelector).filter(':visible').first().parent().css('display') == 'flex' && $(atcFormSelector).find(atcSelector).filter(':visible').first().parent().css('flex-direction') == 'row'){ $(atcFormSelector).find(atcSelector).filter(':visible').first().parent().before('
'); } else{ $(atcFormSelector).find(atcSelector).filter(':visible').first().before('
'); } if($(pdpSelector).parent().css('position') == 'fixed' || $(pdpSelector).parent().css('position') == 'sticky' || $(pdpSelector).parent().css('position') == 'absolute' ){ $(pdpSelector).parent().addClass("recurpay-z-index"); } } else if($(atcFormSelector).find(atcSelector).length){ if($(atcFormSelector).find(atcSelector).first().parent().css('display') == 'flex' && $(atcFormSelector).find(atcSelector).filter(':visible').first().parent().css('flex-direction') == 'row'){ $(atcFormSelector).find(atcSelector).first().parent().before('
'); } else{ $(atcFormSelector).find(atcSelector).first().before('
'); } if($(pdpSelector).parent().css('position') == 'fixed' || $(pdpSelector).parent().css('position') == 'sticky' || $(pdpSelector).parent().css('position') == 'absolute' ){ $(pdpSelector).parent().addClass("recurpay-z-index"); } } else{ $(atcFormSelector).append('
') } } } if($(pdpSelector).length){ recurpay.allProducts = []; for(i=0; i<$(pdpSelector).length; i++){ if($(pdpSelector).eq(i).attr("data-product-id") != undefined && $(pdpSelector).eq(i).attr("data-product-available") != undefined ){ recurpay.allProducts.push($(pdpSelector).eq(i).attr("data-product-id")); } } $.ajax({ url: recurpay.pdpAPI, type: 'POST', async:true, data: {"products": recurpay.allProducts,"settings": true}, success: function(response) { if(response != "ERROR") { if(response.plans.length > 0){ recurpay.productDatas = response.plans; if(response.settings.translations !== null && !$.isEmptyObject(response.settings.translations)){ recurpay.settings = response.settings; document.documentElement.style.setProperty('--recurpay_brand_color', recurpay.settings.snippet_color_codes.subscription_brand_color); document.documentElement.style.setProperty('--recurpay_button_text_color', recurpay.settings.snippet_color_codes.subscription_button_text_color); document.documentElement.style.setProperty('--recurpay_button_bg_color', recurpay.settings.snippet_color_codes.subscription_button_color); } $(response.plans).each(function(){ var pdpHTML = ''; var $this = $(this); if($this[0].product.plans.length >0){ pdpHTML = recurPDP($this[0].product); var getElem = $('.recurpay-pdp-widget[data-product-id="'+$this[0].product.id+'"]'); if($(getElem).length && $(getElem).attr("data-product-available") == "true"){ $(getElem).html(pdpHTML); if($(getElem).attr("data-only-subscription") == "true"){ $(getElem).find(".recurpay__widget[data-recurpay-widget]").addClass("recurpay_only_subscription_widget"); } if((window.location.href.indexOf("/products/") > -1) && (window.location.href.indexOf("snippet_status=false") > -1)){ $(getElem).before("You are previewing subscriptions currently and the option below is not visible to customers on your live store. Click here if you are ready to show it your customers now.") } if($(getElem).is(":hidden") || $(getElem).width() < 220){ logProductEvent("Product snippet added but needs a reverification", "warning"); } } var params = new Proxy(new URLSearchParams(window.location.search), { get: (searchParams, prop) => searchParams.get(prop), }); if(params.variant !== undefined && params.variant !== null){ var variant_id = parseInt(params.variant); let variant_data = []; variant_data.push(...$this[0].product.variants.filter(function(searchId) { return parseInt(searchId.id) == variant_id; })); if(variant_data.length >=1){ recurpay.product.selectedVariant = params.variant recurDiscountedPrice(recurpay.product.selectedVariant); } else{ recurpay.product.selectedVariant = $this[0].product.variants[0].id; recurDiscountedPrice($this[0].product.variants[0].id); } } else{ if(recurpay.product.availableVariant !== "" && recurpay.product.availableVariant !== undefined){ recurpay.product.selectedVariant = recurpay.product.availableVariant; recurDiscountedPrice(recurpay.product.availableVariant); } else{ recurpay.product.selectedVariant = $this[0].product.variants[0].id; recurDiscountedPrice($this[0].product.variants[0].id); } } } }); if(response.settings.sell_only_as_subscription !== undefined && response.settings.sell_only_as_subscription !== null){ if(response.settings.sell_only_as_subscription == true){ updateSelectors(true); } else{ updateSelectors(); } } } } } }); } else{ if((window.location.href.indexOf("/products/") > -1) && (window.location.href.indexOf("recurpay_preview=true") > -1)){ var modalHTML = ""; modalHTML += '
' modalHTML += '
' modalHTML += '
' modalHTML += '
' modalHTML += '
' modalHTML += '
' modalHTML += '' modalHTML += '
' modalHTML += '

You are previewing subscriptions option for this product

' modalHTML += 'Note: This is not visible to your customers' modalHTML += '
' modalHTML += '
' modalHTML += '
' modalHTML += '
Looks like the subscription option is not visible on your store due to some conflict with theme. Talk to us on Live Chat to get it resolved instantly
' modalHTML += '
' modalHTML += '
' if($('[data-recurpay-visibility-modal]').length <= 0){ if($('body').length){ $('body').append(modalHTML); } else if($('html').length){ $('html').append(modalHTML); } } } if((window.location.href.indexOf("/products/") > -1)){ logProductEvent("Failed to show product snippet", "critical"); } } function recurProperties(elem){ var getParent = $(elem).parents(pdpSelector); if( $(getParent).find("[name='recurpay__group_main'][value='subscription']").is(":checked")){ var planName = $(getParent).find('[name="recurpay-input"] option:selected').attr('data-plan-name'), planId = $(getParent).find('[name="recurpay-input"] option:selected').attr('data-plan'); $(getParent).find('.recurpay_plan_name').attr("name","properties[Plan]").val(planName); $(getParent).find('.recurpay_plan_id').attr("name","properties[_PlanId]").val(planId); $(getParent).find('.recurpay__description[data-description-id]').hide(); $(getParent).find('.recurpay__description[data-description-id="'+planId+'"]').show(); if(recurpay.checkout == "shopify"){ var sellingPlanId = $(getParent).find('[name="recurpay-input"] option:selected').attr('data-selling-plan'); $(getParent).find('.recurpay_selling_plan_id').attr("name","selling_plan").val(sellingPlanId); } } else{ $(getParent).find('.recurpay_plan_name').attr("name",""); $(getParent).find('.recurpay_plan_id').attr("name",""); if(recurpay.checkout == "shopify"){ $(getParent).find('.recurpay_selling_plan_id').attr("name",""); } } } function addSubscription(btn){ var variantSelector = $(btn).parents(atcFormSelector).find('[name="id"]'), quantitySelector = $(btn).parents(atcFormSelector).find('[name="quantity"]'), subscriptionPlanId = $(btn).parents(pdpSelector).find('[name="recurpay-input"] option:selected').attr('data-plan'), subscriptionPlanName = $(btn).parents(pdpSelector).find('[name="recurpay-input"] option:selected').attr('data-plan-name'), subscriptionPlanType = $(btn).parents(pdpSelector).find('[name="recurpay-input"] option:selected').attr('data-plan-type'), planVariant = parseInt(variantSelector.val()), planQuantity = 1, planParams = {}; if(quantitySelector.length) { planQuantity = parseInt(quantitySelector.val()); } if(recurpay.checkout == "shopify"){ var sellingPlanId = $(btn).parents(pdpSelector).find('[name="recurpay-input"] option:selected').attr('data-selling-plan'); planParams = { id: planVariant, quantity: planQuantity, selling_plan: sellingPlanId, properties: { 'Plan': subscriptionPlanName, '_PlanId': subscriptionPlanId } } } else{ planParams = { id: planVariant, quantity: planQuantity, properties: { 'Plan': subscriptionPlanName, '_PlanId': subscriptionPlanId } } } if(recurpay.checkout == "recurpay" && !recurpay.prepaidMixedCart && subscriptionPlanType == "prepaid"){ $.getJSON('/cart', function(response) { response.items = []; response.items.push(planParams); recurCart(response); }); } else{ if (recurpay.action == "default" && $(atcFormSelector).find(atcSelector).length){ $(btn).parents(atcFormSelector).find(atcSelector).first().click(); } else{ $.ajax({ type: 'POST', url: '/cart/add.js', dataType: 'json', data: planParams, success: function() { if (recurpay.checkout == "recurpay" && recurpay.action == "checkout"){ $.getJSON('/cart', function(response) { recurCart(response); }); } else if(recurpay.action == "cart"){ document.location.href = '/cart'; } else{ document.location.href = '/checkout'; } }, error: function(xhr, status, error) { var err = eval("(" + xhr.responseText + ")"); $('[data-recurpay-error]') .html(err.description) .show().delay(3000).fadeOut(); } }); } } } $(document).on('change',"[name='recurpay__group_main']", function(e) { var $this = $(this); $this.parents(pdpSelector).find('.recurpay__widget_container').removeClass("recurpay__widget_container--selected"); var checkVal = $this.val(); if($this.is(":checked")){ $this.parents('.recurpay__widget_container').addClass("recurpay__widget_container--selected"); } if(checkVal == "subscription"){ $this.parents(atcFormSelector).find(atcSelector).addClass("recurpay-hide"); $this.parents(atcFormSelector).find(buynowSelector).addClass("recurpay-hide"); $this.parents(pdpSelector).find('.recurpay__plans').show(); $this.parents(pdpSelector).find('.recurpay__group_content_wrapper').slideDown(); } else{ $this.parents(atcFormSelector).find(atcSelector).removeClass("recurpay-hide"); $this.parents(atcFormSelector).find(buynowSelector).removeClass("recurpay-hide"); $this.parents(pdpSelector).find('.recurpay__plans').hide(); $this.parents(pdpSelector).find('.recurpay__group_content_wrapper').slideUp(); } recurProperties($this); }); $(document).on('change',"[name='recurpay-input']", function(e) { var getId = $(this).parents(atcFormSelector).find('input[name="id"], select[name="id"], input#SelectedId').val(); recurDiscountedPrice(getId); recurProperties($(this)); }); $(document).on('click',".recurpay__group_label", function(e) { $(this).parents('.recurpay__widget_container').find('[name="recurpay__group_main"]').prop("checked",true).change(); }); $(document).on('click',".recurpay-modal-cancel-btn", function(e) { $('[data-recurpay-visibility-modal]').hide(); }); function updateSelectors(only_subscription){ for(r=0; r<$(pdpSelector).length; r++){ if($(pdpSelector).eq(r).attr("data-only-subscription") == "true" || only_subscription == true){ $(pdpSelector).eq(r).attr("data-only-subscription",true); $(pdpSelector).eq(r).find(".recurpay__widget[data-recurpay-widget]").addClass("recurpay_only_subscription_widget"); $(pdpSelector).eq(r).find("[name='recurpay__group_main'][value='subscription']").prop("checked",true).change(); } } } $(document).on('click',"[data-recurpay-action]", function(e) { addSubscription($(this)); }); if(recurpay.checkout == "recurpay"){ $(document).on('click', checkoutSelector, function(e) { e.preventDefault(); e.stopPropagation(); $.getJSON('/cart', function(response) { recurCart(response); }) }); if($(recurpay.checkout_btn_override_class).length){ document.addEventListener("click", handler, true); function handler(e) { if($(e.target).is(recurpay.checkout_btn_override_class)){ e.stopPropagation(); e.preventDefault(); $.getJSON('/cart', function(response) { recurCart(response); }); } } } } } //Append jQuery if it is not there, then call to recurpaySubscription //Otherwise directly call to recurpaySubscription if ((typeof(jQuery) == 'undefined')) { initScript('//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js', function() { window.recurpayScript = jQuery.noConflict(true); recurpaySubscription(recurpayScript); }) } else { recurpaySubscription(jQuery); } })(); コン十ツに進む

Welcome to Our Store

零菜 ZEROSAI

カート

世界で一番農薬が使われている食料品と言われたこともある「コーヒー」

人文期間中、無農薬・無化学肥料で造られたミラクルのコーヒー。

地球にも、次世代にも、体にも優しい一杯。

Shop now

妊娠中の至福の一杯

ZEROSAIのコーヒーは、一般的なコーヒーの1/4の低カフェ宿舎。

妊娠とりわけ、カフェ宿舎の取りすぎを気にすることなく、楽しめる。

Shop now

今ならエポスカード新鮮入会で

2,000円offになる個所GET!!

" + thousands), cents = parts[1] ? decimal + parts[1] : ""; return dollars + cents; } switch (formatString.match(placeholderRegex)[1]) { case "amount": value = formatWithDelimiters(cents, 2); break; case "amount_no_decimals": value = formatWithDelimiters(cents, 0, ",", ".", directionFor50); break; case "amount_with_comma_separator": value = formatWithDelimiters(cents, 2, ".", ","); break; case "amount_with_decimal_separator": value = formatWithDelimiters(cents, 2, ",", "."); break; case "amount_no_decimals_with_comma_separator": value = formatWithDelimiters(cents, 0, ".", ",", directionFor50); break; case "amount_no_decimals_with_space_separator": value = formatWithDelimiters(cents, 0, " ", ",", directionFor50); break; case "amount_with_apostrophe_separator": value = formatWithDelimiters(cents, 2, "'", "."); break; } return formatString.replace(placeholderRegex, value); } catch (e) { console.log(e.message); price = cents / 100; return price.toLocaleString(undefined, { style: "currency", currency: fallbackCurrency }); } }, convertMoney: function (value, rate, currency, round) { if (value <= 0) { return 0; } value *= rate; var roundUp = ["USD", "CAD", "AUD", "NZD", "SGD", "HKD", "GBP"]; var roundTo100 = ["JPY"]; var roundTo95 = ["EUR"]; if (round) { if (roundUp.indexOf(currency) !== -1) { value = Math.ceil(value); } else if (roundTo100.indexOf(currency) !== -1) { value = Math.ceil(value / 100) * 100; } else if (roundTo95.indexOf(currency) !== -1) { value = Math.ceil(value) - 0.05; } } return value; } }; function formatPriceMoney(price){ var multiple_price = price*100; var formatted_price = recurpayCart.recurMoney.formatPrice(multiple_price); return formatted_price; } function callCart(){ $.getJSON('/cart', function(response) { createGlobalCart(response); }); } const cxRunTime = window.fetch; window.fetch = function () { return new Promise((resolve, reject) => { cxRunTime .apply(this, arguments) .then((response) => { if ( response.url.indexOf("/cart/add") >= 0 || response.url.indexOf("/cart/change") >= 0 || response.url.indexOf("/cart/update") >= 0 || response.url.indexOf("/cart/clear") >= 0 ) { setTimeout(function() {callCart()}, 1000); } resolve(response); }) .catch((error) => { reject(error); }); }); }; function createGlobalCart(cart){ recurpayCart.items = []; var allProducts = []; if(cart.items.length >0){ for(var i=0; i < cart.items.length; i++){ var Planid = '', item = cart.items[i], property = item.properties, sellingPlan = {}, sellingPlanId = '', subscriptionItem = false, lineProperty = []; if(item.selling_plan_allocation !== undefined && item.selling_plan_allocation !== null){ sellingPlan = item.selling_plan_allocation.selling_plan; sellingPlanId = item.selling_plan_allocation.selling_plan.id; if(sellingPlanId !== undefined && sellingPlanId !== null){ subscriptionItem = true; } } allProducts.push(cart.items[i].product_id); recurpayCart.items.push({ product_id: cart.items[i].product_id, variant_id: cart.items[i].id, selling_plan_id: sellingPlanId, subscription: subscriptionItem, item_details: cart.items[i], plans: [], }) } getCartPlans(allProducts); } } function getCartPlans(products){ $.ajax({ url: recurpayCart.pdpAPI, type: 'POST', async:true, data: {"products": products,"settings": true}, success: function(response) { if(response != "ERROR") { if(response.plans.length > 0){ if(response.settings.translations !== null && !$.isEmptyObject(response.settings.translations)){ recurpayCart.settings = response.settings; } $(response.plans).each(function(){ var $this = $(this); var pdpHTML = ''; var getProductId = $this[0].product.id; var $this = $(this); if($this[0].product.plans.length >0){ var indexes = recurpayCart.items.map((elm, idx) => elm.product_id == getProductId ? idx : '').filter(String); for (var i=0; i0){ for (var i=0; i<$(getSelector).length; i++){ var cartSelector = $(getSelector)[i]; var qtySelectors = $(cartSelector).find('[name="updates[]"], .quantity-selector input'); var linkSelectors = $(cartSelector).find('a[href*="/products/"]'); var overrideAlignment = false; if($(qtySelectors).length <= 0 && $(linkSelectors).length <=0 && $(cartSelector).length >0){ if($(cartSelector).parents("#Cart-Drawer").length >0){ cartSelector = $(getSelector).eq(i).parents("#Cart-Drawer"); qtySelectors = $(cartSelector).find('[name="updates[]"], .quantity-selector input'); linkSelectors = $(cartSelector).find('a[href*="/products/"]'); } else if($(cartSelector).parents(".cart-drawer").length >0){ cartSelector = $(getSelector).eq(i).parents(".cart-drawer"); qtySelectors = $(cartSelector).find('[name="updates[]"], .quantity-selector input'); linkSelectors = $(cartSelector).find('a[href*="/products/"]'); } } if($(cartSelector).is("#cart-notification-form")){ var cartNotificationSelector = $(cartSelector).parents("#cart-notification"); for(var j =0; j < $(cartNotificationSelector).find("#cart-notification-product").length; j++){ var getWidgetCode = recurpayCartWidget(j); if($(cartNotificationSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(cartNotificationSelector).find("#cart-notification-product").addClass("cart-subscription-notification-product"); $(cartNotificationSelector).find("#cart-notification-product").after("
") } $(cartNotificationSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").html(getWidgetCode); } } if($(qtySelectors).length > 0){ for(var j=0; j<$(qtySelectors).length; j++){ var getWidgetCode = recurpayCartWidget(j); if($(qtySelectors).eq(j).parents("cart-drawer").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest("tr").after("
"); } else if($(qtySelectors).eq(j).closest("tr").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ if($(qtySelectors).eq(j).closest("tr").hasClass("cart-item") && $(qtySelectors).eq(j).closest("tr").find(".cart-item__details").length){ $(qtySelectors).eq(j).closest("tr").find(".cart-item__details").append("
"); } else{ $(qtySelectors).eq(j).closest("tr").after("
"); } } else if($(qtySelectors).eq(j).closest("[data-cart-item]").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest("[data-cart-item]").after("
"); } else if($(qtySelectors).eq(j).closest(".CartItem").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ if($(qtySelectors).eq(j).closest(".CartItem").find(".CartItem__Info").length){ $(qtySelectors).eq(j).closest(".CartItem").find(".CartItem__Info").after("
"); } else{ $(qtySelectors).eq(j).closest(".CartItem").after("
"); } } else if($(qtySelectors).eq(j).closest(".cart__item").length > 0){ if($(qtySelectors).eq(j).closest(".cart__item").hasClass("hide")){ if($(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart__item").after("
"); } else{ $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").addClass("recurpay-hide"); } } else if($(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart__item").after("
"); } } else if($(qtySelectors).eq(j).closest(".cart-item__grid").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart-item__grid").after("
"); } else if($(qtySelectors).eq(j).closest(".cart-item").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart-item").after("
"); } else if($(qtySelectors).eq(j).closest(".cart__row").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart__row").after("
"); } else if($(qtySelectors).eq(j).closest(".cart-row").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).closest(".cart-row").after("
"); } else if($(qtySelectors).eq(j).closest(".ajax-cart__item-qty").length > 0 && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ if($(qtySelectors).eq(j).closest(".ajax-cart__item-qty").parents('ul').length >0){ $(qtySelectors).eq(j).closest(".ajax-cart__item-qty").parents('ul').after("
"); } else{ $(qtySelectors).eq(j).closest(".ajax-cart__item-qty").after("
"); } } else if($(qtySelectors).eq(j).parent().css('display') == 'flex' && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ if($(qtySelectors).eq(j).parent().parent().css('display') == 'flex' && $(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).parent().parent().after("
"); } else if($(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).parent().after("
"); } overrideAlignment = true; } else if($(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).parent().after("
"); eventLog = "reverify"; overrideAlignment = true; } else{ if($(cartSelector).find(".upgrade-subscription-cart[data-item-index='"+j+"']").length <=0){ $(qtySelectors).eq(j).after("
"); eventLog = "reverify"; overrideAlignment = true; } } $(".upgrade-subscription-cart[data-item-index='"+j+"']").html(getWidgetCode); if(overrideAlignment){ if($(".upgrade-subscription-cart[data-item-index='"+j+"']").width() < 300){ var getParent = $(".upgrade-subscription-cart[data-item-index='"+j+"']").parent(); var getAdjParent = $(".upgrade-subscription-cart[data-item-index='"+j+"']").parent().parent(); $(".upgrade-subscription-cart[data-item-index='"+j+"']").remove(); $(getParent).after("
"); $(".upgrade-subscription-cart[data-item-index='"+j+"']").html(getWidgetCode); if($(".upgrade-subscription-cart[data-item-index='"+j+"']").width() < 300){ $(".upgrade-subscription-cart[data-item-index='"+j+"']").remove(); $(getAdjParent).after("
"); $(".upgrade-subscription-cart[data-item-index='"+j+"']").html(getWidgetCode); } } } } } else if($(linkSelectors).length > 0){ window.linkArr = []; $(linkSelectors).each(function(){ var $this = $(this); linkArr.push($this.attr("href")); }); linkArr = linkArr.filter(function(itm, i, a) { return i == a.indexOf(itm); }); if(linkArr.length > 0){ for(var j=0; j"); } $(".upgrade-subscription-cart[data-item-index='"+j+"']").html(getWidgetCode); eventLog = "reverify"; } } } else{ if(!$(cartSelector).is("#cart-notification-form") && !$(cartSelector).is("#slidecarthq")){ // logCartEvent("Failed to show cart snippet - Cart Qty", "critical"); } } } if($(".upgrade-subscription-cart").length <=0){ if(eventLog == "failure"){ logCartEvent("Failed to show cart snippet - Cart Qty", "critical"); } else{ logCartEvent("Cart snippet added but needs a reverification", "warning"); } } } else{ logCartEvent("Failed to show cart snippet - Cart Qty", "critical"); } } function logCartEvent(addon,type){ $.ajax({ url: recurpayCart.logURL, type: 'POST', async:true, dataType: 'json', data: { module:"cart_upsell", level: type, payload:{ store : recurpayCart.domainURL, remark: addon } }, success: function(response) { console.log("event logged"); } }); } function recurpayCartWidget(index){ var cartWidget = ""; var showFlag = true; var sellingPlanId = recurpayCart.items[index].selling_plan_id; if(recurpayCart.items[index].selling_plan_id == undefined || recurpayCart.items[index].selling_plan_id == ""){ if(recurpayCart.items[index].plans.length >0){ sellingPlanId = recurpayCart.items[index].plans[0].selling_plan_id; } else{ showFlag = false; } } if(showFlag){ if(recurpayCart.checkout == 'recurpay'){ if(recurpayCart.items[index].item_details.properties != null && recurpayCart.items[index].item_details.properties != undefined && recurpayCart.items[index].item_details.properties != ""){ var planId = recurpayCart.items[index].item_details.properties._PlanId; if(planId != undefined && planId != ""){ var getIndex = recurpayCart.items[index].plans.map((elm, idx) => elm.id == parseInt(planId) ? idx : '').filter(String); } else{ var getIndex = 0; } } else{ var getIndex = 0; } } else{ var getIndex = recurpayCart.items[index].plans.map((elm, idx) => elm.selling_plan_id == sellingPlanId ? idx : '').filter(String); } var getSellingObject = recurpayCart.items[index].plans[getIndex]; var getDiscount = getSellingObject.pricing_policy[0].discount.value; var getQty = recurpayCart.items[index].item_details.quantity; var getPrice = parseFloat(recurpayCart.items[index].item_details.final_price*getQty)/100; var discountedPrice = getPrice - (getPrice * getDiscount / 100); var formattedPrice = formatPriceMoney(discountedPrice); var formattedHtmlPrice = '' if(recurpayCart.items[index].selling_plan_id == undefined || recurpayCart.items[index].selling_plan_id == "" && recurpayCart.items[index].item_details.properties == null || recurpayCart.items[index].item_details.properties._PlanId == undefined || recurpayCart.items[index].item_details.properties._PlanId == ""){ if(recurpayCart.items[index].plans.length >0){ cartWidget = '
' cartWidget += '
' cartWidget += '' cartWidget += '' cartWidget += '
' } } else{ if(recurpayCart.checkout == 'recurpay'){ var getOriginalPrice = getPrice + (getPrice - discountedPrice); } else{ var getOriginalPrice = parseFloat(recurpayCart.items[index].item_details.selling_plan_allocation.compare_at_price*getQty)/100; } var getSavings = getOriginalPrice-getPrice; var getSavingsHTML = formatPriceMoney(getOriginalPrice-getPrice); cartWidget = '
' cartWidget += '
' cartWidget += '
'+recurpayCart.settings.translations.cart_subscription_dropdown_label+'
' cartWidget += '' cartWidget += '
' if(getSavings >0){ cartWidget += '
' cartWidget += '' cartWidget += ''+recurpayCart.settings.translations.cart_subscription_success_label+'' cartWidget += '
' } cartWidget += '
' } if(getDiscount <=0){ cartWidget = cartWidget.replace('[[DISCOUNT_PERCENTAGE]]%', ''); } else{ cartWidget = cartWidget.replace('[[DISCOUNT_PERCENTAGE]]', getDiscount); } cartWidget = cartWidget.replace('[[AMOUNT]]', formattedHtmlPrice); cartWidget = cartWidget.replace('[[SAVED_AMOUNT]]', getSavingsHTML); } return cartWidget; } function updateCartData(elem, getSellingPlan){ var $this = $(elem); var getIndex = parseInt($this.parents(".upgrade-icon-wrapper").attr("data-index")); var getQty = parseInt($this.parents(".upgrade-icon-wrapper").attr("data-qty")); var getProperties = recurpayCart.items[getIndex].item_details.properties; var getAttributes = ''; if(!$.isEmptyObject(getProperties)){ getProperties['_PlanId'] = null; getProperties['Plan'] = null; getProperties['_is_cart_influenced'] = null; getAttributes = { '_is_cart_influenced' : null } } if($.isEmptyObject(getProperties)){ getProperties = {}; getAttributes = { '_is_cart_influenced' : null } } var getParams = { 'line': getIndex+1, 'quantity': getQty, 'selling_plan': getSellingPlan, 'properties':getProperties, 'attributes':getAttributes } if(getSellingPlan !== undefined && getSellingPlan !== ""){ if(recurpayCart.checkout == 'recurpay'){ var planIndex = recurpayCart.items[getIndex].plans.map((elm, idx) => elm.id == parseInt(getSellingPlan) ? idx : '').filter(String); getParams.selling_plan = ""; } else{ var planIndex = recurpayCart.items[getIndex].plans.map((elm, idx) => elm.selling_plan_id == getSellingPlan ? idx : '').filter(String); } var getPlanId = recurpayCart.items[getIndex].plans[planIndex].id; var getSellingPlanName = recurpayCart.items[getIndex].plans[planIndex].name; getParams.properties['_PlanId'] = getPlanId; getParams.properties['Plan'] = getSellingPlanName; getParams.properties['_is_cart_influenced'] = 'Influenced by Recurpay cart subscriptions' getParams.attributes = { _is_cart_influenced : 'Influenced by Recurpay cart subscriptions' } } var cartURL = "/cart/change.js"; $this.parents(".upgrade-icon-wrapper").addClass("btn-loading"); $.ajax({ url: cartURL, type: 'POST', async:true, dataType: 'json', data: getParams, success: function(response) { if($this.parents('cart-drawer').length >0){ $.ajax({ url: '/?section_id=cart-drawer', type: 'GET', dataType: 'html', success:function(carthtml) { $('cart-drawer').html($(carthtml).find('cart-drawer').html()); createGlobalCart(response); $this.parents(".upgrade-icon-wrapper").removeClass("btn-loading"); } }); } else if(window.SLIDECART_UPDATE !== undefined){ window.SLIDECART_UPDATE(); createGlobalCart(response); } else{ window.location.href="/cart"; $this.parents(".upgrade-icon-wrapper").removeClass("btn-loading"); } } }); } $(document).on('click',".subscribe-text-button", function(e){ var getSellingPlan = $(this).parents(".upgrade-icon-wrapper").attr("data-default-selling-plan"); if(recurpayCart.checkout == 'recurpay'){ getSellingPlan = $(this).parents(".upgrade-icon-wrapper").attr("data-plan-id"); } updateCartData($(this),getSellingPlan); }); $(document).on('change',".cart-plan-dropdown", function(e){ e.preventDefault(); var getSellingPlan = $(this).val(); if(recurpayCart.checkout == 'recurpay'){ getSellingPlan = $(this).find('option:selected').attr('data-plan-id'); } updateCartData($(this),getSellingPlan); }); var getCartUpsellSession = sessionStorage.getItem("recurpay_cart_upsell"); if(getCartUpsellSession == "true" || getCartUpsellSession == undefined || getCartUpsellSession == null){ sessionStorage.setItem("recurpay_cart_upsell", "true"); callCart(); } } //Append jQuery if it is not there, then call to recurpayCartSubscription //Otherwise directly call to recurpayCartSubscription if ((typeof(jQuery) == 'undefined')) { initScript('//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js', function() { window.recurpayCartScript = jQuery.noConflict(true); recurpayCartSubscription(recurpayCartScript); }) } else { recurpayCartSubscription(jQuery); } })();

https://khbxm.wage.asia https://vtmjf.wage.asia https://hertk.wage.asia https://nemjg.wage.asia https://riyvs.wage.asia https://vibad.wage.asia https://yajev.wage.asia https://jansm.wage.asia https://hwxan.wage.asia https://tbkwf.wage.asia https://bfgjj.wage.asia https://rkfvj.wage.asia https://aiigm.wage.asia https://qivxj.wage.asia https://vwvnq.wage.asia