Hide Cart Until Item Is Added

Look Demo

Hide the shopping cart until an item is been added to it. This plugin uses code injection and works with the Brine template family.

How To Install

From your Squarespace account, go to Site Code Injection. Copy and paste the code below into the Footer Code Injection box.

<script>
 (function () {
   var carts = [].slice.call(document.querySelectorAll('.Cart'));
   carts.forEach(function(cart) 
     
   );

   function hideCart(cart) {
     var cartQty = cart.querySelector('.sqs-cart-quantity');
     // Handler
     function handler(target) {
       if (target.innerHTML === '0') {
         cart.setAttribute('hidden', '');
       } else 
         
       
     }
     // Observer handler
     var observer = new MutationObserver(function(mutations) 
       
     );
     // Hide/show the cart when the page is loaded
     handler(cartQty);
     // Hide/show the cart when an item was added/removed
     observer.observe(cartQty, { childList: true });
   }
 })();
 </script>

Customize

You do not need to change any values or properties.

Notes

No notes.

CommerceMoov Labs