Skip to main content

Limit the Cart to One Upsell at a Time

Use custom HTML to hide the upsell module after a single upsell is added to the cart.

Updated today

Overview

This customization prevents multiple upsells from being added at once by hiding the upsell section as soon as one upsell is accepted. Once the upsell is removed, the module reappears.

This is useful if you want to:

  • Simplify the cart experience

  • Reduce decision fatigue

  • Maintain exclusivity around certain offers


How it works

  • When a customer accepts an upsell, the upsell section is hidden

  • If the upsell item is removed, the upsell section becomes visible again

  • Works with both AI-recommended and manual upsells


Where to add the code

  1. Go to Upcart > Cart Editor > Settings > Custom HTML

  2. Paste the following code into the Above announcements section


HTML script to copy

<script>   // Show upsells again when all upsells are removed   window.upcartOnItemRemoved = (_, item) => {     if (item?.properties?.__upcartUpsell) {       const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");       if (upsells) upsells.style.display = "block";     }   };    // Hide upsells when one is added   window.upcartOnAddUpsell = () => {     const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");     if (upsells) upsells.style.display = "none";   };    // Check for upsell items in the cart on load   window.upcartOnCartLoaded = (cart) => {     const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");     const items = cart.items || [];     const hasUpsell = items.some(item => item?.properties?.__upcartUpsell);     if (upsells && hasUpsell) {       upsells.style.display = "none";     }   }; </script>

Result

Once this customization is added:

  • Customers only see upsells if they have not already accepted one

  • The upsell module is hidden as soon as an upsell is added

  • The module reappears automatically if the upsell item is removed

  • No need to configure product IDs or tags

This keeps your upsell experience focused, uncluttered, and easy for customers to engage with.


Still need help?

For more advanced customization, we recommend working with a Shopify Expert. They can assist with HTML, CSS, and JavaScript inside your cart drawer.

Did this answer your question?