@gem-sdk/components 12.0.0-dev.44 → 12.0.0-dev.46

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.
Files changed (21) hide show
  1. package/dist/cjs/post-purchase/product/components/ProductPrice.js +1 -1
  2. package/dist/cjs/post-purchase/product/components/product-offer/common/attrs.js +1 -1
  3. package/dist/cjs/post-purchase/product/components/product-subscription/common/classes.js +1 -1
  4. package/dist/cjs/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -1
  5. package/dist/cjs/post-purchase/product/helpers/product-price-breakdown/getPrice.js +1 -0
  6. package/dist/cjs/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
  7. package/dist/cjs/post-purchase/product/hooks/useProductPriceBreakdown.js +1 -0
  8. package/dist/cjs/post-purchase/product/hooks/useRecurringSubtotal.js +1 -0
  9. package/dist/cjs/post-purchase/product/index.js +1 -1
  10. package/dist/cjs/third-party/components/SealSubscriptions.liquid.js +35 -8
  11. package/dist/esm/post-purchase/product/components/ProductPrice.js +1 -1
  12. package/dist/esm/post-purchase/product/components/product-offer/common/attrs.js +1 -1
  13. package/dist/esm/post-purchase/product/components/product-subscription/common/classes.js +1 -1
  14. package/dist/esm/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -1
  15. package/dist/esm/post-purchase/product/helpers/product-price-breakdown/getPrice.js +1 -0
  16. package/dist/esm/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
  17. package/dist/esm/post-purchase/product/hooks/useProductPriceBreakdown.js +1 -0
  18. package/dist/esm/post-purchase/product/hooks/useRecurringSubtotal.js +1 -0
  19. package/dist/esm/post-purchase/product/index.js +1 -1
  20. package/dist/esm/third-party/components/SealSubscriptions.liquid.js +37 -10
  21. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js"),TooltipHover=require("../../../common/components/TooltipHover.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:o,builderProps:t,children:s,setting:c})=>{let i=core.useCurrentVariant(),u=core.useProduct(),a=core.convertDecimalToNumber(i?.price)??0,p=core.convertDecimalToNumber(i?.salePrice)??0,n=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),d=a-n>0?a-n:a,{isDynamicProduct:l}=useDynamicProduct.useDynamicProduct(),{t:m}=core.useI18nStore(),{isEditMode:x}=core.useRenderMode(),{priceType:g,source:h}=c??{},y="compare"===g,P="offer"===g,f="price"===h,j="compare-price"===h,b=React.useMemo(()=>y?f?a:p:P?d:a,[y,f,P,a,p,d]),R=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(b)||0,2)),!1),N=u?.baseID?.replace("gid://shopify/Product/",""),v=React.useMemo(()=>y&&(!n&&p<a||j&&!p||f&&a<=0),[y,n,a,p,j]);return(!b&&!P||v)&&x?jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:m("No compare price")})})}):v&&!x?null:jsxRuntime.jsxs("div",{...o,className:core.cls(t?.uid),style:{...r},id:`shopify-text-element-${t?.uid}`,"data-product-id":N,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:l?"$???":R},className:core.cls({"gp-money":P,"gp-product-compare-price":y,"gp-line-through":y&&e?.lineThrough})}),s]})};exports.default=PostPurchaseProductPrice;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js"),TooltipHover=require("../../../common/components/TooltipHover.js"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:o,builderProps:t,children:i,setting:s})=>{let c=core.useCurrentVariant(),n=core.useProduct(),l=core.useProductStore(e=>e.selectedSellingPlan),u=core.convertDecimalToNumber(c?.price)??0,a=core.convertDecimalToNumber(c?.salePrice)??0,p=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),{isDynamicProduct:d}=useDynamicProduct.useDynamicProduct(),{t:g}=core.useI18nStore(),{isEditMode:m}=core.useRenderMode(),{priceType:P,source:f}=s??{},x="compare"===P,h="offer"===P,y="price"===f,j="compare-price"===f,R=c?.sellingPlanGroups,b=n?.sellingPlanGroups,N=React.useMemo(()=>{if(!l)return null;let e=c?.sellingPlanGroups??n?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===l)return e}return null},[JSON.stringify(R),JSON.stringify(b),l]),D=JSON.stringify(N?.pricingPolicies),v=N?.baseID,T=React.useMemo(()=>!N||u<=0?0:getPrice.calculateSellingPlanDiscount({variantPrice:u,pricingPolicies:N.pricingPolicies}),[D,u]),M=React.useMemo(()=>{if(h&&l&&v){let e=parseFloat(core.shopifyPriceRounding(u-T,2)),r=parseFloat(core.shopifyPriceRounding(e-p,2));return r>0?r:0}let e=parseFloat(core.shopifyPriceRounding(u-p,2));return e>0?e:0},[h,l,v,u,T,p]),S=React.useMemo(()=>x?y?u:a:h?M:u,[x,y,h,u,a,M]),q=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(S)||0,2)),!1),F=n?.baseID?.replace("gid://shopify/Product/",""),k=React.useMemo(()=>x&&(!p&&a<u||j&&!a||y&&u<=0),[x,p,u,a,j,y]);return(!S&&!h||k)&&m?jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:g("No compare price")})})}):k&&!m?null:jsxRuntime.jsxs("div",{...o,className:core.cls(t?.uid),style:{...r},id:`shopify-text-element-${t?.uid}`,"data-product-id":F,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:d?"$???":q},className:core.cls({"gp-money":h,"gp-product-compare-price":x,"gp-line-through":x&&e?.lineThrough})}),i]})};exports.default=PostPurchaseProductPrice;
