Gift With Purchases

Additions and removals of Gift with Purchases must be handled by the site. In general, the following steps are needed:

  1. Determine if the cart qualifies for a GWP

    1. If yes, follow the Add GWP steps below

    2. If no, remove the GWP if already it's in the cart

Add GWP Steps

const experienceId = 'abc123';

const igOffer = useIgOffer(experienceId>
const igOfferTier = useIgOfferTier(experienceId, units);

if (igOffer.offer && igOfferTier.tier?.isGiftWithPurchase){
    const giftWithPurchaseProductId = igOfferTier.giftWithPurchaseProductId;
    const giftWithPurchaseVariantId = igOfferTier.giftWithPurchaseVariantId;
    
    const lineItemProperty = {
    key: '_igGWP'
    value: igOffer.offer.id.split("-").pop()}
    
    // Add item to the cart with the above line item property
}

Last updated