โ ๏ธ 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.
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 guide shows how to prevent specific products (e.g. warranties, shipping protection, low-priority items) from appearing in your upsells by excluding them based on Product ID, Product Handle, or Product Tags.
You can add this code in Upcart > Editor > Settings > Custom HTML, in locations such as Above announcements/rewards.
Exclude by product ID
To find a product ID:
Go to Shopify Admin > Products
Open the product and copy the long numeric ID from the URL (after
/products/)
Example:
<script>
window.upcartModifyListOfUpsells = (upsells) => {
var productIDsToExclude = [
6958755512477,
6958755610781
];
return upsells.filter(item =>
!productIDsToExclude.includes(item.id)
);
};
</script>
Exclude by product handle
To find a product handle:
In Shopify Admin > Products, open the product
Scroll to Search engine listing preview > Edit
The handle is the last part of the product URL (e.g.
ocean-blue-shirt)
Place this script in both Above announcements and Rewards HTML locations:
<script>
window.upcartModifyListOfUpsells = (upsells) => {
var productHandlesToExclude = [
"ocean-blue-shirt",
"yellow-wool-jumper"
];
return upsells.filter(item =>
!productHandlesToExclude.includes(item.handle)
);
};
</script>
Exclude by product tags
To add or find tags:
Go to Shopify Admin > Products
Open a product and scroll to the Tags section
Tags are case-sensitive
Adding collection product tags in bulk:
Go to Shopify Admin > Products
Click Search and Filter (F) > Add Filter > Collection
Select the collection of the items you want to exclude
Select all items (top left checkbox)
Click more button (...) > Add Tags
Select or type in the tag to apply it to all items in the collection
Example script:
<script>
window.upcartModifyListOfUpsells = (upsells) => {
var productTagsToExclude = [
"Exclude From UpCart Upsells"
];
return upsells.filter(item =>
!item.tags.some(tag =>
productTagsToExclude.includes(tag)
)
);
};
</script>
Best practices
Tags must match exactly, including capitalization
If you're filtering upsells in multiple locations (e.g. AI and manual), paste the code in both HTML sections
Always test your implementation using Sandbox Mode before going live
Need help?
For help writing or debugging advanced customizations, we recommend reaching out to a Shopify Expert. Upcart support does not assist with custom JavaScript, HTML, or CSS implementations.