All Collections
Widgets
Gift with Purchase
Selectable Gift-With-Purchase Widgets
Selectable Gift-With-Purchase Widgets

This is an advanced tutorial on customizing Rebuy widgets to offer a Selectable Gift With Purchase.

Dante Maxwell avatar
Written by Dante Maxwell
Updated this week

Picture this: you're browsing through your favorite online store, and you stumble upon an irresistible offer—a free gift with your purchase. But hold on, what if we told you there's an even better way to delight your customers? Why not take your customer experience to a whole new level by offering them a gift of their choice.

The top three reasons why merchants choose to enhance their customer experience by offering a selectable gift with purchase are:

  1. Personalization and customization:
    Customers love feeling special, and giving them the power to choose a gift that resonates with their preferences and needs does just that. It's like giving them the keys to a treasure trove where they can find the perfect reward for themselves.

  2. Increased perceived value:
    When customers have options, they perceive greater value. Think about it—they'll be comparing the different gifts, assessing which one brings the most joy or utility to their lives. By providing a selection, you're not just handing out a gift; you're delivering an experience that makes customers feel like they're getting something truly valuable in return.

  3. Enhanced engagement and excitement:
    When faced with a range of enticing choices, customers can't help but feel a rush of anticipation. The mere act of browsing through the available options ignites their curiosity and engages them on a deeper level. It's like a mini-adventure within their shopping journey, making them feel more connected to your brand and more likely to come back for more.

Before we begin

  • If you only have a single product with no variants to offer as a free gift, consider using Rebuy's standard Gift With Purchase widget type or the Smart Cart's Tiered Progress Bar.

  • If you only have a single product to offer as a free gift that requires the customer to choose a specific variant (size, color etc.), consider using the Smart Cart's Tiered Progress Bar.

  • If you have multiple products for a customer to choose from as their free gift, continue following the steps outlined in this guide.

  • Please note that "Selectable Gift with Purchase" is not a standard Rebuy widget type and therefore must be customized. We recommend that only advanced users follow this process.

A Selectable Gift With Purchase widget works in combination with Rebuy's Smart Cart. There are two styles of Selectable Gift With Purchase widgets that we'll cover in this guide:

A pop-up Selectable Gift With Purchase

and

A Selectable Gift With Purchase widget embedded in the cart drawer (Smart Cart)



How to create a Pop-up Selectable Gift With Purchase Widget

Step 1) Create a new Cart Cross Sell Widget and install it in the Rebuy Smart Cart. Be sure to choose the "Cart Flyout" type of widget. Check out our guide on Creating Cart Cross Sell Widgets for reference.

Step 2) Expand the options in the Language tab and reconfigure the default copy with relevance to the offer and delivered in your own brand's voice:

Step 3) Expand the Discount tab. Input enough of a discount to display the products as free:

Step 4) Expand the options in the Layout tab. Under Display Type, select Popup and choose the best popup trigger for your offer. Most of the time, this will be Add to cart. Reconfigure the default layout from list view to grid view, and adjust the number of columns to accommodate the number of free gifts a customer would have to choose from:

Step 5) Expand the options in the Advanced tab. Copy the following code and paste it into the Ready section of the Advanced tab:

function popupSelectableGWP() {
setTimeout(() => {
//check for free gift items in the cart
const giftItem = Rebuy.SmartCart.items().find(item => item.properties._widget_id === `${widget.id}`);
//if there is no gift item and the widget rules match
if (!giftItem && widget.data.metadata.matched_rules.length) {
widget.show()
//hide the widget if theres already a gift in cart
} else {
widget.hide() }
//if widget rules is no longer match, remove free gift
if (widget.data?.metadata.matched_rules.length === 0) { Rebuy.Cart.removeItem(giftItem)
}
}, 300)
}
popupSelectableGWP() //runs on page load
document.addEventListener('rebuy:cart.change', popupSelectableGWP) //runs on cart change

The code does 3 things. First, it checks if a gift item from this widget is already in the cart. Second, if there is no gift present, and the rule in the widget's Data Source is matching, the pop-up is triggered. Third, if a gift from this widget is present in the cart and the Data Source's rule(s) ceases to match, the gift previously added by the widget will be removed.



Step 6) Configure the Data Source rules that will trigger the Selectable Gift With Purchase popup:

Most commonly, this is done with a cart subtotal rule but other conditions can be used as well. For example, offering free samples when a customer adds specific products to their cart. Check out our guide on Gift With Purchase Best Practices for reference.

Step 7) Add the following CSS code snippet to the CSS input found in your Rebuy Theme by navigating to Dashboard > Manage Rebuy Theme:

.property-value-XXXXX .rebuy-cart__flyout-item-quantity-widget {
display: none;
}

.property-value-XXXXX .rebuy-cart__flyout-item-subscription {
display: none;
}

Replace "XXXXX" with the actual widget ID. This above CSS code hides the quantity selector and subscription upgrade option on any line item in Rebuy's Smart Cart that was added from the associated Rebuy widget ID.

