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


🎯 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

  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

  1. Click Save

If you're using v1 - then you can follow the below screenshot to configure the auto add behaviour.


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

A. Product Discount (Gift Logic)

  1. Go to Unified Discount and then Create Discount

  2. Set manual code: FREEGIFT

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

  1. Enable the discount class 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 [email protected].

Last updated