(() => {
const executeDynamicBundleBlock = ({ blockElement, productId = null, isCustomPage = false }) => {
const babBundles = [{"id":23530,"shop":"4c0bba-2.myshopify.com","name":"Your Home, Your Gym","description":null,"status":"ACTIVE","customerIncludeTags":null,"discountType":"PERCENTAGE","discountValue":10.0,"products":null,"variants":"[{\"productId\":10109810016543,\"variantId\":51127775461663,\"name\":\"Cable Machine CR63 - 55 LB A Pair-🔥 Top Choice\",\"productHandle\":\"cable-machine-cr63\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/summer_sale_1.webp?v=1754105678\",\"quantity\":1,\"price\":\"399.99\",\"status\":\"ACTIVE\",\"productTitle\":\"Cable Machine CR63\",\"variantTitle\":\"55 LB A Pair-🔥 Top Choice\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":10109810016543,\"variantId\":51127775428895,\"name\":\"Cable Machine CR63 - None\",\"productHandle\":\"cable-machine-cr63\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/summer_sale_1.webp?v=1754105678\",\"quantity\":1,\"price\":\"219.99\",\"status\":\"ACTIVE\",\"productTitle\":\"Cable Machine CR63\",\"variantTitle\":\"None\",\"isMandatory\":false,\"preSelected\":true,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":10223207350559,\"variantId\":51135896027423,\"name\":\"Adjustable Dumbbell MX55 (A Pair) \",\"productHandle\":\"adjustable-dumbbell\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/dumbbell_5_704c06a5-4a17-4d01-aba9-80d00dd37c71.webp?v=1755659245\",\"quantity\":1,\"price\":\"259.00\",\"status\":\"ACTIVE\",\"productTitle\":\"Adjustable Dumbbell MX55 (A Pair)\",\"variantTitle\":null,\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042750107935,\"name\":\"HIVEGYM ACCESSOIRES - Extension Rope\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"26.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Extension Rope\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042750075167,\"name\":\"HIVEGYM ACCESSOIRES - Pull Rope Handle\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"26.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Pull Rope Handle\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042749976863,\"name\":\"HIVEGYM ACCESSOIRES - Reward-Exercise Bar\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"36.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Reward-Exercise Bar\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042750140703,\"name\":\"HIVEGYM ACCESSOIRES - Reward-HIVEGYM Basic Box\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"60.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Reward-HIVEGYM Basic Box\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042750042399,\"name\":\"HIVEGYM ACCESSOIRES - Reward-Suction Cup*2\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"70.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Reward-Suction Cup*2\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":9802827596063,\"variantId\":50042750009631,\"name\":\"HIVEGYM ACCESSOIRES - Suction Cup\",\"productHandle\":\"hivegym-basic-box-copy\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_3_a2624be1-2715-4f6e-bed2-c103715188af.webp?v=1734517818\",\"quantity\":1,\"price\":\"40.00\",\"status\":\"ACTIVE\",\"productTitle\":\"HIVEGYM ACCESSOIRES\",\"variantTitle\":\"Suction Cup\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8806754156831,\"variantId\":50038623109407,\"name\":\"Portable Gym HIVEGYM Power Pump - Advanced\",\"productHandle\":\"hivegym-power-pump\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_1295c6dd-0ad2-4f67-b020-0dd85bdca327.webp?v=1746609865\",\"quantity\":1,\"price\":\"249.00\",\"status\":\"ACTIVE\",\"productTitle\":\"Portable Gym HIVEGYM Power Pump\",\"variantTitle\":\"Advanced\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8806754156831,\"variantId\":50038623076639,\"name\":\"Portable Gym HIVEGYM Power Pump - Basic\",\"productHandle\":\"hivegym-power-pump\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_1295c6dd-0ad2-4f67-b020-0dd85bdca327.webp?v=1746609865\",\"quantity\":1,\"price\":\"239.00\",\"status\":\"ACTIVE\",\"productTitle\":\"Portable Gym HIVEGYM Power Pump\",\"variantTitle\":\"Basic\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null},{\"productId\":8806754156831,\"variantId\":50038623142175,\"name\":\"Portable Gym HIVEGYM Power Pump - Professional\",\"productHandle\":\"hivegym-power-pump\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/hivegym_1295c6dd-0ad2-4f67-b020-0dd85bdca327.webp?v=1746609865\",\"quantity\":1,\"price\":\"520.00\",\"status\":\"ACTIVE\",\"productTitle\":\"Portable Gym HIVEGYM Power Pump\",\"variantTitle\":\"Professional\",\"isMandatory\":false,\"preSelected\":false,\"minQuantity\":null,\"maxQuantity\":null}]","sequenceNo":null,"bundleType":"CLASSIC_BUILD_A_BOX","settings":null,"bundleProductId":null,"bundleVariantId":null,"productHandle":null,"discountId":null,"price":null,"numberOfProducts":0,"subscriptionBundlingEnabled":false,"subscriptionId":null,"minProductCount":2,"maxProductCount":null,"uniqueRef":"YK7wWFRke7","bundleRedirect":"CART","customRedirectURL":null,"minOrderAmount":20.0,"tieredDiscount":null,"productViewStyle":"QUICK_ADD","singleProductSettings":null,"trackInventory":false,"sellingPlanType":"BUNDLE_LEVEL","clearCart":"ENABLED","minPrice":null,"maxPrice":null,"externalBuildABoxId":null,"variantVisibilityType":"SHOW_VARIANTS_AS_OPTIONS","subTitle":"An exclusive discount will be applied at checkout.","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":"hivegym页面bundle","sections":"[{\"id\":1,\"name\":\"\",\"description\":\"\",\"minProductCount\":0,\"maxProductCount\":0,\"variants\":[]}]","limitToUsePerCustomer":-3,"discountedVariantSelectionLimit":null,"hideOneTimePurchase":false,"hideSubscriptionPurchase":false,"maxOrderAmount":null,"collectionData":null,"productSelectionType":"PRODUCT","tag":"appstle_bundles","productChooseType":"CHOOSE_ALL","variantSelectionLimit":null,"discountTargetType":"PRODUCT","enableSubscription":false,"subscriptionWidgetPosition":"BELOW","subscribeTitle":"Subscribe and Save","subscribeSubtitle":"Delivered Monthly","subscriptionPreselected":true,"getYAppliesOn":"BOTH","announcementBarMessage":null,"automaticDiscountNodeId":"gid://shopify/DiscountAutomaticNode/1974983917855","recurringCycleLimit":0},{"id":23531,"shop":"4c0bba-2.myshopify.com","name":"YOUR HOME, YOUR GYM","description":null,"status":"ACTIVE","customerIncludeTags":null,"discountType":"NO_DISCOUNT","discountValue":null,"products":"[{\"productId\":10223207350559,\"variantId\":null,\"price\":null,\"name\":\"Adjustable Dumbbell MX55 (A Pair)\",\"productHandle\":\"adjustable-dumbbell\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/dumbbell_5_704c06a5-4a17-4d01-aba9-80d00dd37c71.webp?v=1755659245\",\"quantity\":1,\"status\":\"ACTIVE\",\"options\":[]},{\"productId\":10109810016543,\"variantId\":null,\"price\":null,\"name\":\"Cable Machine CR63\",\"productHandle\":\"cable-machine-cr63\",\"imageSrc\":\"https://cdn.shopify.com/s/files/1/0802/0315/3695/files/summer_sale_1.webp?v=1754105678\",\"quantity\":1,\"status\":\"ACTIVE\",\"options\":[{\"name\":\"Cable Machine CR63 (Pair it with)\",\"value\":[{\"name\":\"55 LB A Pair-🔥 Top Choice\",\"selected\":true},{\"name\":\"None\",\"selected\":true}]}]}]","variants":"[]","sequenceNo":null,"bundleType":"CLASSIC","settings":null,"bundleProductId":10238240325919,"bundleVariantId":null,"productHandle":"your-home-your-gym","discountId":null,"price":null,"numberOfProducts":0,"subscriptionBundlingEnabled":false,"subscriptionId":null,"minProductCount":null,"maxProductCount":null,"uniqueRef":"y1RQh4yKi8","bundleRedirect":"CART","customRedirectURL":null,"minOrderAmount":null,"tieredDiscount":null,"productViewStyle":"QUICK_ADD","singleProductSettings":null,"trackInventory":false,"sellingPlanType":"BUNDLE_LEVEL","clearCart":"ENABLED","minPrice":478.99,"maxPrice":658.99,"externalBuildABoxId":null,"variantVisibilityType":"SHOW_VARIANTS_AS_INDIVIDUAL","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":"固定","sections":"[{\"id\":1,\"name\":\"\",\"description\":\"\",\"minProductCount\":0,\"maxProductCount\":0,\"variants\":[]}]","limitToUsePerCustomer":null,"discountedVariantSelectionLimit":null,"hideOneTimePurchase":false,"hideSubscriptionPurchase":false,"maxOrderAmount":null,"collectionData":null,"productSelectionType":"PRODUCT","tag":"appstle_bundles","productChooseType":"CHOOSE_ALL","variantSelectionLimit":null,"discountTargetType":"PRODUCT","enableSubscription":false,"subscriptionWidgetPosition":"BELOW","subscribeTitle":"Subscribe and Save","subscribeSubtitle":"Delivered Monthly","subscriptionPreselected":true,"getYAppliesOn":"BOTH","announcementBarMessage":null,"automaticDiscountNodeId":null,"recurringCycleLimit":null}];
window['isAppstleBuildABox'] = true;
window.sessionStorage.setItem('external-bundle-token', window.appstle_bundle_external_token);
const referenceBundle = blockElement.getAttribute('ref') || null;
const baseFilteredBundles = Array.isArray(babBundles) && babBundles?.length > 0 && babBundles.filter((rule) => {
if(!isCustomPage) {
rule.themeType = 'THEME_TWO';
}
if (rule?.bundleType === 'CLASSIC_BUILD_A_BOX' && rule?.status === 'ACTIVE' && (rule?.showBundleInProductPage === true || isCustomPage)) {
try {
const variants = JSON.parse(rule?.variants || '[]');
if(productId) return variants.some((variant) => parseInt(variant?.productId) === parseInt(productId));
if(!productId) return true;
} catch (e) {
console.error('Failed to parse JSON:', e);
return false;
}
}
return false;
}) || [];
const filteredBundles = isCustomPage && referenceBundle ? baseFilteredBundles?.filter(rule => rule?.uniqueRef === referenceBundle) : baseFilteredBundles;
if (filteredBundles?.length > 0 && blockElement) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = "https://bundles-admin.appstle.com/content/build-a-box.css?v=1760355692209";
document.head.appendChild(link);
const script = document.createElement('script');
script.async = true;
script.src = "https://bundles-admin.appstle.com/app/build-a-box.bundle.js?v=1760355692209";
document.head.appendChild(script);
filteredBundles.forEach((rule) => {
const bundleDiv = document.createElement('div');
const uniqueRef = rule?.uniqueRef;
bundleDiv.setAttribute('appstle-dynamic-bundle-unique-reference', uniqueRef);
bundleDiv.className = isCustomPage ? `appstleBundlesCustomPage appstleCustomPageDynamicBundle-${uniqueRef}` : `appstleBundlesProductPage appstleDynamicBundle-${uniqueRef}`;
blockElement.appendChild(bundleDiv);
const appBlockDiv = document.querySelector(isCustomPage ? 'div[data-block-handle="appstle-bundle-dynamic-pricing-custom-page"]' : 'div[data-block-handle="appstle-bundle-product-page-build-a-box"]');
if (appBlockDiv) {
appBlockDiv.appendChild(blockElement);
}
});
}
};
const executeDynamicBundleLogic = () => {
const productId = "";
const blockElement = document.getElementById('dynamic-pricing-bundle-product-page');
const blockElements = document.querySelectorAll('.ab-dynamic-bundle-custom-placement-selector');
if (blockElement && productId) {
blockElement.classList.add(`product-id-${productId}`);
executeDynamicBundleBlock({ blockElement, productId, isCustomPage: false });
}
if (blockElements && blockElements.length > 0) {
blockElements.forEach((element) => {
const productId = element?.getAttribute('data-product-id');
element.classList.add(`product-id-${productId}`);
executeDynamicBundleBlock({ blockElement: element, productId, isCustomPage: false });
});
}
const customPageBlockElement = document.getElementById('dynamic-pricing-bundle-custom-page');
if (customPageBlockElement) executeDynamicBundleBlock({ blockElement: customPageBlockElement, productId: null, isCustomPage: true });
}
document.addEventListener('DOMContentLoaded', executeDynamicBundleLogic);
})();
document.addEventListener('DOMContentLoaded', () => {
const bundleSettings = {"id":7661,"shop":"4c0bba-2.myshopify.com","showOnProductPage":null,"selector":null,"placement":"AFTER","customCss":null,"customizeBundleOptionType":"RADIO","buyButtonSelector":null,"labels":"{\"productDiscountCombinedWithOrderDiscount\":true,\"bundleListViewDetailsButtonLabel\":\"View Details\",\"topBarFixedDiscountTitlePostfix\":\"{{currency}}{{discount}} off on shipping\",\"requiredLoginValidationLabel\":\"Please log in to purchase this bundle!\",\"volumeDiscountTypeLabel\":\"Volume Discount\",\"loginAlertLinkLabel\":\"Click here to login\",\"includedSubscriptionPlans\":\"\",\"breadCrumbProductsLabel\":\"Choose Products\",\"enableClassicBundleRecreation\":true,\"emptyProductImage\":\"https://cdn.shopify.com/s/files/1/0661/9224/4900/files/EmptyImage.jpg?v=1718447038\",\"enableAnnouncementBarAutoRotate\":true,\"reviewOrderInfoLabel\":\"\",\"productDiscountCombinedWithProductDiscount\":true,\"bundleMaximumQuantityLabel\":\"Add maximum up to {{maximum_quantity}} product\",\"volumeDiscountAppliesOnOneTimePurchase\":true,\"productAddToBundleLabel\":\"Add\",\"defaultSelectedPurchaseOptionSwitch\":\"ONE_TIME\",\"breadCrumbReviewBundleLabel\":\"Review Bundle\",\"enableScrollingToBundleSection\":false,\"orderNoteLabel\":\"Order Note\",\"showProductPerPage\":50,\"dynamicBundleDiscountCombinedWithShippingDiscount\":true,\"hidePurchaseOptionSelectLabel\":false,\"showPriceAsDecimals\":false,\"fixedDiscountText\":\"Enjoy a fixed discount of {{currency}}{{discount_value}} on your purchase!\",\"sectionTotalLabel\":\"Section Total\",\"fieldDisabledBackgroundColor\":\"#D1D5DB\",\"bundleTotalLabel\":\"Total\",\"disableRefreshSellingPlan\":false,\"checkInventoryQuantity\":false,\"showSubscriptionPlanDescription\":false,\"disableProductDescription\":false,\"fixedPricingBundleTypeLabel\":\"Fixed Pricing Bundle\",\"subscriptionAvailableLabel\":\"Subscription Available\",\"excludeSubscriptionPlans\":\"\",\"readLessText\":\"Read Less\",\"buyXGetYDiscountAppliesOnSubscription\":true,\"shippingDiscountLabel\":\"{{discount}}{{discount_type}} Shipping Discount\",\"selectedGiftProductProgressLabelText\":\"{{selected_product_quantity}} gift products added. The required quantity is {{required_product_quantity}}.\",\"disableFitImage\":false,\"secondaryTextColor\":\"#ece0dc\",\"bundleProductsQuantityLabel\":\"{{quantity}}x quantity\",\"buyXGetYDiscountCombinedWithProductDiscount\":true,\"tieredDiscountLabel\":\"{{discount_amount}}{{discount_type}} Discount\",\"buyXGetYQuantityValidationLabel\":\"Add {{product_quantity}} quantities of the gift product (Get Y)\",\"primaryTextColor\":\"#000000\",\"modalOpenOnAddToCart\":true,\"notApplicableForSubscribeAndSaveNotificationTitle\":\"Not applicable for subscribe & save\",\"customSignInLink\":\"\",\"productDiscountAppliesOnOneTimePurchase\":true,\"topBarDiscountUnlockTitlePrefix\":\"You've unlocked \",\"loginAlertTextLabel\":\"You need to login to purchase this bundle.\",\"buyXGetYChooseProductLabel\":\"Choose Product\",\"chooseAPlanLabel\":\"Choose Plan\",\"singleParentProductDirectRedirectToChildProducts\":true,\"buyXGetYFixedDiscountText\":\"Enjoy a fixed discount of {{discount_value}} {{currency}}\",\"primaryColor\":\"#000000\",\"buyXGetYGiftProductPriceVisibilityType\":\"UNIT_PRICE\",\"shippingDiscountRecurringCycleLimit\":0,\"volumeDiscountVariantSelectLabel\":\"Denominations\",\"chooseSourceProductValidationLabel\":\"Please choose source product!\",\"shippingDiscountAppliesOnSubscription\":true,\"volumeDiscountSpentAmountRewardsLabel\":\"Spend {{currency}}{{spent_amount}} and get {{discount}}{{discount_type}} discount!\",\"hideBundleToastNotification\":false,\"classicBundleTypeLabel\":\"Classic Bundle\",\"volumeDiscountRecurringCycleLimit\":0,\"bundleListDescription\":\"Explore our Bundles and Discounted Pricing and enjoy exclusive discounts when you buy products together\",\"getYNoProductSelectedLabel\":\"No gift product selected (Get Y)\",\"hideVariantSelectLabel\":false,\"availableOnlySubscriptionLabel\":\"Available Only On Subscription\",\"enableParentProductDetailButton\":false,\"bundleListTitle\":\"List of Bundles and Discounted Pricing\",\"chooseAssociatedProductsValidationLabel\":\"Please choose associated products!\",\"selectedSourceProductLabel\":\"Selected\",\"enableBuyXGetYWidgetMergeAsOptions\":false,\"volumeDiscountNextApplicableSpentAmountRewardsLabel\":\"Spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}\",\"sectionNoProductSelectedValidationLabel\":\"No product selected for: {{section_name}}!\",\"bundlePageBackgroundColor\":\"#FAFAF9\",\"showVendorName\":false,\"buyXQuantityValidationLabel\":\"Add {{product_quantity}} quantities of the product (Bux X)\",\"sectionMaximumQuantityValidationLabel\":\"Maximum quantity not selected for: {{section_name}}!\",\"enableMaxDiscountCap\":false,\"volumeAmountDiscountSaveRewardsLabel\":\"Save {{currency}}{{discount}}!\",\"sectionLabel\":\"Section\",\"disabledTextColor\":\"#6B7280\",\"primaryHoverColor\":\"#000000\",\"shippingDiscountCombinedWithOrderDiscount\":true,\"defaultDiscountBarMessage\":\"Welcome to our store\",\"enableBundleProductFilter\":false,\"buyXGetYDiscountCombinedWithOrderDiscount\":true,\"bundleSubtotalLabel\":\"Subtotal\",\"reviewOrderDescription\":\"Check your items and select your required frequency plan\",\"dynamicBundleDiscountCombinedWithOrderDiscount\":true,\"volumeDiscountSaveRewardsLabel\":\"Save {{discount}}{{discount_type}}!\",\"addingProductsToBundle\":\"Adding products to bundle\",\"buyXGetYMergedWidgetTitle\":\"Select Buy X Get Y Discount\",\"bundleModalHeaderLabel\":\"Your Bundle({{total_quantity}})\",\"productAddedToBundleNotificationDescription\":\"{{product_title}} added to bundle.\",\"dynamicBundleDiscountAppliesOnSubscription\":true,\"productDiscountTypeLabel\":\"Product Discount\",\"bundleTopHtml\":\"\",\"proceedToCheckoutButtonText\":\"\",\"defaultSelectedPurchaseOption\":\"ONE_TIME\",\"showDraftProduct\":false,\"switchSubscriptionLabel\":\"Subscribe & Save\",\"percentDiscountText\":\"Get {{discount_value}}% off on your purchase!\",\"discountUsageLimitExceedLabel\":\"You have exceeded the bundle usage limit\",\"reviewOrderLabel\":\"Review Bundle\",\"chooseSectionProductsLabel\":\"Choose Section Products\",\"primaryDisabledColor\":\"#333333\",\"bundleMinimumOrderAmountLabel\":\"Add minimum {{minimum_amount}} order amount\",\"dynamicBundleDiscountRecurringCycleLimit\":0,\"breadCrumbSelectSectionLabel\":\"Select Section\",\"loadMoreButtonLabel\":\"Load More\",\"bundleQuantityRewardsLabel\":\"Add {{quantity}} item, get {{discount}}{{discount_type}} discount\",\"shippingDiscountCombinedWithProductDiscount\":true,\"sellingPlanNameSortOrder\":\"ASC\",\"switchOnTimeLabel\":\"One Time\",\"volumeDiscountCombinedWithProductDiscount\":true,\"chooseProductsText\":\"Products\",\"productDetailsViewType\":\"SHOW_PRODUCT_POPUP\",\"enableManualBundleBlockIntegration\":false,\"volumeDiscountNextApplicableQuantityRewardsLabel\":\"Buy {{quantity}} get {{discount}}{{discount_type}}\",\"bundleCheckoutLabel\":\"Checkout\",\"productDiscountCombinedWithShippingDiscount\":true,\"skipSelectSectionPage\":false,\"productCardBackgroundColor\":\"#ffffff\",\"buyXGetYFreeLabel\":\"Free\",\"buttonBackgroundColor\":\"#000000\",\"dockbarHeadingLabel\":\"Bundle\",\"discountMessageInterval\":3000,\"sectionedBundleTypeLabel\":\"Sectioned Bundle\",\"buyXGetYAddToCartLabel\":\"Add to cart\",\"buyXGetYDiscountCombinedWithShippingDiscount\":true,\"dynamicBundleDiscountCodeText\":\"BUNDLE_DISCOUNT_{{bundle_id}}\",\"productDiscountAppliesOnSubscription\":true,\"selectedProgressLabelText\":\"{{total_bundle_items}} item added with a minimum quantity of {{minimum_quantity}}\",\"requiredBundleProductLabel\":\"Your bundle needs {{min_product_count}} more item(s).\",\"sellingPlanSelectionDropDownLabel\":\"Purchase Options\",\"buyXGetYPercentDiscountText\":\"Enjoy a percentage discount of {{discount_value}}%\",\"dockbarDescriptionLabel\":\"You're getting the most rewards!\",\"productDiscountRecurringCycleLimit\":0,\"preventClickableProductsOnCart\":false,\"enableProductDetailButton\":false,\"discountTargetType\":\"VARIANT\",\"buyXGetYDiscountTypeLabel\":\"Buy X Get Y Discount\",\"customOfferLink\":\"collections/all\",\"noItemsInBundle\":\"No items added to the bundle\",\"topBarPercentDiscountTitlePostfix\":\"{{discount}}% off on shipping\",\"variantSelectionDropDownLabel\":\"Variants\",\"chooseSectionLabel\":\"Choose Section\",\"dynamicPricingBundleTypeLabel\":\"Dynamic Pricing Bundle\",\"breadCrumbPlanLabel\":\"Select Plan\",\"showDynamicBundleOrderNote\":false,\"showOutOfStockProduct\":true,\"disabledSellingPlanSelectionValidation\":false,\"disableViewShopifyProduct\":false,\"bundleDiscountLabel\":\"Discount\",\"topBarDiscountRequiredAmountTitlePrefix\":\"Add {{currency}}{{remainingAmount}} more to unlock \",\"volumeDiscountAppliedQuantityRewardsLabel\":\"Applied: buy {{quantity}} get {{discount}}{{discount_type}}\",\"bundleNotEligibleLabel\":\"You're not eligible to purchase this bundle!\",\"reviewOrderProductsLabel\":\"Bundle Products\",\"outOfStockLabel\":\"Out Of Stock\",\"showUnitPrice\":false,\"buyXGetYFreeGiftDiscountText\":\"Enjoy the free product\",\"showDescriptionPopup\":true,\"maxDiscountCapValue\":0,\"readMoreText\":\"Read More\",\"totalBundleProductsAddedLabel\":\"{{total_bundle_items}} Products Added\",\"bundleMinimumQuantityLabel\":\"Add minimum {{minimum_quantity}} product\",\"noSourceProductSelectedLabel\":\"No source product selected.\",\"nonListedProductText\":\"Non-Listed\",\"buyXNoProductSelectedLabel\":\"No product selected (Buy X)\",\"volumeDiscountQuantityRewardsLabel\":\"Buy {{quantity}} quantity and get {{discount}}{{discount_type}} discount!\",\"freeShippingLabel\":\"Free Shipping\",\"previousButtonLabel\":\"Previous Step\",\"draftBundlePageTitle\":\"Oops! This bundle is temporarily unavailable.\",\"productDetailsMaximumDescriptionCount\":300,\"oneTimeOnlyLabel\":\"One time only\",\"buyXAnyNumberOfProductChooseLabel\":\"Choose any number of products\",\"productFilterConfig\":\"{\\\"enabled\\\":false,\\\"filters\\\":[]}\",\"volumeAmountDiscountQuantityRewardsLabel\":\"Buy {{quantity}} quantity and get {{currency}}{{discount}} discount!\",\"disableDiscountedPricingRedirectToCart\":false,\"volumeDiscountCombinedWithOrderDiscount\":true,\"dynamicBundleDiscountAppliesOnOneTimePurchase\":true,\"choosePlanButtonLabel\":\"Choose Plan\",\"enableAnnouncementBar\":false,\"bundleQuantityLabel\":\"{{quantity}}x\",\"showClassicBundleWidgetInChildProduct\":false,\"shippingDiscountAppliesOnOneTimePurchase\":true,\"classicBundleLinkLabel\":\"Go to the Classic Bundle\",\"topBarDiscountRequiredQuantityTitlePrefix\":\"Add {{remainingQuantity}} more item(s) to unlock \",\"bundleDetailsLabel\":\"Your bundle:\",\"buyXGetYDiscountAppliesOnOneTimePurchase\":true,\"volumeDiscountAppliedSpentAmountRewardsLabel\":\"Applied: spend {{spent_amount}}{{currency}} get {{discount}}{{discount_type}}\",\"enableAutoRemoveRelevantBundleItemInCart\":false,\"bundleModalShowRewardsLabel\":\"Show all rewards\",\"topBarFreeShippingTitlePostfix\":\"free shipping\",\"buyXGetYDiscountRecurringCycleLimit\":0,\"cartAndCheckoutMandatoryProductValidationMessage\":\"This bundle or discount must include all required products and they cannot be removed.\",\"volumeAmountDiscountSpentAmountRewardsLabel\":\"Spend {{currency}}{{spent_amount}} and get {{currency}}{{discount}} discount!\",\"notApplicableForOneTimeNotificationTitle\":\"Not applicable for one time\",\"showDiscountToNonEligibleCustomers\":false,\"primaryDisabledTextColor\":\"#ffffff\",\"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\",\"nextButtonLabel\":\"Next Step\",\"classicBundleDescriptionLabel\":\"Your bundle contains the following products.\",\"bundleBottomHtml\":\"\",\"sectionMinimumQuantityValidationLabel\":\"Minimum quantity not selected for: {{section_name}}!\",\"volumeDiscountAppliesOnSubscription\":true,\"dynamicBundleDiscountCombinedWithProductDiscount\":true,\"buyXGetYAnyNumberOfGiftProductLabel\":\"Choose any number of gift products\",\"descriptionLength\":200,\"bundleDiscountNote\":\"Discounts will be applied at checkout.\",\"bundleModalCloseRewardsLabel\":\"Close all rewards\",\"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.\",\"enableShowMultipleImages\":false,\"redirectToCartPageOnCartIconClick\":true,\"freeShippingDiscountCodeText\":\"FREE_SHIPPING_{{bundle_id}}\",\"customOfferLinkButtonLabel\":\"Explore Offers\",\"oneTimePurchaseLabel\":\"One Time Purchase\",\"bundleMaximumOrderAmountLabel\":\"Add maximum {{maximum_amount}} order amount\",\"enableBundleProductAscOrderView\":true,\"productAddedToBundleNotificationTitle\":\"Added to bundle\",\"showClassicBundleProductVariant\":false,\"customHtmlInject\":\"[]\",\"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":"#000000","primaryTextColor":"#000000","secondaryTextColor":"#ece0dc","primaryHoverColor":"#000000","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","defaultSelectedPurchaseOptionSwitch":"ONE_TIME","defaultSelectedPurchaseOption":"ONE_TIME","discountTargetType":"VARIANT","enableShowMultipleImages":false,"buyXGetYAnyNumberOfGiftProductLabel":"Choose any number of gift products","showDiscountToNonEligibleCustomers":false,"dynamicBundleDiscountRecurringCycleLimit":0,"dynamicBundleDiscountAppliesOnOneTimePurchase":true,"dynamicBundleDiscountAppliesOnSubscription":true,"volumeDiscountRecurringCycleLimit":0,"volumeDiscountAppliesOnOneTimePurchase":true,"volumeDiscountAppliesOnSubscription":true,"productDiscountRecurringCycleLimit":0,"productDiscountAppliesOnOneTimePurchase":true,"productDiscountAppliesOnSubscription":true,"buyXGetYDiscountRecurringCycleLimit":0,"buyXGetYDiscountAppliesOnOneTimePurchase":true,"buyXGetYDiscountAppliesOnSubscription":true,"shippingDiscountRecurringCycleLimit":0,"shippingDiscountAppliesOnOneTimePurchase":true,"shippingDiscountAppliesOnSubscription":true,"buyXNoProductSelectedLabel":"No product selected (Buy X)","getYNoProductSelectedLabel":"No gift product selected (Get Y)","buyXQuantityValidationLabel":"Add {{product_quantity}} quantities of the product (Bux X)","buyXAnyNumberOfProductChooseLabel":"Choose any number of products","freeShippingDiscountCodeText":"FREE_SHIPPING_{{bundle_id}}","includedSubscriptionPlans":"","excludeSubscriptionPlans":"","enableBuyXGetYWidgetMergeAsOptions":false,"buyXGetYMergedWidgetTitle":"Select Buy X Get Y Discount","showClassicBundleProductVariant":false,"showProductPerPage":50,"loadMoreButtonLabel":"Load More","enableBundleProductAscOrderView":true,"cartAndCheckoutMandatoryProductValidationMessage":"This bundle or discount must include all required products and they cannot be removed.","sellingPlanNameSortOrder":"ASC","showVendorName":false,"disableFitImage":false,"enableAutoRemoveRelevantBundleItemInCart":false,"enableBundleProductFilter":false,"productFilterConfig":"{\"enabled\":false,\"filters\":[]}","enableMaxDiscountCap":false,"maxDiscountCapValue":0,"classicBundleLinkLabel":"Go to the Classic Bundle","showPriceAsDecimals":false,"showClassicBundleWidgetInChildProduct":false,"showOutOfStockProduct":true,"showDraftProduct":false,"totalBundleProductsAddedLabel":"{{total_bundle_items}} Products Added","bundleProductsQuantityLabel":"{{quantity}}x quantity","showUnitPrice":false,"productDetailsViewType":"SHOW_PRODUCT_POPUP","disableRefreshSellingPlan":false,"enableShippingDiscountBar":null,"enableVolumeDiscountBar":null,"defaultDiscountBarMessage":"Welcome to our store","discountMessageInterval":3000,"addedBundleToTheCart":null,"disabledSellingPlanSelectionValidation":false,"volumeDiscountVariantSelectLabel":"Denominations","enableScrollingToBundleSection":false,"enableClassicBundleRecreation":true,"topBarDiscountUnlockTitlePrefix":"You've unlocked ","topBarDiscountRequiredAmountTitlePrefix":"Add {{currency}}{{remainingAmount}} more to unlock ","topBarDiscountRequiredQuantityTitlePrefix":"Add {{remainingQuantity}} more item(s) to unlock ","topBarPercentDiscountTitlePostfix":"{{discount}}% off on shipping","topBarFixedDiscountTitlePostfix":"{{currency}}{{discount}} off on shipping","topBarFreeShippingTitlePostfix":"free shipping","checkInventoryQuantity":false,"hideBundleToastNotification":false,"enableBundleRecreation":null,"enableAnnouncementBar":false,"enableAnnouncementBarAutoRotate":true,"bundleListTitle":"List of Bundles and Discounted Pricing","bundleListDescription":"Explore our Bundles and Discounted Pricing and enjoy exclusive discounts when you buy products together","bundleListViewDetailsButtonLabel":"View Details","classicBundleTypeLabel":"Classic Bundle","dynamicPricingBundleTypeLabel":"Dynamic Pricing Bundle","fixedPricingBundleTypeLabel":"Fixed Pricing Bundle","sectionedBundleTypeLabel":"Sectioned Bundle","volumeDiscountTypeLabel":"Volume Discount","productDiscountTypeLabel":"Product Discount","buyXGetYDiscountTypeLabel":"Buy X Get Y Discount","bundlePageBackgroundColor":"#FAFAF9","productCardBackgroundColor":"#ffffff","buttonBackgroundColor":"#000000","showPrepaidPerDeliveryPrice":null,"prepaidPerDeliveryPriceLabel":null};
if (!bundleSettings?.enableAutoRemoveRelevantBundleItemInCart) return;
const originalFetch = window.fetch;
window.fetch = async function (...args) {
const [resource, config] = args;
const isRemoveRequest = typeof resource === 'string' &&
resource.includes('/cart/change') &&
config?.method === 'POST';
if (!isRemoveRequest) {
return originalFetch(...args);
}
let bodyData = {};
try {
bodyData = JSON.parse(config.body);
} catch (e) {
console.warn('Failed to parse request body', e);
return originalFetch(...args);
}
if (bodyData.quantity !== 0) {
return originalFetch(...args);
}
const cart = await fetch('/cart.js').then(res => res.json());
const removingLineIndex = parseInt(bodyData?.line) - 1;
const removingItem = cart?.items[removingLineIndex];
const bundleId = removingItem?.properties?.["_appstle-bb-id"];
if (!bundleId) {
return originalFetch(...args);
}
const updates = {};
cart?.items.forEach(item => {
if (item?.properties?.["_appstle-bb-id"] === bundleId) {
updates[item?.key] = 0;
}
});
const hasNonBundleItems = cart?.items.some(item => !item?.properties?.["_appstle-bb-id"]);
await fetch('/cart/update.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ updates })
});
if (hasNonBundleItems) {
const sections = bodyData?.sections;
const sectionsUrl = bodyData?.sections_url || '/cart';
const htmlResponse = await fetch(
`/?sections=${sections.join(',')}§ions_url=${encodeURIComponent(sectionsUrl)}`
);
const htmlData = await htmlResponse.json();
return new Response(JSON.stringify({
status: 'bundle removed',
sections: htmlData
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
return originalFetch(...args);
};
});
document.addEventListener('DOMContentLoaded', () => {
const originalFetch = window.fetch;
window.fetch = async function (...args) {
const [resource, config] = args;
const isCartUpdate = typeof resource === 'string' &&
(resource.includes('/cart/change') || resource.includes('/cart/update')) &&
config?.method === 'POST';
if (!isCartUpdate) {
return originalFetch(...args);
}
const response = await originalFetch(...args);
const cart = await fetch('/cart.js').then(res => res.json());
const hasBundleItems = cart?.items.some(item =>
item?.properties?.["_appstle-bb-id"]
);
const freeProductItems = cart?.items.filter(item =>
item?.properties?.["_appstle_free_product"] === true ||
item?.properties?.["_appstle_free_product"] === "true"
);
if (!hasBundleItems && freeProductItems.length > 0) {
const updates = {};
freeProductItems.forEach(item => {
updates[item?.key] = 0;
});
await fetch('/cart/update.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ updates })
});
let bodyData = {};
try {
bodyData = JSON.parse(config.body);
} catch (e) {
}
if (bodyData?.sections) {
const sections = bodyData.sections;
const sectionsUrl = bodyData.sections_url || '/cart';
const htmlResponse = await fetch(
`/?sections=${sections.join(',')}§ions_url=${encodeURIComponent(sectionsUrl)}`
);
const htmlData = await htmlResponse.json();
return new Response(JSON.stringify({
status: 'free product removed',
sections: htmlData
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
}
return response;
};
});