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
Get Subscription Discount
To get the price for a product, you can use window.igData?.price.getSubscriptionDiscountByVariantId
(). This will return the discount object: {subscriptionDiscount: 10, subscriptionDiscountType: "percentage"}
The types for subscription discount are: "percentage" | "dollar"
Example
Last updated