Step 8) This step is optional. You'll only need to implement this step if the Gift With Purchase products being surfaced are intended to be hidden from all other areas of the online store. To remove the pointer event on the gift item in the Smart Cart so that customers cannot click on the gift and go to that items product page.

Place this code in the Smart Cart > Custom CSS block:

/* replace XXXXX with the widget's ID */
.rebuy-cart__flyout-item.property-value-XXXXX .rebuy-cart__flyout-item-product-title, .rebuy-cart__flyout-item.property-value-XXXXX .rebuy-cart__flyout-item-media {
pointer-events: none;
}

Step 9) Ensure that the discounted (Free) gift product appears as Free once the customer has selected it and added it to their cart and/or checkout. This step will differ depending on whether your shop is on a Shopify Plus Plan or not. For non-Shopify Plus accounts, you'll need to create a new Automatic Discount. For Shopify Plus accounts, you can use the Shopify Script Creator and Shopify Script Editor app to create and publish an associated line item script. For more information on how discounts are managed with Rebuy, please check out our guide on Understanding Product and Widget Level Discounts.

Setting up an Automatic Discount for a Selectable Gift With Purchase Widget - Watch Video


See it in Action

Pop-Up Selectable Gift With Purchase In Action - Watch Video


How to create an embedded Selectable Gift With Purchase Widget

Step 1) Create a new Cart Cross Sell Widget and install it in the Rebuy Smart Cart. Be sure to choose the "Cart Flyout" type of widget. Check out our guide on Creating Cart Cross Sell Widgets for reference.

Step 2) Expand the options in the Language tab and reconfigure the default copy with relevance to the offer and delivered in your own brand's voice:

Step 3) Expand the Discount tab. Input enough of a discount to display the products as free:

Step 4) Expand the options in the Advanced tab. Copy the following code and paste it into the Ready section of the Advanced tab:


function embedSelectableGWP () {
setTimeout(() => {
//check for a free gift item in the cart
const giftItem = Rebuy.SmartCart.items().find(item => item.properties?._widget_id === `${widget.id}`);
//hide widget if there is a gift item
if (giftItem) {
document.querySelector(`#rebuy-widget-${widget.id}`).style.display = 'none';
//display the widget if not
} else {
document.querySelector(`#rebuy-widget-${widget.id}`).style.display = 'block';
}
//if widget rules is no longer match, remove free gift
if (widget.data?.metadata.matched_rules.length === 0) {
Rebuy.Cart.removeItem(giftItem)
}
}, 500)
}
//runs on page load
embedSelectableGWP()
//runs on each cart change
document.addEventListener('rebuy:cart.change', embedSelectableGWP)

The code does 3 things. First, it checks if a gift item from this widget is already in the cart. Second, if there is no gift present, and the rule in the widget's Data Source is matching, the pop-up is triggered. Third, if a gift from this widget is present in the cart and the Data Source's rule(s) ceases to match, the gift previously added by the widget will be removed.

Step 5) Configure the Data Source rules that will trigger the Selectable Gift With Purchase popup:

Most commonly, this is done with a cart subtotal rule but other conditions can be used as well. For example, offering free samples when a customer adds specific products to their cart. Check out our guide on Gift With Purchase Best Practices for reference.

Step 6) Add the following CSS code snippet to the CSS input found in your Rebuy Theme by navigating to Dashboard > Manage Rebuy Theme:

.property-value-XXXXX .rebuy-cart__flyout-item-quantity-widget {
display: none;
}

.property-value-XXXXX .rebuy-cart__flyout-item-subscription {
display: none;
}

Replace "XXXXX" with the actual widget ID. This above CSS code hides the quantity selector and subscription upgrade option on any line item in Rebuy's Smart Cart that was added from the associated Rebuy widget ID.

Step 7) This step is optional. You'll only need to implement this step if the Gift With Purchase products being surfaced are intended to be hidden from all other areas of the online store. To remove the pointer event on the gift item in the Smart Cart so that customers cannot click on the gift and go to that items product page.

Place this code in the Smart Cart > Custom CSS block:

/* replace XXXXX with the widget's ID */
.rebuy-cart__flyout-item.property-value-XXXXX .rebuy-cart__flyout-item-product-title, .rebuy-cart__flyout-item.property-value-XXXXX .rebuy-cart__flyout-item-media {
pointer-events: none;
}

Step 8) Ensure that the discounted (Free) gift product appears as Free once the customer has selected it and added it to their cart and/or checkout. This step will differ depending on whether your shop is on a Shopify Plus Plan or not. For non-Shopify Plus accounts, you'll need to create a new Automatic Discount. For Shopify Plus accounts, you can use the Shopify Script Creator and Shopify Script Editor app to create and publish an associated line item script. For more information on how discounts are managed with Rebuy, please check out our guide on Understanding Product and Widget Level Discounts.

Setting up an Automatic Discount for a Selectable Gift With Purchase Widget - Watch Video

See it in action

Embedded Selectable Gift With Purchase In Action - Watch Video


Associated Help Center Resources

The following links can support you further in your implementation of this process.
Creating Cart Cross Sell Widgets
Creating a Free Gift With Purchase without Shopify Plus


Did this answer your question?