> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aftersell.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

⚠️ **Important notice**

This customization only works with Version 1 of the Upcart cart modules. If you recently upgraded your cart to Version 2, these customizations may not work. You will need to use the new selectors provided for Version 2 in the [migration guide.](/upcart/upcart_v20_migration_guide)

If your customizations are not working as expected, you can also revert your cart back to Version 1 instead of using Version 2.

We are currently working on new customization templates for Version 2 of the modules, and they will be available soon.

# 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 upsells are removed  
  window.upcartSubscribeItemRemoved((event) => {  
    if (event.item?.properties?.__upcartUpsell) {  
      const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");  
      if (upsells) upsells.style.display = "block";  
    }  
  });  
  
  // Hide upsells once one is added  
  window.upcartSubscribeUpsellsAddedToCart(() => {  
    const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");  
    if (upsells) upsells.style.display = "none";  
  });  
  
  // Check for upsell in cart when it loads  
  window.upcartSubscribeCartLoaded((event) => {  
    const upsells = window.upcartDocumentOrShadowRoot.querySelector(".upcart-upsells-module");  
    const items = event.cart.items || [];  
    const hasUpsell = items.some(item => item?.properties?.__upcartUpsell);  
    if (upsells && hasUpsell) {  
      upsells.style.display = "none";  
    }  
  });  
</script>
```

<Note>
  **Legacy note:** `window.upcartOnItemRemoved`, `window.upcartOnAddUpsell`, and `window.upcartOnCartLoaded` callbacks still work but are deprecated and log console warnings. Use `upcartSubscribeItemRemoved`, `upcartSubscribeUpsellsAddedToCart`, and `upcartSubscribeCartLoaded` for all new scripts.
</Note>

***

## 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.

[See Shopify Experts](https://www.shopify.com/partners/directory)
