test
1 month ago
events.js
1 month ago
events.js.map
1 month ago
facebook.js
1 month ago
facebook.js.map
1 month ago
functions.js
3 years ago
functions.js.map
1 year ago
getters.js
2 months ago
getters.js.map
2 months ago
google.js
1 year ago
google.js.map
1 year ago
index.js
2 years ago
index.js.map
2 years ago
mutations.js
1 year ago
mutations.js.map
1 year ago
store.js
1 month ago
store.js.map
1 month ago
watchers.js
1 month ago
watchers.js.map
1 month ago
events.js
1 lines
| 1 | import"../checkouts/events";import state,{on}from"./store";on("set",((t,e,i)=>{if("checkout"!==t)return;if(null==i?void 0:i.id)return;if(!(null==e?void 0:e.id))return;if(!state.isCheckoutPage)return;const n=new CustomEvent("scCheckoutInitiated",{detail:e,bubbles:!0});document.dispatchEvent(n)}));const COMPLETED_CHECKOUTS_KEY="scCompletedCheckouts",hasTrackedCompletion=t=>{try{return JSON.parse(localStorage.getItem("scCompletedCheckouts")||"[]").includes(t)}catch{return!1}},trackCompletion=t=>{try{const e=JSON.parse(localStorage.getItem("scCompletedCheckouts")||"[]");localStorage.setItem("scCompletedCheckouts",JSON.stringify([...e,t].slice(-20)))}catch{}};on("set",((t,e,i)=>{var n,o;if("checkout"!==t)return;if(!(null==e?void 0:e.status)||(null==i?void 0:i.status)===(null==e?void 0:e.status))return;if(!["paid","processing"].includes(e.status))return;if(hasTrackedCompletion(e.id))return;trackCompletion(e.id);const s=new CustomEvent("scOrderPaid",{detail:e,bubbles:!0});document.dispatchEvent(s);const c=new CustomEvent("scCheckoutCompleted",{detail:e,bubbles:!0});document.dispatchEvent(c);const u=((null===(n=null==e?void 0:e.line_items)||void 0===n?void 0:n.data)||[]).filter((t=>{var e;return(null===(e=null==t?void 0:t.price)||void 0===e?void 0:e.trial_duration_days)>0}));if(u.length>0){const t=new CustomEvent("scTrialStarted",{detail:u,bubbles:!0});document.dispatchEvent(t)}const r=((null===(o=null==e?void 0:e.line_items)||void 0===o?void 0:o.data)||[]).filter((t=>{var e;return(null===(e=null==t?void 0:t.price)||void 0===e?void 0:e.recurring_interval_count)>0}));if(r.length>0){const t=new CustomEvent("scSubscriptionStarted",{detail:r,bubbles:!0});document.dispatchEvent(t)}})),on("set",((t,e,i)=>{if("checkout"!==t)return;if(!state.isCheckoutPage)return;if(!(null==e?void 0:e.selected_shipping_choice))return;if((null==i?void 0:i.selected_shipping_choice)===(null==e?void 0:e.selected_shipping_choice))return;const n=new CustomEvent("scShippingInfoAdded",{detail:e,bubbles:!0});document.dispatchEvent(n)})),on("set",((t,e,i)=>{if("checkout"!==t)return;if(!state.isCheckoutPage)return;if(!(null==i?void 0:i.id))return;if(JSON.stringify(e)===JSON.stringify(i))return;const n=new CustomEvent("scCheckoutUpdated",{detail:{currentCheckout:e,previousCheckout:i},bubbles:!0});document.dispatchEvent(n)})); |