@@ -1 +1 @@
1
- "use strict";const getProductOfferAttrs=(t,o)=>({"data-uid":o||"","data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")||""});exports.getProductOfferAttrs=getProductOfferAttrs;
1
+ "use strict";const getProductOfferAttrs=(t,o)=>({"data-uid":o||"","data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")||"","data-product-gp-id":t?.id||""});exports.getProductOfferAttrs=getProductOfferAttrs;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core");const getWrapperClasses=()=>core.composeClasses("gp-flex gp-gap-x-[10px] gap-[10px]"),getContainerClasses=()=>core.composeClasses("gp-flex gp-flex-col"),getSellingPlanRadioContainerClasses=()=>core.composeClasses("gp-relative gp-flex gp-flex-col"),getSellingPlanRadioLabelClasses=()=>core.composeClasses("gp-mb-2 gp-text-xs gp-leading-[1.3]"),getSellingPlanRadioOptionsClasses=()=>core.composeClasses("gp-flex gp-flex-col"),getSellingPlanRadioOptionTextClasses=()=>core.composeClasses("gp-text-[14px] gp-leading-[1.3] gp-text-text-light-500"),getSubscriptionRadioLabelClasses=e=>{let s=e?"gp-opacity-50 gp-cursor-not-allowed":"";return core.composeClasses(`gp-flex gp-items-center gp-cursor-pointer gp-gap-2 ${s}`.trim())},getSubscriptionRadioInputClasses=()=>core.composeClasses("gp-relative gp-min-h-[24px] gp-min-w-[24px] gp-w-5 gp-h-5 gp-cursor-pointer gp-appearance-none gp-rounded-full gp-bg-light-100 gp-transition-all gp-border-light-500 gp-border-2 checked:gp-border-[#1879b9] checked:gp-border-[5px] checked:gp-after:gp-content-[''] checked:gp-after:gp-absolute checked:gp-after:gp-top-1/2 checked:gp-after:gp-left-1/2 checked:gp-after:gp-transform checked:gp-after:gp--translate-x-1/2 checked:gp-after:gp--translate-y-1/2 checked:gp-after:gp-h-2 checked:gp-after:gp-w-2 checked:gp-after:gp-rounded-full checked:gp-after:gp-bg-white disabled:gp-cursor-not-allowed"),getSellingPlanDropdownContainerClasses=()=>core.composeClasses("gp-relative"),getSellingPlanDropdownLabelClasses=()=>core.composeClasses("!gp-max-w-[calc(100%_-_66px)] gp-absolute gp-left-[12px] gp-top-[6px] gp-p-0 gp-text-xs gp-leading-[1.3] gp-text-[#737373] gp-transition-[top]"),getSellingPlanDropdownLabelSpanClasses=()=>core.composeClasses("gp-max-w-full"),getSellingPlanDropdownLabelInnerSpanClasses=()=>core.composeClasses("gp-block gp-overflow-hidden"),getSellingPlanDropdownSelectClasses=({isNoLabel:e=!1})=>core.composeClasses(`gp-min-h-[47px] gp-appearance-none gp-bg-transparent gp-w-full gp-whitespace-nowrap gp-rounded-[5px] gp-border gp-border-[#d9d9d9] gp-pl-[11px] gp-pr-[40px] gp-text-[14px] gp-outline-none gp-text-[#545454] gp-leading-[1.3] ${e?"gp-pt-0 gp-pb-0":"gp-pt-[21px] gp-pb-[6px]"}`),getSellingPlanDropdownOptionClasses=()=>core.composeClasses("gp-text-[14px] gp-text-black"),getSellingPlanDropdownIconContainerClasses=()=>core.composeClasses("gp-pointer-events-none gp-absolute gp-right-[2px] gp-top-[50%] gp-flex gp-h-[43%] gp-w-[40px] gp-translate-y-[-50%] gp-items-center gp-justify-center gp-border-l-[1px] gp-bg-white gp-border-[#545454]"),getSellingPlanDropdownIconClasses=()=>core.composeClasses("gp-h-[10px] gp-w-[10px]");exports.getContainerClasses=getContainerClasses,exports.getSellingPlanDropdownContainerClasses=getSellingPlanDropdownContainerClasses,exports.getSellingPlanDropdownIconClasses=getSellingPlanDropdownIconClasses,exports.getSellingPlanDropdownIconContainerClasses=getSellingPlanDropdownIconContainerClasses,exports.getSellingPlanDropdownLabelClasses=getSellingPlanDropdownLabelClasses,exports.getSellingPlanDropdownLabelInnerSpanClasses=getSellingPlanDropdownLabelInnerSpanClasses,exports.getSellingPlanDropdownLabelSpanClasses=getSellingPlanDropdownLabelSpanClasses,exports.getSellingPlanDropdownOptionClasses=getSellingPlanDropdownOptionClasses,exports.getSellingPlanDropdownSelectClasses=getSellingPlanDropdownSelectClasses,exports.getSellingPlanRadioContainerClasses=getSellingPlanRadioContainerClasses,exports.getSellingPlanRadioLabelClasses=getSellingPlanRadioLabelClasses,exports.getSellingPlanRadioOptionTextClasses=getSellingPlanRadioOptionTextClasses,exports.getSellingPlanRadioOptionsClasses=getSellingPlanRadioOptionsClasses,exports.getSubscriptionRadioInputClasses=getSubscriptionRadioInputClasses,exports.getSubscriptionRadioLabelClasses=getSubscriptionRadioLabelClasses,exports.getWrapperClasses=getWrapperClasses;
1
+ "use strict";var core=require("@gem-sdk/core");const getWrapperClasses=()=>core.composeClasses("gp-flex gp-gap-x-[10px] gap-[10px]"),getContainerClasses=()=>core.composeClasses("gp-flex gp-flex-col"),getSellingPlanRadioContainerClasses=()=>core.composeClasses("gp-relative gp-flex gp-flex-col"),getSellingPlanRadioLabelClasses=()=>core.composeClasses("gp-text-xs gp-leading-[1.3]"),getSellingPlanRadioOptionsClasses=()=>core.composeClasses("gp-flex gp-flex-col"),getSellingPlanRadioOptionTextClasses=()=>core.composeClasses("gp-text-[14px] gp-leading-[1.3] gp-text-text-light-500"),getSubscriptionRadioLabelClasses=e=>{let s=e?"gp-opacity-50 gp-cursor-not-allowed":"";return core.composeClasses(`gp-flex gp-items-center gp-cursor-pointer gp-gap-2 ${s}`.trim())},getSubscriptionRadioInputClasses=()=>core.composeClasses("gp-relative gp-min-h-[18px] gp-min-w-[18px] gp-mt-[3px] gp-w-4 gp-h-4 gp-cursor-pointer gp-appearance-none gp-rounded-full gp-bg-light-100 gp-transition-all gp-border-light-500 gp-border-2 checked:gp-border-[#1879b9] checked:gp-border-[6px] checked:gp-after:gp-content-[''] checked:gp-after:gp-absolute checked:gp-after:gp-top-1/2 checked:gp-after:gp-left-1/2 checked:gp-after:gp-transform checked:gp-after:gp--translate-x-1/2 checked:gp-after:gp--translate-y-1/2 checked:gp-after:gp-h-2 checked:gp-after:gp-w-2 checked:gp-after:gp-rounded-full checked:gp-after:gp-bg-white disabled:gp-cursor-not-allowed"),getSellingPlanDropdownContainerClasses=()=>core.composeClasses("gp-relative"),getSellingPlanDropdownLabelClasses=()=>core.composeClasses("!gp-max-w-[calc(100%_-_66px)] gp-absolute gp-left-[12px] gp-top-[6px] gp-p-0 gp-text-xs gp-leading-[1.3] gp-text-[#737373] gp-transition-[top]"),getSellingPlanDropdownLabelSpanClasses=()=>core.composeClasses("gp-max-w-full"),getSellingPlanDropdownLabelInnerSpanClasses=()=>core.composeClasses("gp-block gp-overflow-hidden"),getSellingPlanDropdownSelectClasses=({isNoLabel:e=!1})=>core.composeClasses(`gp-min-h-[47px] gp-appearance-none gp-bg-transparent gp-w-full gp-whitespace-nowrap gp-rounded-[5px] gp-border gp-border-[#d9d9d9] gp-pl-[11px] gp-pr-[40px] gp-text-[14px] gp-outline-none gp-text-[#545454] gp-leading-[1.3] ${e?"gp-pt-0 gp-pb-0":"gp-pt-[21px] gp-pb-[6px]"}`),getSellingPlanDropdownOptionClasses=()=>core.composeClasses("gp-text-[14px] gp-text-black"),getSellingPlanDropdownIconContainerClasses=()=>core.composeClasses("gp-pointer-events-none gp-absolute gp-right-[2px] gp-top-[50%] gp-flex gp-h-[43%] gp-w-[40px] gp-translate-y-[-50%] gp-items-center gp-justify-center gp-border-l-[1px] gp-bg-white gp-border-[#545454]"),getSellingPlanDropdownIconClasses=()=>core.composeClasses("gp-h-[10px] gp-w-[10px]");exports.getContainerClasses=getContainerClasses,exports.getSellingPlanDropdownContainerClasses=getSellingPlanDropdownContainerClasses,exports.getSellingPlanDropdownIconClasses=getSellingPlanDropdownIconClasses,exports.getSellingPlanDropdownIconContainerClasses=getSellingPlanDropdownIconContainerClasses,exports.getSellingPlanDropdownLabelClasses=getSellingPlanDropdownLabelClasses,exports.getSellingPlanDropdownLabelInnerSpanClasses=getSellingPlanDropdownLabelInnerSpanClasses,exports.getSellingPlanDropdownLabelSpanClasses=getSellingPlanDropdownLabelSpanClasses,exports.getSellingPlanDropdownOptionClasses=getSellingPlanDropdownOptionClasses,exports.getSellingPlanDropdownSelectClasses=getSellingPlanDropdownSelectClasses,exports.getSellingPlanRadioContainerClasses=getSellingPlanRadioContainerClasses,exports.getSellingPlanRadioLabelClasses=getSellingPlanRadioLabelClasses,exports.getSellingPlanRadioOptionTextClasses=getSellingPlanRadioOptionTextClasses,exports.getSellingPlanRadioOptionsClasses=getSellingPlanRadioOptionsClasses,exports.getSubscriptionRadioInputClasses=getSubscriptionRadioInputClasses,exports.getSubscriptionRadioLabelClasses=getSubscriptionRadioLabelClasses,exports.getWrapperClasses=getWrapperClasses;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),core=require("@gem-sdk/core"),extractSellingPlanSettings=require("../common/extractSellingPlanSettings.js"),findMatchedGroup=require("../helpers/findMatchedGroup.js"),findDefaultValue=require("../helpers/findDefaultValue.js"),findVariantByOptions=require("../helpers/findVariantByOptions.js");const useSellingSubscription=e=>{let t=core.useProduct(),n=core.useVariants(),{selectedOptions:l}=core.useSelectedOption(),r=core.useProductStore(e=>e.selectedSellingPlan),i=core.useProductStore(e=>e.setSelectedSellingPlan),a=core.usePageStore(e=>e.sellingPlanMeta),s=core.useEditorMode(),u=React.useRef(!1);React.useEffect(()=>{if(!u.current&&s===core.RenderModeEnv.EDIT&&!a){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),u.current=!0}},[s,a]);let o=a??e?.sellingPlans,c=React.useMemo(()=>{if(!o)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return a&&l&&(e=findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l})),extractSellingPlanSettings.extractSellingPlanSettings({sellingPlansSetting:o,currentVariant:e,product:t,isFromEvent:!!a})},[o,a,n,l,t]),d=React.useMemo(()=>l?findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l}):null,[l,n]),{sellingPlans:f,defaultValue:p}=React.useMemo(()=>{let e=d?.sellingPlanGroups??t?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let n=findMatchedGroup.findMatchedGroup({sellingPlanGroups:e,extractedSettings:c,currentVariant:d}),l=n?.sellingPlans?.filter(e=>null!=e)??[],r=l.map(e=>({label:e.name||"",value:e.baseID})),i=findDefaultValue.findDefaultValue({validPlans:l,extractedSettings:c,currentVariant:d,plans:r});return{sellingPlans:r,defaultValue:i}},[t,d,c]);return{sellingPlans:f,defaultValue:p,selectedSellingPlan:r,setSelectedSellingPlan:i}};exports.useSellingSubscription=useSellingSubscription;
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),extractSellingPlanSettings=require("../common/extractSellingPlanSettings.js"),findMatchedGroup=require("../helpers/findMatchedGroup.js"),findDefaultValue=require("../helpers/findDefaultValue.js"),findVariantByOptions=require("../helpers/findVariantByOptions.js");const useSellingSubscription=e=>{let t=core.useProduct(),n=core.useVariants(),{selectedOptions:l}=core.useSelectedOption(),r=core.useProductStore(e=>e.selectedSellingPlan),i=core.useProductStore(e=>e.setSelectedSellingPlan),a=core.usePageStore(e=>e.sellingPlanMeta),u=core.useEditorMode(),s=React.useRef(!1),o=React.useRef(void 0);React.useEffect(()=>{if(!s.current&&u===core.RenderModeEnv.EDIT&&!a){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),s.current=!0}},[u,a]);let c=a??e?.sellingPlans,d=React.useMemo(()=>{if(!c)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return a&&l&&(e=findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l})),extractSellingPlanSettings.extractSellingPlanSettings({sellingPlansSetting:c,currentVariant:e,product:t,isFromEvent:!!a})},[c,a,n,l,t]),f=React.useMemo(()=>l?findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l}):null,[l,n]);React.useEffect(()=>{o.current=void 0},[f?.baseID]);let{sellingPlans:p,defaultValue:g}=React.useMemo(()=>{let e=f?.sellingPlanGroups??t?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let n=findMatchedGroup.findMatchedGroup({sellingPlanGroups:e,extractedSettings:d,currentVariant:f}),l=n?.sellingPlans?.filter(e=>null!=e)??[],r=l.map(e=>({label:e.name||"",value:e.baseID})),i=findDefaultValue.findDefaultValue({validPlans:l,extractedSettings:d,currentVariant:f,plans:r});return{sellingPlans:r,defaultValue:i}},[t,f,d]);return React.useEffect(()=>{!r&&g&&o.current!==g&&(o.current=g,i(g))},[g,r,i]),{sellingPlans:p,defaultValue:g,selectedSellingPlan:r,setSelectedSellingPlan:i}};exports.useSellingSubscription=useSellingSubscription;
@@ -0,0 +1 @@
1
+ "use strict";var types=require("../../components/product-subscription/types.js");const findPolicyWithoutAfterCycle=({policies:e})=>{let t=e.filter(e=>null!=e);if(0===t.length)return null;let l=t.find(e=>{let t=e?.AfterCycle??e.afterCycle;return!t});return l??t[0]??null},parseAmount=({value:e})=>{if(!e)return 0;let t=parseFloat(e);return isNaN(t)||t<=0?0:t},calculatePercentageDiscount=({variantPrice:e,percentage:t})=>isNaN(t)||t<=0?0:e*t/100,calculateFixedAmountDiscount=({amount:e})=>parseAmount({value:e}),calculatePriceDiscount=({variantPrice:e,fixedPrice:t})=>{let l=parseAmount({value:t});return l<=0?0:e-l},calculateSellingPlanDiscount=({variantPrice:e,pricingPolicies:t})=>{if(!t||0===t.length)return 0;let l=t.filter(e=>null!=e);if(0===l.length)return 0;let r=findPolicyWithoutAfterCycle({policies:l});if(!r)return 0;let n=r.AdjustmentType??r.adjustmentType,u=r.AdjustmentValue??r.adjustmentValue;return n&&u?n===types.AdjustmentType.FIXED_AMOUNT&&u.amount?calculateFixedAmountDiscount({amount:u.amount}):n===types.AdjustmentType.PERCENTAGE&&void 0!==u.percentage?calculatePercentageDiscount({variantPrice:e,percentage:u.percentage}):n===types.AdjustmentType.PRICE&&u.amount?calculatePriceDiscount({variantPrice:e,fixedPrice:u.amount}):0:0},calculateFixedAmountPrice=({variantPrice:e,amount:t})=>{let l=parseAmount({value:t});return l<=0?e:e-l},calculatePercentagePrice=({variantPrice:e,percentage:t})=>isNaN(t)||t<=0?e:e-e*t/100,calculateFixedPrice=({fixedPrice:e})=>parseAmount({value:e}),calculateRecurringPrice=({variantPrice:e,pricingPolicies:t})=>{if(!t||0===t.length)return e;let l=t.filter(e=>null!=e);if(0===l.length)return e;let r=findPolicyWithoutAfterCycle({policies:l});if(!r)return e;let n=r.AdjustmentType??r.adjustmentType,u=r.AdjustmentValue??r.adjustmentValue;return n&&u?n===types.AdjustmentType.FIXED_AMOUNT&&u.amount?calculateFixedAmountPrice({variantPrice:e,amount:u.amount}):n===types.AdjustmentType.PERCENTAGE&&void 0!==u.percentage?calculatePercentagePrice({variantPrice:e,percentage:u.percentage}):n===types.AdjustmentType.PRICE&&u.amount?calculateFixedPrice({fixedPrice:u.amount}):e:e},getIntervalText=({interval:e,intervalCount:t})=>{let l={DAY:{singular:"day",plural:"days"},WEEK:{singular:"week",plural:"weeks"},MONTH:{singular:"month",plural:"months"},YEAR:{singular:"year",plural:"years"}}[e];if(!l){let l=e.toLowerCase();return 1===t?`every ${l}`:`every ${t} ${l}`}let r=1===t?l.singular:l.plural;return 1===t?`every ${r}`:`every ${t} ${r}`},formatInterval=({billingPolicy:e})=>{if(!e)return"";let t=e.interval?.toUpperCase();if(!t)return"";let l=e.intervalCount??1;return getIntervalText({interval:t,intervalCount:l})};exports.calculateRecurringPrice=calculateRecurringPrice,exports.calculateSellingPlanDiscount=calculateSellingPlanDiscount,exports.findPolicyWithoutAfterCycle=findPolicyWithoutAfterCycle,exports.formatInterval=formatInterval;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js");const useGetMoneyLines=(e,t)=>{let{isDynamicProduct:o,dynamicPrice:u,dynamicDiscount:i,isEnableDynamicDiscount:s}=useDynamicProduct.useDynamicProduct(),a=core.useProductOfferDiscount(),n=core.useCurrentVariant(),{quantity:r}=core.useQuantity(),{t:l}=core.useI18nStore(),c=a*(r||1),b=core.useFormatMoney(c,!1),p=core.convertDecimalToNumber(n?.price)??0,d=p*(r||1),h=core.useFormatMoney(d,!1),L=core.shopifyPriceRounding(c,2),y=core.useFormatMoney(d-parseFloat(L),!1),m=()=>{let n=[];return!1!==e.isShowSubTotalLabel&&n.push({title:t.subTotalLabel,money:o?u:h,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&n.push({title:t.discountLabel,money:o&&i&&s?`${i.value}%`:a>0?b:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&n.push({title:t.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&n.push({title:t.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&n.push({title:t.totalLabel,money:o?u:y,uniqueId:"totalLabel"}),t?.isShowRecurringTotalLabel!==!1&&n.push({title:l("Recurring subtotal"),money:"$20.00 every week",uniqueId:"recurringTotalLabel",subTitle:l("Doesn't include shipping, tax or duties")}),n};return{getMoneyLines:m}};exports.useGetMoneyLines=useGetMoneyLines;
1
+ "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js"),useRecurringSubtotal=require("./useRecurringSubtotal.js"),useProductPriceBreakdown=require("./useProductPriceBreakdown.js");const useGetMoneyLines=(e,t)=>{let{isDynamicProduct:u,dynamicPrice:i,dynamicDiscount:o,isEnableDynamicDiscount:s}=useDynamicProduct.useDynamicProduct(),{t:r}=core.useI18nStore(),a=useRecurringSubtotal.useRecurringSubtotal(),{subTotalMoneyFormatted:l,offerDiscountTotal:n,discountMoneyFormatted:c,totalMoneyFormatted:b}=useProductPriceBreakdown.useProductPriceBreakdown(),d=()=>{let d=[];return!1!==e.isShowSubTotalLabel&&d.push({title:t.subTotalLabel,money:u?i:l,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&d.push({title:t.discountLabel,money:u&&o&&s?`${o.value}%`:n>0?c:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&d.push({title:t.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&d.push({title:t.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&d.push({title:t.totalLabel,money:u?i:b,uniqueId:"totalLabel"}),t?.isShowRecurringTotalLabel!==!1&&a&&d.push({title:r("Recurring subtotal"),money:a,uniqueId:"recurringTotalLabel",subTitle:r("Doesn't include shipping, tax or duties")}),d};return{getMoneyLines:d}};exports.useGetMoneyLines=useGetMoneyLines;
@@ -0,0 +1 @@
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const useProductPriceBreakdown=()=>{let e=core.useProductOfferDiscount(),r=core.useCurrentVariant(),o=core.useProduct(),c=core.useProductStore(e=>e.selectedSellingPlan),{quantity:i}=core.useQuantity(),n=React.useMemo(()=>{if(!c)return null;let e=r?.sellingPlanGroups??o?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===c);if(e)return e}return null},[r,o,c]),t=core.convertDecimalToNumber(r?.price)??0,s=React.useMemo(()=>!n||t<=0?0:getPrice.calculateSellingPlanDiscount({variantPrice:t,pricingPolicies:n.pricingPolicies}),[n,t]),u=parseFloat(core.shopifyPriceRounding(t-s,2)),l=parseFloat(core.shopifyPriceRounding(u*(i||1),2)),a=core.useFormatMoney(l,!1),P=e*(i||1),d=parseFloat(core.shopifyPriceRounding(P,2)),p=core.useFormatMoney(d,!1),g=core.shopifyPriceRounding(d,2),f=parseFloat(core.shopifyPriceRounding(l-parseFloat(g),2)),y=core.useFormatMoney(f>0?f:0,!1);return{price:t,sellingPlanDiscountPerUnit:s,priceAfterSellingPlanDiscount:u,subTotal:l,subTotalMoneyFormatted:a,offerDiscountTotal:P,discountWithQuantity:d,discountMoneyFormatted:p,totalMoneyFormatted:y}};exports.useProductPriceBreakdown=useProductPriceBreakdown;
@@ -0,0 +1 @@
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const useRecurringSubtotal=()=>{let e=core.useCurrentVariant(),r=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),{quantity:l}=core.useQuantity(),t=e?.sellingPlanGroups,n=r?.sellingPlanGroups,u=core.convertDecimalToNumber(e?.price)??0,c=React.useMemo(()=>{if(!i)return null;let l=e?.sellingPlanGroups??r?.sellingPlanGroups??[];for(let e of l)if(e?.sellingPlans){for(let r of e.sellingPlans)if(r?.baseID===i)return r}return null},[JSON.stringify(t),JSON.stringify(n),i]),o=JSON.stringify(c?.pricingPolicies),s=JSON.stringify(c?.billingPolicy),a=c?.baseID,g=React.useMemo(()=>{if(!a||!e||u<=0||!c)return 0;let r=getPrice.calculateRecurringPrice({variantPrice:u,pricingPolicies:c.pricingPolicies}),i=r*(l||1);return parseFloat(core.shopifyPriceRounding(i,2))},[o,u,l,a]),P=React.useMemo(()=>{if(!a||!c)return null;let e=c.billingPolicy;return getPrice.formatInterval({billingPolicy:e})},[s,a]),f=core.useFormatMoney(g,!1),p=React.useMemo(()=>a&&!(g<=0)&&P?`${f} ${P}`:null,[a,g,P,f]);return p};exports.useRecurringSubtotal=useRecurringSubtotal;
@@ -1 +1 @@
1
- "use strict";require("react/jsx-runtime"),require("@gem-sdk/core"),require("@gem-sdk/system"),require("react"),require("./components/product-variant/components/variants/VariantItem.js"),require("next/link"),require("./constants/index.js"),require("next/head"),require("next/image"),require("react-youtube"),require("./components/product-subscription/types.js"),require("./components/product-subscription/components/OneTimePurchaseTooltip.js"),require("../image/components/Img.js");var ProductTitle$1=require("./settings/product-title/ProductTitle.js"),ProductDescription$1=require("./settings/product-description/ProductDescription.js"),ProductPrice$1=require("./settings/product-price/ProductPrice.js"),ProductVariant$1=require("./settings/product-variants/ProductVariant.js"),index$1=require("./settings/accept-button/index.js"),index$2=require("./settings/product-quantity/index.js"),index$4=require("./settings/product-offer/index.js"),index$3=require("./settings/product-price-breakdown/index.js"),ProductDiscountTag$1=require("./settings/product-discount-tag/ProductDiscountTag.js"),index$5=require("./settings/product-subscription/index.js"),ProductImages=require("./settings/product-image/ProductImages.js");const postPurchaseProductSetting={PostPurchaseProductTitle:ProductTitle$1.default,PostPurchaseProductDescription:ProductDescription$1.default,PostPurchaseProductPrice:ProductPrice$1.default,PostPurchaseProductVariants:ProductVariant$1.default,PostPurchaseAcceptButton:index$1.default,PostPurchaseProductQuantity:index$2.default,PostPurchaseProductPriceBreakdown:index$3.default,PostPurchaseProductOffer:index$4.default,PostPurchaseProductDiscountTag:ProductDiscountTag$1.default,PostPurchaseProductImages:ProductImages.default,PostPurchaseProductSubscription:index$5.default};exports.postPurchaseProductSetting=postPurchaseProductSetting;
1
+ "use strict";require("react/jsx-runtime"),require("@gem-sdk/core"),require("@gem-sdk/system"),require("react"),require("./components/product-subscription/types.js"),require("./components/product-variant/components/variants/VariantItem.js"),require("next/link"),require("./constants/index.js"),require("next/head"),require("next/image"),require("react-youtube"),require("./components/product-subscription/components/OneTimePurchaseTooltip.js"),require("../image/components/Img.js");var ProductTitle$1=require("./settings/product-title/ProductTitle.js"),ProductDescription$1=require("./settings/product-description/ProductDescription.js"),ProductPrice$1=require("./settings/product-price/ProductPrice.js"),ProductVariant$1=require("./settings/product-variants/ProductVariant.js"),index$1=require("./settings/accept-button/index.js"),index$2=require("./settings/product-quantity/index.js"),index$4=require("./settings/product-offer/index.js"),index$3=require("./settings/product-price-breakdown/index.js"),ProductDiscountTag$1=require("./settings/product-discount-tag/ProductDiscountTag.js"),index$5=require("./settings/product-subscription/index.js"),ProductImages=require("./settings/product-image/ProductImages.js");const postPurchaseProductSetting={PostPurchaseProductTitle:ProductTitle$1.default,PostPurchaseProductDescription:ProductDescription$1.default,PostPurchaseProductPrice:ProductPrice$1.default,PostPurchaseProductVariants:ProductVariant$1.default,PostPurchaseAcceptButton:index$1.default,PostPurchaseProductQuantity:index$2.default,PostPurchaseProductPriceBreakdown:index$3.default,PostPurchaseProductOffer:index$4.default,PostPurchaseProductDiscountTag:ProductDiscountTag$1.default,PostPurchaseProductImages:ProductImages.default,PostPurchaseProductSubscription:index$5.default};exports.postPurchaseProductSetting=postPurchaseProductSetting;
@@ -7,20 +7,47 @@
7
7
  </div>
8
8
  <script>
9
9
  const moneyFormatGp = {{ shop.money_format | json }};
10
+
11
+ const formatCurrency = (cents, format) => {
12
+ if (typeof Shopify !== 'undefined' && Shopify.formatMoney) {
13
+ return Shopify.formatMoney(cents, format);
14
+ }
15
+ return (cents / 100).toFixed(2);
16
+ };
17
+
10
18
  document.addEventListener('DOMContentLoaded', function() {
11
- document.addEventListener('sealsubs:price_update', function(data) {
12
- const subPrice = data?.detail?.price || 0
13
- const gpPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-price.gp-money');
14
- const compareAtPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-product-compare-price');
19
+ document.addEventListener('sealsubs:selling_plan_changed', function(e) {
20
+ const productWrapper = e.detail?.element?.closest('gp-product');
21
+ if (!productWrapper) return;
22
+
23
+ const comparePriceContainers = productWrapper.querySelectorAll('gp-product-price');
24
+ const hasSellingPlan = !!e.detail.selling_plan_id;
25
+
26
+ comparePriceContainers.forEach(container => {
27
+ if (!hasSellingPlan) {
28
+ container.style.removeProperty('display');
29
+ } else {
30
+ container.style.setProperty('display', 'block', 'important');
31
+ }
32
+ });
33
+ });
34
+
35
+ document.addEventListener('sealsubs:price_update', function(e) {
36
+ const detail = e.detail;
37
+ const productWrapper = detail?.element?.closest('gp-product');
38
+ if (!productWrapper) return;
39
+
40
+ const gpPriceElement = productWrapper.querySelector('gp-product-price .gp-price.gp-money');
41
+ const compareAtPriceElement = productWrapper.querySelector('gp-product-price .gp-product-compare-price');
15
42
 
16
- if (gpPriceElement) {
17
- gpPriceElement.innerHTML = Shopify?.formatMoney(subPrice, moneyFormatGp);
43
+ if (gpPriceElement && typeof detail.price !== 'undefined') {
44
+ gpPriceElement.innerHTML = formatCurrency(detail.price, moneyFormatGp);
18
45
  }
19
46
 
20
47
  if (compareAtPriceElement) {
21
- const compareAtPrice = data?.detail?.compareAtPrice || 0
48
+ const compareAtPrice = detail?.compareAtPrice || 0;
22
49
  setTimeout(function() {
23
- compareAtPriceElement.innerHTML = Shopify?.formatMoney(compareAtPrice, moneyFormatGp);
50
+ compareAtPriceElement.innerHTML = formatCurrency(compareAtPrice, moneyFormatGp);
24
51
  });
25
52
  }
26
53
  });
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useCurrentVariant as t,useProduct as o,convertDecimalToNumber as p,shopifyPriceRounding as s,useProductOfferDiscount as i,useI18nStore as a,useRenderMode as c,useFormatMoney as l,cls as d}from"@gem-sdk/core";import{useMemo as m}from"react";import n from"../../text/components/Text.js";import{useDynamicProduct as g}from"../hooks/useDynamicProduct.js";import u from"../../../common/components/TooltipHover.js";let PostPurchaseProductPrice=({styles:h,style:f,builderAttrs:x,builderProps:y,children:P,setting:b})=>{let N=t(),j=o(),k=p(N?.price)??0,v=p(N?.salePrice)??0,w=parseFloat(s(i(),2)),D=k-w>0?k-w:k,{isDynamicProduct:T}=g(),{t:F}=a(),{isEditMode:$}=c(),{priceType:H,source:I}=b??{},S="compare"===H,q="offer"===H,z="price"===I,A="compare-price"===I,B=m(()=>S?z?k:v:q?D:k,[S,z,q,k,v,D]),C=l(parseFloat(s(Number(B)||0,2)),!1),E=j?.baseID?.replace("gid://shopify/Product/",""),G=m(()=>S&&(!w&&v<k||A&&!v||z&&k<=0),[S,w,k,v,A]);return(!B&&!q||G)&&$?e(u,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:e("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:F("No compare price")})})}):G&&!$?null:r("div",{...x,className:d(y?.uid),style:{...f},id:`shopify-text-element-${y?.uid}`,"data-product-id":E,children:[e(n,{styles:h,setting:{text:T?"$???":C},className:d({"gp-money":q,"gp-product-compare-price":S,"gp-line-through":S&&h?.lineThrough})}),P]})};export{PostPurchaseProductPrice as default};
2
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useCurrentVariant as t,useProduct as i,useProductStore as o,convertDecimalToNumber as l,shopifyPriceRounding as s,useProductOfferDiscount as p,useI18nStore as a,useRenderMode as n,useFormatMoney as c,cls as g}from"@gem-sdk/core";import{useMemo as d}from"react";import m from"../../text/components/Text.js";import{useDynamicProduct as u}from"../hooks/useDynamicProduct.js";import f from"../../../common/components/TooltipHover.js";import{calculateSellingPlanDiscount as P}from"../helpers/product-price-breakdown/getPrice.js";let PostPurchaseProductPrice=({styles:h,style:y,builderAttrs:x,builderProps:b,children:N,setting:j})=>{let k=t(),D=i(),F=o(e=>e.selectedSellingPlan),S=l(k?.price)??0,v=l(k?.salePrice)??0,w=parseFloat(s(p(),2)),{isDynamicProduct:G}=u(),{t:I}=a(),{isEditMode:J}=n(),{priceType:O,source:T}=j??{},$="compare"===O,H="offer"===O,q="price"===T,z="compare-price"===T,A=k?.sellingPlanGroups,B=D?.sellingPlanGroups,C=d(()=>{if(!F)return null;let e=k?.sellingPlanGroups??D?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===F)return e}return null},[JSON.stringify(A),JSON.stringify(B),F]),E=JSON.stringify(C?.pricingPolicies),K=C?.baseID,L=d(()=>!C||S<=0?0:P({variantPrice:S,pricingPolicies:C.pricingPolicies}),[E,S]),M=d(()=>{if(H&&F&&K){let e=parseFloat(s(S-L,2)),r=parseFloat(s(e-w,2));return r>0?r:0}let e=parseFloat(s(S-w,2));return e>0?e:0},[H,F,K,S,L,w]),Q=d(()=>$?q?S:v:H?M:S,[$,q,H,S,v,M]),R=c(parseFloat(s(Number(Q)||0,2)),!1),U=D?.baseID?.replace("gid://shopify/Product/",""),V=d(()=>$&&(!w&&v<S||z&&!v||q&&S<=0),[$,w,S,v,z,q]);return(!Q&&!H||V)&&J?e(f,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:e("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:I("No compare price")})})}):V&&!J?null:r("div",{...x,className:g(b?.uid),style:{...y},id:`shopify-text-element-${b?.uid}`,"data-product-id":U,children:[e(m,{styles:h,setting:{text:G?"$???":R},className:g({"gp-money":H,"gp-product-compare-price":$,"gp-line-through":$&&h?.lineThrough})}),N]})};export{PostPurchaseProductPrice as default};
@@ -1 +1 @@
1
- let getProductOfferAttrs=(t,o)=>({"data-uid":o||"","data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")||""});export{getProductOfferAttrs};
1
+ let getProductOfferAttrs=(t,o)=>({"data-uid":o||"","data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")||"","data-product-gp-id":t?.id||""});export{getProductOfferAttrs};
@@ -1 +1 @@
1
- import{composeClasses as e}from"@gem-sdk/core";let getWrapperClasses=()=>e("gp-flex gp-gap-x-[10px] gap-[10px]"),getContainerClasses=()=>e("gp-flex gp-flex-col"),getSellingPlanRadioContainerClasses=()=>e("gp-relative gp-flex gp-flex-col"),getSellingPlanRadioLabelClasses=()=>e("gp-mb-2 gp-text-xs gp-leading-[1.3]"),getSellingPlanRadioOptionsClasses=()=>e("gp-flex gp-flex-col"),getSellingPlanRadioOptionTextClasses=()=>e("gp-text-[14px] gp-leading-[1.3] gp-text-text-light-500"),getSubscriptionRadioLabelClasses=p=>{let g=p?"gp-opacity-50 gp-cursor-not-allowed":"";return e(`gp-flex gp-items-center gp-cursor-pointer gp-gap-2 ${g}`.trim())},getSubscriptionRadioInputClasses=()=>e("gp-relative gp-min-h-[24px] gp-min-w-[24px] gp-w-5 gp-h-5 gp-cursor-pointer gp-appearance-none gp-rounded-full gp-bg-light-100 gp-transition-all gp-border-light-500 gp-border-2 checked:gp-border-[#1879b9] checked:gp-border-[5px] checked:gp-after:gp-content-[''] checked:gp-after:gp-absolute checked:gp-after:gp-top-1/2 checked:gp-after:gp-left-1/2 checked:gp-after:gp-transform checked:gp-after:gp--translate-x-1/2 checked:gp-after:gp--translate-y-1/2 checked:gp-after:gp-h-2 checked:gp-after:gp-w-2 checked:gp-after:gp-rounded-full checked:gp-after:gp-bg-white disabled:gp-cursor-not-allowed"),getSellingPlanDropdownContainerClasses=()=>e("gp-relative"),getSellingPlanDropdownLabelClasses=()=>e("!gp-max-w-[calc(100%_-_66px)] gp-absolute gp-left-[12px] gp-top-[6px] gp-p-0 gp-text-xs gp-leading-[1.3] gp-text-[#737373] gp-transition-[top]"),getSellingPlanDropdownLabelSpanClasses=()=>e("gp-max-w-full"),getSellingPlanDropdownLabelInnerSpanClasses=()=>e("gp-block gp-overflow-hidden"),getSellingPlanDropdownSelectClasses=({isNoLabel:p=!1})=>e(`gp-min-h-[47px] gp-appearance-none gp-bg-transparent gp-w-full gp-whitespace-nowrap gp-rounded-[5px] gp-border gp-border-[#d9d9d9] gp-pl-[11px] gp-pr-[40px] gp-text-[14px] gp-outline-none gp-text-[#545454] gp-leading-[1.3] ${p?"gp-pt-0 gp-pb-0":"gp-pt-[21px] gp-pb-[6px]"}`),getSellingPlanDropdownOptionClasses=()=>e("gp-text-[14px] gp-text-black"),getSellingPlanDropdownIconContainerClasses=()=>e("gp-pointer-events-none gp-absolute gp-right-[2px] gp-top-[50%] gp-flex gp-h-[43%] gp-w-[40px] gp-translate-y-[-50%] gp-items-center gp-justify-center gp-border-l-[1px] gp-bg-white gp-border-[#545454]"),getSellingPlanDropdownIconClasses=()=>e("gp-h-[10px] gp-w-[10px]");export{getContainerClasses,getSellingPlanDropdownContainerClasses,getSellingPlanDropdownIconClasses,getSellingPlanDropdownIconContainerClasses,getSellingPlanDropdownLabelClasses,getSellingPlanDropdownLabelInnerSpanClasses,getSellingPlanDropdownLabelSpanClasses,getSellingPlanDropdownOptionClasses,getSellingPlanDropdownSelectClasses,getSellingPlanRadioContainerClasses,getSellingPlanRadioLabelClasses,getSellingPlanRadioOptionTextClasses,getSellingPlanRadioOptionsClasses,getSubscriptionRadioInputClasses,getSubscriptionRadioLabelClasses,getWrapperClasses};
1
+ import{composeClasses as e}from"@gem-sdk/core";let getWrapperClasses=()=>e("gp-flex gp-gap-x-[10px] gap-[10px]"),getContainerClasses=()=>e("gp-flex gp-flex-col"),getSellingPlanRadioContainerClasses=()=>e("gp-relative gp-flex gp-flex-col"),getSellingPlanRadioLabelClasses=()=>e("gp-text-xs gp-leading-[1.3]"),getSellingPlanRadioOptionsClasses=()=>e("gp-flex gp-flex-col"),getSellingPlanRadioOptionTextClasses=()=>e("gp-text-[14px] gp-leading-[1.3] gp-text-text-light-500"),getSubscriptionRadioLabelClasses=p=>{let g=p?"gp-opacity-50 gp-cursor-not-allowed":"";return e(`gp-flex gp-items-center gp-cursor-pointer gp-gap-2 ${g}`.trim())},getSubscriptionRadioInputClasses=()=>e("gp-relative gp-min-h-[18px] gp-min-w-[18px] gp-mt-[3px] gp-w-4 gp-h-4 gp-cursor-pointer gp-appearance-none gp-rounded-full gp-bg-light-100 gp-transition-all gp-border-light-500 gp-border-2 checked:gp-border-[#1879b9] checked:gp-border-[6px] checked:gp-after:gp-content-[''] checked:gp-after:gp-absolute checked:gp-after:gp-top-1/2 checked:gp-after:gp-left-1/2 checked:gp-after:gp-transform checked:gp-after:gp--translate-x-1/2 checked:gp-after:gp--translate-y-1/2 checked:gp-after:gp-h-2 checked:gp-after:gp-w-2 checked:gp-after:gp-rounded-full checked:gp-after:gp-bg-white disabled:gp-cursor-not-allowed"),getSellingPlanDropdownContainerClasses=()=>e("gp-relative"),getSellingPlanDropdownLabelClasses=()=>e("!gp-max-w-[calc(100%_-_66px)] gp-absolute gp-left-[12px] gp-top-[6px] gp-p-0 gp-text-xs gp-leading-[1.3] gp-text-[#737373] gp-transition-[top]"),getSellingPlanDropdownLabelSpanClasses=()=>e("gp-max-w-full"),getSellingPlanDropdownLabelInnerSpanClasses=()=>e("gp-block gp-overflow-hidden"),getSellingPlanDropdownSelectClasses=({isNoLabel:p=!1})=>e(`gp-min-h-[47px] gp-appearance-none gp-bg-transparent gp-w-full gp-whitespace-nowrap gp-rounded-[5px] gp-border gp-border-[#d9d9d9] gp-pl-[11px] gp-pr-[40px] gp-text-[14px] gp-outline-none gp-text-[#545454] gp-leading-[1.3] ${p?"gp-pt-0 gp-pb-0":"gp-pt-[21px] gp-pb-[6px]"}`),getSellingPlanDropdownOptionClasses=()=>e("gp-text-[14px] gp-text-black"),getSellingPlanDropdownIconContainerClasses=()=>e("gp-pointer-events-none gp-absolute gp-right-[2px] gp-top-[50%] gp-flex gp-h-[43%] gp-w-[40px] gp-translate-y-[-50%] gp-items-center gp-justify-center gp-border-l-[1px] gp-bg-white gp-border-[#545454]"),getSellingPlanDropdownIconClasses=()=>e("gp-h-[10px] gp-w-[10px]");export{getContainerClasses,getSellingPlanDropdownContainerClasses,getSellingPlanDropdownIconClasses,getSellingPlanDropdownIconContainerClasses,getSellingPlanDropdownLabelClasses,getSellingPlanDropdownLabelInnerSpanClasses,getSellingPlanDropdownLabelSpanClasses,getSellingPlanDropdownOptionClasses,getSellingPlanDropdownSelectClasses,getSellingPlanRadioContainerClasses,getSellingPlanRadioLabelClasses,getSellingPlanRadioOptionTextClasses,getSellingPlanRadioOptionsClasses,getSubscriptionRadioInputClasses,getSubscriptionRadioLabelClasses,getWrapperClasses};
@@ -1 +1 @@
1
- import{useRef as e,useEffect as l,useMemo as n}from"react";import{useProduct as t,useVariants as r,useSelectedOption as i,useProductStore as s,usePageStore as o,useEditorMode as a,RenderModeEnv as u}from"@gem-sdk/core";import{extractSellingPlanSettings as p}from"../common/extractSellingPlanSettings.js";import{findMatchedGroup as m}from"../helpers/findMatchedGroup.js";import{findDefaultValue as f}from"../helpers/findDefaultValue.js";import{findVariantByOptions as g}from"../helpers/findVariantByOptions.js";let useSellingSubscription=c=>{let d=t(),P=r(),{selectedOptions:S}=i(),v=s(e=>e.selectedSellingPlan),h=s(e=>e.setSelectedSellingPlan),b=o(e=>e.sellingPlanMeta),V=a(),j=e(!1);l(()=>{if(!j.current&&V===u.EDIT&&!b){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),j.current=!0}},[V,b]);let E=b??c?.sellingPlans,D=n(()=>{if(!E)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return b&&S&&(e=g({variants:P,selectedOptions:S})),p({sellingPlansSetting:E,currentVariant:e,product:d,isFromEvent:!!b})},[E,b,P,S,d]),G=n(()=>S?g({variants:P,selectedOptions:S}):null,[S,P]),{sellingPlans:x,defaultValue:I}=n(()=>{let e=G?.sellingPlanGroups??d?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let l=m({sellingPlanGroups:e,extractedSettings:D,currentVariant:G}),n=l?.sellingPlans?.filter(e=>null!=e)??[],t=n.map(e=>({label:e.name||"",value:e.baseID})),r=f({validPlans:n,extractedSettings:D,currentVariant:G,plans:t});return{sellingPlans:t,defaultValue:r}},[d,G,D]);return{sellingPlans:x,defaultValue:I,selectedSellingPlan:v,setSelectedSellingPlan:h}};export{useSellingSubscription};
1
+ import{useRef as e,useEffect as l,useMemo as n}from"react";import{useProduct as t,useVariants as r,useSelectedOption as i,useProductStore as s,usePageStore as o,useEditorMode as u,RenderModeEnv as a}from"@gem-sdk/core";import{extractSellingPlanSettings as p}from"../common/extractSellingPlanSettings.js";import{findMatchedGroup as m}from"../helpers/findMatchedGroup.js";import{findDefaultValue as c}from"../helpers/findDefaultValue.js";import{findVariantByOptions as d}from"../helpers/findVariantByOptions.js";let useSellingSubscription=f=>{let g=t(),v=r(),{selectedOptions:P}=i(),S=s(e=>e.selectedSellingPlan),b=s(e=>e.setSelectedSellingPlan),h=o(e=>e.sellingPlanMeta),V=u(),j=e(!1),D=e(void 0);l(()=>{if(!j.current&&V===a.EDIT&&!h){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),j.current=!0}},[V,h]);let E=h??f?.sellingPlans,G=n(()=>{if(!E)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return h&&P&&(e=d({variants:v,selectedOptions:P})),p({sellingPlansSetting:E,currentVariant:e,product:g,isFromEvent:!!h})},[E,h,v,P,g]),I=n(()=>P?d({variants:v,selectedOptions:P}):null,[P,v]);l(()=>{D.current=void 0},[I?.baseID]);let{sellingPlans:x,defaultValue:M}=n(()=>{let e=I?.sellingPlanGroups??g?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let l=m({sellingPlanGroups:e,extractedSettings:G,currentVariant:I}),n=l?.sellingPlans?.filter(e=>null!=e)??[],t=n.map(e=>({label:e.name||"",value:e.baseID})),r=c({validPlans:n,extractedSettings:G,currentVariant:I,plans:t});return{sellingPlans:t,defaultValue:r}},[g,I,G]);return l(()=>{!S&&M&&D.current!==M&&(D.current=M,b(M))},[M,S,b]),{sellingPlans:x,defaultValue:M,selectedSellingPlan:S,setSelectedSellingPlan:b}};export{useSellingSubscription};
@@ -0,0 +1 @@
1
+ import{AdjustmentType as e}from"../../components/product-subscription/types.js";let findPolicyWithoutAfterCycle=({policies:e})=>{let t=e.filter(e=>null!=e);if(0===t.length)return null;let l=t.find(e=>{let t=e?.AfterCycle??e.afterCycle;return!t});return l??t[0]??null},parseAmount=({value:e})=>{if(!e)return 0;let t=parseFloat(e);return isNaN(t)||t<=0?0:t},calculatePercentageDiscount=({variantPrice:e,percentage:t})=>isNaN(t)||t<=0?0:e*t/100,calculateFixedAmountDiscount=({amount:e})=>parseAmount({value:e}),calculatePriceDiscount=({variantPrice:e,fixedPrice:t})=>{let l=parseAmount({value:t});return l<=0?0:e-l},calculateSellingPlanDiscount=({variantPrice:t,pricingPolicies:l})=>{if(!l||0===l.length)return 0;let r=l.filter(e=>null!=e);if(0===r.length)return 0;let n=findPolicyWithoutAfterCycle({policies:r});if(!n)return 0;let u=n.AdjustmentType??n.adjustmentType,a=n.AdjustmentValue??n.adjustmentValue;return u&&a?u===e.FIXED_AMOUNT&&a.amount?calculateFixedAmountDiscount({amount:a.amount}):u===e.PERCENTAGE&&void 0!==a.percentage?calculatePercentageDiscount({variantPrice:t,percentage:a.percentage}):u===e.PRICE&&a.amount?calculatePriceDiscount({variantPrice:t,fixedPrice:a.amount}):0:0},calculateFixedAmountPrice=({variantPrice:e,amount:t})=>{let l=parseAmount({value:t});return l<=0?e:e-l},calculatePercentagePrice=({variantPrice:e,percentage:t})=>isNaN(t)||t<=0?e:e-e*t/100,calculateFixedPrice=({fixedPrice:e})=>parseAmount({value:e}),calculateRecurringPrice=({variantPrice:t,pricingPolicies:l})=>{if(!l||0===l.length)return t;let r=l.filter(e=>null!=e);if(0===r.length)return t;let n=findPolicyWithoutAfterCycle({policies:r});if(!n)return t;let u=n.AdjustmentType??n.adjustmentType,a=n.AdjustmentValue??n.adjustmentValue;return u&&a?u===e.FIXED_AMOUNT&&a.amount?calculateFixedAmountPrice({variantPrice:t,amount:a.amount}):u===e.PERCENTAGE&&void 0!==a.percentage?calculatePercentagePrice({variantPrice:t,percentage:a.percentage}):u===e.PRICE&&a.amount?calculateFixedPrice({fixedPrice:a.amount}):t:t},getIntervalText=({interval:e,intervalCount:t})=>{let l={DAY:{singular:"day",plural:"days"},WEEK:{singular:"week",plural:"weeks"},MONTH:{singular:"month",plural:"months"},YEAR:{singular:"year",plural:"years"}}[e];if(!l){let l=e.toLowerCase();return 1===t?`every ${l}`:`every ${t} ${l}`}let r=1===t?l.singular:l.plural;return 1===t?`every ${r}`:`every ${t} ${r}`},formatInterval=({billingPolicy:e})=>{if(!e)return"";let t=e.interval?.toUpperCase();if(!t)return"";let l=e.intervalCount??1;return getIntervalText({interval:t,intervalCount:l})};export{calculateRecurringPrice,calculateSellingPlanDiscount,findPolicyWithoutAfterCycle,formatInterval};
@@ -1 +1 @@
1
- import{useProductOfferDiscount as e,useCurrentVariant as t,useQuantity as l,useI18nStore as i,useFormatMoney as o,convertDecimalToNumber as a,shopifyPriceRounding as u}from"@gem-sdk/core";import{useDynamicProduct as n}from"./useDynamicProduct.js";let useGetMoneyLines=(s,r)=>{let{isDynamicProduct:p,dynamicPrice:b,dynamicDiscount:h,isEnableDynamicDiscount:L}=n(),c=e(),d=t(),{quantity:m}=l(),{t:g}=i(),w=c*(m||1),S=o(w,!1),T=a(d?.price)??0,y=T*(m||1),f=o(y,!1),q=u(w,2),x=o(y-parseFloat(q),!1),I=()=>{let e=[];return!1!==s.isShowSubTotalLabel&&e.push({title:r.subTotalLabel,money:p?b:f,uniqueId:"subTotalLabel"}),!1!==s.isShowDiscountLabel&&e.push({title:r.discountLabel,money:p&&h&&L?`${h.value}%`:c>0?S:"No discount",uniqueId:"discountLabel"}),!1!==s.isShowShippingLabel&&e.push({title:r.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==s.isShowTaxesLabel&&e.push({title:r.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==s.isShowTotalLabel&&e.push({title:r.totalLabel,money:p?b:x,uniqueId:"totalLabel"}),r?.isShowRecurringTotalLabel!==!1&&e.push({title:g("Recurring subtotal"),money:"$20.00 every week",uniqueId:"recurringTotalLabel",subTitle:g("Doesn't include shipping, tax or duties")}),e};return{getMoneyLines:I}};export{useGetMoneyLines};
1
+ import{useI18nStore as e}from"@gem-sdk/core";import{useDynamicProduct as t}from"./useDynamicProduct.js";import{useRecurringSubtotal as i}from"./useRecurringSubtotal.js";import{useProductPriceBreakdown as o}from"./useProductPriceBreakdown.js";let useGetMoneyLines=(l,u)=>{let{isDynamicProduct:a,dynamicPrice:s,dynamicDiscount:n,isEnableDynamicDiscount:r}=t(),{t:b}=e(),p=i(),{subTotalMoneyFormatted:c,offerDiscountTotal:d,discountMoneyFormatted:h,totalMoneyFormatted:L}=o(),m=()=>{let e=[];return!1!==l.isShowSubTotalLabel&&e.push({title:u.subTotalLabel,money:a?s:c,uniqueId:"subTotalLabel"}),!1!==l.isShowDiscountLabel&&e.push({title:u.discountLabel,money:a&&n&&r?`${n.value}%`:d>0?h:"No discount",uniqueId:"discountLabel"}),!1!==l.isShowShippingLabel&&e.push({title:u.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==l.isShowTaxesLabel&&e.push({title:u.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==l.isShowTotalLabel&&e.push({title:u.totalLabel,money:a?s:L,uniqueId:"totalLabel"}),u?.isShowRecurringTotalLabel!==!1&&p&&e.push({title:b("Recurring subtotal"),money:p,uniqueId:"recurringTotalLabel",subTitle:b("Doesn't include shipping, tax or duties")}),e};return{getMoneyLines:m}};export{useGetMoneyLines};
@@ -0,0 +1 @@
1
+ import{useMemo as e}from"react";import{useProductOfferDiscount as r,useCurrentVariant as l,useProduct as i,useProductStore as o,useQuantity as t,convertDecimalToNumber as n,shopifyPriceRounding as a,useFormatMoney as s}from"@gem-sdk/core";import{calculateSellingPlanDiscount as p}from"../helpers/product-price-breakdown/getPrice.js";let useProductPriceBreakdown=()=>{let c=r(),u=l(),P=i(),d=o(e=>e.selectedSellingPlan),{quantity:f}=t(),g=e(()=>{if(!d)return null;let e=u?.sellingPlanGroups??P?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===d);if(e)return e}return null},[u,P,d]),m=n(u?.price)??0,F=e(()=>!g||m<=0?0:p({variantPrice:m,pricingPolicies:g.pricingPolicies}),[g,m]),k=parseFloat(a(m-F,2)),w=parseFloat(a(k*(f||1),2)),b=s(w,!1),B=c*(f||1),G=parseFloat(a(B,2)),h=s(G,!1),j=a(G,2),v=parseFloat(a(w-parseFloat(j),2)),x=s(v>0?v:0,!1);return{price:m,sellingPlanDiscountPerUnit:F,priceAfterSellingPlanDiscount:k,subTotal:w,subTotalMoneyFormatted:b,offerDiscountTotal:B,discountWithQuantity:G,discountMoneyFormatted:h,totalMoneyFormatted:x}};export{useProductPriceBreakdown};
@@ -0,0 +1 @@
1
+ import{useMemo as l}from"react";import{useCurrentVariant as r,useProduct as e,useProductStore as i,useQuantity as n,convertDecimalToNumber as t,shopifyPriceRounding as s,useFormatMoney as o}from"@gem-sdk/core";import{calculateRecurringPrice as u,formatInterval as g}from"../helpers/product-price-breakdown/getPrice.js";let useRecurringSubtotal=()=>{let c=r(),f=e(),p=i(l=>l.selectedSellingPlan),{quantity:a}=n(),P=c?.sellingPlanGroups,b=f?.sellingPlanGroups,m=t(c?.price)??0,S=l(()=>{if(!p)return null;let l=c?.sellingPlanGroups??f?.sellingPlanGroups??[];for(let r of l)if(r?.sellingPlans){for(let l of r.sellingPlans)if(l?.baseID===p)return l}return null},[JSON.stringify(P),JSON.stringify(b),p]),y=JSON.stringify(S?.pricingPolicies),d=JSON.stringify(S?.billingPolicy),G=S?.baseID,J=l(()=>{if(!G||!c||m<=0||!S)return 0;let l=u({variantPrice:m,pricingPolicies:S.pricingPolicies}),r=l*(a||1);return parseFloat(s(r,2))},[y,m,a,G]),N=l(()=>{if(!G||!S)return null;let l=S.billingPolicy;return g({billingPolicy:l})},[d,G]),O=o(J,!1),k=l(()=>G&&!(J<=0)&&N?`${O} ${N}`:null,[G,J,N,O]);return k};export{useRecurringSubtotal};
@@ -1 +1 @@
1
- import"react/jsx-runtime";import"@gem-sdk/core";import"@gem-sdk/system";import"react";import"./components/product-variant/components/variants/VariantItem.js";import"next/link";import"./constants/index.js";import"next/head";import"next/image";import"react-youtube";import"./components/product-subscription/types.js";import"./components/product-subscription/components/OneTimePurchaseTooltip.js";import"../image/components/Img.js";import t from"./settings/product-title/ProductTitle.js";import o from"./settings/product-description/ProductDescription.js";import r from"./settings/product-price/ProductPrice.js";import s from"./settings/product-variants/ProductVariant.js";import i from"./settings/accept-button/index.js";import e from"./settings/product-quantity/index.js";import c from"./settings/product-offer/index.js";import n from"./settings/product-price-breakdown/index.js";import p from"./settings/product-discount-tag/ProductDiscountTag.js";import u from"./settings/product-subscription/index.js";import m from"./settings/product-image/ProductImages.js";let postPurchaseProductSetting={PostPurchaseProductTitle:t,PostPurchaseProductDescription:o,PostPurchaseProductPrice:r,PostPurchaseProductVariants:s,PostPurchaseAcceptButton:i,PostPurchaseProductQuantity:e,PostPurchaseProductPriceBreakdown:n,PostPurchaseProductOffer:c,PostPurchaseProductDiscountTag:p,PostPurchaseProductImages:m,PostPurchaseProductSubscription:u};export{postPurchaseProductSetting};
1
+ import"react/jsx-runtime";import"@gem-sdk/core";import"@gem-sdk/system";import"react";import"./components/product-subscription/types.js";import"./components/product-variant/components/variants/VariantItem.js";import"next/link";import"./constants/index.js";import"next/head";import"next/image";import"react-youtube";import"./components/product-subscription/components/OneTimePurchaseTooltip.js";import"../image/components/Img.js";import t from"./settings/product-title/ProductTitle.js";import o from"./settings/product-description/ProductDescription.js";import r from"./settings/product-price/ProductPrice.js";import s from"./settings/product-variants/ProductVariant.js";import i from"./settings/accept-button/index.js";import e from"./settings/product-quantity/index.js";import c from"./settings/product-offer/index.js";import n from"./settings/product-price-breakdown/index.js";import p from"./settings/product-discount-tag/ProductDiscountTag.js";import u from"./settings/product-subscription/index.js";import m from"./settings/product-image/ProductImages.js";let postPurchaseProductSetting={PostPurchaseProductTitle:t,PostPurchaseProductDescription:o,PostPurchaseProductPrice:r,PostPurchaseProductVariants:s,PostPurchaseAcceptButton:i,PostPurchaseProductQuantity:e,PostPurchaseProductPriceBreakdown:n,PostPurchaseProductOffer:c,PostPurchaseProductDiscountTag:p,PostPurchaseProductImages:m,PostPurchaseProductSubscription:u};export{postPurchaseProductSetting};
@@ -1,26 +1,53 @@
1
- import{template as e,makeStyleResponsive as t}from"@gem-sdk/core";let SealSubscriptions=({setting:r,advanced:o})=>{let{align:c}=r??{};return e`
1
+ import{template as e,makeStyleResponsive as t}from"@gem-sdk/core";let SealSubscriptions=({setting:r,advanced:o})=>{let{align:n}=r??{};return e`
2
2
  <div
3
3
  class="${o?.cssClass}"
4
- style="${{...t("ta",c)}}"
4
+ style="${{...t("ta",n)}}"
5
5
  >
6
6
  <div class="sealsubs-target-element" data-handle="{{ product.handle }}"></div>
7
7
  </div>
8
8
  <script>
9
9
  const moneyFormatGp = {{ shop.money_format | json }};
10
+
11
+ const formatCurrency = (cents, format) => {
12
+ if (typeof Shopify !== 'undefined' && Shopify.formatMoney) {
13
+ return Shopify.formatMoney(cents, format);
14
+ }
15
+ return (cents / 100).toFixed(2);
16
+ };
17
+
10
18
  document.addEventListener('DOMContentLoaded', function() {
11
- document.addEventListener('sealsubs:price_update', function(data) {
12
- const subPrice = data?.detail?.price || 0
13
- const gpPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-price.gp-money');
14
- const compareAtPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-product-compare-price');
19
+ document.addEventListener('sealsubs:selling_plan_changed', function(e) {
20
+ const productWrapper = e.detail?.element?.closest('gp-product');
21
+ if (!productWrapper) return;
22
+
23
+ const comparePriceContainers = productWrapper.querySelectorAll('gp-product-price');
24
+ const hasSellingPlan = !!e.detail.selling_plan_id;
25
+
26
+ comparePriceContainers.forEach(container => {
27
+ if (!hasSellingPlan) {
28
+ container.style.removeProperty('display');
29
+ } else {
30
+ container.style.setProperty('display', 'block', 'important');
31
+ }
32
+ });
33
+ });
34
+
35
+ document.addEventListener('sealsubs:price_update', function(e) {
36
+ const detail = e.detail;
37
+ const productWrapper = detail?.element?.closest('gp-product');
38
+ if (!productWrapper) return;
39
+
40
+ const gpPriceElement = productWrapper.querySelector('gp-product-price .gp-price.gp-money');
41
+ const compareAtPriceElement = productWrapper.querySelector('gp-product-price .gp-product-compare-price');
15
42
 
16
- if (gpPriceElement) {
17
- gpPriceElement.innerHTML = Shopify?.formatMoney(subPrice, moneyFormatGp);
43
+ if (gpPriceElement && typeof detail.price !== 'undefined') {
44
+ gpPriceElement.innerHTML = formatCurrency(detail.price, moneyFormatGp);
18
45
  }
19
46
 
20
47
  if (compareAtPriceElement) {
21
- const compareAtPrice = data?.detail?.compareAtPrice || 0
48
+ const compareAtPrice = detail?.compareAtPrice || 0;
22
49
  setTimeout(function() {
23
- compareAtPriceElement.innerHTML = Shopify?.formatMoney(compareAtPrice, moneyFormatGp);
50
+ compareAtPriceElement.innerHTML = formatCurrency(compareAtPrice, moneyFormatGp);
24
51
  });
25
52
  }
26
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.44",
3
+ "version": "12.0.0-dev.46",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -27,7 +27,7 @@
27
27
  "i18n:generate": "node ./scripts/update-locales-to-setting.js"
28
28
  },
29
29
  "devDependencies": {
30
- "@gem-sdk/core": "12.0.0-dev.44",
30
+ "@gem-sdk/core": "12.0.0-dev.46",
31
31
  "@gem-sdk/styles": "12.0.0-dev.44",
32
32
  "@gem-sdk/system": "12.0.0-dev.44",
33
33
  "@types/react-transition-group": "^4.4.12",