swellAPI.getActiveRedemptionOptions()
This method returns an array containing all active redemption options you setup. You can use this method to build a custom interface around your redemption options.
$(document).on("swell:initialized", () => {
swellAPI.getActiveRedemptionOptions().forEach(option => {
//render each option
});
});
$(document).on("swell:initialized", () => {
swellAPI.getActiveRedemptionOptions().forEach(option => {
if (option.appliesToId !== null) {
$(".swell-redemptions-list").append(
$("<li>").addClass("swell-buy-product-btn").attr({
"data-variant-id": option.appliesToId,
"data-hide-logged-out": "true|false",
"data-confirm-title": "Are you sure?",
"data-confirm-btn-text": "Redeem",
"data-error-type": "red",
"data-error-title": "Whoops!",
"data-error-okay-text": "Ok",
"data-success-type": "green",
"data-success-title": "Success!",
"data-success-content": "Product was successfully added to your cart",
"data-success-ok-btn": "Keep Shopping",
"data-success-cart-btn": "View Cart",
"data-success-cart-link": "/cart",
"data-box-width": "400px",
"data-mobile-box-width": "90%"
})
)
}
});
});
Redemption Option Object
Attribute | Type | Description |
---|---|---|
id | int | The redemption option id, useful for setting up click handlers or triggering custom redemptions |
name | string | Name of this option as set in the admin |
icon | string | The Font Awesome icon class or image URL set for this option |
description | string | The description of this option |
costText | string | The number of points required string set in admin “200 Points” |
costInPoints | int | The number of points required to redeem this option |
appliesToID | string | Can be comma-separated or empty string. This is the variant ID |
backgroundImageURL | string | The hosted URL of the background image associated with this redemption option |
discountType | string | The discount type associated with this redemption option. This is the discount type selected when creating redemptions in the Swell admin |