# Objects

{% hint style="info" %}
The documentation below describes the API as of version 9.x of the script.&#x20;

Public properties or functions that are not in the `discountNinja.api` namespace should be considered obsolete and will be removed in the next major version release.

Using undocumented functions or objects will result in issues as custom code that relies on those functions or objects may break in the future when Discount Ninja's script is automatically updated.
{% endhint %}

{% hint style="info" %}
Note that the properties of the objects made available by the API should be considered **read-only.** To modify the state of the object's properties, the user can:

* call one of the available [functions](https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api/promotion-engine/javascript-api/functions)
* publish one of the available [events](https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api/promotion-engine/javascript-api/events)
  {% endhint %}

## Product variant price info

<table data-header-hidden><thead><tr><th width="241">Property</th><th width="139">Type</th><th></th></tr></thead><tbody><tr><td><code>amount</code></td><td><code>number</code></td><td>The discount amount, expressed in cents.</td></tr><tr><td><code>discountCode</code></td><td><code>string</code></td><td>The offer token, Shopify discount code or promotion code associated with the applied discount.</td></tr><tr><td><code>discountedPrice</code></td><td><code>number</code></td><td>The discounted price, expressed in cents.</td></tr><tr><td><code>isCurrentProduct</code></td><td><code>boolean</code></td><td><code>true</code> if the user is on a product page that matches the handle for this object</td></tr><tr><td><code>isDiscountedByOffer</code></td><td><code>boolean</code></td><td><code>true</code> if the variant is discounted by a Discount Ninja offer (not, for example, a compare-at price).</td></tr><tr><td><code>offerToken</code></td><td><code>string</code></td><td>The token of the offer associated with the applied discount.</td></tr><tr><td><code>originalPrice</code></td><td><code>number</code></td><td>The original price (i.e. the price before discounts are applied), expressed in cents.</td></tr><tr><td><code>percentage</code></td><td><code>number</code></td><td>The discount percentage.</td></tr><tr><td><code>productHandle</code></td><td><code>string</code></td><td>The handle of the product associated with the object.</td></tr><tr><td><code>sellingPlan</code></td><td><code>number</code> | <code>null</code></td><td>The id of the selected selling plan for subscription products. <code>Null</code> for one-time purchases.</td></tr><tr><td><code>promotionToken</code></td><td><code>string</code></td><td>The token of the promotion associated with the applied discount.</td></tr><tr><td><code>variantId</code></td><td><code>number</code> | <code>null</code></td><td>The id of the selected variant. <code>Null</code> if the variant is not known, for example for products on collection pages.</td></tr></tbody></table>

## Entitlement info

<table data-header-hidden><thead><tr><th width="243">Property</th><th width="192">Type</th><th></th></tr></thead><tbody><tr><td><code>offerToken</code></td><td><code>string</code></td><td>The token of the offer.</td></tr><tr><td><code>applied</code></td><td><code>boolean</code></td><td>Indicates if the offer has been applied to the cart.</td></tr><tr><td><code>source</code></td><td><code>"app" | "native" | null</code></td><td>Set to "<code>app</code>" if the offer was configured in Discount Ninja. If set to "<code>native</code>", this offer is a wrapper for a discount configured in Shopify.</td></tr><tr><td><code>prerequisite</code></td><td><code>object</code></td><td></td></tr><tr><td>   <code>prerequisiteItems</code></td><td><code>array</code></td><td>An array of objects that lists the line items that are considered prerequisites for this offer to apply.<br><br>Each object has two properties:<br>- <code>key</code> (<code>string</code>): the key of the line item<br>- <code>quantity</code> (<code>number</code>): the number of items on the line item that are prerequisites</td></tr><tr><td><code>entitlement</code></td><td><code>object</code></td><td></td></tr><tr><td>   <code>amount</code></td><td><code>number | null</code></td><td>The amount that is discounted. <code>Null</code> for a shipping offer.</td></tr><tr><td>   <code>level</code></td><td><code>"product" | "order" | "shipping"</code></td><td>Indicates at what level the offer discounts the cart.</td></tr><tr><td>   <code>type</code></td><td><code>"gift" | "percentage" | "fixed_amount" | "fixed_price"</code></td><td>The type of entitlement that is applied by the offer.</td></tr><tr><td>   <code>target</code></td><td><code>object</code></td><td></td></tr><tr><td>      <code>variants</code></td><td><code>string | null</code></td><td>A comma-separated list of variant ids the customer is entitled to.</td></tr><tr><td>      <code>collections</code></td><td><code>string | null</code></td><td>A comma-separated list of collection handles the customer is entitled to.</td></tr><tr><td>      <code>products</code></td><td><code>string | null</code></td><td>A comma-separated list of product handles the customer is entitled to.</td></tr><tr><td>      <code>allProducts</code></td><td><code>boolean</code></td><td>Set to <code>true</code> if the entitlement applies to all products.</td></tr><tr><td>      <code>shipping</code></td><td><code>boolean</code></td><td>Set to <code>true</code> if the entitlement applies to the shipping line.</td></tr><tr><td>   <code>entitledItems</code></td><td><code>object</code></td><td></td></tr><tr><td>      <code>quantity</code></td><td><code>number</code></td><td>The number of items the customer is entitled to.</td></tr><tr><td>      <code>claimed</code></td><td><code>number</code></td><td>The number of entitled items the customer has added to the cart.</td></tr><tr><td>      <code>lineItems</code></td><td><code>array</code></td><td>An array of objects that lists the line items that are considered entitled items.<br><br>Each object has two properties:<br>- <code>key</code> (<code>string</code>): the key of the line item<br>- <code>quantity</code> (<code>number</code>): the number of items on the line item that are entitlements</td></tr><tr><td>      <code>sets</code></td><td><code>array</code></td><td>An array of objects that lists the sets ( a group of prerequisites and entitlements).</td></tr></tbody></table>

