Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As an example, here’s a custom example of a Shopify add to cart script (note, you’d update the domain to your wesite’s):

Code Block
<script>
        setTimeout(() => {
          const przWidget = document.getElementsByClassName('preezie-widget-app')[0]
          if(przWidget) {
            przWidget.addEventListener('przAddToCartEvent', (event) => {
                console.log(event.detail);
                fetch("https://preeziepreezietest.myshopify.com/cart/add.js", {
                  method: "POST", 
                  mode: "cors",
                  cache: "no-cache", 
                  credentials: "same-origin", 
                  headers: {
                    "Content-Type": "application/json"    
                  },
                  redirect: "follow", 
                  referrerPolicy: "no-referrer", 
                  body: JSON.stringify({"items":event.detail} ), 
              });
            })
          }          
        }, 2000);
      </script>

...