What is Prevagen? Learn More about Prevagen Skip to content Skip to content
Home Why Prevagen Prevagen Reviews Rewards Shop
Prevagen
Home What is Prevagen The Research Behind Prevagen Common Questions Answered Prevagen Reviews Rewards Shop
' if(count !== 0){ accountTemplate += '
Pause, reschedule or cancel at your convenience.
' accountTemplate += '
View and edit subscription
' } else{ accountTemplate += '
There are no active subscriptions
' accountTemplate += '
' } accountTemplate += '' return accountTemplate; } $.ajax({ url: recurpay.accountAPI, type: 'GET', success: function(response){ var accountHTML = ''; if(response != "ERROR" && response.success == true) { accountHTML = recurAccount(response.data.subscription.count); } else { accountHTML = recurAccount(0); } if($(accountSelector).length){ $(accountSelector).html(accountHTML); } }, error: function(jqXhr, textStatus, errorThrown){ console.log( errorThrown ); } }); $(document).on('click', subscriptionSelector, function(e) { e.preventDefault(); var checkoutForm = $(""); $('body').append(checkoutForm); checkoutForm.submit(); }); } // CART PAGE function recurCart(cartData){ var checkoutData = [], cartItems = cartData.items, cartAttributes = [], cartNote = cartData.note, recurpayCheckout = false; $.each( cartData.attributes, function(key, value ) { if(key != "Plan" && key != '_PlanId'){ cartAttributes.push({ name: key, value:value }); } }); for(var i=0; i < cartItems.length; i++){ var Planid = '', item = cartItems[i], property = item.properties, lineProperty = []; if(property){ if(property._PlanId){ Planid = property._PlanId recurpayCheckout = true; } $.each( property, function(key, value ) { if(key != "Plan" && key != '_PlanId'){ lineProperty.push({ name: key, value:value }); } }); } if(Planid == ''){ checkoutData.push({ quantity: item.quantity, variant_id: item.id, properties: lineProperty, type: 'ONETIME', currency:'INR' }); } else{ checkoutData.push({ quantity: item.quantity, variant_id: item.id, properties: lineProperty, plan_id: Planid, type: 'SUBSCRIPTION', currency:'INR' }); } } if(recurpayCheckout) { var getCheckoutData = JSON.stringify(checkoutData), getCartAttributes = JSON.stringify(cartAttributes), cartNote = $('[name="note"]').val(); checkoutForm = $(""); $('body').append(checkoutForm); checkoutForm.submit(); } else { document.location.href = "/checkout"; } } // VARIANT SELECTOR function getProductHandle(href) { if (typeof href === "undefined") { var href = window.location.href; href = href.replace("/products/products", "/products"); } if (/\/products\/([^\?\/\n]+)/.test(href)) { var found = href.match(/\/products\/([^\?\/\n]+)/); if (typeof found[1] !== "undefined") { try { return decodeURIComponent(found[1]).replace("#", ""); } catch (e) { return found[1].replace("#", ""); } } } return false; } recurpay.recurMoney = { formatPrice: function (price, convertCurrency) { if (typeof Shopify !== "undefined" && Shopify.hasOwnProperty("currency") && Shopify.currency.hasOwnProperty("rate")) { var currency = Shopify.currency.active; var exchangeRate = Shopify.currency.rate; var moneyFormat = "" + currency; var currencyFormat = ""; if (typeof convertCurrency === "undefined") { convertCurrency = false; } if (convertCurrency && exchangeRate !== "1.0") { price = this.convertMoney(price, exchangeRate, currency); } var bodyAttrMoneyFormat = $("body").attr("data-money-format"); if (currencyFormat !== "") { moneyFormat = currencyFormat; } else { if (typeof Shopify !== "undefined" && typeof Shopify.currency_settings !== "undefined" && typeof Shopify.currency_settings.money_format !== "undefined") { moneyFormat = Shopify.currency_settings.money_format; } else if (typeof window.money_format !== "undefined") { moneyFormat = window.money_format; } else if (typeof window.Theme !== "undefined" && typeof window.Theme.moneyFormat !== "undefined") { moneyFormat = window.Theme.moneyFormat; } else if (typeof window.theme !== "undefined" && typeof window.theme.moneyFormat !== "undefined") { moneyFormat = window.theme.moneyFormat; } else if (typeof window.theme !== "undefined" && typeof window.theme.money_format === "string") { moneyFormat = window.theme.money_format; } else if (typeof window.theme !== "undefined" && typeof window.theme.settings !== "undefined" && typeof window.theme.settings.moneyFormat !== "undefined") { moneyFormat = theme.settings.moneyFormat; } else if (typeof window.theme !== "undefined" && typeof window.theme.strings !== "undefined" && typeof window.theme.strings.moneyFormat === "string") { moneyFormat = window.theme.strings.moneyFormat; } else if (typeof window.Currency !== "undefined" && typeof window.Currency.money_format !== "undefined" && typeof window.Currency.money_format[currency] === "string") { moneyFormat = window.Currency.money_format[currency]; } else if (typeof window.Currency !== "undefined" && typeof window.Currency.money_format === "string") { moneyFormat = window.Currency.money_format; } else if (typeof bodyAttrMoneyFormat !== "undefined" && typeof bodyAttrMoneyFormat === "string" && bodyAttrMoneyFormat !== "") { moneyFormat = bodyAttrMoneyFormat; } else if (typeof wsgMoneyFormat === "string") { moneyFormat = wsgMoneyFormat; } else if (typeof price_format === "string") { moneyFormat = price_format; } else { price = price / 100; return price.toLocaleString(undefined, { style: "currency", currency: currency || this.getDefaultCurrency() }); } } return this.formatMoney(price, moneyFormat, currency || this.getDefaultCurrency()); } return ""; }, formatMoney: function (cents, format, fallbackCurrency, directionFor50) { if (typeof directionFor50 === "undefined") { var directionFor50 = "up"; } try { if (typeof cents == "string") { cents = cents.replace(".", ""); } var value = ""; var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/; var formatString = format; function defaultOption(opt, def) { return typeof opt == "undefined" ? def : opt; } function formatWithDelimiters(number, precision, thousands, decimal, directionFor50) { precision = defaultOption(precision, 2); thousands = defaultOption(thousands, ","); decimal = defaultOption(decimal, "."); directionFor50 = defaultOption(directionFor50, "up"); if (isNaN(number) || number == null) { return 0; } var originalNumber = number; number = (number / 100.0).toFixed(precision); if (directionFor50 === "down") { if (originalNumber / 100 - number === -0.5) { number -= 1; number = number.toString(); } } var parts = number.split("."), dollars = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + 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 fetchVariants(){ if(getProductHandle() !== false){ var productURL = "/products/"+getProductHandle()+".json"; $.ajax({ url: productURL, type: 'GET', success: function(response){ recurpay.productData = response; var params = new Proxy(new URLSearchParams(window.location.search), { get: (searchParams, prop) => searchParams.get(prop), }); recurpay.product.selectedVariant = params.variant recurDiscountedPrice(recurpay.product.selectedVariant); }, error: function(jqXhr, textStatus, errorThrown){ console.log( errorThrown ); } }); } } function calculatePrice(variant_id){ var variant_json = {}; var variant_price = 0; if(variant_id !== undefined && variant_id !== null){ variant_id = parseInt(variant_id); var variant_data = recurpay.productData.product.variants.filter(function(searchId) { return searchId.id == variant_id; }); if(variant_data.length >=1){ var get_variant_price = variant_data[0].price; // var get_variant_price = variant_data[0].price*100; // variant_price = recurpay.recurMoney.formatPrice(get_variant_price); } } else{ var get_variant_price = recurpay.productData.product.variants[0].price; // var get_variant_price = recurpay.productData.product.variants[0].price*100; // variant_price = recurpay.recurMoney.formatPrice(get_variant_price); } return get_variant_price; } 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 () { setTimeout(function() { recurpay.product.selectedVariant = $(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 () { setTimeout(function() { recurpay.product.selectedVariant = $(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 () { setTimeout(function() { recurpay.product.selectedVariant = $(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 () { setTimeout(function() { recurpay.product.selectedVariant = $(atcFormSelector).find('input[name="id"], select[name="id"], input#SelectedId').val(); recurDiscountedPrice(recurpay.product.selectedVariant); },100); }); function recurDiscountedPrice(variant){ $("#recurpay__frequency_label option").each(function(){ var $this = $(this); var getDiscount = $(this).attr("data-plan-discount"); var getPlanName = $(this).attr("data-plan-name"); var getVariantPrice = calculatePrice(variant); var discountedPrice = getVariantPrice - (getVariantPrice * getDiscount / 100); if(parseFloat(getVariantPrice) !== parseFloat(discountedPrice)){ $this.html(getPlanName+" ("+formatPriceMoney(discountedPrice)+")"); if($this.is(':selected')){ $this.parents('.recurpay__widget').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_compare_price").html("
"+formatPriceMoney(getVariantPrice)+" "); } } else{ $this.html(getPlanName+"("+formatPriceMoney(discountedPrice)+")"); if($this.is(':selected')){ $this.parents('.recurpay__widget').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_compare_price").html(""); } } if($this.is(':selected')){ $this.parents('.recurpay__widget').find(".recurpay__widget_container[data-type='subscription-purchase']").find(".recurpay__group_selling_price").html("
"+formatPriceMoney(discountedPrice)+" "); } $this.parents('.recurpay__widget').find(".recurpay__widget_container[data-type='onetime-purchase']").find(".recurpay__group_selling_price").html("
"+formatPriceMoney(getVariantPrice)+" "); $this.find(".recurpay_selling_price").html("
"+formatPriceMoney(discountedPrice)+" "); $this.find(".recurpay__plan--prices").show(); }); } // PRODUCT PAGEfunction recurPDP(data){ var prepaidCount = 0, regularCount = 0, prepaidDiscount = [], maxPrepaidDiscount = '', getPlanDesc = ''; 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.discount.value); } else{ regularCount += regularCount+1; } } if(plan.discount.type == "percentage" && plan.discount.value != 0){ PlanDiscount = plan.discount.value; DiscountPercentageHtml = '
(' + plan.discount.value + '% Off) '; } if(plan.description) { DescriptionHtml = ''; } PlanHtml += '
'; if(recurpay.checkout == "shopify"){ if(key == 0){ PlanHtml += ''+plan.name+' ' } else{ PlanHtml += ''+plan.name+' ' } } else{ if(key == 0){ PlanHtml += ''+plan.name+' ' } else{ PlanHtml += ''+plan.name+' ' } } GetPlans += PlanHtml; getPlanDesc += DescriptionHtml; }) if(regularCount > 0 && prepaidCount >0){ maxPrepaidDiscount = Math.max.apply(Math,prepaidDiscount); } if(recurpay.product.only_subscription !== "" && recurpay.product.only_subscription == "true"){ pdpTemplate += '
' } else{ pdpTemplate += '
' } pdpTemplate += '
' pdpTemplate += '' pdpTemplate += '' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '
'+recurpay.labelOnetimeText+'
' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '' pdpTemplate += '' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += '
'+recurpay.labelSubscriptionText+'
' pdpTemplate += '
'+recurpay.labelSubscriptionDesc+'
' pdpTemplate += '
' pdpTemplate += '
' pdpTemplate += ''+recurpay.dropdownLabel+' ' pdpTemplate += '' pdpTemplate += '
'+getPlanDesc+'
' 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){ $.ajax({ url: recurpay.pdpAPI, type: 'GET', async: true, success: function(response) { var pdpHTML = ''; if(response != "ERROR" && response.success == true) { if(response.data.plans.length > 0){ pdpHTML = recurPDP(response.data); fetchVariants(); } } if($(pdpSelector).length && recurpay.product.available == "true"){ $(pdpSelector).html(pdpHTML); if((window.location.href.indexOf("/products/") > -1) && (window.location.href.indexOf("snippet_status=false") > -1)){ $(pdpSelector).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. ") } } } }); } 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 += '
' 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 += '
' modalHTML += '' modalHTML += ' ' modalHTML += '
' if($('[data-recurpay-visibility-modal]').length <= 0){ if($('body').length){ $('body').append(modalHTML); } else if($('html').length){ $('html').append(modalHTML); } } } } function recurProperties(){ if($("[name='recurpay__group_main'][value='subscription']").is(":checked")){ var planName = $('[name="recurpay-input"] option:selected').attr('data-plan-name'), planId = $('[name="recurpay-input"] option:selected').attr('data-plan'); $('#recurpay_plan_name').attr("name","properties[Plan]").val(planName); $('#recurpay_plan_id').attr("name","properties[_PlanId]").val(planId); $('.recurpay__description[data-description-id]').hide(); $('.recurpay__description[data-description-id="'+planId+'"]').show(); if(recurpay.checkout == "shopify"){ var sellingPlanId = $('[name="recurpay-input"] option:selected').attr('data-selling-plan'); $('#recurpay_selling_plan_id').attr("name","selling_plan").val(sellingPlanId); } } else{ $('#recurpay_plan_name').attr("name",""); $('#recurpay_plan_id').attr("name",""); if(recurpay.checkout == "shopify"){ $('#recurpay_selling_plan_id').attr("name",""); } } } function addSubscription(){ debugger; var variantSelector = $(pdpSelector).parents(atcFormSelector).find('[name="id"]'), quantitySelector = $(pdpSelector).parents(atcFormSelector).find('[name="quantity"]'), subscriptionPlanId = $('[name="recurpay-input"] option:selected').attr('data-plan'), subscriptionPlanName = $('[name="recurpay-input"] option:selected').attr('data-plan-name'), subscriptionPlanType = $('[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 = $('[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){ $(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) { $('.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"){ // $(atcFormSelector).find(atcSelector).addClass("recurpay-hide"); // $(buynowSelector).addClass("recurpay-hide"); $('.recurpay__plans').show(); $('.recurpay__group_content_wrapper').slideDown(); } else{ // $(atcFormSelector).find(atcSelector).removeClass("recurpay-hide"); // $(buynowSelector).removeClass("recurpay-hide"); $('.recurpay__plans').hide(); $('.recurpay__group_content_wrapper').slideUp(); } recurProperties(); // recurDiscountedPrice(recurpay.product.selectedVariant) }); $(document).on('change',"[name='recurpay-input']", function(e) { recurDiscountedPrice(recurpay.product.selectedVariant); recurProperties(); }); $(document).on('click',".recurpay-modal-cancel-btn", function(e) { $('[data-recurpay-visibility-modal]').hide(); }); if(recurpay.product.only_subscription !== "" && recurpay.product.only_subscription == "true"){ $("[name='recurpay__group_main'][value='subscription']").prop("checked",true).change(); } $(document).on('click',"[data-recurpay-action]", function(e) { addSubscription(); }); 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); } })();
{{/if}}
{{#if show_maximum_qty}} {{/if}} {{#if show_discount_value}} {{/if}} {{#if show_discounted_price}} {{/if}}
{{{requirement_label}}} {{{maximum_requirement_label}}} {{{discount_label}}} {{{discounted_price_label}}}