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

# Preventing Reward exploits and Automatically Open Upcart On Shopify Cart Page

> This article shows how to stop customers from getting unlimited free products on your store.

# Overview

Upcart rewards allow you to offer free gifts or bonus items based on customer behaviour. However, without proper controls, customers may be able to access these reward products without actually qualifying for them.

This guide outlines two recommended methods for securing your rewards. You can implement one or both depending on your level of control and theme flexibility.

***

# Method 1: Remove Manual Add-to-Cart and Quantity Controls in Shopify

Some customers may try to:

* Add reward products from their **product pages** using the regular “Add to Cart” button
* Visit Shopify’s **/cart** page and manually increase the quantity of reward items

These actions occur outside of the Upcart experience and are not automatically restricted. This method helps prevent those behaviours entirely.

***

# Method 2: Automatically Open Upcart on the Theme Cart Page

If you prefer a lighter approach, you can redirect customers into the Upcart experience anytime they attempt to access the Shopify cart page.

## Overview

* Automatically opens the Upcart drawer when visiting `/cart`
* Can be combined with hiding cart content and showing a message

## Setup Instructions

1. Go to **Upcart > Settings > HTML > Scripts (Before Load)**
2. Paste the following script:

Modern API (recommended):

```text theme={"theme":{"light":"snazzy-light","dark":"github-dark"}}
<script>
  window.upcartSubscribeCartLoaded(function(event) {
    // event.cart.items contains the cart items
  });
</script>
```

Legacy API (still works but deprecated):

```text theme={"theme":{"light":"snazzy-light","dark":"github-dark"}}
<script>  
  var cartWasOpened = false;  
  upcartOnCartLoaded = (cart) => {  
    if (document.location.pathname == "/cart") {  
      upcartOpenCart();  
      cartWasOpened = true;  
    }  
  }  
</script>
```

3. Optionally, edit the Shopify cart page to:

* Hide the **Items** section
* Add a **Rich Text** block such as:\
  “To view your cart, please use the drawer in the top-right corner.”

This does not block editing but encourages customers to interact with Upcart instead.

***

## Watch the Video Walkthrough

**For a full demonstration, watch the step-by-step video guide.**

It covers hiding Add to Cart buttons, removing quantity selectors, and preventing unauthorized cart edits:

<iframe src="https://go.screenpal.com/player/cOfrDinOu3i" title="Preventing Reward Exploits" allowFullScreen style={{ width: '100%', aspectRatio: '16/9', borderRadius: '12px' }} />

## Step-by-Step Instructions from the Video

## Step 1: Create a Custom Product Template

1. Navigate to **Online Store > Themes > Customise**
2. Select **Products > Create Template**
3. Enter a name (e.g., `free-products`) and click **Create Template**

## Step 2: Remove Purchase Elements

1. In the new template editor, remove:
   * The **variant picker**
   * The **quantity selector**
   * The **Add to Cart / Buy buttons**
2. Click **Save**

## Step 3: Assign the Template to Your Reward Product

1. In the Shopify admin, search for your free gift product
2. Scroll to the **Theme Template** section
3. Select your new `free-products` template instead of the default one

This removes the ability for customers to manually add the product to their cart via its product page.

## Step 4: Disable Cart Quantity Controls

1. Go to **Online Store > Themes > Edit Code**
2. Open the file responsible for rendering the cart page (commonly `main-cart-items.liquid`)
3. Search for `quantity`, then:
   * Comment out the **quantity heading**
   * Comment out the entire **quantity selector block** (`<td>` through `</td>`)
   * Optionally comment out the **remove button** (trash icon), if applicable

Use `Control + /` or wrap code blocks with `{% comment %}` and `{% endcomment %}` to safely disable them.

This ensures customers cannot edit reward quantities or manipulate their cart through Shopify’s native cart page.

***

## Choosing the Right Approach

|                                     |                           |
| ----------------------------------- | ------------------------- |
| Objective                           | Recommended Method        |
| Fully block unauthorized reward use | Method 1                  |
| Nudge customers into Upcart         | Method 2                  |
| Maximise protection                 | Use both methods together |

***

## Need Assistance?

If you're unsure which files to edit or prefer help setting this up, please contact our support team. We're happy to guide you through the process.
