campaigns.getGWP(options)

Returns all the eligible Gift-with-Purchase "tiers"

Parameters options (optional):

  • achieved: boolean (optional) - When true, this will only return eligible (achieved) gift with purchase tiers. When omitted or false, this will return all gwp tiers.

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:

[
 {
  autoAddGiftWithPurchase: boolean, //if Intelligems will automatically add the GWP to cart
  giftWithPurchaseProductId: string | null, // Shopify Product ID (i.e. "7191907565616")
  giftWithPurchaseVariantId: string | null, // Shopify Variant ID (i.e. "435713513473145")
  giftWithPurchaseHandle: string | null, // Shopify handle (i.e. /products/<handle>)
  isGiftWithPurchase: boolean,
  isFreeShipping: boolean,
  minimumUnits: integer, // minimum requirement to be eligible, in dollars or items
 }
]

Adding a GWP 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

fetch("/cart/add.js", {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
      },
    body: JSON.stringify({
        items: [{
            id: variantID, 
            quantity: 1, 
            properties: {_igGWP: "true"}
        }])
    }
);

Last updated