Price Object

For advanced and custom price testing integrations.

Overview

If your Shopify theme has a lot of custom javascript, you will likely need to use this API to make price tests work. Common use cases for custom javascript are things like:

  • Custom bundle and pack builders

  • Custom upsells for an item

  • Custom in-cart upsells

  • PDPs with lots of customization that don't use a typical <form type="/cart/add">

Get Price

To get the price for a product, you can use window.igData?.price.getPriceByVariantId(). This will return the price as a string in currency (i.e. "29.95")

If there is no price test running or this product is not in a price test, we will return null.

Example

...
// Imagine item = product.variant;
// You want the price for that item
const itemPrice = window.igData?.price.getPriceByVariantId(item.id) || item.price;
...

Last updated