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.

 (function () {
   var carts = [].slice.call(document.querySelectorAll('.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
     // Hide/show the cart when an item was added/removed
     observer.observe(cartQty, { childList: true });


You do not need to change any values or properties.


No notes.

CommerceMoov Labs