Gift With Purchases

Additions and removals of gift-with-purchase items 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 it's already in the cart.

Add GWP Steps

const experienceId = "abc123";

const { offer } = useIgOffer(experienceId);
const { tier } = useIgOfferTier(experienceId, units);

if (offer && tier?.isGiftWithPurchase) {
  const giftWithPurchaseProductId = tier.giftWithPurchaseProductId;
  const giftWithPurchaseVariantId = tier.giftWithPurchaseVariantId;

  const lineItemProperty = {
    key: "_igGWP",
    value: offer.id.split("-").pop(),
  };

  // Add item to the cart with the above line item property.
}

Last updated