🛒Auto-Add a Gift Product to Cart Based on Discount Code (plus only)
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.
⚠️ Important: This functionality requires Shopify Plus because it uses Checkout UI Extensions, which are only available on Plus plans.
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 and is only available to use for Shopify Plus merchants due to limtiations.
🎯 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
In your Shopify admin, go to
Settings → Checkout → Customize
If you're on Shopify Plus, you’ll be taken to the Checkout Editor.
In the left-hand blocks menu, click “Add app block”
Search for and add:
Auto Add Gift - v1
(basic version)or
Auto Add Gift - v2
(recommended)
💡 Use v2 for better flexibility
Click Save
Step 2: Configure Gift Logic in the Dollarlabs App
Open the Dollarlabs app from your Shopify Admin.
Go to the “Auto Add Gift - v2” section.
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 feature.
A. Product Discount (Gift Logic)
Go to Unified Discount and then
Create Discount
Set manual code:
FREEGIFT
Choose:
Buy Conditions: Create a cart group for the free product
Targets: Target the free product cart group
Quantity limits: Setup Max quantity from flags and set it to 1
B. Order Discount (Ensures Discount Code Application)
Enable the discount class for Order discount
Set: 0% off and setup conditions if needed.
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
Go to your storefront.
Add any product to cart.
Apply the discount code
FREEGIFT
.The gift product should appear in the cart with a 100% discount.
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 [email protected].
Last updated