FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
packages
/
blocks-next
/
build
/
scripts
/
checkout-events
Edit File: index.js
var t={d:function(e,n){for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e={};t.d(e,{l:function(){return i},n:function(){return n}});const n=(t,e)=>{if((t?.line_items?.data||[]).forEach((t=>{const n=(e?.line_items?.data||[]).find((e=>e.id===t.id));if(!n||n.quantity<t.quantity){const e=new CustomEvent("scAddedToCart",{detail:{...t,quantity:t.quantity-(n?.quantity||0)},bubbles:!0});document.dispatchEvent(e)}})),(e?.line_items?.data||[]).forEach((e=>{const n=(t?.line_items?.data||[]).find((t=>t.id===e.id));if(!n||e.quantity>n.quantity){const t=new CustomEvent("scRemovedFromCart",{detail:{...e,quantity:e.quantity-(n?.quantity||0)},bubbles:!0});document.dispatchEvent(t)}})),JSON.stringify(t?.line_items?.data||[])!==JSON.stringify(e?.line_items?.data||[])){const n=new CustomEvent("scCartUpdated",{detail:{currentCart:t,previousCart:e},bubbles:!0});document.dispatchEvent(n)}},i=t=>{const e=new CustomEvent("scViewedCart",{detail:t,bubbles:!0});document.dispatchEvent(e)};var a=e.l,s=e.n;export{a as processCartViewEvent,s as processCheckoutEvents};
Save
Back