> For the complete documentation index, see [llms.txt](https://help.dollarlabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.dollarlabs.io/dollarlabs-ultimate-discounts/auto-add-a-gift-product-to-cart-based-on-discount-code-plus-only.md).

# Auto-Add a Gift Product to Cart Based on Discount Code (plus only)

{% hint style="warning" %}
The **Auto-Add Gift to Cart** feature (triggered by coupon codes) is being **deprecated**. Shopify’s recent restrictions on Checkout Extensions make this feature incompatible with their Terms of Service.

**Impact:**

* New configurations cannot be created.
* Existing configurations will continue to work for now, but we recommend reviewing your setup.

**Need help?**\
If you are an existing merchant with active configurations, please contact us at **<support@dollarlabs.io>**. Our team will assist you with managing or transitioning your current setup.
{% endhint %}

This guide shows you how to **automatically add a free gift product** to the cart **when a specific discount code is applied**, using the **Dollarlabs app** on **Shopify Plus**. This is a great way to run “Buy X, Get Y Free” or “Free Gift with Coupon” style promotions - with built-in protection against abuse.

{% embed url="<https://youtu.be/oRti_xHpeIk>" %}

> ⚠️ **Important**: This functionality requires **Shopify Plus** because it uses **Checkout UI Extensions**, which are only available on Plus plans.

{% hint style="warning" %}
This feature should only be used to add products to the cart that do not increase the total order value of the cart. \
\
Ensure compliance with [Shopify's app requirements](https://shopify.dev/docs/apps/launch/app-requirements-checklist#1-prohibited-and-restricted-app-configurations) and is only available to use for Shopify Plus merchants due to [limtiations](https://shopify.dev/docs/api/checkout-ui-extensions).
{% endhint %}

***

#### 🎯 Common Use Case

**Customer enters a discount code → Free product is automatically added to cart**

Example:

> Customer applies code `FREEGIFT` → A ₹50 product is added to their cart for free

***

### 🔧 Setup Guide

#### Step 1: Add the “Auto Add Gift” Block to Checkout

1. In your Shopify admin, go to `Settings → Checkout → Customize` \
   ![](/files/FcpVx5VtwyoWczZnCvyA)
2. If you're on **Shopify Plus**, you’ll be taken to the Checkout Editor.
3. In the left-hand blocks menu, click **“Add app block”**
4. Search for and add:
   * `Auto Add Gift - v1` *(basic version)*
   * or `Auto Add Gift - v2` *(recommended)*

> 💡 **Use v2 for better flexibility**&#x20;

5. Click **Save**

{% hint style="info" %}
If you're using v1 - then you can follow the below screenshot to configure the auto add behaviour.

![](/files/Mu9SbeW5VRGC5ar9jb6s)
{% endhint %}

***

#### Step 2: Configure Gift Logic in the Dollarlabs App

1. Open the **Dollarlabs** app from your Shopify Admin.
2. Go to the **“Auto Add Gift - v2”** section.
3. Create a new rule:
   * **Condition**: Discount code equals `FREEGIFT`
   * **Action**: Add Product ID `xyz` to cart *(the free gift)*

***

#### Step 3: Set Up Discount Code in Shopify Admin

You’ll need to configure a discount that does both Product / Order discount using our [Unified discounts](/dollarlabs-ultimate-discounts/unified-discount-engine-v2.md) feature.

**A. Product Discount (Gift Logic)**

1. Go to Unified Discount  and then `Create Discount`&#x20;
2. Set manual code: `FREEGIFT`
3. Choose:
   * **Buy Conditions**: Create a cart group for the free product&#x20;
   * **Targets**: Target the free product cart group
   * **Quantity limits**: Setup [Max quantity](/dollarlabs-ultimate-discounts/unified-discount-engine-v2/limits/max-quantity.md) from flags and set it to 1

**B. Order Discount (Ensures Discount Code Application)**

1. Enable the [discount class](/dollarlabs-ultimate-discounts/unified-discount-engine-v2/discount-classes.md) for Order discount
2. Set: 0% off and setup conditions if needed.
3. Purpose: This ensures the discount code is recognized at checkout so that the app script can trigger

> 💡 Shopify requires the discount code to be valid in order for the logic to execute.

***

#### 🛡️ Abuse Protection

* **Limit quantity**: Only the specified quantity of gift product will receive discount
* **Auto removal**: If the customer removes the discount code, the gift product is automatically removed from the cart.
* **Only for valid use**: You **can only auto-add free products** via this method (Shopify restriction).

***

#### ✅ Final Test

1. Go to your storefront.
2. Add any product to cart.
3. Apply the discount code `FREEGIFT`.
4. The gift product should appear in the cart with a 100% discount.
5. If the code is removed, the gift product disappears automatically.

***

#### 💬 Still Have Questions?

We’re happy to help.\
Reach out to us via in-app chat or email support at **<support@dollarlabs.com>**.
