@kachingappz/bundles-js 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles-js.iife.js +39 -7
- package/dist/index.d.ts +19 -0
- package/dist/index.js +174 -92
- package/dist/kaching-bundle-component/index.d.ts +19 -0
- package/dist/kaching-bundle-component/index.js +203 -121
- package/dist/react/index.cjs +39 -7
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +193 -111
- package/package.json +3 -3
package/dist/bundles-js.iife.js
CHANGED
|
@@ -88,8 +88,8 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
91
|
-
`,h=async(e,{country:t,language:n,productIds:r,includeSellingPlans:i=!0,includeAvailableQuantity:a=!0,includeProductRating:o=!1,includeProductSubtitle:s=!1,productSubtitleMetafield:
|
|
92
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${
|
|
91
|
+
`,h=async(e,{country:t,language:n,productIds:r,includeSellingPlans:i=!0,includeAvailableQuantity:a=!0,includeProductRating:o=!1,includeProductSubtitle:s=!1,includeProductTabFields:l=!1,productSubtitleMetafield:u=`descriptors.subtitle`,useExternalMetafieldNamespace:d=!1,batchSize:f=250,onBatchError:p,variantImageTransform:h={maxWidth:200,maxHeight:200}})=>{if(!r.length)return[];let y=r.map(e=>typeof e==`string`&&e.startsWith(`gid://`)?e:`gid://shopify/Product/${e}`),b=c({country:t,language:n}),x=`
|
|
92
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${b} {
|
|
93
93
|
shop {
|
|
94
94
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
95
95
|
value
|
|
@@ -152,6 +152,10 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
152
152
|
subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
|
|
153
153
|
value
|
|
154
154
|
}
|
|
155
|
+
category @include(if: $includeProductTabFields) {
|
|
156
|
+
id
|
|
157
|
+
}
|
|
158
|
+
tags @include(if: $includeProductTabFields)
|
|
155
159
|
requiresSellingPlan
|
|
156
160
|
sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
|
|
157
161
|
nodes {
|
|
@@ -159,6 +163,7 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
159
163
|
nodes {
|
|
160
164
|
id
|
|
161
165
|
name
|
|
166
|
+
recurringDeliveries
|
|
162
167
|
priceAdjustments {
|
|
163
168
|
adjustmentValue {
|
|
164
169
|
__typename
|
|
@@ -184,7 +189,16 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
|
-
`,
|
|
192
|
+
`,S=d?`app--2935586817--kaching_bundles`:`$app:kaching_bundles`,C=u.indexOf(`.`),w=u.slice(0,C),T=u.slice(C+1),E=[],D=Math.min(f,250);for(let e=0;e<y.length;e+=D)E.push(y.slice(e,e+D));let O=1,k=async n=>{let[r,c]=await Promise.all([e.query(x,{variables:{productGIDs:n,includeSellingPlans:i,includeAvailableQuantity:a,includeProductRating:o,includeProductSubtitle:s,includeProductTabFields:l,subtitleNamespace:w,subtitleKey:T,metafieldNamespace:S,variantImageTransform:h}}),l?g(e,t,n):null]);return r.shop.currencyRateConstant&&(O=JSON.parse(r.shop.currencyRateConstant.value).amount/1e6),c?{nodes:r.nodes.map(e=>e&&{...e,productType:c.get(e.id)})}:r},A;if(p){let e=await Promise.allSettled(E.map(k));for(let t of e)t.status===`rejected`&&p(t.reason instanceof Error?t.reason:Error(String(t.reason)));A=e.filter(e=>e.status===`fulfilled`).flatMap(e=>e.value.nodes)}else A=(await Promise.all(E.map(k))).flatMap(e=>e.nodes);let j=A.filter(e=>e!=null);if(p){let t=await Promise.allSettled(j.map(async t=>v(await _(e,t,{includeSellingPlans:i,includeAvailableQuantity:a,variantImageTransform:h},b),e.shopifyDomain,O))),n=[];for(let e of t)e.status===`fulfilled`?n.push(e.value):p(e.reason instanceof Error?e.reason:Error(String(e.reason)));return n}return(await Promise.all(j.map(t=>_(e,t,{includeSellingPlans:i,includeAvailableQuantity:a,variantImageTransform:h},b)))).map(t=>v(t,e.shopifyDomain,O))},g=async(e,t,n)=>{try{let r=await e.query(`
|
|
193
|
+
query FetchProductTypes($productGIDs: [ID!]!) ${c({country:t})} {
|
|
194
|
+
nodes(ids: $productGIDs) {
|
|
195
|
+
... on Product {
|
|
196
|
+
id
|
|
197
|
+
productType
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
`,{variables:{productGIDs:n}});return new Map(r.nodes.filter(e=>e!=null).map(e=>[e.id,e.productType]))}catch(e){return console.error(e),null}},_=async(e,t,n,r=``)=>{if(t.variants.nodes.length<250)return t;let i=new Set,a=[],o=[],s=async s=>{let c=!0,l=null;for(;c;){let{nodes:u,pageInfo:d}=(await e.query(`
|
|
188
202
|
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
|
|
189
203
|
product(id: $productGID) {
|
|
190
204
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
@@ -198,7 +212,7 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
198
212
|
}
|
|
199
213
|
}
|
|
200
214
|
}
|
|
201
|
-
`,{variables:{productGID:t.id,cursor:l,reverse:s,...n}})).product.variants;for(let e of u){if(i.has(e.id)){c=!1;break}i.add(e.id),s?o.push(e):a.push(e)}d.hasNextPage||(c=!1),l=d.endCursor}};return await Promise.all([s(!1),s(!0)]),t.variants.nodes=[...a,...o.reverse()],t},
|
|
215
|
+
`,{variables:{productGID:t.id,cursor:l,reverse:s,...n}})).product.variants;for(let e of u){if(i.has(e.id)){c=!1;break}i.add(e.id),s?o.push(e):a.push(e)}d.hasNextPage||(c=!1),l=d.endCursor}};return await Promise.all([s(!1),s(!0)]),t.variants.nodes=[...a,...o.reverse()],t},v=(e,t,n)=>{let r=e.variants.nodes.map(({unitPriceMeasurement:e,...t})=>({id:Number(t.id.split(`/`).pop()),availableForSale:t.availableForSale,price:Math.round(Number(t.price.amount)*100),compareAtPrice:t.compareAtPrice?Math.round(Number(t.compareAtPrice.amount)*100):null,options:t.selectedOptions.map(e=>e.value),imageId:t.image?Number(t.image.id.split(`/`).pop()):null,image:t.image?.url||null,sellingPlans:t.sellingPlanAllocations?.nodes.map(e=>({id:Number(e.sellingPlan.id.split(`/`).pop()),price:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].price.amount)*100):Math.round(Number(t.price.amount)*100),compareAtPrice:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(t.price.amount)*100),perDeliveryPrice:e.priceAdjustments.length>0?Math.round(Number(e.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(t.price.amount)*100)}))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:t.quantityAvailable??null,unitPriceMeasurement:e?.quantityUnit&&e?.referenceUnit?{quantityValue:e.quantityValue,quantityUnit:e.quantityUnit.toLowerCase(),referenceValue:e.referenceValue,referenceUnit:e.referenceUnit.toLowerCase()}:null})),i=e.options.map((e,t)=>{let n=e.optionValues.map(e=>({id:Number(e.id.split(`/`).pop()),defaultName:e.name,name:e.name,swatch:{color:e.swatch?.color||null,image:e.swatch?.image?.previewImage?.url||null}}));return{defaultName:e.name,name:e.name,position:t+1,optionValues:x(n,t,r)}}),a=e=>{let t=e.priceAdjustments[0];if(!t)return null;let n=t.adjustmentValue;switch(n.__typename){case`SellingPlanPercentagePriceAdjustment`:return{type:`percentage`,value:n.adjustmentPercentage};case`SellingPlanFixedAmountPriceAdjustment`:return{type:`fixed_amount`,value:o(n.adjustmentAmount.amount)};case`SellingPlanFixedPriceAdjustment`:return{type:`price`,value:o(n.price.amount)};default:throw Error(`Unknown price adjustment type: ${n.__typename}`)}},o=e=>n===1?Number(e)*100:Math.round(Number(e)*100*n),s=e.sellingPlanGroups?.nodes.flatMap(e=>e.sellingPlans.nodes.map(e=>({id:Number(e.id.split(`/`).pop()),name:e.name,recurringDeliveries:e.recurringDeliveries,priceAdjustment:a(e)})))||[],c=e.variants.nodes.some(e=>e.requiresComponents);return{id:Number(e.id.split(`/`).pop()),handle:e.handle,url:e.onlineStoreUrl||`https://${t}/products/${e.handle}`,availableForSale:e.availableForSale,createdAt:e.createdAt,title:e.title,image:e.featuredImage?.url||null,collectionIds:e.collections.nodes.map(e=>Number(e.id.split(`/`).pop())),options:i,selectedVariantId:Number(e.variants.nodes[0].id.split(`/`).pop()),variants:r,requiresSellingPlan:e.requiresSellingPlan,sellingPlans:s,isNativeBundle:c,metafields:{text:e.metafield?.value||null,text2:e.metafield2?.value||null,text3:e.metafield3?.value||null,text4:e.metafield4?.value||null},rating:y(e.reviewsRating,e.reviewsRatingCount),subtitle:e.subtitle?.value||null,productType:e.productType||null,categoryGid:e.category?.id??null,tags:e.tags??[]}},y=(e,t)=>{if(!e)return null;let n=b(e.value);if(n===null)return null;let r=Number(t?.value);return{value:n,count:Number.isInteger(r)&&r>0?r:null}},b=e=>{try{let{value:t,scale_max:n}=JSON.parse(e),r=Number(t)/Number(n)*5;return Number.isFinite(r)&&r>0?Math.min(5,r):null}catch{return null}},x=(e,t,n)=>e.filter(e=>n.filter(n=>n.options[t]===e.name).length>0);[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var S=`app--2935586817`,C=async(e,{language:n,country:r,useExternalMetafieldNamespace:i})=>{let a=i?`${S}--kaching_bundles`:`$app:kaching_bundles`,o=i?S:`$app`,s=c({country:r}),{localization:{country:{currency:{isoCode:l}}},shop:{moneyFormat:u,paymentSettings:{currencyCode:d},currencyRateConstant:f,primaryDomain:p,settingsMetafield:m}}=await e.query(`
|
|
202
216
|
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${s} {
|
|
203
217
|
localization {
|
|
204
218
|
country {
|
|
@@ -223,7 +237,7 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
223
237
|
}
|
|
224
238
|
}
|
|
225
239
|
}
|
|
226
|
-
`,{variables:{metafieldNamespace:a,settingsNamespace:o}}),h=l===d?u:t(l,{language:n,country:r}),g=f?
|
|
240
|
+
`,{variables:{metafieldNamespace:a,settingsNamespace:o}}),h=l===d?u:t(l,{language:n,country:r}),g=f?w(f.value):1,_=m?JSON.parse(m.value):null,v=_?.feature_flags??{},y=_?.custom_selectors??{};return{shopifyDomain:p.host,moneyFormat:h,locale:n?.toLowerCase()||`en`,liquidLocale:n?.toLowerCase()||`en`,country:r??`US`,currencyRate:g,marketId:0,productId:null,storefrontAccessToken:_?.storefront_access_token??null,includeSellingPlans:_?.include_selling_plans??!1,includeAvailableQuantity:_?.include_available_quantity??!1,customApiHost:_?.custom_api_host??null,keepQuantityInput:_?.keep_quantity_input??!1,ignoreDeselect:_?.ignore_deselect??!1,ignoreUnitPrice:_?.ignore_unit_price??!1,requireCustomerLogin:_?.require_customer_login??!1,abTestsRunning:_?.ab_tests_running??!1,webPixel:_?.web_pixel??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`Out of stock`,"system.invalid_variant":`Invalid variant`,"system.unavailable_option_value":`Unavailable option value`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:y.quantity??null,addToCartButton:y.add_to_cart_button??null,variantPicker:y.variant_picker??null,price:y.price??null,priceCompare:y.price_compare??null},shopCustomStyles:_?.shop_custom_styles??``,featureFlags:v,brandColors:_?.brand_colors??null}},w=e=>JSON.parse(e).amount/1e6,T=async(e,t,n=200)=>{let r=[...new Set(t.filter(Boolean).filter(e=>!e.startsWith(`placeholder`)))];if(r.length===0)return[];let i=[];for(let e=0;e<r.length;e+=250)i.push(r.slice(e,e+250));return(await Promise.all(i.map(t=>e.query(`
|
|
227
241
|
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
228
242
|
nodes(ids: $mediaImageIds) {
|
|
229
243
|
... on MediaImage {
|
|
@@ -234,5 +248,23 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
234
248
|
}
|
|
235
249
|
}
|
|
236
250
|
}
|
|
237
|
-
`,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},
|
|
238
|
-
`));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${fe}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},G=`kaching-bundles-block`,K=1e4,q=`/kaching-bundles-block.js`,me=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,he=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,J=new WeakSet,Y=async e=>{let t=e.document;if(!e.customElements.get(G)){if(J.has(t))return Q(e,G);J.add(t);try{await _e(e)}catch(e){throw J.delete(t),e}}},ge=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,X=()=>ge()?me:he,_e=async e=>{let t=e.document,n=X();if(t.querySelector(`script[src="${n}"]`))return Q(e,G);let r=ve(t);if(r&&await be(t,r))return Q(e,G);let i=t.createElement(`script`);return i.src=n,await Z(t,i),Q(e,G)},ve=e=>{let t=e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);return Array.from(t,e=>e.href).find(ye)},ye=e=>{try{return new URL(e).pathname.endsWith(q)}catch{return!1}},be=async(e,t)=>{let n=e.createElement(`script`);n.type=`module`,n.setAttribute(`crossorigin`,`anonymous`),n.src=t;try{return await Z(e,n),!0}catch{return n.remove(),!1}},Z=(e,t)=>new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(Error(`Failed to load script`)),e.head.appendChild(t)}),Q=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${K}ms`)),K))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var $=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),xe={config:{shopifyDomain:``,moneyFormat:"${{amount}}",locale:`en`,country:`US`,currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:``},dealBlock:{id:`example`,nanoId:`example`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:``,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:`duo`,cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`bold`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},dealBars:[{id:`single`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Single`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`duo`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Duo`,subtitle:`You save 20%`,label:`SAVE $32`,quantity:2,discountType:`percentage`,discountValue:`20`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`trio`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Trio`,subtitle:`You save 25%`,label:`SAVE $60`,quantity:3,discountType:`percentage`,discountValue:`25`,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`duo`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:``,customStyles:``,lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:`example-product`,url:null,availableForSale:!0,title:`Example product`,image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:[`Default Title`],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},Se=class extends HTMLElement{constructor(...e){super(...e),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return[`selected-variant-id`,`product-id`,`country`,`language`]}async connectedCallback(){await this.initialize()}async initialize(){let e=++this.initializeId;if(this.cleanup(),this.hasAttribute(`demo`)){if(await Y(window),e!==this.initializeId)return;this.renderInnerElement(xe);return}let t=this.getAttribute(`shop-domain`),n=this.getAttribute(`storefront-token`),r=this.getAttribute(`product-id`);if(!t||!n||!r)return;let[i]=await Promise.all([W({shopifyDomain:t,storefrontAccessToken:n},{productId:r,dealBlockId:this.getAttribute(`deal-block-id`)??void 0,abTestVariantId:this.getAttribute(`ab-test-variant-id`)??void 0,country:this.getAttribute(`country`)?.toUpperCase()??void 0,language:this.getAttribute(`language`)?.toUpperCase()??void 0}),Y(window)]);i&&e===this.initializeId&&this.renderInnerElement(i)}renderInnerElement(e){let{config:t,dealBlock:n,product:r,otherProducts:i,mediaImages:a,collectionBreaksProducts:o,translations:s}=e;this.innerElement=document.createElement(`kaching-bundles-block`),this.innerElement.setAttribute(`deal-block-id`,n.id),this.innerElement.setAttribute(`config`,JSON.stringify(t)),this.innerElement.setAttribute(`deal-block`,JSON.stringify(n)),this.innerElement.setAttribute(`media-images`,JSON.stringify(a??[])),this.innerElement.setAttribute(`product`,JSON.stringify(r)),this.innerElement.setAttribute(`other-products`,JSON.stringify(i??[])),this.innerElement.setAttribute(`collection-breaks-products`,JSON.stringify(o??[])),this.innerElement.setAttribute(`translations`,JSON.stringify(s??{}));let c=this.getAttribute(`selected-variant-id`);this.innerElement.setAttribute(`current-variant-id`,String(c?c.split(`/`).pop():r.variants[0].id)),this.hasAttribute(`compact`)&&this.innerElement.setAttribute(`compact`,``);let l=this.innerElement,u=()=>{if(this.innerElement!==l)return;let e=l.items();e&&this.dispatchEvent(new CustomEvent(`items-changed`,{detail:{items:e},bubbles:!0}))};this.handleItemsChanged=e=>{e.stopPropagation(),u()};let d=this.handleItemsChanged;l.addEventListener(`kaching-bundles-block-loaded`,()=>{this.innerElement===l&&(l.addEventListener(`items-changed`,d),this.dispatchEvent(new CustomEvent(`loaded`,{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener(`items-changed`,this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&=(this.innerElement.remove(),null)}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`product-id`||e===`country`||e===`language`?this.initialize():e===`selected-variant-id`&&this.innerElement&&n&&this.innerElement.setAttribute(`current-variant-id`,n.includes(`/`)?String(n.split(`/`).pop()):n))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}};return customElements.define(`kaching-bundle-component`,Se),e.fetchKachingBundlesData=W,e})({});
|
|
251
|
+
`,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},E=100,D=async(e,{dealBlock:t,country:n,language:r})=>{let i=[...new Set(t.dealBars.flatMap(e=>e.dealBarType===f.MixAndMatch?e.bundleProducts:[]).flatMap(e=>(e.selectedCollections??[]).map(e=>e.id)))];if(i.length===0)return[];let a=c({country:n,language:r}),o=await e.query(`
|
|
252
|
+
query FetchMixAndMatchCollectionProductGIDs($collectionGIDs: [ID!]!) ${a} {
|
|
253
|
+
nodes(ids: $collectionGIDs) {
|
|
254
|
+
... on Collection {
|
|
255
|
+
id
|
|
256
|
+
products(first: ${E}) {
|
|
257
|
+
nodes {
|
|
258
|
+
id
|
|
259
|
+
variants(first: 1) {
|
|
260
|
+
nodes {
|
|
261
|
+
requiresComponents
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
`,{variables:{collectionGIDs:i}});return[...new Set(o.nodes.filter(e=>e!==null).flatMap(e=>e.products.nodes).filter(e=>!e.variants.nodes.some(e=>e.requiresComponents)).map(e=>e.id))]},O=e=>[...k(e),...A(e),...j(e),...M(e),...N(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),k=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),A=e=>e.dealBars.flatMap(e=>e.dealBarType===f.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),j=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),M=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),N=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),ee=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],te=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ne=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],re=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ie=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),ae=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},oe=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),se=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ce=(e,{includeMixAndMatchSwapProducts:t=!0}={})=>{let n=[...le(e),...ue(e),...de(e),...P(e),...F(e),...I(e,t),...L(e),...R(e)];return Array.from(new Set(n.filter(e=>e!=null)))},le=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),ue=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),de=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],P=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),F=e=>e.dealBars.filter(e=>e.dealBarType===f.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),I=(e,t)=>e.dealBars.filter(e=>e.dealBarType===f.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...t?e.selectedProducts?.map(e=>e.id)??[]:[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),L=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),R=e=>e.dealBars.filter(e=>e.dealBarType===f.Sku).flatMap(({productGID:e})=>e?[e]:[]),z=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},B=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new z({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new z({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},V=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),B(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},H=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},fe=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await p(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await p(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await h(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0}),s=i.visibility===`deal-products`&&t.blockVisibility===`excluded-products`;return o=o.filter(e=>e.availableForSale&&(!s||H([t],e).length>0)),o},pe=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`,"system.gifts_required_alert":`Please choose your free gifts`},r=e?me(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},me=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=U(e);return n.find(e=>U(e.locale)===r)?.translations},U=e=>e.toLowerCase().replace(/_/g,`-`),he=`2026-07`,W=async(e,{productId:t,dealBlockId:n,abTestVariantId:r,country:i=void 0,language:a=void 0})=>{try{let o=[Number(t.split(`/`).pop())],s=new ge(e);i||=s.i18n?.country,a||=s.i18n?.language;let c=await C(s,{language:a,country:i,useExternalMetafieldNamespace:!0});s.shopifyDomain=c.shopifyDomain;let u=c.storefrontAccessToken?new V(c.shopifyDomain,c.storefrontAccessToken):s,[d,f]=await Promise.all([h(u,{country:i,language:a,productIds:o,useExternalMetafieldNamespace:!0}),l(u,{useExternalMetafieldNamespace:!0,useMetaobjects:c.featureFlags.storefront_metaobjects})]),p=d[0];if(!p)return null;let m=H(f,p),g=n?m.filter(e=>e.id===n||e.nanoId===n):m,_=(r?g.find(e=>e.abTestVariantId===r):void 0)??g[0]??m[0];if(!_)return null;let v=O(_),[y,b,x,S]=await Promise.all([(async()=>{let e=[];try{e=await D(u,{dealBlock:_,country:i,language:a})}catch(e){console.error(e)}return h(u,{country:i,language:a,productIds:[...new Set([...ce(_),...e])],useExternalMetafieldNamespace:!0})})(),T(u,v,300),fe(u,_,{country:i,language:a}),pe({language:a,dealBlockId:_.id})]);return{product:p,dealBlock:_,config:c,otherProducts:y,mediaImages:b,collectionBreaksProducts:x??[],translations:S}}catch(e){return console.error(e),null}},ge=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
|
|
270
|
+
`));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${he}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},G=`kaching-bundles-block`,K=1e4,q=`/kaching-bundles-block.js`,_e=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,ve=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,J=new WeakSet,Y=async e=>{let t=e.document;if(!e.customElements.get(G)){if(J.has(t))return Q(e,G);J.add(t);try{await xe(e)}catch(e){throw J.delete(t),e}}},ye=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,be=()=>ye()?_e:ve,xe=async e=>{let t=e.document,n=be();if(t.querySelector(`script[src="${n}"]`))return Q(e,G);let r=Se(t);if(r&&await X(t,r))return Q(e,G);let i=t.createElement(`script`);return i.src=n,await Z(t,i),Q(e,G)},Se=e=>{let t=e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);return Array.from(t,e=>e.href).find(Ce)},Ce=e=>{try{return new URL(e).pathname.endsWith(q)}catch{return!1}},X=async(e,t)=>{let n=e.createElement(`script`);n.type=`module`,n.setAttribute(`crossorigin`,`anonymous`),n.src=t;try{return await Z(e,n),!0}catch{return n.remove(),!1}},Z=(e,t)=>new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(Error(`Failed to load script`)),e.head.appendChild(t)}),Q=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${K}ms`)),K))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var $=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),we={config:{shopifyDomain:``,moneyFormat:"${{amount}}",locale:`en`,country:`US`,currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:``},dealBlock:{id:`example`,nanoId:`example`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:``,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:`duo`,cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`bold`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},dealBars:[{id:`single`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Single`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`duo`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Duo`,subtitle:`You save 20%`,label:`SAVE $32`,quantity:2,discountType:`percentage`,discountValue:`20`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`trio`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Trio`,subtitle:`You save 25%`,label:`SAVE $60`,quantity:3,discountType:`percentage`,discountValue:`25`,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`duo`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:``,customStyles:``,lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:`example-product`,url:null,availableForSale:!0,title:`Example product`,image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:[`Default Title`],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},Te=class extends HTMLElement{constructor(...e){super(...e),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return[`selected-variant-id`,`product-id`,`country`,`language`]}async connectedCallback(){await this.initialize()}async initialize(){let e=++this.initializeId;if(this.cleanup(),this.hasAttribute(`demo`)){if(await Y(window),e!==this.initializeId)return;this.renderInnerElement(we);return}let t=this.getAttribute(`shop-domain`),n=this.getAttribute(`storefront-token`),r=this.getAttribute(`product-id`);if(!t||!n||!r)return;let[i]=await Promise.all([W({shopifyDomain:t,storefrontAccessToken:n},{productId:r,dealBlockId:this.getAttribute(`deal-block-id`)??void 0,abTestVariantId:this.getAttribute(`ab-test-variant-id`)??void 0,country:this.getAttribute(`country`)?.toUpperCase()??void 0,language:this.getAttribute(`language`)?.toUpperCase()??void 0}),Y(window)]);i&&e===this.initializeId&&this.renderInnerElement(i)}renderInnerElement(e){let{config:t,dealBlock:n,product:r,otherProducts:i,mediaImages:a,collectionBreaksProducts:o,translations:s}=e;this.innerElement=document.createElement(`kaching-bundles-block`),this.innerElement.setAttribute(`deal-block-id`,n.id),this.innerElement.setAttribute(`config`,JSON.stringify(t)),this.innerElement.setAttribute(`deal-block`,JSON.stringify(n)),this.innerElement.setAttribute(`media-images`,JSON.stringify(a??[])),this.innerElement.setAttribute(`product`,JSON.stringify(r)),this.innerElement.setAttribute(`other-products`,JSON.stringify(i??[])),this.innerElement.setAttribute(`collection-breaks-products`,JSON.stringify(o??[])),this.innerElement.setAttribute(`translations`,JSON.stringify(s??{}));let c=this.getAttribute(`selected-variant-id`);this.innerElement.setAttribute(`current-variant-id`,String(c?c.split(`/`).pop():r.variants[0].id)),this.hasAttribute(`compact`)&&this.innerElement.setAttribute(`compact`,``);let l=this.innerElement,u=()=>{if(this.innerElement!==l)return;let e=l.items();e&&this.dispatchEvent(new CustomEvent(`items-changed`,{detail:{items:e},bubbles:!0}))};this.handleItemsChanged=e=>{e.stopPropagation(),u()};let d=this.handleItemsChanged;l.addEventListener(`kaching-bundles-block-loaded`,()=>{this.innerElement===l&&(l.addEventListener(`items-changed`,d),this.dispatchEvent(new CustomEvent(`loaded`,{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener(`items-changed`,this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&=(this.innerElement.remove(),null)}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`product-id`||e===`country`||e===`language`?this.initialize():e===`selected-variant-id`&&this.innerElement&&n&&this.innerElement.setAttribute(`current-variant-id`,n.includes(`/`)?String(n.split(`/`).pop()):n))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}};return customElements.define(`kaching-bundle-component`,Te),e.fetchKachingBundlesData=W,e})({});
|
package/dist/index.d.ts
CHANGED
|
@@ -315,6 +315,7 @@ declare type DealBlock = {
|
|
|
315
315
|
showTotalPriceInAddToCartButton?: boolean;
|
|
316
316
|
includeUpsellsInDealBarPrice?: boolean;
|
|
317
317
|
skipCart: boolean;
|
|
318
|
+
skipCartRemoveOtherProducts?: boolean;
|
|
318
319
|
showVariantsForSingleQuantity: boolean;
|
|
319
320
|
preselectedDealBarId: string | null;
|
|
320
321
|
cornerRadius: number;
|
|
@@ -578,6 +579,15 @@ declare interface GlobalConfig {
|
|
|
578
579
|
"system.deal_page_default_empty_note"?: string;
|
|
579
580
|
"system.deal_page_default_add_to_box"?: string;
|
|
580
581
|
"system.deal_page_default_add_box_to_cart"?: string;
|
|
582
|
+
"system.deal_page_default_subscribe_title"?: string;
|
|
583
|
+
"system.deal_page_default_subscribe_subtitle"?: string;
|
|
584
|
+
"system.deal_page_default_one_time_title"?: string;
|
|
585
|
+
"system.deal_page_purchase_options"?: string;
|
|
586
|
+
"system.deal_page_frequency"?: string;
|
|
587
|
+
"system.deal_page_one_time_only"?: string;
|
|
588
|
+
"system.deal_page_subscription_only"?: string;
|
|
589
|
+
"system.deal_page_some_items_subscription_only"?: string;
|
|
590
|
+
"system.deal_page_remove_subscription_only_items"?: string;
|
|
581
591
|
"system.deal_page_items_range"?: string;
|
|
582
592
|
"system.deal_page_tip_box_size"?: string;
|
|
583
593
|
"system.deal_page_about_this_price"?: string;
|
|
@@ -648,6 +658,7 @@ declare interface GlobalConfig {
|
|
|
648
658
|
intercept_cart_request?: boolean;
|
|
649
659
|
klaviyo_integration?: boolean;
|
|
650
660
|
legacy_saved_percentage?: boolean;
|
|
661
|
+
localized_most_popular_badge?: boolean;
|
|
651
662
|
low_priority_scripts?: boolean;
|
|
652
663
|
native_swatches_disabled?: boolean;
|
|
653
664
|
observe_external_selling_plan?: boolean;
|
|
@@ -669,6 +680,7 @@ declare interface GlobalConfig {
|
|
|
669
680
|
widget_scroll_guard?: boolean;
|
|
670
681
|
};
|
|
671
682
|
shopCustomStyles: string;
|
|
683
|
+
shopDealPageCustomStyles?: string;
|
|
672
684
|
brandColors?: BrandColors | null;
|
|
673
685
|
}
|
|
674
686
|
|
|
@@ -763,6 +775,9 @@ declare interface MixAndMatchProduct {
|
|
|
763
775
|
id: string;
|
|
764
776
|
variantGIDs: string[] | null;
|
|
765
777
|
}[];
|
|
778
|
+
selectedCollections?: {
|
|
779
|
+
id: string;
|
|
780
|
+
}[];
|
|
766
781
|
}
|
|
767
782
|
|
|
768
783
|
declare type MostPopularBadge = BaseBadge & {
|
|
@@ -814,6 +829,9 @@ declare interface Product {
|
|
|
814
829
|
};
|
|
815
830
|
rating?: ProductRating | null;
|
|
816
831
|
subtitle?: string | null;
|
|
832
|
+
productType?: string | null;
|
|
833
|
+
categoryGid?: string | null;
|
|
834
|
+
tags?: string[];
|
|
817
835
|
}
|
|
818
836
|
|
|
819
837
|
declare interface ProductOption {
|
|
@@ -958,6 +976,7 @@ declare type ScratchOff = {
|
|
|
958
976
|
declare interface SellingPlan {
|
|
959
977
|
id: number;
|
|
960
978
|
name: string;
|
|
979
|
+
recurringDeliveries?: boolean;
|
|
961
980
|
priceAdjustment: {
|
|
962
981
|
type: "percentage" | "fixed_amount" | "price";
|
|
963
982
|
value: number;
|