Gift With Purchase
Threshold promotions that unlock a gift as the cart total crosses a line.
v2.0.0@magic-spells/gift-with-purchase
Usage
<gift-with-purchase
threshold="75.00"
current="45.00"
variant-id="12345678"
money-format="${{amount}}"
message-above="🎉 Congratulations! You've qualified for your FREE gift!"
message-below="Add [amount] more to unlock your free gift! 🎁">
<div class="gwp-product">
<img src="gift-image.jpg" alt="Free Gift" />
<div class="gwp-content">
<h4 class="gwp-title">Free Sample Set</h4>
<p class="gwp-variant">Travel Size Collection</p>
</div>
</div>
<p data-content-gwp-message class="text-sm font-medium"></p>
</gift-with-purchase>About
A powerful, e-commerce web component for automatic gift-with-purchase threshold promotions. Seamlessly integrates with Shopify and automatically manages gift items in the cart based on spending thresholds.
Features
- 🎁 Automatic Gift Management - Adds/removes gifts based on cart thresholds using smart pricing logic
- 🛒 Shopify Integration - Built-in Cart API support with proper line item properties
- 📱 Cart Panel Sync - Automatically syncs with cart-panel components using calculated_subtotal
- 🎨 Highly Customizable - CSS custom properties and swappable content elements
- ⚡ Event-Driven - Custom events for gift addition, removal, and errors
- 🔧 Flexible Content - Data attributes for dynamic image, title, and variant updates
Attributes
| Attribute | Description | Example |
|---|---|---|
| threshold | Spending threshold to unlock the gift (auto-converts for multi-currency) | "75.00" |
| current | Current cart amount (typically set automatically via cart-panel) | "45.00" |
| variant-id | Shopify variant ID for the gift product | "12345678" |
| promo-ended | Disables the promo and hides the component | "true" |
| product-available | Whether the gift product is available (disables if false) | "true" |
| message-above | Message shown when threshold is met | "🎉 Congratulations! You've qualified for your FREE gift!" |
| message-below | Message shown below threshold; use [amount] for remaining amount | "Add [amount] more to unlock your free gift! 🎁" |
| money-format | Shopify-style money format for currency display | "${{amount}}" |
About, features, usage and options are taken from the package README.