Objects

The documentation below describes the API as of version 9.x of the script.

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.

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:

Product variant price info

amount

number

The discount amount, expressed in cents.

discountCode

string

The offer token, Shopify discount code or promotion code associated with the applied discount.

discountedPrice

number

The discounted price, expressed in cents.

isCurrentProduct

boolean

true if the user is on a product page that matches the handle for this object

isDiscountedByOffer

boolean

true if the variant is discounted by a Discount Ninja offer (not, for example, a compare-at price).

offerToken

string

The token of the offer associated with the applied discount.

originalPrice

number

The original price (i.e. the price before discounts are applied), expressed in cents.

percentage

number

The discount percentage.

productHandle

string

The handle of the product associated with the object.

sellingPlan

number | null

The id of the selected selling plan for subscription products. Null for one-time purchases.

promotionToken

string

The token of the promotion associated with the applied discount.

variantId

number | null

The id of the selected variant. Null if the variant is not known, for example for products on collection pages.

Entitlement info

offerToken

string

The token of the offer.

applied

boolean

Indicates if the offer has been applied to the cart.

source

"app" | "native" | null

Set to "app" if the offer was configured in Discount Ninja. If set to "native", this offer is a wrapper for a discount configured in Shopify.

prerequisite

object

prerequisiteItems

array

An array of objects that lists the line items that are considered prerequisites for this offer to apply. Each object has two properties: - key (string): the key of the line item - quantity (number): the number of items on the line item that are prerequisites

entitlement

object

target

object

variants

string | null

A comma-separated list of variant ids the customer is entitled to.

collections

string | null

A comma-separated list of collection handles the customer is entitled to.

products

string | null

A comma-separated list of product handles the customer is entitled to.

allProducts

boolean

Set to true if the entitlement applies to all products.

shipping

boolean

Set to true if the entitlement applies to the shipping line.

entitledItems

object

quantity

number

The number of items the customer is entitled to.

claimed

number

The number of entitled items the customer has added to the cart.

lineItems

array

An array of objects that lists the line items that are considered entitled items. Each object has two properties: - key (string): the key of the line item - quantity (number): the number of items on the line item that are entitlements

sets

array

An array of objects that lists the sets ( a group of prerequisites and entitlements).

Last updated