Skip to main content
All CollectionsDiscountingGift with Purchase
LEGACY: How To Create A GWP Shopify Script
LEGACY: How To Create A GWP Shopify Script

Create Gift With Purchase Shopify Scripts using a script creator

Strauss Van Wagenen avatar
Written by Strauss Van Wagenen
Updated this week

This guide walks you through how to create a Gift With Purchase (GWP) Shopify Script using a third-party script creator. It's intended for merchants still using legacy Shopify Scripts to power GWP experiences with Rebuy.

⚠️ Important Notes:

🚨 Before You Begin

  • Rebuy does not create or customize Shopify Scripts.
    We provide this guide as a reference. For custom script support, please contact Shopify Support.

  • Learn more about what Rebuy Support can help with on our Support Scope Policy page.

GWP Setup Overview

Creating a Gift With Purchase requires two main steps:

1. Create a GWP Widget

To create the widget that triggers the free gift, follow this guide:
👉 How to Create a GWP Widget

2. Create a Discounting Script

To apply the discount via Shopify Scripts:

Step 1: Use the Shopify Script Creator Tool

  1. Click Create new, then select Conditional Discount.

Step 2: Configure Your Script

  • Set the Discounted Item Selector to:
    Has Properties

  • In the Keys and Values section:

    • Key: _widget_id

    • Value: (Enter the ID of the widget you want to discount)

  • Choose your discount (for example, set it to 100% for a free gift).

  • Click Save.

💡 If you’re unsure where to find your widget ID, it’s available in your Rebuy Admin under the widget settings.

Step 3: Add the Script to Shopify

  1. Copy the generated script to your clipboard.

  2. Open the Shopify Script Editor in your Shopify Admin.

  3. Create a new Blank Template.

  4. Paste the copied script.

  5. Preview and test it in your store to confirm it works.

✅ Test and Confirm

  • Add a qualifying item to your cart to trigger the GWP.

  • Make sure the correct item is added and discounted as expected.

You're All Set!

If everything works as expected, congrats—you’ve successfully created a GWP using a Shopify Script and a Rebuy widget! 🎉

What's Next?

As Shopify moves away from legacy Scripts, we encourage merchants to explore the Rebuy Discounting feature built on Shopify Functions, which offers more flexibility and long-term support.

Did this answer your question?