# How to Add Free Gifts Automatically to the Cart

The Gifting feature in Dollarlabs Offer Engine allows you to automatically add a free product to the customer’s cart when they purchase a specific product, variant, collection, or any item.

This is perfect for “Buy X, Get Y” promos, freebie campaigns, and quantity-based campaigns.

{% embed url="<https://dollarlabs.neetorecord.com/watch/53c04c9a39330ab4d502>" %}

***

### What the Gifting Feature Does

With gifting, you can set up rules such as:

* Buy this product → Automatically receive a free gift in the cart
* Scale gifts based on quantity (e.g., buy 3 → get 3 gifts)
* Add multiple free gifts
* Limit gift quantity using a maximum cap
* Show “Free Gift” messaging directly on your product page using our Theme Blocks
* Treat a product selection as a grouped requirement (new)

***

## How to Set Up a Gifting Rule

### 1. Set up an offer in the Offer Engine&#x20;

* Go to your Dollarlabs Discount App
* Go to the **Offer Engine page**
* Create a price list if you haven't already

***

### 2. Configure the Trigger Product

Inside the pricelist:

* Add a new rule
* Choose where the rule applies:
  * A specific product
  * A variant
  * A collection
  * Or any purchase

Example:\
You select Variant ABC as the product that triggers the gift.

***

### 3. Add the Gift Product

Scroll to the **Gift Products** section:

* Click **Add Gift Product**
* Select the product and variant you want to offer as a free gift\
  (example: Product ID 1001)

You can add more than one gift by clicking **Add Gift Product** again.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2FvJZcLx93lrnc8sMNUHBQ%2Fimage.png?alt=media&#x26;token=82494423-69bf-4182-8d42-90fb0e11e098" alt="" width="375"><figcaption></figcaption></figure>

***

## Gift Behavior Options

There are now **two different behaviors** available depending on whether “Consider selection as group of products” is enabled or not.

***

## Behavior 1: Standard Gifting (Checkbox OFF – Previous Behavior)

This is the original gifting behavior.

The selected product(s) act independently.

#### How it works

If:

* Trigger product = Variant ABC
* Gift scales with quantity = ON

Then:

* Buy 1 → Get 1 gift
* Buy 3 → Get 3 gifts
* Buy 10 → Get 10 gifts

If scaling is OFF:

* Buy 1 or 5 → Get 1 gift

You can also:

* Set a maximum cap (e.g., maximum 10 gifts)

#### Important Note

Previously, gifting worked strictly in a 1:1 logic:\
Each qualifying product unit directly triggered its corresponding gift unit.

There was no grouped quantity threshold logic.

***

## Behavior 2: Group-Based Gifting (Checkbox ON – New Setting)

Enable:

✅ **Consider selection as group of products**

When this is enabled, the selected list of products is treated as a group.

The gift is added only when the **minimum quantity threshold across the group** is met.

Instead of each item triggering a gift individually, the system counts total qualifying items from the rule’s selection.

***

### Quantity From Group

You can define:

**Quantity from group** → Minimum number of items required from the selected products before a gift is added.

Example:

* Rule applies to Collection X
* Consider selection as group = ON
* Quantity from group = 3
* Gift scales with quantity = ON

If a customer adds:

* 1 item → No gift
* 2 items → No gift
* 3 items → 1 gift
* 6 items → 2 gifts
* 9 items → 3 gifts

This allows repetition logic such as:

Buy 3 from Collection X → Get 1 gift\
Buy 6 → Get 2 gifts\
Buy 9 → Get 3 gifts

This is ideal for bundle-style promotions.

***

### How Group Behavior Works With Scaling

You can combine:

* Consider selection as group
* Quantity from group threshold
* Gift scales with quantity
* Maximum cap

Example:

* Quantity from group = 3
* Gift scales with quantity = ON
* Maximum cap = 5

If a customer buys:

* 15 qualifying items → 5 gifts (capped)

***

## Enable Required Theme Blocks

To make gifting work on your storefront, two theme blocks must be active:

#### A. Gift Block (Product Page)

Shows the “Free Gift” message on the product page for eligible variants.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2F4xZ6lD3AYfjuoZr6kfIV%2Fimage.png?alt=media&#x26;token=4f4b707e-17f0-4056-af2d-5ca1161c4e43" alt=""><figcaption></figcaption></figure>

#### B. Code Embed (Cart Logic)

Ensures the gift is automatically added to and synced in the cart.

To enable:

* Click **Add Block & Activate**
* Dollarlabs automatically adds the blocks inside your theme
* Move the Gift Block where you want it (usually near the variant selector)
* Click Save

Once activated correctly, these blocks will show a green status inside the Pricelist editor.

***

## Test the Feature

#### A. On the Product Page

Switch to the eligible variant — you should see a message like:

“You will receive Product 1001 for free.”

Switch to a non-eligible variant — no gift message will appear.

#### B. In the Cart

When you add the product(s):

* The gift is automatically added as a free line item
* If scaling is OFF → gift stays fixed
* If scaling is ON → gift quantity updates dynamically
* If quantity exceeds max cap → gift remains capped
* Adding unrelated variants/products will not affect the gift

For group behavior:

* Gift appears only after the defined group threshold is reached
* Reducing quantity below threshold automatically removes the gift

***

## Advanced: Using Window Variables (For Custom Themes)

If you prefer to render your own custom gift UI, you can use the global object:

`window.DOLLAR_VARIANT_GIFTS`

This contains:

* All variants for the current product
* Whether the variant is eligible
* The list of gift products
* Quantity scaling data
* Group threshold data
* Maximum caps

You can use this to design custom gift badges, blocks, or banners.

***

## Current Capabilities

Supported:

* Product-based gifting
* Variant-based gifting
* Collection-based gifting
* “Any purchase” gifting
* Quantity scaling
* Group-based gifting with thresholds
* Repetition logic (e.g., Buy 3 → Get 1 repeatedly)

Not yet supported (coming soon):

* Cart value–based gifting (e.g., “Spend $100 → Get Gift”)

***

## Need Help?

If you have questions or want us to set this up on your store:

📩 Email us at <support@dollarlabs.io>\
Or just ping us on chat 🙂
