# Price Hooks

`useIgPrices()` returns the price (and compare-at price) for the currently assigned variation when one is available. When no eligible experience is found or the experience is not ready, the hook falls back to the original price inputs and marks `isIgPrice` as `false`.

High-level behavior:

1. If no `productId` or `variantId` is provided, the hook returns a best-effort conversion of `originalPrice` / `originalCompareAtPrice` (if provided) and sets `isIgPrice: false`.
2. If the product/variant is part of an active experience and the user has a resolved variation assignment, the hook returns the assigned test price and sets `isIgPrice: true`.
3. If the experience is pending assignment or the experience is in preview but the user is not (or vice-versa), the hook returns original prices and sets `isReady` accordingly.

## `useIgPrices()`

Returns the product price based on the user's test group. Intelligems will return the original prices if updated prices are not found. You may pass in an object with the required data or an array of objects. If an array is passed in, the response will be an object keyed by `variantId`.

<pre class="language-typescript"><code class="lang-typescript">export interface UseIgPricesProps {
  productId?: string;
  variantId?: string;
  originalPrice?: number | string;
  originalCompareAtPrice?: number | string;
  currencyCode?: string;
}

export interface IgPriceReturn {
  value: number | null;
  currencyCode: string;
}

export interface DuplicateProductReturn {
  productId: string;
  variantId: string;
  handle: string;
}

export interface UseIgPricesReturn {
  igPrice?: IgPriceReturn;
  igCompareAtPrice?: IgPriceReturn;
  duplicateProduct?: DuplicateProductReturn;
  experienceId?: string;
  variationId?: string;
  isIgPrice: boolean;
  isReady: boolean;
}

type UseIgPricesInput = UseIgPricesProps | UseIgPricesProps[];

<strong>export type UseIgPricesOutput&#x3C;T extends UseIgPricesInput> =
</strong>  T extends UseIgPricesProps[]
    ? Record&#x3C;string, UseIgPricesReturn>
    : UseIgPricesReturn;

const useIgPrices = &#x3C;T extends UseIgPricesInput>(
  props: UseIgPricesInput
) => UseIgPricesOutput
</code></pre>

When passing an array, the return value is an object keyed by `variantId`. Use `isIgMultiPriceReturn()` to type-guard the multi-return shape.

## `useIgStyles`

Useful for manually styling components for integration mode.

```tsx
const igStyles = useIgStyles(isIgPrice);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://headless.intelligems.io/version-1.2.16/reference/hooks/price-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