## Discounted Cart

<table data-header-hidden><thead><tr><th width="283">Property</th><th width="192">Type</th><th></th></tr></thead><tbody><tr><td><code>appliedPromotions</code></td><td><code>array</code></td><td>The list of the product, discount and shipping promotions applied to the cart.</td></tr><tr><td>   <code>offerToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja offer.</td></tr><tr><td>   <code>promotionToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja promotion.</td></tr><tr><td>   <code>discountCode</code></td><td><code>string | null</code></td><td>The discount code if the discount is applied using a Shopify discount code. <code>Null</code> if the discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>priceRuleId</code></td><td><code>string | null</code></td><td>The identifier of the Shopify price rule if the discount is applied using a Shopify discount code. <code>Null</code> if the discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>amount</code></td><td><code>number</code></td><td>The discount amount, in cents.</td></tr><tr><td>   <code>tier</code></td><td><code>number</code></td><td>The number of the tier of the offer that is applied. The first tier is <code>1</code>.</td></tr><tr><td>   <code>level</code></td><td><code>"product" | "order" | "shipping"</code> </td><td>Indicates at what level the offer discounts the cart.</td></tr><tr><td><code>currency</code></td><td><code>string</code></td><td>The <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO code</a> of the currency of the cart.</td></tr><tr><td><code>discountCode</code></td><td><code>string | null</code></td><td>The native Shopify discount code that is applied to the cart. <code>Null</code> if no code is applied.</td></tr><tr><td><code>items</code></td><td><code>array</code></td><td>The list of line items in the cart.</td></tr><tr><td>   <code>offerToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja offer.</td></tr><tr><td>   <code>promotionToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja promotion.</td></tr><tr><td>   <code>discountCode</code></td><td><code>string | null</code></td><td>The discount code if the product discount is applied using a Shopify discount code. <code>Null</code> if the product discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>priceRuleId</code></td><td><code>string | null</code></td><td>The identifier of the Shopify price rule if the product discount is applied using a Shopify discount code. <code>Null</code> if the product discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>discount</code></td><td><code>object</code></td><td></td></tr><tr><td>      <code>product</code></td><td><code>object</code></td><td></td></tr><tr><td>         <code>amount</code></td><td><code>number</code></td><td>The discount, in cents, per product.</td></tr><tr><td>         <code>percentage</code></td><td><code>number</code></td><td>The discount per product as a percentage.</td></tr><tr><td>      <code>line</code></td><td><code>object</code></td><td></td></tr><tr><td>         <code>amount</code></td><td><code>number</code></td><td>The discount for the cart line, in cents.</td></tr><tr><td>         <code>percentage</code></td><td><code>number</code></td><td>The discount for the cart line as a percentage.</td></tr><tr><td>   <code>isGift</code></td><td><code>boolean</code></td><td><code>True</code> if the item represents a gift with purchase.</td></tr><tr><td>   <code>isSubscriptionProduct</code></td><td><code>boolean</code></td><td><code>True</code> if the item is purchased with a selling plan.</td></tr><tr><td>   <code>price</code></td><td><code>object</code></td><td></td></tr><tr><td>      <code>product</code></td><td><code>object</code></td><td></td></tr><tr><td>         <code>discounted</code></td><td><code>number</code></td><td>The discounted price per product, in cents.</td></tr><tr><td>         <code>original</code></td><td><code>number</code></td><td>The original price per product, in cents.</td></tr><tr><td>         <code>compareAt</code></td><td><code>number</code></td><td>The compare-at price per product, in cents.</td></tr><tr><td>      <code>line</code></td><td><code>object</code></td><td></td></tr><tr><td>         <code>discounted</code></td><td><code>number</code></td><td>The discounted price for the cart line, in cents.</td></tr><tr><td>         <code>original</code></td><td><code>number</code></td><td>The compare-at price for the cart line, in cents.</td></tr><tr><td>         <code>compareAt</code></td><td><code>number</code></td><td>The compare-at price for the cart line, in cents.</td></tr><tr><td><code>product</code></td><td><code>object</code></td><td></td></tr><tr><td>   <code>available</code></td><td><code>boolean</code></td><td><code>True</code> if the variant is available. <code>False</code> if the variant is out of stock.</td></tr><tr><td>   <code>collectionIds</code></td><td><code>string | null</code></td><td>A comma-separated list of collection identifiers associated with the product. <code>Null</code> if the product does not belong to any collections. </td></tr><tr><td>   <code>collections</code></td><td><code>string | null</code></td><td>A comma-separated list of collection handles associated with the product. <code>Null</code> if the product does not belong to any collections. </td></tr><tr><td>   <code>productHandle</code></td><td><code>string</code></td><td>The handle of the product.</td></tr><tr><td>   <code>productId</code></td><td><code>number</code></td><td>The identifier of the product.</td></tr><tr><td>   <code>sellingPlanId</code></td><td><code>number | null</code></td><td>The identifier of the selling plan. <code>Null</code> for one-time purchases.</td></tr><tr><td>   <code>tags</code></td><td><code>string | null</code></td><td>A comma-separated list of tags associated with the product. <code>Null</code> if the product does not have tags. </td></tr><tr><td>   <code>title</code></td><td><code>string</code></td><td>The title of the variant.</td></tr><tr><td>   <code>variantId</code></td><td><code>number</code></td><td>The identifier of the variant.</td></tr><tr><td><code>orderDiscount</code></td><td><code>number</code></td><td>The total order discount in cents.</td></tr><tr><td><code>orderDiscounts</code></td><td><code>array</code></td><td>The list of order discounts applied to the cart.</td></tr><tr><td>   <code>offerToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja offer.</td></tr><tr><td>   <code>promotionToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja promotion.</td></tr><tr><td>   <code>discountCode</code></td><td><code>string | null</code></td><td>The discount code if the order discount is applied using a Shopify discount code. <code>Null</code> if the order discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>priceRuleId</code></td><td><code>string | null</code></td><td>The identifier of the Shopify price rule if the order discount is applied using a Shopify discount code. <code>Null</code> if the order discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>amount</code></td><td><code>number</code></td><td>The discount amount, in cents.</td></tr><tr><td>   <code>percentage</code></td><td><code>number</code></td><td>The discount percentage.</td></tr><tr><td>   <code>tier</code></td><td><code>number</code></td><td>The number of the tier of the offer that is applied. The first tier is <code>1</code>.</td></tr><tr><td>   <code>lineItems</code></td><td><code>array</code></td><td>The list of line items affected by the order discount.</td></tr><tr><td>   <code>valueType</code></td><td><code>"percentage" | "fixed_amount" | "fixed_price"</code></td><td>The type of discount.</td></tr><tr><td><code>shipping</code></td><td><code>object | undefined</code></td><td>An object containing information about the shipping discount that is applied to the cart. <code>Undefined</code> if no shipping discount is applied.</td></tr><tr><td>   <code>offerToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja offer.</td></tr><tr><td>   <code>promotionToken</code></td><td><code>string</code></td><td>The token of the Discount Ninja promotion.</td></tr><tr><td>   <code>discountCode</code></td><td><code>string | null</code></td><td>The discount code if the shipping discount is applied using a Shopify discount code. <code>Null</code> if the shipping discount is applied using a Discount Ninja offer.</td></tr><tr><td>   <code>priceRuleId</code></td><td><code>number | null</code></td><td>The identifier of the Shopify price rule if the shipping discount is applied using a Shopify discount code. <code>Null</code> if the shipping discount is applied using a Discount Ninja offer.</td></tr><tr><td><code>subtotal</code></td><td><code>object</code></td><td>Overview of the subtotal of the cart, after applying product discounts.</td></tr><tr><td>   <code>discount</code></td><td><code>number</code></td><td>The discount in cents. This is the sum of all product discounts.</td></tr><tr><td>   <code>discountedPrice</code></td><td><code>number</code></td><td>The subtotal in cents after product discounts.</td></tr><tr><td>   <code>originalPrice</code></td><td><code>number</code></td><td>The subtotal in cents before product discounts.</td></tr><tr><td><code>total</code></td><td><code>object</code></td><td>Overview of the total of the cart, after applying product and order discounts.</td></tr><tr><td>      <code>discount</code></td><td><code>number</code></td><td>The discount in cents. This is the sum of all product and order discounts.</td></tr><tr><td>      <code>discountedPrice</code></td><td><code>number</code></td><td>The total in cents after product and order discounts.</td></tr><tr><td>      <code>originalPrice</code></td><td><code>number</code></td><td>The total in cents before product and order discounts.</td></tr><tr><td><code>token</code></td><td><code>number</code></td><td>The token of the cart, provided by Shopify.</td></tr></tbody></table>
