Control the gift with purchase component in real-time. Adjust the cart amount and threshold to see how the component responds and automatically manages the gift.
Travel Size Collection
Examples of different gift configurations and visual styles.
Limited Edition
Full Size Products
<gift-with-purchase
threshold="75.00"
current="45.00"
variant-id="12345678"
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></p>
</gift-with-purchase>
const gwp = document.querySelector('gift-with-purchase');
// Update cart amount
gwp.setCurrentAmount(85.50);
// Change threshold
gwp.setThreshold(100.00);
// Update variant ID
gwp.setVariantId('87654321');
// Get current state
const state = gwp.getState();
console.log(state.isActive, state.isAdded, state.remainingAmount);
<cart-panel>
<gift-with-purchase
threshold="75.00"
variant-id="12345678"
message-above="🎉 Congratulations! You've qualified for FREE shipping!"
message-below="Add ${ amount } more to get FREE shipping! 🚚">
<!-- Gift content -->
</gift-with-purchase>
</cart-panel>
<gift-with-purchase
threshold="75.00"
variant-id="12345678"
message-above="🎉 Congratulations! You've qualified for your FREE gift!"
message-below="Add ${ amount } more to unlock your free gift! 🎁">
<!-- Add a paragraph with data-content-gwp-message for the component to inject messages -->
<p data-content-gwp-message class="your-custom-styles"></p>
</gift-with-purchase>
// Listen for gift events
gwp.addEventListener('gwp:added', (event) => {
console.log('Gift added:', event.detail);
});
gwp.addEventListener('gwp:removed', (event) => {
console.log('Gift removed:', event.detail);
});
gwp.addEventListener('gwp:error', (event) => {
console.error('GWP Error:', event.detail);
});
Automatically adds and removes gifts from the cart based on threshold rules and cart changes.
Built-in support for Shopify Cart API with proper line item properties for gift identification.
Automatically syncs with cart-panel components and responds to cart data changes in real-time.
CSS custom properties, data attributes, and swappable content elements for complete customization.
Emits custom events for gift addition, removal, and errors for easy integration with other components.
Style your gift content with any CSS classes or frameworks. The component looks for your message element with data-content-gwp-message.