Déjate seducir por la exquisitez de nuestro Chocolate Dark 62% Cacao con Galletas y Amaretto. Esta tableta de chocolate combina la riqueza del chocolate negro con...
Disfruta de una experiencia de sabor excepcional con la Tableta de Chocolate Vanini Dark Bagua. Intenso sabor a cacao. Textura Exquisita: El chocolate negro Vanini se...
Descubre la intensidad y la pureza del Chocolate Dark Bagua 95% Cacao, una tableta diseñada para los verdaderos amantes del chocolate negro. Con un 95% de...
Sumérgete en una experiencia de chocolate auténtico con nuestro Chocolate Dark con Nibs de Cacao 74%. Esta tableta de chocolate, elaborada con un 74% de cacao...
Un delicioso chocolate oscuro con 62% de cacao, enriquecido con vibrantes notas de naranja confitada. Este chocolate combina el intenso sabor del cacao con el dulzor...
Descubre una experiencia tropical con nuestro Chocolate Dark 62% Cacao con Mango y Fruta de la Pasión. Esta exquisita tableta de chocolate negro combina la riqueza...
Una tableta hecha con fino cacao orgánico de origen único en Uganda, enriquecida con crujientes pistachos salados y presentada en un envase innovador y sostenible. Así...
CHOCOLATE CON LECHE VEGANO Para elaborar el chocolate vegano sin lácteos se ha sustituido la leche por una alternativa de origen 100 % vegetal: la chufa....
Este chocolate es perfecto para aquellos que no pueden tomar azúcar y que tampoco quieren renunciar al chocolate negro. Se elabora con un contenido en cacao...
Sumérgete en el placer auténtico del chocolate con nuestra tableta Fondant Zero. Elaborado con los mejores granos de cacao, esta exquisita creación de la marca Torras...
El Chocolate Fondant Zero 95% Cacao de Torras es una experiencia intensa y indulgente para los amantes del chocolate oscuro. Con un alto contenido de cacao...
La Tableta de Chocolate con Jengibre y Maca de Torras ofrece una experiencia de sabor única, combinando el dulzor suave del chocolate con el toque especiado...
La tableta de chocolate Madame Chéri Pistacho & Chocolate Estilo Dubái es una verdadera joya de la confitería gourmet. Con una fusión exquisita entre la intensidad...
Composición: CACAO 81% AZÚCAR 18% MANTECA DE CACO 45% RECOMENDADO PARA: Cobertura Rellenos A la taza Cremas y espumas Origen Perú | Variedad Criollo- finca...
Se elabora con un contenido en cacao del 72%, manteca de cacao y azúcar. Su sabor es intenso, duradero ligeramente amargo, con aroma a frutas y especias....
Descubre la tableta de chocolate Torras con 79% de cacao, una delicia para los amantes del chocolate intenso. Elaborada con cacao de alta calidad, ofrece un...
El Chocolate Organic BIO 100% Cacao de Torras es una opción excepcional para los amantes del chocolate puro y auténtico. Elaborado con ingredientes orgánicos de la...
El Chocolate 90% Cacao de Torras es una elección sofisticada para quienes aprecian el chocolate oscuro con un toque de dulzura sutil. Con un cacao de...
Inicia sesión para finalizar tus compras con mayor rapidez.
Tu carrito
Al seleccionar una opción, se actualiza toda la página.
Ventana nueva
(() => {
document.addEventListener('DOMContentLoaded', async () => {
const hasNextVolumeDiscountSelector = document.querySelectorAll('.appstle-bundle-cart-next-volume-discount-stand-alone-selector')?.length > 0;
if (hasNextVolumeDiscountSelector) {
await executeCartLogic();
setupCartMutationObserver();
}
});
const executeCartLogic = async () => {
const discountElements = document.querySelectorAll('.appstle-bundle-cart-next-volume-discount-stand-alone-selector');
const cartItems = await getShopifyCartItems();
const bundleSettings = {"id":3650,"shop":"casa-perris.myshopify.com","showOnProductPage":null,"selector":null,"placement":null,"customCss":null,"customizeBundleOptionType":"RADIO","buyButtonSelector":null,"labels":"{\"switchSubscriptionLabel\":\"Subscribe & Save\",\"productDiscountCombinedWithOrderDiscount\":true,\"percentDiscountText\":\"Get {{discount_value}}% off on your purchase!\",\"discountUsageLimitExceedLabel\":\"You have exceeded the bundle usage limit\",\"requiredLoginValidationLabel\":\"Please log in to purchase this bundle!\",\"reviewOrderLabel\":\"Review Bundle\",\"loginAlertLinkLabel\":\"Click here to login\",\"chooseSectionProductsLabel\":\"Choose Section Products\",\"primaryDisabledColor\":\"#333333\",\"bundleMinimumOrderAmountLabel\":\"Add minimum {{minimum_amount}} order amount\",\"breadCrumbSelectSectionLabel\":\"Select Section\",\"breadCrumbProductsLabel\":\"Choose Products\",\"bundleQuantityRewardsLabel\":\"Add {{quantity}} item, get {{discount}}{{discount_type}} discount\",\"emptyProductImage\":\"https://cdn.shopify.com/s/files/1/0661/9224/4900/files/EmptyImage.jpg?v=1718447038\",\"shippingDiscountCombinedWithProductDiscount\":true,\"reviewOrderInfoLabel\":\"\",\"switchOnTimeLabel\":\"One Time\",\"volumeDiscountCombinedWithProductDiscount\":true,\"productDiscountCombinedWithProductDiscount\":true,\"bundleMaximumQuantityLabel\":\"Add maximum up to {{maximum_quantity}} product\",\"chooseProductsText\":\"Products\",\"enableManualBundleBlockIntegration\":false,\"volumeDiscountNextApplicableQuantityRewardsLabel\":\"Buy {{quantity}} get {{discount}}{{discount_type}}\",\"bundleCheckoutLabel\":\"Checkout\",\"productDiscountCombinedWithShippingDiscount\":true,\"productAddToBundleLabel\":\"Add\",\"breadCrumbReviewBundleLabel\":\"Review Bundle\",\"orderNoteLabel\":\"Order Note\",\"skipSelectSectionPage\":false,\"buyXGetYFreeLabel\":\"Free\",\"dockbarHeadingLabel\":\"Bundle\",\"dynamicBundleDiscountCombinedWithShippingDiscount\":true,\"hidePurchaseOptionSelectLabel\":false,\"buyXGetYAddToCartLabel\":\"Add to cart\",\"fixedDiscountText\":\"Enjoy a fixed discount of {{currency}}{{discount_value}} on your purchase!\",\"buyXGetYDiscountCombinedWithShippingDiscount\":true,\"sectionTotalLabel\":\"Section Total\",\"dynamicBundleDiscountCodeText\":\"BUNDLE_DISCOUNT_{{bundle_id}}\",\"fieldDisabledBackgroundColor\":\"#D1D5DB\",\"selectedProgressLabelText\":\"{{total_bundle_items}} item added with a minimum quantity of {{minimum_quantity}}\",\"bundleTotalLabel\":\"Total\",\"requiredBundleProductLabel\":\"Your bundle needs {{min_product_count}} more item(s).\",\"sellingPlanSelectionDropDownLabel\":\"Purchase Options\",\"showSubscriptionPlanDescription\":false,\"disableProductDescription\":false,\"buyXGetYPercentDiscountText\":\"Enjoy a percentage discount of {{discount_value}}%\",\"dockbarDescriptionLabel\":\"You're getting the most rewards!\",\"subscriptionAvailableLabel\":\"Subscription Available\",\"preventClickableProductsOnCart\":false,\"readLessText\":\"Read Less\",\"enableProductDetailButton\":false,\"customOfferLink\":\"collections/all\",\"noItemsInBundle\":\"No items added to the bundle\",\"variantSelectionDropDownLabel\":\"Variants\",\"shippingDiscountLabel\":\"{{discount}}{{discount_type}} Shipping Discount\",\"chooseSectionLabel\":\"Choose Section\",\"selectedGiftProductProgressLabelText\":\"{{selected_product_quantity}} gift products added. The required quantity is {{required_product_quantity}}.\",\"breadCrumbPlanLabel\":\"Select Plan\",\"showDynamicBundleOrderNote\":false,\"secondaryTextColor\":\"#ffffff\",\"disableViewShopifyProduct\":false,\"bundleDiscountLabel\":\"Discount\",\"volumeDiscountAppliedQuantityRewardsLabel\":\"Applied: buy {{quantity}} get {{discount}}{{discount_type}}\",\"buyXGetYDiscountCombinedWithProductDiscount\":true,\"bundleNotEligibleLabel\":\"You're not eligible to purchase this bundle!\",\"reviewOrderProductsLabel\":\"Bundle Products\",\"outOfStockLabel\":\"Out Of Stock\",\"tieredDiscountLabel\":\"{{discount_amount}}{{discount_type}} Discount\",\"buyXGetYFreeGiftDiscountText\":\"Enjoy the free product\",\"buyXGetYQuantityValidationLabel\":\"Add {{product_quantity}} quantities of the gift product (Get Y)\",\"showDescriptionPopup\":true,\"primaryTextColor\":\"#000000\",\"readMoreText\":\"Read More\",\"modalOpenOnAddToCart\":true,\"notApplicableForSubscribeAndSaveNotificationTitle\":\"Not applicable for subscribe & save\",\"bundleMinimumQuantityLabel\":\"Add minimum {{minimum_quantity}} product\",\"customSignInLink\":\"\",\"noSourceProductSelectedLabel\":\"No source product selected.\",\"nonListedProductText\":\"Non-Listed\",\"volumeDiscountQuantityRewardsLabel\":\"Buy {{quantity}} quantity and get {{discount}}{{discount_type}} discount!\",\"loginAlertTextLabel\":\"You need to login to purchase this bundle.\",\"buyXGetYChooseProductLabel\":\"Choose Product\",\"freeShippingLabel\":\"Free Shipping\",\"previousButtonLabel\":\"Previous Step\",\"draftBundlePageTitle\":\"Oops! This bundle is temporarily unavailable.\",\"chooseAPlanLabel\":\"Choose Plan\",\"productDetailsMaximumDescriptionCount\":300,\"singleParentProductDirectRedirectToChildProducts\":true,\"oneTimeOnlyLabel\":\"One time only\",\"buyXGetYFixedDiscountText\":\"Enjoy a fixed discount of {{discount_value}} {{currency}}\",\"primaryColor\":\"#82AF58\",\"buyXGetYGiftProductPriceVisibilityType\":\"UNIT_PRICE\",\"volumeAmountDiscountQuantityRewardsLabel\":\"Buy {{quantity}} quantity and get {{currency}}{{discount}} discount!\",\"disableDiscountedPricingRedirectToCart\":false,\"chooseSourceProductValidationLabel\":\"Please choose source product!\",\"volumeDiscountCombinedWithOrderDiscount\":true,\"choosePlanButtonLabel\":\"Choose Plan\",\"bundleQuantityLabel\":\"{{quantity}}x\",\"volumeDiscountSpentAmountRewardsLabel\":\"Spend {{currency}}{{spent_amount}} and get {{discount}}{{discount_type}} discount!\",\"hideVariantSelectLabel\":false,\"bundleDetailsLabel\":\"Your bundle:\",\"availableOnlySubscriptionLabel\":\"Available Only On Subscription\",\"enableParentProductDetailButton\":false,\"volumeDiscountAppliedSpentAmountRewardsLabel\":\"Applied: spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}\",\"chooseAssociatedProductsValidationLabel\":\"Please choose associated products!\",\"selectedSourceProductLabel\":\"Selected\",\"bundleModalShowRewardsLabel\":\"Show all rewards\",\"volumeDiscountNextApplicableSpentAmountRewardsLabel\":\"Spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}\",\"sectionNoProductSelectedValidationLabel\":\"No product selected for: {{section_name}}!\",\"volumeAmountDiscountSpentAmountRewardsLabel\":\"Spend {{currency}}{{spent_amount}} and get {{currency}}{{discount}} discount!\",\"sectionMaximumQuantityValidationLabel\":\"Maximum quantity not selected for: {{section_name}}!\",\"notApplicableForOneTimeNotificationTitle\":\"Not applicable for one time\",\"primaryDisabledTextColor\":\"#ffffff\",\"volumeAmountDiscountSaveRewardsLabel\":\"Save {{currency}}{{discount}}!\",\"sectionLabel\":\"Section\",\"draftBundlePageSubTitle\":\"In the meantime, check out our latest offers and discounts!\",\"volumeDiscountCombinedWithShippingDiscount\":true,\"bundleSpentAmountRewardsLabel\":\"Spent {{spent_amount}} worth of items, get {{discount}}{{discount_type}} discount\",\"disabledTextColor\":\"#6B7280\",\"primaryHoverColor\":\"#82AF58\",\"nextButtonLabel\":\"Next Step\",\"classicBundleDescriptionLabel\":\"Your bundle contains the following products.\",\"shippingDiscountCombinedWithOrderDiscount\":true,\"bundleBottomHtml\":\"\",\"sectionMinimumQuantityValidationLabel\":\"Minimum quantity not selected for: {{section_name}}!\",\"dynamicBundleDiscountCombinedWithProductDiscount\":true,\"descriptionLength\":200,\"bundleDiscountNote\":\"Discounts will be applied at checkout.\",\"bundleModalCloseRewardsLabel\":\"Close all rewards\",\"buyXGetYDiscountCombinedWithOrderDiscount\":true,\"dockbarCurrentRewardLabel\":\"You got {{discount_amount}}{{discount_type}} discount\",\"productDetailsAddToBundleLabel\":\"Add to bundle\",\"cartAndCheckoutQuantityValidationMessage\":\"Orders must match the quantity range: Min {{min_quantity}}, Max {{max_quantity}}\",\"bundleNoProductSelectedLabel\":\"No product selected\",\"checkoutInfoLabel\":\"Add products from each section to enable the add to cart button.\",\"bundleSubtotalLabel\":\"Subtotal\",\"redirectToCartPageOnCartIconClick\":true,\"reviewOrderDescription\":\"Check your items and select your required frequency plan\",\"dynamicBundleDiscountCombinedWithOrderDiscount\":true,\"customOfferLinkButtonLabel\":\"Explore Offers\",\"oneTimePurchaseLabel\":\"One Time Purchase\",\"volumeDiscountSaveRewardsLabel\":\"Save {{discount}}{{discount_type}}!\",\"bundleMaximumOrderAmountLabel\":\"Add maximum {{maximum_amount}} order amount\",\"addingProductsToBundle\":\"Adding products to bundle\",\"bundleModalHeaderLabel\":\"Your Bundle({{total_quantity}})\",\"productAddedToBundleNotificationTitle\":\"Added to bundle\",\"productAddedToBundleNotificationDescription\":\"{{product_title}} added to bundle.\",\"customHtmlInject\":\"[]\",\"bundleTopHtml\":\"\",\"proceedToCheckoutButtonText\":\"\",\"breadCrumbReviewSectionLabel\":\"Review Section\"}","bundleTopHtml":"","bundleBottomHtml":"","proceedToCheckoutButtonText":"","chooseProductsText":"Products","productAddToBundleLabel":"Add","productDetailsAddToBundleLabel":"Add to bundle","productDetailsMaximumDescriptionCount":300,"variantSelectionDropDownLabel":"Variants","sellingPlanSelectionDropDownLabel":"Purchase Options","dockbarHeadingLabel":"Bundle","dockbarCurrentRewardLabel":"You got {{discount_amount}}{{discount_type}} discount","dockbarDescriptionLabel":"You're getting the most rewards!","bundleModalHeaderLabel":"Your Bundle({{total_quantity}})","bundleModalShowRewardsLabel":"Show all rewards","bundleModalCloseRewardsLabel":"Close all rewards","bundleQuantityRewardsLabel":"Add {{quantity}} item, get {{discount}}{{discount_type}} discount","bundleSpentAmountRewardsLabel":"Spent {{spent_amount}} worth of items, get {{discount}}{{discount_type}} discount","bundleQuantityLabel":"{{quantity}}x","bundleSubtotalLabel":"Subtotal","bundleDiscountLabel":"Discount","bundleTotalLabel":"Total","bundleCheckoutLabel":"Checkout","bundleMinimumQuantityLabel":"Add minimum {{minimum_quantity}} product","bundleMaximumQuantityLabel":"Add maximum up to {{maximum_quantity}} product","bundleMinimumOrderAmountLabel":"Add minimum {{minimum_amount}} order amount","oneTimePurchaseLabel":"One Time Purchase","noItemsInBundle":"No items added to the bundle","modalOpenOnAddToCart":true,"productAddedToBundleNotificationTitle":"Added to bundle","productAddedToBundleNotificationDescription":"{{product_title}} added to bundle.","chooseAPlanLabel":"Choose Plan","nextButtonLabel":"Next Step","previousButtonLabel":"Previous Step","chooseSourceProductValidationLabel":"Please choose source product!","chooseAssociatedProductsValidationLabel":"Please choose associated products!","choosePlanButtonLabel":"Choose Plan","selectedSourceProductLabel":"Selected","noSourceProductSelectedLabel":"No source product selected.","reviewOrderLabel":"Review Bundle","reviewOrderDescription":"Check your items and select your required frequency plan","reviewOrderProductsLabel":"Bundle Products","reviewOrderInfoLabel":"","orderNoteLabel":"Order Note","selectedProgressLabelText":"{{total_bundle_items}} item added with a minimum quantity of {{minimum_quantity}}","availableOnlySubscriptionLabel":"Available Only On Subscription","subscriptionAvailableLabel":"Subscription Available","oneTimeOnlyLabel":"One time only","switchOnTimeLabel":"One Time","switchSubscriptionLabel":"Subscribe & Save","breadCrumbPlanLabel":"Select Plan","breadCrumbProductsLabel":"Choose Products","breadCrumbReviewBundleLabel":"Review Bundle","showDescriptionPopup":true,"tieredDiscountLabel":"{{discount_amount}}{{discount_type}} Discount","emptyProductImage":"https://cdn.shopify.com/s/files/1/0661/9224/4900/files/EmptyImage.jpg?v=1718447038","outOfStockLabel":"Out Of Stock","notApplicableForOneTimeNotificationTitle":"Not applicable for one time","notApplicableForSubscribeAndSaveNotificationTitle":"Not applicable for subscribe & save","disableProductDescription":false,"descriptionLength":200,"readLessText":"Read Less","readMoreText":"Read More","bundleNoProductSelectedLabel":"No product selected","customHtmlInject":"[]","bundleDetailsLabel":"Your bundle:","bundleDiscountNote":"Discounts will be applied at checkout.","fixedDiscountText":"Enjoy a fixed discount of {{currency}}{{discount_value}} on your purchase!","percentDiscountText":"Get {{discount_value}}% off on your purchase!","hideVariantSelectLabel":false,"hidePurchaseOptionSelectLabel":false,"primaryColor":"#82AF58","primaryTextColor":"#000000","secondaryTextColor":"#ffffff","primaryHoverColor":"#82AF58","primaryDisabledColor":"#333333","primaryDisabledTextColor":"#ffffff","fieldDisabledBackgroundColor":"#D1D5DB","disabledTextColor":"#6B7280","volumeDiscountSaveRewardsLabel":"Save {{discount}}{{discount_type}}!","volumeDiscountQuantityRewardsLabel":"Buy {{quantity}} quantity and get {{discount}}{{discount_type}} discount!","volumeDiscountSpentAmountRewardsLabel":"Spend {{currency}}{{spent_amount}} and get {{discount}}{{discount_type}} discount!","volumeDiscountAppliedQuantityRewardsLabel":"Applied: buy {{quantity}} get {{discount}}{{discount_type}}","volumeDiscountAppliedSpentAmountRewardsLabel":"Applied: spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}","volumeDiscountNextApplicableQuantityRewardsLabel":"Buy {{quantity}} get {{discount}}{{discount_type}}","volumeDiscountNextApplicableSpentAmountRewardsLabel":"Spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}","addingProductsToBundle":"Adding products to bundle","freeShippingLabel":"Free Shipping","requiredBundleProductLabel":"Your bundle needs {{min_product_count}} more item(s).","enableProductDetailButton":false,"requiredLoginValidationLabel":"Please log in to purchase this bundle!","bundleNotEligibleLabel":"You're not eligible to purchase this bundle!","loginAlertTextLabel":"You need to login to purchase this bundle.","loginAlertLinkLabel":"Click here to login","customSignInLink":"","shippingDiscountLabel":"{{discount}}{{discount_type}} Shipping Discount","classicBundleDescriptionLabel":"Your bundle contains the following products.","singleParentProductDirectRedirectToChildProducts":true,"buyXGetYFixedDiscountText":"Enjoy a fixed discount of {{discount_value}} {{currency}}","buyXGetYPercentDiscountText":"Enjoy a percentage discount of {{discount_value}}%","buyXGetYFreeGiftDiscountText":"Enjoy the free product","buyXGetYAddToCartLabel":"Add to cart","buyXGetYFreeLabel":"Free","disableDiscountedPricingRedirectToCart":false,"nonListedProductText":"Non-Listed","preventClickableProductsOnCart":false,"buyXGetYChooseProductLabel":"Choose Product","showSubscriptionPlanDescription":false,"volumeAmountDiscountSaveRewardsLabel":"Save {{currency}}{{discount}}!","volumeAmountDiscountQuantityRewardsLabel":"Buy {{quantity}} quantity and get {{currency}}{{discount}} discount!","volumeAmountDiscountSpentAmountRewardsLabel":"Spend {{currency}}{{spent_amount}} and get {{currency}}{{discount}} discount!","enableManualBundleBlockIntegration":false,"cartAndCheckoutQuantityValidationMessage":"Orders must match the quantity range: Min {{min_quantity}}, Max {{max_quantity}}","dynamicBundleDiscountCodeText":"BUNDLE_DISCOUNT_{{bundle_id}}","discountUsageLimitExceedLabel":"You have exceeded the bundle usage limit","disableViewShopifyProduct":false,"redirectToCartPageOnCartIconClick":true,"sectionLabel":"Section","chooseSectionLabel":"Choose Section","chooseSectionProductsLabel":"Choose Section Products","breadCrumbSelectSectionLabel":"Select Section","breadCrumbReviewSectionLabel":"Review Section","checkoutInfoLabel":"Add products from each section to enable the add to cart button.","sectionNoProductSelectedValidationLabel":"No product selected for: {{section_name}}!","sectionMinimumQuantityValidationLabel":"Minimum quantity not selected for: {{section_name}}!","sectionMaximumQuantityValidationLabel":"Maximum quantity not selected for: {{section_name}}!","dynamicBundleDiscountCombinedWithProductDiscount":true,"dynamicBundleDiscountCombinedWithShippingDiscount":true,"dynamicBundleDiscountCombinedWithOrderDiscount":true,"volumeDiscountCombinedWithProductDiscount":true,"volumeDiscountCombinedWithShippingDiscount":true,"volumeDiscountCombinedWithOrderDiscount":true,"productDiscountCombinedWithProductDiscount":true,"productDiscountCombinedWithShippingDiscount":true,"productDiscountCombinedWithOrderDiscount":true,"buyXGetYDiscountCombinedWithProductDiscount":true,"buyXGetYDiscountCombinedWithShippingDiscount":true,"buyXGetYDiscountCombinedWithOrderDiscount":true,"shippingDiscountCombinedWithProductDiscount":true,"shippingDiscountCombinedWithOrderDiscount":true,"showDynamicBundleOrderNote":false,"bundleMaximumOrderAmountLabel":"Add maximum {{maximum_amount}} order amount","buyXGetYQuantityValidationLabel":"Add {{product_quantity}} quantities of the gift product (Get Y)","selectedGiftProductProgressLabelText":"{{selected_product_quantity}} gift products added. The required quantity is {{required_product_quantity}}.","draftBundlePageTitle":"Oops! This bundle is temporarily unavailable.","draftBundlePageSubTitle":"In the meantime, check out our latest offers and discounts!","customOfferLink":"collections/all","customOfferLinkButtonLabel":"Explore Offers","enableParentProductDetailButton":false,"sectionTotalLabel":"Section Total","skipSelectSectionPage":false,"buyXGetYGiftProductPriceVisibilityType":"UNIT_PRICE"};
const isLoggedIn = false
const customerTags = null
for (const element of discountElements) {
const variantId = parseInt(element.getAttribute('data-variant-id'), 10);
const matchedBundleRules = getMatchingBundleRulesByVariantId(variantId, isLoggedIn, customerTags);
const allTieredDiscounts = getAllTieredDiscountsByMatchedVolumeBundles(matchedBundleRules);
const currentAppliedDiscount = getCurrentTieredDiscountByVariantId(cartItems, allTieredDiscounts, variantId, false);
const nextApplicableDiscount = getCurrentTieredDiscountByVariantId(cartItems, allTieredDiscounts, variantId, true);
if (!areObjectsIdentical(currentAppliedDiscount, nextApplicableDiscount) && nextApplicableDiscount) {
const cartItem = getMatchedCartItemByVariantId(cartItems, variantId);
const nextApplicableDiscountLabel = `${nextApplicableDiscount.discountBasedOn === 'QUANTITY' ? 'Buy' : `Spend ${window?.Shopify?.currency?.active}`} ${nextApplicableDiscount.value} get ${nextApplicableDiscount.discountType === 'FIXED_AMOUNT' ? `${window?.Shopify?.currency?.active} ` : ''}${nextApplicableDiscount.discount}${nextApplicableDiscount.discountType === 'PERCENTAGE' ? '%' : ''}`;
const updatedNextApplicableDiscountLabel = nextApplicableDiscount?.discountBasedOn === "QUANTITY" && bundleSettings?.volumeDiscountNextApplicableQuantityRewardsLabel ? bundleSettings?.volumeDiscountNextApplicableQuantityRewardsLabel.replace("{{quantity}}", nextApplicableDiscount?.value).replace("{{discount}}", nextApplicableDiscount?.discount).replace("{{discount_type}}", nextApplicableDiscount?.discountType === "PERCENTAGE" ? "%" : ` ${window?.Shopify?.currency?.active}`) :
nextApplicableDiscount?.discountBasedOn === "AMOUNT" && bundleSettings?.volumeDiscountNextApplicableSpentAmountRewardsLabel ? bundleSettings?.volumeDiscountNextApplicableSpentAmountRewardsLabel.replace("{{spent_amount}}", nextApplicableDiscount?.value).replace("{{currency}}", ` ${window?.Shopify?.currency?.active}`).replace("{{discount}}", nextApplicableDiscount?.discount).replace("{{discount_type}}", nextApplicableDiscount?.discountType === "PERCENTAGE" ? "%" : ` ${window?.Shopify?.currency?.active}`) : nextApplicableDiscountLabel;
element.innerHTML = createDiscountLink(updatedNextApplicableDiscountLabel, cartItem?.url);
} else {
element.innerHTML = '';
}
}
};
const setupCartMutationObserver = () => {
const targetNode = document.body;
if (!targetNode) return;
const observer = new MutationObserver(async mutations => {
const cartChanged = mutations.some(mutation =>
mutation.type === 'childList' || mutation.type === 'attributes'
);
if (cartChanged) {
observer.disconnect();
await executeCartLogic();
setupCartMutationObserver();
}
});
observer.observe(targetNode, { attributes: true, childList: true, subtree: true });
};
const areObjectsIdentical = (obj1, obj2) => {
if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null) {
return false;
}
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
if (keys1.length !== keys2.length) {
return false;
}
for (let key of keys1) {
if (!keys2.includes(key)) {
return false;
}
const val1 = obj1[key];
const val2 = obj2[key];
const areObjects = typeof val1 === 'object' && typeof val2 === 'object';
if (areObjects && !areObjectsIdentical(val1, val2)) {
return false;
} else if (!areObjects && val1 !== val2) {
return false;
}
}
return true;
};
const createDiscountLink = (content, url) => {
return `${content}`;
};
const getCurrentTieredDiscountByVariantId = (cartItems, allTieredDiscounts, variantId, isNextApplicableDiscount) => {
let applicableDiscount = null;
const cartItem = getMatchedCartItemByVariantId(cartItems, variantId);
if (!cartItem) return null;
if (cartItem && isNextApplicableDiscount) {
cartItem.quantity = cartItem.quantity + 1;
}
const originalPrice = ((cartItem.price * cartItem.quantity) / 100);
let applicableQuantityBasedDiscount = allTieredDiscounts
.filter(tieredDiscount => tieredDiscount.discountBasedOn === 'QUANTITY')
.filter(tieredDiscount => cartItem.quantity >= tieredDiscount.value);
applicableQuantityBasedDiscount = applicableQuantityBasedDiscount.length > 0 ? getBestQuantityOrAmountBasedDiscount(applicableQuantityBasedDiscount, originalPrice) : null;
let applicableSpendAmountBasedDiscount = allTieredDiscounts
.filter(tieredDiscount => tieredDiscount.discountBasedOn === 'AMOUNT')
.filter(tieredDiscount => originalPrice >= tieredDiscount.value);
applicableSpendAmountBasedDiscount = applicableSpendAmountBasedDiscount.length > 0 ? getBestQuantityOrAmountBasedDiscount(applicableSpendAmountBasedDiscount, originalPrice) : null;
if (applicableQuantityBasedDiscount && applicableSpendAmountBasedDiscount) {
if ((applicableQuantityBasedDiscount.discountType === 'PERCENTAGE' && applicableSpendAmountBasedDiscount.discountType === 'PERCENTAGE') || (applicableQuantityBasedDiscount.discountType === 'FIXED_AMOUNT' && applicableSpendAmountBasedDiscount.discountType === 'FIXED_AMOUNT')) {
if (applicableQuantityBasedDiscount.discount > applicableSpendAmountBasedDiscount.discount) {
applicableDiscount = applicableQuantityBasedDiscount;
} else {
applicableDiscount = applicableSpendAmountBasedDiscount;
}
} else if (applicableQuantityBasedDiscount.discountType === 'PERCENTAGE' && applicableSpendAmountBasedDiscount.discountType === 'FIXED_AMOUNT') {
if (((applicableQuantityBasedDiscount.discount / 100) * originalPrice) > applicableSpendAmountBasedDiscount.discount) {
applicableDiscount = applicableQuantityBasedDiscount;
} else {
applicableDiscount = applicableSpendAmountBasedDiscount;
}
} else if (applicableQuantityBasedDiscount.discountType === 'FIXED_AMOUNT' && applicableSpendAmountBasedDiscount.discountType === 'PERCENTAGE') {
if (applicableQuantityBasedDiscount.discount > ((applicableSpendAmountBasedDiscount.discount / 100) * originalPrice)) {
applicableDiscount = applicableQuantityBasedDiscount;
} else {
applicableDiscount = applicableSpendAmountBasedDiscount;
}
}
} else if (applicableQuantityBasedDiscount) {
applicableDiscount = applicableQuantityBasedDiscount;
} else if (applicableSpendAmountBasedDiscount) {
applicableDiscount = applicableSpendAmountBasedDiscount;
}
return applicableDiscount;
};
const getBestQuantityOrAmountBasedDiscount = (applicableQuantityOrAmountBasedDiscount, originalPrice) => {
return applicableQuantityOrAmountBasedDiscount.reduce((greater, current) => {
if ((greater.discountType === 'PERCENTAGE' && current.discountType === 'PERCENTAGE') || (greater.discountType === 'FIXED_AMOUNT' && current.discountType === 'FIXED_AMOUNT')) {
return current.discount > greater.discount ? current : greater;
} else if (current.discountType === 'FIXED_AMOUNT' && greater.discountType === 'PERCENTAGE') {
return current.discount > ((greater.discount / 100) * originalPrice) ? current : greater;
} else if (current.discountType === 'PERCENTAGE' && greater.discountType === 'FIXED_AMOUNT') {
return ((current.discount / 100) * originalPrice) > greater.discount ? current : greater;
}
return current.discount > greater.discount ? current : greater;
});
};
const getAllTieredDiscountsByMatchedVolumeBundles = (volumeBundles) => {
return volumeBundles.reduce((acc, item) => {
const tieredDiscount = JSON.parse(item?.tieredDiscount || '[]');
acc.push(...tieredDiscount);
return acc;
}, []);
};
const isBundleRestrictedCustomerByTagsByNextVolumeDiscount = (item, customerTags) => {
if (!item?.restrictTags) return false;
const restrictTags = item?.restrictTags?.split(',');
return (
customerTags && customerTags?.length > 0 && customerTags?.some(tag => restrictTags?.includes(tag))
);
};
const isBundleAllowedByCustomersTagByNextVolumeDiscount = (item, customerTags) => {
if (!item?.allowedTags) return true;
const allowedCustomersOnly = item?.allowedTags?.split(',');
return (
customerTags &&
customerTags?.length > 0 &&
customerTags?.some(tags => allowedCustomersOnly?.includes(tags))
);
};
const isBundleRestrictedByNextVolumeDiscount = (item, customerTags) => {
return isBundleRestrictedCustomerByTagsByNextVolumeDiscount(item, customerTags) || !isBundleAllowedByCustomersTagByNextVolumeDiscount(item, customerTags);
};
const getMatchingBundleRulesByVariantId = (variantId, isLoggedIn, customerTags) => {
const bundleRules = [{"id":9496,"shop":"casa-perris.myshopify.com","name":"Save an additional 5% on orders over €250","description":null,"status":"ACTIVE","customerIncludeTags":null,"discountType":"NO_DISCOUNT","discountValue":null,"products":"null","variants":"[{\"productId\":14886582124917,\"variantId\":54936583111029,\"name\":\"2x1 Pasta de wasabi S&B 90g \",\"productHandle\":\"pasta-de-wasabi-s-b-90g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/pasta_de_wasabi_90g_sb.png?v=1737367017\",\"quantity\":1,\"price\":\"3.24\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Pasta de wasabi S&B 90g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14867986350453,\"variantId\":54867478479221,\"name\":\"2x1 Rollo de Higos y Chocolate 160g \",\"productHandle\":\"rollo-de-higos-y-chocolate-160g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/rollo_higos_y_chocolate_3.jpg?v=1734089597\",\"quantity\":1,\"price\":\"6.98\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Rollo de Higos y Chocolate 160g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14884971643253,\"variantId\":54931749405045,\"name\":\"Acai en polvo BIO 75g \",\"productHandle\":\"acai-en-polvo-bio-75g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/1411ACAIENPOLVOBIO_1.jpg?v=1737121943\",\"quantity\":1,\"price\":\"7.18\",\"status\":\"ACTIVE\",\"productTitle\":\"Acai en polvo BIO 75g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237523599550,\"variantId\":44354918056126,\"name\":\"Aceite de Aguacate NaturGreen 250ml \",\"productHandle\":\"aceite-de-aguacate-250-ml-natur-green\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/NG-DE-AGUACATE-250-ML-4.jpg?v=1719574619\",\"quantity\":1,\"price\":\"12.75\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Aguacate NaturGreen 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237580746942,\"variantId\":44355014066366,\"name\":\"Aceite de Almendras ECO 250ml \",\"productHandle\":\"aceite-de-almendras-eco-250ml\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/ACEITE_ALMENDRA_MANDOLE.jpg?v=1721207994\",\"quantity\":1,\"price\":\"12.14\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Almendras ECO 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null}]","sequenceNo":null,"bundleType":"VOLUME_DISCOUNT","settings":null,"bundleProductId":null,"bundleVariantId":null,"productHandle":null,"discountId":null,"price":null,"numberOfProducts":0,"subscriptionBundlingEnabled":false,"subscriptionId":null,"minProductCount":null,"maxProductCount":null,"uniqueRef":"4ydLc6Hiel","bundleRedirect":"CART","customRedirectURL":null,"minOrderAmount":null,"tieredDiscount":"[{\"discountBasedOn\":\"AMOUNT\",\"value\":250,\"discount\":5,\"discountType\":\"PERCENTAGE\"}]","productViewStyle":"QUICK_ADD","singleProductSettings":"null","trackInventory":false,"sellingPlanType":"BUNDLE_LEVEL","clearCart":"ENABLED","minPrice":null,"maxPrice":null,"externalBuildABoxId":null,"variantVisibilityType":"SHOW_VARIANTS_AS_OPTIONS","subTitle":null,"freeShipping":false,"themeType":"THEME_TWO","showBundleInProductPage":true,"combinedWithProductDiscount":true,"combinedWithShippingDiscount":true,"combinedWithOrderDiscount":true,"allowedTags":null,"restrictTags":null,"selectionType":"FLEXIBLE","bundleHtml":"null","discountedVariants":"null","allowedCountries":null,"appliesOn":"BOTH","purchaseRequirement":"NO_REQUIREMENT","productDiscountType":"EACH_PRODUCT","countrySelectionType":"ALL_COUNTRY","discountApplyApproach":"SHOPIFY_DISCOUNT_FUNCTION","discountedProductChooseType":"CHOOSE_ALL","internalName":"Save an additional 5% on orders over €250","sections":"[{\"id\":1,\"name\":\"\",\"description\":\"\",\"minProductCount\":0,\"maxProductCount\":0,\"variants\":[]}]","limitToUsePerCustomer":null,"discountedVariantSelectionLimit":null,"hideOneTimePurchase":false,"hideSubscriptionPurchase":false,"maxOrderAmount":null,"collectionData":"[{\"id\":306090246334,\"title\":\"A Granel\",\"handle\":\"granel-a-granel-al-peso-graneria\",\"image\":null},{\"id\":310717972670,\"title\":\"AOVE\",\"handle\":\"aove\",\"image\":null},{\"id\":306088083646,\"title\":\"Arroces\",\"handle\":\"arroces\",\"image\":null},{\"id\":306089361598,\"title\":\"Aceite vegetal y vinagre\",\"handle\":\"aceite-vegetal\",\"image\":null},{\"id\":306089066686,\"title\":\"Algas\",\"handle\":\"algas\",\"image\":null},{\"id\":306088214718,\"title\":\"Alubias\",\"handle\":\"alubias\",\"image\":null},{\"id\":306088902846,\"title\":\"Asiático\",\"handle\":\"asiatico\",\"image\":null},{\"id\":306089263294,\"title\":\"Azafrán\",\"handle\":\"azafran\",\"image\":null},{\"id\":306088018110,\"title\":\"Azúcar y edulcorantes\",\"handle\":\"azucar-y-edulcorantes\",\"image\":null},{\"id\":306088935614,\"title\":\"Bebida y Leche Vegetal\",\"handle\":\"bebida-vegetal\",\"image\":null},{\"id\":306089918654,\"title\":\"Cafe, té e infusiones\",\"handle\":\"cafe-te-e-infusiones\",\"image\":null},{\"id\":306089459902,\"title\":\"Café\",\"handle\":\"cafe\",\"image\":null},{\"id\":306088771774,\"title\":\"Caramelizados\",\"handle\":\"caramelizados\",\"image\":null},{\"id\":306088476862,\"title\":\"Cereales y Gramíneas\",\"handle\":\"cereales-y-gramineas\",\"image\":null},{\"id\":306087690430,\"title\":\"Chocolates\",\"handle\":\"chocolates\",\"image\":null},{\"id\":306088542398,\"title\":\"Coberturas\",\"handle\":\"coberturas\",\"image\":null},{\"id\":306089951422,\"title\":\"Condimentos\",\"handle\":\"condimentos\",\"image\":null},{\"id\":306089328830,\"title\":\"Condimentos, salsas y cremas\",\"handle\":\"condimentos-y-salsas-cremas\",\"image\":null},{\"id\":306297700542,\"title\":\"Conservas y encurtidos\",\"handle\":\"conservas-y-encurtidos\",\"image\":null},{\"id\":306088673470,\"title\":\"Copos\",\"handle\":\"copos\",\"image\":null},{\"id\":306089590974,\"title\":\"Cremas dulces\",\"handle\":\"cremas-dulces\",\"image\":null},{\"id\":306089394366,\"title\":\"Cremas y purés\",\"handle\":\"cremas-y-pures\",\"image\":null},{\"id\":306090279102,\"title\":\"Ecológico\",\"handle\":\"ecologico-eco\",\"image\":null},{\"id\":306090016958,\"title\":\"Esencias y aromas\",\"handle\":\"esencias-y-aromas\",\"image\":null},{\"id\":306087887038,\"title\":\"Especias\",\"handle\":\"especias\",\"image\":null},{\"id\":306090180798,\"title\":\"Frescos\",\"handle\":\"frescos\",\"image\":null},{\"id\":306088116414,\"title\":\"Fruta Deshidratada\",\"handle\":\"fruta-deshidratada\",\"image\":null},{\"id\":306089099454,\"title\":\"Fruta confitada\",\"handle\":\"fruta-confitada\",\"image\":null},{\"id\":306088378558,\"title\":\"Frutos secos\",\"handle\":\"frutos-secos\",\"image\":null},{\"id\":306087755966,\"title\":\"Frutos secos crudos\",\"handle\":\"frutos-secos-crudos\",\"image\":null},{\"id\":306088575166,\"title\":\"Frutos secos tostados\",\"handle\":\"frutos-secos-tostados\",\"image\":null},{\"id\":306087788734,\"title\":\"Féculas y Sémolas\",\"handle\":\"feculas-y-semolas\",\"image\":null},{\"id\":306088968382,\"title\":\"Galletas y snacks\",\"handle\":\"galletas-y-snacks\",\"image\":null},{\"id\":309347582142,\"title\":\"Gourmet\",\"handle\":\"gourmet\",\"image\":null},{\"id\":306088050878,\"title\":\"Garbanzos\",\"handle\":\"garbanzos\",\"image\":null},{\"id\":306089427134,\"title\":\"Granolas\",\"handle\":\"granolas\",\"image\":null},{\"id\":306087952574,\"title\":\"Granos\",\"handle\":\"granos\",\"image\":null},{\"id\":306088280254,\"title\":\"Guisantes\",\"handle\":\"guisantes\",\"image\":null},{\"id\":306087985342,\"title\":\"Harinas\",\"handle\":\"harinas\",\"image\":null},{\"id\":306090311870,\"title\":\"Herbolistería\",\"handle\":\"herbolisteria\",\"image\":null},{\"id\":306089656510,\"title\":\"Legumbres\",\"handle\":\"legumbres\",\"image\":null},{\"id\":306088149182,\"title\":\"Lentejas\",\"handle\":\"lentejas\",\"image\":null},{\"id\":306089623742,\"title\":\"Levadura\",\"handle\":\"levadura\",\"image\":null},{\"id\":306090115262,\"title\":\"Macrobiótica\",\"handle\":\"macrobiotica\",\"image\":null},{\"id\":306089689278,\"title\":\"Mermeladas\",\"handle\":\"mermeladas\",\"image\":null},{\"id\":306089001150,\"title\":\"Miel Artesanal\",\"handle\":\"miel-artesanal\",\"image\":null},{\"id\":663585292661,\"title\":\"Navidad\",\"handle\":\"navidad\",\"image\":null},{\"id\":306789810366,\"title\":\"Novedades\",\"handle\":\"novedades\",\"image\":null},{\"id\":306090049726,\"title\":\"OFERTAS\",\"handle\":\"ofertas\",\"image\":null},{\"id\":306090148030,\"title\":\"Panellets\",\"handle\":\"panellets\",\"image\":null},{\"id\":306089984190,\"title\":\"Repostería\",\"handle\":\"reposteria\",\"image\":null},{\"id\":306089525438,\"title\":\"Pasta\",\"handle\":\"pasta\",\"image\":null},{\"id\":306087919806,\"title\":\"Sales\",\"handle\":\"sal\",\"image\":null},{\"id\":306088247486,\"title\":\"Salvado\",\"handle\":\"salvado\",\"image\":null},{\"id\":306088345790,\"title\":\"Semillas\",\"handle\":\"semillas\",\"image\":null},{\"id\":306089164990,\"title\":\"Setas\",\"handle\":\"setas\",\"image\":null},{\"id\":306088837310,\"title\":\"Snacks\",\"handle\":\"snacks\",\"image\":null},{\"id\":306089132222,\"title\":\"Superalimentos\",\"handle\":\"superalimentos\",\"image\":null},{\"id\":306089197758,\"title\":\"Suplementos dietéticos\",\"handle\":\"suplementos-dieteticos\",\"image\":null},{\"id\":306089230526,\"title\":\"Tabletas\",\"handle\":\"tabletas\",\"image\":null},{\"id\":306087657662,\"title\":\"Tarjetas Regalo\",\"handle\":\"uncategorized\",\"image\":null},{\"id\":306087723198,\"title\":\"Té e infusiones\",\"handle\":\"te-e-infusiones\",\"image\":null},{\"id\":306090082494,\"title\":\"Utensilios y menaje\",\"handle\":\"utensilios-de-cocina-menaje-hogar\",\"image\":null},{\"id\":306088509630,\"title\":\"Vegano\",\"handle\":\"vegano\",\"image\":null},{\"id\":306089296062,\"title\":\"Vinagres\",\"handle\":\"vinagres\",\"image\":null},{\"id\":306089853118,\"title\":\"Zumos y bebidas\",\"handle\":\"zumos\",\"image\":null}]","productSelectionType":null},{"id":9497,"shop":"casa-perris.myshopify.com","name":"Save an additional 10% on orders over €500","description":null,"status":"ACTIVE","customerIncludeTags":null,"discountType":"NO_DISCOUNT","discountValue":null,"products":"null","variants":"[{\"productId\":14886582124917,\"variantId\":54936583111029,\"name\":\"2x1 Pasta de wasabi S&B 90g \",\"productHandle\":\"pasta-de-wasabi-s-b-90g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/pasta_de_wasabi_90g_sb.png?v=1737367017\",\"quantity\":1,\"price\":\"3.24\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Pasta de wasabi S&B 90g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14867986350453,\"variantId\":54867478479221,\"name\":\"2x1 Rollo de Higos y Chocolate 160g \",\"productHandle\":\"rollo-de-higos-y-chocolate-160g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/rollo_higos_y_chocolate_3.jpg?v=1734089597\",\"quantity\":1,\"price\":\"6.98\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Rollo de Higos y Chocolate 160g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14884971643253,\"variantId\":54931749405045,\"name\":\"Acai en polvo BIO 75g \",\"productHandle\":\"acai-en-polvo-bio-75g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/1411ACAIENPOLVOBIO_1.jpg?v=1737121943\",\"quantity\":1,\"price\":\"7.18\",\"status\":\"ACTIVE\",\"productTitle\":\"Acai en polvo BIO 75g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237523599550,\"variantId\":44354918056126,\"name\":\"Aceite de Aguacate NaturGreen 250ml \",\"productHandle\":\"aceite-de-aguacate-250-ml-natur-green\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/NG-DE-AGUACATE-250-ML-4.jpg?v=1719574619\",\"quantity\":1,\"price\":\"12.75\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Aguacate NaturGreen 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237580746942,\"variantId\":44355014066366,\"name\":\"Aceite de Almendras ECO 250ml \",\"productHandle\":\"aceite-de-almendras-eco-250ml\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/ACEITE_ALMENDRA_MANDOLE.jpg?v=1721207994\",\"quantity\":1,\"price\":\"12.14\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Almendras ECO 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null}]","sequenceNo":null,"bundleType":"VOLUME_DISCOUNT","settings":null,"bundleProductId":null,"bundleVariantId":null,"productHandle":null,"discountId":null,"price":null,"numberOfProducts":0,"subscriptionBundlingEnabled":false,"subscriptionId":null,"minProductCount":null,"maxProductCount":null,"uniqueRef":"LlHY2rxR9H","bundleRedirect":"CART","customRedirectURL":null,"minOrderAmount":null,"tieredDiscount":"[{\"discountBasedOn\":\"AMOUNT\",\"value\":500,\"discount\":10,\"discountType\":\"PERCENTAGE\"}]","productViewStyle":"QUICK_ADD","singleProductSettings":"null","trackInventory":false,"sellingPlanType":"BUNDLE_LEVEL","clearCart":"ENABLED","minPrice":null,"maxPrice":null,"externalBuildABoxId":null,"variantVisibilityType":"SHOW_VARIANTS_AS_OPTIONS","subTitle":null,"freeShipping":false,"themeType":"THEME_TWO","showBundleInProductPage":true,"combinedWithProductDiscount":true,"combinedWithShippingDiscount":true,"combinedWithOrderDiscount":true,"allowedTags":null,"restrictTags":null,"selectionType":"FLEXIBLE","bundleHtml":"null","discountedVariants":"null","allowedCountries":null,"appliesOn":"BOTH","purchaseRequirement":"NO_REQUIREMENT","productDiscountType":"EACH_PRODUCT","countrySelectionType":"ALL_COUNTRY","discountApplyApproach":"SHOPIFY_DISCOUNT_FUNCTION","discountedProductChooseType":"CHOOSE_ALL","internalName":"Save an additional 10% on orders over €500","sections":"[{\"id\":1,\"name\":\"\",\"description\":\"\",\"minProductCount\":0,\"maxProductCount\":0,\"variants\":[]}]","limitToUsePerCustomer":null,"discountedVariantSelectionLimit":null,"hideOneTimePurchase":false,"hideSubscriptionPurchase":false,"maxOrderAmount":null,"collectionData":"[{\"id\":306090246334,\"title\":\"A Granel\",\"handle\":\"granel-a-granel-al-peso-graneria\",\"image\":null},{\"id\":310717972670,\"title\":\"AOVE\",\"handle\":\"aove\",\"image\":null},{\"id\":306088083646,\"title\":\"Arroces\",\"handle\":\"arroces\",\"image\":null},{\"id\":306089361598,\"title\":\"Aceite vegetal y vinagre\",\"handle\":\"aceite-vegetal\",\"image\":null},{\"id\":306089066686,\"title\":\"Algas\",\"handle\":\"algas\",\"image\":null},{\"id\":306088214718,\"title\":\"Alubias\",\"handle\":\"alubias\",\"image\":null},{\"id\":306088902846,\"title\":\"Asiático\",\"handle\":\"asiatico\",\"image\":null},{\"id\":306089263294,\"title\":\"Azafrán\",\"handle\":\"azafran\",\"image\":null},{\"id\":306088018110,\"title\":\"Azúcar y edulcorantes\",\"handle\":\"azucar-y-edulcorantes\",\"image\":null},{\"id\":306088935614,\"title\":\"Bebida y Leche Vegetal\",\"handle\":\"bebida-vegetal\",\"image\":null},{\"id\":306089918654,\"title\":\"Cafe, té e infusiones\",\"handle\":\"cafe-te-e-infusiones\",\"image\":null},{\"id\":306089459902,\"title\":\"Café\",\"handle\":\"cafe\",\"image\":null},{\"id\":306088771774,\"title\":\"Caramelizados\",\"handle\":\"caramelizados\",\"image\":null},{\"id\":306088476862,\"title\":\"Cereales y Gramíneas\",\"handle\":\"cereales-y-gramineas\",\"image\":null},{\"id\":306087690430,\"title\":\"Chocolates\",\"handle\":\"chocolates\",\"image\":null},{\"id\":306088542398,\"title\":\"Coberturas\",\"handle\":\"coberturas\",\"image\":null},{\"id\":306089951422,\"title\":\"Condimentos\",\"handle\":\"condimentos\",\"image\":null},{\"id\":306089328830,\"title\":\"Condimentos, salsas y cremas\",\"handle\":\"condimentos-y-salsas-cremas\",\"image\":null},{\"id\":306297700542,\"title\":\"Conservas y encurtidos\",\"handle\":\"conservas-y-encurtidos\",\"image\":null},{\"id\":306088673470,\"title\":\"Copos\",\"handle\":\"copos\",\"image\":null},{\"id\":306089590974,\"title\":\"Cremas dulces\",\"handle\":\"cremas-dulces\",\"image\":null},{\"id\":306089394366,\"title\":\"Cremas y purés\",\"handle\":\"cremas-y-pures\",\"image\":null},{\"id\":306090279102,\"title\":\"Ecológico\",\"handle\":\"ecologico-eco\",\"image\":null},{\"id\":306090016958,\"title\":\"Esencias y aromas\",\"handle\":\"esencias-y-aromas\",\"image\":null},{\"id\":306087887038,\"title\":\"Especias\",\"handle\":\"especias\",\"image\":null},{\"id\":306090180798,\"title\":\"Frescos\",\"handle\":\"frescos\",\"image\":null},{\"id\":306088116414,\"title\":\"Fruta Deshidratada\",\"handle\":\"fruta-deshidratada\",\"image\":null},{\"id\":306089099454,\"title\":\"Fruta confitada\",\"handle\":\"fruta-confitada\",\"image\":null},{\"id\":306088378558,\"title\":\"Frutos secos\",\"handle\":\"frutos-secos\",\"image\":null},{\"id\":306087755966,\"title\":\"Frutos secos crudos\",\"handle\":\"frutos-secos-crudos\",\"image\":null},{\"id\":306088575166,\"title\":\"Frutos secos tostados\",\"handle\":\"frutos-secos-tostados\",\"image\":null},{\"id\":306087788734,\"title\":\"Féculas y Sémolas\",\"handle\":\"feculas-y-semolas\",\"image\":null},{\"id\":306088968382,\"title\":\"Galletas y snacks\",\"handle\":\"galletas-y-snacks\",\"image\":null},{\"id\":309347582142,\"title\":\"Gourmet\",\"handle\":\"gourmet\",\"image\":null},{\"id\":306088050878,\"title\":\"Garbanzos\",\"handle\":\"garbanzos\",\"image\":null},{\"id\":306089427134,\"title\":\"Granolas\",\"handle\":\"granolas\",\"image\":null},{\"id\":306087952574,\"title\":\"Granos\",\"handle\":\"granos\",\"image\":null},{\"id\":306088280254,\"title\":\"Guisantes\",\"handle\":\"guisantes\",\"image\":null},{\"id\":306087985342,\"title\":\"Harinas\",\"handle\":\"harinas\",\"image\":null},{\"id\":306090311870,\"title\":\"Herbolistería\",\"handle\":\"herbolisteria\",\"image\":null},{\"id\":306089656510,\"title\":\"Legumbres\",\"handle\":\"legumbres\",\"image\":null},{\"id\":306088149182,\"title\":\"Lentejas\",\"handle\":\"lentejas\",\"image\":null},{\"id\":306089623742,\"title\":\"Levadura\",\"handle\":\"levadura\",\"image\":null},{\"id\":306090115262,\"title\":\"Macrobiótica\",\"handle\":\"macrobiotica\",\"image\":null},{\"id\":306089689278,\"title\":\"Mermeladas\",\"handle\":\"mermeladas\",\"image\":null},{\"id\":306089001150,\"title\":\"Miel Artesanal\",\"handle\":\"miel-artesanal\",\"image\":null},{\"id\":663585292661,\"title\":\"Navidad\",\"handle\":\"navidad\",\"image\":null},{\"id\":306789810366,\"title\":\"Novedades\",\"handle\":\"novedades\",\"image\":null},{\"id\":306090049726,\"title\":\"OFERTAS\",\"handle\":\"ofertas\",\"image\":null},{\"id\":306090148030,\"title\":\"Panellets\",\"handle\":\"panellets\",\"image\":null},{\"id\":306089984190,\"title\":\"Repostería\",\"handle\":\"reposteria\",\"image\":null},{\"id\":306089525438,\"title\":\"Pasta\",\"handle\":\"pasta\",\"image\":null},{\"id\":306087919806,\"title\":\"Sales\",\"handle\":\"sal\",\"image\":null},{\"id\":306088247486,\"title\":\"Salvado\",\"handle\":\"salvado\",\"image\":null},{\"id\":306088345790,\"title\":\"Semillas\",\"handle\":\"semillas\",\"image\":null},{\"id\":306089164990,\"title\":\"Setas\",\"handle\":\"setas\",\"image\":null},{\"id\":306088837310,\"title\":\"Snacks\",\"handle\":\"snacks\",\"image\":null},{\"id\":306089132222,\"title\":\"Superalimentos\",\"handle\":\"superalimentos\",\"image\":null},{\"id\":306089197758,\"title\":\"Suplementos dietéticos\",\"handle\":\"suplementos-dieteticos\",\"image\":null},{\"id\":306089230526,\"title\":\"Tabletas\",\"handle\":\"tabletas\",\"image\":null},{\"id\":306087657662,\"title\":\"Tarjetas Regalo\",\"handle\":\"uncategorized\",\"image\":null},{\"id\":306087723198,\"title\":\"Té e infusiones\",\"handle\":\"te-e-infusiones\",\"image\":null},{\"id\":306090082494,\"title\":\"Utensilios y menaje\",\"handle\":\"utensilios-de-cocina-menaje-hogar\",\"image\":null},{\"id\":306088509630,\"title\":\"Vegano\",\"handle\":\"vegano\",\"image\":null},{\"id\":306089296062,\"title\":\"Vinagres\",\"handle\":\"vinagres\",\"image\":null},{\"id\":306089853118,\"title\":\"Zumos y bebidas\",\"handle\":\"zumos\",\"image\":null}]","productSelectionType":null},{"id":9498,"shop":"casa-perris.myshopify.com","name":"Save an additional 10% on orders over €1,000","description":null,"status":"ACTIVE","customerIncludeTags":null,"discountType":"NO_DISCOUNT","discountValue":null,"products":"null","variants":"[{\"productId\":14886582124917,\"variantId\":54936583111029,\"name\":\"2x1 Pasta de wasabi S&B 90g \",\"productHandle\":\"pasta-de-wasabi-s-b-90g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/pasta_de_wasabi_90g_sb.png?v=1737367017\",\"quantity\":1,\"price\":\"3.24\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Pasta de wasabi S&B 90g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14867986350453,\"variantId\":54867478479221,\"name\":\"2x1 Rollo de Higos y Chocolate 160g \",\"productHandle\":\"rollo-de-higos-y-chocolate-160g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/rollo_higos_y_chocolate_3.jpg?v=1734089597\",\"quantity\":1,\"price\":\"6.98\",\"status\":\"ACTIVE\",\"productTitle\":\"2x1 Rollo de Higos y Chocolate 160g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":14884971643253,\"variantId\":54931749405045,\"name\":\"Acai en polvo BIO 75g \",\"productHandle\":\"acai-en-polvo-bio-75g\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/1411ACAIENPOLVOBIO_1.jpg?v=1737121943\",\"quantity\":1,\"price\":\"7.18\",\"status\":\"ACTIVE\",\"productTitle\":\"Acai en polvo BIO 75g\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237523599550,\"variantId\":44354918056126,\"name\":\"Aceite de Aguacate NaturGreen 250ml \",\"productHandle\":\"aceite-de-aguacate-250-ml-natur-green\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/NG-DE-AGUACATE-250-ML-4.jpg?v=1719574619\",\"quantity\":1,\"price\":\"12.75\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Aguacate NaturGreen 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8237580746942,\"variantId\":44355014066366,\"name\":\"Aceite de Almendras ECO 250ml \",\"productHandle\":\"aceite-de-almendras-eco-250ml\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0660/1411/8078/files/ACEITE_ALMENDRA_MANDOLE.jpg?v=1721207994\",\"quantity\":1,\"price\":\"12.14\",\"status\":\"ACTIVE\",\"productTitle\":\"Aceite de Almendras ECO 250ml\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null}]","sequenceNo":null,"bundleType":"VOLUME_DISCOUNT","settings":null,"bundleProductId":null,"bundleVariantId":null,"productHandle":null,"discountId":null,"price":null,"numberOfProducts":0,"subscriptionBundlingEnabled":false,"subscriptionId":null,"minProductCount":null,"maxProductCount":null,"uniqueRef":"3847RmifvX","bundleRedirect":"CART","customRedirectURL":null,"minOrderAmount":null,"tieredDiscount":"[{\"discountBasedOn\":\"AMOUNT\",\"value\":1000,\"discount\":13,\"discountType\":\"PERCENTAGE\"}]","productViewStyle":"QUICK_ADD","singleProductSettings":"null","trackInventory":false,"sellingPlanType":"BUNDLE_LEVEL","clearCart":"ENABLED","minPrice":null,"maxPrice":null,"externalBuildABoxId":null,"variantVisibilityType":"SHOW_VARIANTS_AS_OPTIONS","subTitle":null,"freeShipping":false,"themeType":"THEME_TWO","showBundleInProductPage":true,"combinedWithProductDiscount":true,"combinedWithShippingDiscount":true,"combinedWithOrderDiscount":true,"allowedTags":null,"restrictTags":null,"selectionType":"FLEXIBLE","bundleHtml":"null","discountedVariants":"null","allowedCountries":null,"appliesOn":"BOTH","purchaseRequirement":"NO_REQUIREMENT","productDiscountType":"EACH_PRODUCT","countrySelectionType":"ALL_COUNTRY","discountApplyApproach":"SHOPIFY_DISCOUNT_FUNCTION","discountedProductChooseType":"CHOOSE_ALL","internalName":"Save an additional 13% on orders over €1,000","sections":"[{\"id\":1,\"name\":\"\",\"description\":\"\",\"minProductCount\":0,\"maxProductCount\":0,\"variants\":[]}]","limitToUsePerCustomer":null,"discountedVariantSelectionLimit":null,"hideOneTimePurchase":false,"hideSubscriptionPurchase":false,"maxOrderAmount":null,"collectionData":"[{\"id\":306090246334,\"title\":\"A Granel\",\"handle\":\"granel-a-granel-al-peso-graneria\",\"image\":null},{\"id\":310717972670,\"title\":\"AOVE\",\"handle\":\"aove\",\"image\":null},{\"id\":306088083646,\"title\":\"Arroces\",\"handle\":\"arroces\",\"image\":null},{\"id\":306089361598,\"title\":\"Aceite vegetal y vinagre\",\"handle\":\"aceite-vegetal\",\"image\":null},{\"id\":306089066686,\"title\":\"Algas\",\"handle\":\"algas\",\"image\":null},{\"id\":306088214718,\"title\":\"Alubias\",\"handle\":\"alubias\",\"image\":null},{\"id\":306088902846,\"title\":\"Asiático\",\"handle\":\"asiatico\",\"image\":null},{\"id\":306089263294,\"title\":\"Azafrán\",\"handle\":\"azafran\",\"image\":null},{\"id\":306088018110,\"title\":\"Azúcar y edulcorantes\",\"handle\":\"azucar-y-edulcorantes\",\"image\":null},{\"id\":306088935614,\"title\":\"Bebida y Leche Vegetal\",\"handle\":\"bebida-vegetal\",\"image\":null},{\"id\":306089918654,\"title\":\"Cafe, té e infusiones\",\"handle\":\"cafe-te-e-infusiones\",\"image\":null},{\"id\":306089459902,\"title\":\"Café\",\"handle\":\"cafe\",\"image\":null},{\"id\":306088771774,\"title\":\"Caramelizados\",\"handle\":\"caramelizados\",\"image\":null},{\"id\":306088476862,\"title\":\"Cereales y Gramíneas\",\"handle\":\"cereales-y-gramineas\",\"image\":null},{\"id\":306087690430,\"title\":\"Chocolates\",\"handle\":\"chocolates\",\"image\":null},{\"id\":306088542398,\"title\":\"Coberturas\",\"handle\":\"coberturas\",\"image\":null},{\"id\":306089951422,\"title\":\"Condimentos\",\"handle\":\"condimentos\",\"image\":null},{\"id\":306089328830,\"title\":\"Condimentos, salsas y cremas\",\"handle\":\"condimentos-y-salsas-cremas\",\"image\":null},{\"id\":306297700542,\"title\":\"Conservas y encurtidos\",\"handle\":\"conservas-y-encurtidos\",\"image\":null},{\"id\":306088673470,\"title\":\"Copos\",\"handle\":\"copos\",\"image\":null},{\"id\":306089590974,\"title\":\"Cremas dulces\",\"handle\":\"cremas-dulces\",\"image\":null},{\"id\":306089394366,\"title\":\"Cremas y purés\",\"handle\":\"cremas-y-pures\",\"image\":null},{\"id\":306090279102,\"title\":\"Ecológico\",\"handle\":\"ecologico-eco\",\"image\":null},{\"id\":306090016958,\"title\":\"Esencias y aromas\",\"handle\":\"esencias-y-aromas\",\"image\":null},{\"id\":306087887038,\"title\":\"Especias\",\"handle\":\"especias\",\"image\":null},{\"id\":306090180798,\"title\":\"Frescos\",\"handle\":\"frescos\",\"image\":null},{\"id\":306088116414,\"title\":\"Fruta Deshidratada\",\"handle\":\"fruta-deshidratada\",\"image\":null},{\"id\":306089099454,\"title\":\"Fruta confitada\",\"handle\":\"fruta-confitada\",\"image\":null},{\"id\":306088378558,\"title\":\"Frutos secos\",\"handle\":\"frutos-secos\",\"image\":null},{\"id\":306087755966,\"title\":\"Frutos secos crudos\",\"handle\":\"frutos-secos-crudos\",\"image\":null},{\"id\":306088575166,\"title\":\"Frutos secos tostados\",\"handle\":\"frutos-secos-tostados\",\"image\":null},{\"id\":306087788734,\"title\":\"Féculas y Sémolas\",\"handle\":\"feculas-y-semolas\",\"image\":null},{\"id\":306088968382,\"title\":\"Galletas y snacks\",\"handle\":\"galletas-y-snacks\",\"image\":null},{\"id\":309347582142,\"title\":\"Gourmet\",\"handle\":\"gourmet\",\"image\":null},{\"id\":306088050878,\"title\":\"Garbanzos\",\"handle\":\"garbanzos\",\"image\":null},{\"id\":306089427134,\"title\":\"Granolas\",\"handle\":\"granolas\",\"image\":null},{\"id\":306087952574,\"title\":\"Granos\",\"handle\":\"granos\",\"image\":null},{\"id\":306088280254,\"title\":\"Guisantes\",\"handle\":\"guisantes\",\"image\":null},{\"id\":306087985342,\"title\":\"Harinas\",\"handle\":\"harinas\",\"image\":null},{\"id\":306090311870,\"title\":\"Herbolistería\",\"handle\":\"herbolisteria\",\"image\":null},{\"id\":306089656510,\"title\":\"Legumbres\",\"handle\":\"legumbres\",\"image\":null},{\"id\":306088149182,\"title\":\"Lentejas\",\"handle\":\"lentejas\",\"image\":null},{\"id\":306089623742,\"title\":\"Levadura\",\"handle\":\"levadura\",\"image\":null},{\"id\":306090115262,\"title\":\"Macrobiótica\",\"handle\":\"macrobiotica\",\"image\":null},{\"id\":306089689278,\"title\":\"Mermeladas\",\"handle\":\"mermeladas\",\"image\":null},{\"id\":306089001150,\"title\":\"Miel Artesanal\",\"handle\":\"miel-artesanal\",\"image\":null},{\"id\":663585292661,\"title\":\"Navidad\",\"handle\":\"navidad\",\"image\":null},{\"id\":306789810366,\"title\":\"Novedades\",\"handle\":\"novedades\",\"image\":null},{\"id\":306090049726,\"title\":\"OFERTAS\",\"handle\":\"ofertas\",\"image\":null},{\"id\":306090148030,\"title\":\"Panellets\",\"handle\":\"panellets\",\"image\":null},{\"id\":306089984190,\"title\":\"Repostería\",\"handle\":\"reposteria\",\"image\":null},{\"id\":306089525438,\"title\":\"Pasta\",\"handle\":\"pasta\",\"image\":null},{\"id\":306087919806,\"title\":\"Sales\",\"handle\":\"sal\",\"image\":null},{\"id\":306088247486,\"title\":\"Salvado\",\"handle\":\"salvado\",\"image\":null},{\"id\":306088345790,\"title\":\"Semillas\",\"handle\":\"semillas\",\"image\":null},{\"id\":306089164990,\"title\":\"Setas\",\"handle\":\"setas\",\"image\":null},{\"id\":306088837310,\"title\":\"Snacks\",\"handle\":\"snacks\",\"image\":null},{\"id\":306089132222,\"title\":\"Superalimentos\",\"handle\":\"superalimentos\",\"image\":null},{\"id\":306089197758,\"title\":\"Suplementos dietéticos\",\"handle\":\"suplementos-dieteticos\",\"image\":null},{\"id\":306089230526,\"title\":\"Tabletas\",\"handle\":\"tabletas\",\"image\":null},{\"id\":306087657662,\"title\":\"Tarjetas Regalo\",\"handle\":\"uncategorized\",\"image\":null},{\"id\":306087723198,\"title\":\"Té e infusiones\",\"handle\":\"te-e-infusiones\",\"image\":null},{\"id\":306090082494,\"title\":\"Utensilios y menaje\",\"handle\":\"utensilios-de-cocina-menaje-hogar\",\"image\":null},{\"id\":306088509630,\"title\":\"Vegano\",\"handle\":\"vegano\",\"image\":null},{\"id\":306089296062,\"title\":\"Vinagres\",\"handle\":\"vinagres\",\"image\":null},{\"id\":306089853118,\"title\":\"Zumos y bebidas\",\"handle\":\"zumos\",\"image\":null}]","productSelectionType":null}];
return bundleRules?.filter(rule => {
if ((rule?.allowedTags || rule?.restrictTags) && !isLoggedIn) {
return false;
}
if ((rule?.allowedTags || rule?.restrictTags) && isLoggedIn && isBundleRestrictedByNextVolumeDiscount(rule, customerTags)) {
return false;
}
return rule?.bundleType === 'VOLUME_DISCOUNT' && rule?.status === 'ACTIVE' && JSON.parse(rule?.variants)?.some(variant => parseInt(variant?.variantId, 10) === variantId);
}) || [];
};
const getMatchedCartItemByVariantId = (cartItems, variantId) => cartItems?.items?.find(item => item?.variant_id === variantId);
const getShopifyCartItems = async () => {
try {
const response = await fetch(`${Shopify?.routes?.root}cart.js`);
if (!response.ok) {
console.error('Network response was not ok');
return [];
}
return await response.json();
} catch (error) {
console.error('Failed to fetch cart items:', error);
return [];
}
};
})();