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