💎
Headless Docs
Version 0.2.0
Version 0.2.0
  • Overview
  • Change Log
  • Next.js Steps
    • Requirements
    • Determine Page Methods
      • Route Hashing Method
      • Cookies Method
    • Install Middleware
    • Add Intelligems Provider
    • Read User Context
      • Route Hashing Method
      • Cookies Method
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Gatsby Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Pack Digital Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Examples
    • Content Testing
  • Reference
    • Middleware Objects
      • IgMiddlewareConfig
      • IgMiddlewareHandler
    • Providers
      • Next.js
      • Gatsby
    • Components
      • Price Components
    • Hooks
      • Price Hooks
      • Track Hooks
      • Experiment Hooks
      • Test Group Hooks
      • Cart & Checkout Hooks
Powered by GitBook
On this page
  • useIgCart()
  • useIgCheckout()
  1. Reference
  2. Hooks

Cart & Checkout Hooks

useIgCart()

Use this hook if your site manages user carts through the Storefront Cart API.

Requires the cartId. The hook will add a cart attribute to each cart session.

Returns a wrapCustomAttributes function. This function will add Intelligems-required line item properties to any existing line item properties.

interface WrapStorefrontItemCustomAttributesParams{
    productId: string;
    variantId: string;
    customAttributes?: {
        key: string;
        value: string;
    }[] | null;
};

interface WrapStorefrontItemCustomAttributesResponse {
    key: string;
    value: string;
}[];

const useIgCart: (cartId: string) => {
    wrapCustomAttributes: (options: WrapStorefrontItemCustomAttributesParams) => WrapStorefrontItemCustomAttributesResponse;
};

useIgCheckout()

Use this hook if your site manages user carts through the Storefront Checkout API.

Requires the checkoutId. The hook will add a checkout attribute to each checkout session.

Returns a wrapCustomAttributes function. This function will add Intelligems-required line item properties to any existing line item properties.

interface WrapStorefrontItemCustomAttributesParams{
    productId: string;
    variantId: string;
    customAttributes?: {
        key: string;
        value: string;
    }[] | null;
};

interface WrapStorefrontItemCustomAttributesResponse {
    key: string;
    value: string;
}[];

const useIgCheckout: (checkoutId: string) => {
    wrapCustomAttributes: (options: WrapStorefrontItemCustomAttributesParams) => WrapStorefrontItemCustomAttributesResponse;
};
PreviousTest Group Hooks

Last updated 1 year ago