Loyalty point custom code - for collection page and product variant change

Loyalty point custom code - for collection page and product variant change

Product Variant change

<script>
$(document).ready(function() {
var productVariants = JSON.parse($('variant-selects script[type="application/json"]').text());

$('variant-selects select').change(function() {
var selectedOptions = [];

$('variant-selects select').each(function() {
selectedOptions.push($(this).val());
});

var selectedVariant = productVariants.find(function(variant) {
return variant.options.every(function(option, index) {
return option === selectedOptions[index];
});
});

if (selectedVariant) {
var roundedPrice = Math.floor(selectedVariant.price / 100);
var AioAppMakePoint = AioAppConfig.ischeckcustomeractiveremote.loyalty_points.make_a_purchase.points;

var actualpoint = roundedPrice*AioAppMakePoint;
$('.aaa-lyt-make-a-purchase-point-widget div b').text( actualpoint);
}
});
});

</script>

Collection page filter

<script>function renderHelloInNewDivs() {    if (typeof AioAppConfig === 'undefined') {        console.error('AioAppConfig is not defined.');        return;    }    $('.aaa-lyt-make-a-purchase-point-collection-widget').each(function() {        var datapprice = $(this).attr("data-custom-pprice");        if (!$(this).attr('data-processed')) {            $(this).attr('data-processed', 'true');            var AioAppMakePoint = AioAppConfig.ischeckcustomeractiveremote.loyalty_points.make_a_purchase.points;              var actualpoint = datapprice * AioAppMakePoint;            $(this).html('<div class="aaa-lyt-make-a-purchase-icon"><svg width="23" height="22" viewBox="0 0 23 22" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.6772 5.12592H18.5206C18.7422 4.70753 18.8595 4.24184 18.8627 3.7684C18.8634 3.15229 18.6733 2.55108 18.3186 2.04735C17.9638 1.54361 17.4618 1.16206 16.8815 0.955098C16.3012 0.748136 15.6711 0.725916 15.0776 0.89149C14.4842 1.05706 13.9566 1.40231 13.5672 1.87981C13.5379 1.92216 12.3172 3.54033 11.532 4.58508C10.7458 3.53925 9.524 1.91456 9.48924 1.87004C9.09862 1.39487 8.57066 1.05206 7.97766 0.888563C7.38466 0.725065 6.75562 0.748868 6.17668 0.956712C5.59773 1.16456 5.09719 1.54628 4.74359 2.04961C4.38999 2.55294 4.20062 3.15327 4.20142 3.7684C4.20456 4.24184 4.32191 4.70753 4.54351 5.12592H3.3869C2.7391 5.12678 2.11807 5.3845 1.66001 5.84257C1.20194 6.30064 0.944221 6.92166 0.943359 7.56946V11.3705C0.943359 11.5866 1.02917 11.7937 1.18192 11.9465C1.33468 12.0992 1.54185 12.185 1.75787 12.185H2.02938V17.8866C1.9656 18.4369 2.02707 18.9944 2.20919 19.5176C2.3913 20.0407 2.68935 20.5159 3.08104 20.9076C3.47272 21.2992 3.9479 21.5973 4.47103 21.7794C4.99417 21.9615 5.55171 22.023 6.10195 21.9592H16.9621C17.5124 22.023 18.0699 21.9615 18.5931 21.7794C19.1162 21.5973 19.5914 21.2992 19.9831 20.9076C20.3747 20.5159 20.6728 20.0407 20.8549 19.5176C21.037 18.9944 21.0985 18.4369 21.0347 17.8866V12.185H21.3062C21.5222 12.185 21.7294 12.0992 21.8822 11.9465C22.0349 11.7937 22.1207 11.5866 22.1207 11.3705V7.56946C22.1199 6.92166 21.8621 6.30064 21.4041 5.84257C20.946 5.3845 20.325 5.12678 19.6772 5.12592ZM20.4917 7.56946V10.556H12.3466V6.75495H19.6772C19.8931 6.75524 20.1001 6.84114 20.2528 6.99383C20.4055 7.14652 20.4914 7.35353 20.4917 7.56946ZM14.8325 2.90718C14.9578 2.75118 15.1168 2.62551 15.2975 2.53957C15.4782 2.45363 15.676 2.40963 15.8761 2.41087C16.2362 2.41087 16.5814 2.5539 16.836 2.80848C17.0906 3.06307 17.2336 3.40836 17.2336 3.7684C17.2336 4.12843 17.0906 4.47373 16.836 4.72831C16.5814 4.9829 16.2362 5.12592 15.8761 5.12592H13.1611C13.8963 4.15068 14.7814 2.97343 14.8325 2.90718ZM5.83044 3.7684C5.83102 3.40854 5.97423 3.06358 6.22869 2.80912C6.48315 2.55466 6.82811 2.41145 7.18797 2.41087C7.38443 2.40888 7.57885 2.45085 7.75699 2.53372C7.93513 2.61659 8.09248 2.73825 8.21751 2.88981C8.27399 2.96691 9.16561 4.1485 9.90302 5.12592H7.18797C6.82811 5.12535 6.48315 4.98214 6.22869 4.72768C5.97423 4.47322 5.83102 4.12826 5.83044 3.7684ZM2.57239 7.56946C2.57268 7.35353 2.65858 7.14652 2.81127 6.99383C2.96396 6.84114 3.17097 6.75524 3.3869 6.75495H10.7175V10.556H2.57239V7.56946ZM3.65841 17.8866V12.185H10.7175V20.3302H6.10195C4.3893 20.3302 3.65841 19.5993 3.65841 17.8866ZM19.4057 17.8866C19.4057 19.5993 18.6748 20.3302 16.9621 20.3302H12.3466V12.185H19.4057V17.8866Z" fill="#FF2A65"></path></svg></div> <div>GanarĂ¡s <b>' + actualpoint + '</b> puntos por esta compra.</div>');        }    });}function waitForAioAppConfig() {    if (typeof AioAppConfig !== 'undefined') {        renderHelloInNewDivs();        setInterval(renderHelloInNewDivs, 2200);    } else {        setTimeout(waitForAioAppConfig, 100);    }}$(document).ready(function() {    waitForAioAppConfig();});</script>
    • Related Articles

    • Ultimate Guide to AiTrillion's Loyalty Rewards Program

      Watch the 5-minute loyalty setup video: Introduction This guide walks you through setting up a Loyalty Rewards Program in AiTrillion, explaining how it works and how you can track campaign performance to boost customer retention and sales. Loyalty ...
    • Custom loyalty rewards page

      Introduction In this article, we'll show you how to effortlessly set up and personalize a dedicated page of Loyalty Rewards. Follow these steps to set up a custom Loyalty Rewards Page: Step 1: Go to Loyalty Rewards > Display On Store. Then click on ...
    • Review Ratings on the Collection Page

      Introduction AiTrillion can help you display product review ratings on the collection page so that your customers are convinced to make a purchase. How it would look on your collection page: Here are the steps to show Review Ratings on the Collection ...
    • Create a loyalty page

      Introduction Discover the step-by-step process for crafting a Loyalty page template tailored to your brand's needs and customer engagement goals. Please follow the below steps to create the loyalty template: Step 1: First login to your Shopify admin. ...
    • Hide Membership product from products/collection page (Membership V2)

      Introduction In this article, we'll explore the intricacies of hiding memberships from product collections effectively. Here are the steps to hide membership from product collection -: Add a hidden tag to membership products: Go to your Shopify ...