campaigns.getGWP(options)
Returns all eligible Gift-with-Purchase tiers for the current user's cart.
Parameters
options (object, optional):
achieved (boolean, optional) - When
true, returns only gift-with-purchase tiers that the user has qualified for based on their current cart. Whenfalseor omitted, returns all available gift-with-purchase tiers regardless of qualification status.
Example
console.log(igData.campaigns.getGWP({achieved: true}))
[
{
giftWithPurchaseProductId: "7191907565616",
giftWithPurchaseVariantId: null,
autoAddGiftWithPurchase: false,
giftWithPurchaseHandle: "ceramic-risotto-plate",
id: "0c8f4018-4b42-45ae-9fc4-8f5a9969c32a",
minimumUnits: 100,
unitDiscount: 0,
isFreeShipping: true,
isGiftWithPurchase: true,
}
]Return
The function returns a list of tiers:
Adding a Gift-with-Purchase to the Cart
When adding your own GWP to the cart, all you need to do is add {"_igGWP": "true"} to the item properties.
Example
Last updated
Was this helpful?