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.
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
amount
number | null
The amount that is discounted. Null
for a shipping offer.
level
"product" | "order" | "shipping"
Indicates at what level the offer discounts the cart.
type
"gift" | "percentage" | "fixed_amount" | "fixed_price"
The type of entitlement that is applied by the offer.
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).
Discounted Cart
appliedPromotions
array
The list of the product, discount and shipping promotions applied to the cart.
offerToken
string
The token of the Discount Ninja offer.
promotionToken
string
The token of the Discount Ninja promotion.
discountCode
string | null
The discount code if the discount is applied using a Shopify discount code. Null
if the discount is applied using a Discount Ninja offer.
priceRuleId
string | null
The identifier of the Shopify price rule if the discount is applied using a Shopify discount code. Null
if the discount is applied using a Discount Ninja offer.
amount
number
The discount amount, in cents.
tier
number
The number of the tier of the offer that is applied. The first tier is 1
.
level
"product" | "order" | "shipping"
Indicates at what level the offer discounts the cart.
discountCode
string | null
The native Shopify discount code that is applied to the cart. Null
if no code is applied.
items
array
The list of line items in the cart.
offerToken
string
The token of the Discount Ninja offer.
promotionToken
string
The token of the Discount Ninja promotion.
discountCode
string | null
The discount code if the product discount is applied using a Shopify discount code. Null
if the product discount is applied using a Discount Ninja offer.
priceRuleId
string | null
The identifier of the Shopify price rule if the product discount is applied using a Shopify discount code. Null
if the product discount is applied using a Discount Ninja offer.
discount
object
product
object
amount
number
The discount, in cents, per product.
percentage
number
The discount per product as a percentage.
line
object
amount
number
The discount for the cart line, in cents.
percentage
number
The discount for the cart line as a percentage.
isGift
boolean
True
if the item represents a gift with purchase.
isSubscriptionProduct
boolean
True
if the item is purchased with a selling plan.
price
object
product
object
discounted
number
The discounted price per product, in cents.
original
number
The original price per product, in cents.
compareAt
number
The compare-at price per product, in cents.
line
object
discounted
number
The discounted price for the cart line, in cents.
original
number
The compare-at price for the cart line, in cents.
compareAt
number
The compare-at price for the cart line, in cents.
product
object
available
boolean
True
if the variant is available. False
if the variant is out of stock.
collectionIds
string | null
A comma-separated list of collection identifiers associated with the product. Null
if the product does not belong to any collections.
collections
string | null
A comma-separated list of collection handles associated with the product. Null
if the product does not belong to any collections.
productHandle
string
The handle of the product.
productId
number
The identifier of the product.
sellingPlanId
number | null
The identifier of the selling plan. Null
for one-time purchases.
tags
string | null
A comma-separated list of tags associated with the product. Null
if the product does not have tags.
title
string
The title of the variant.
variantId
number
The identifier of the variant.
orderDiscount
number
The total order discount in cents.
orderDiscounts
array
The list of order discounts applied to the cart.
offerToken
string
The token of the Discount Ninja offer.
promotionToken
string
The token of the Discount Ninja promotion.
discountCode
string | null
The discount code if the order discount is applied using a Shopify discount code. Null
if the order discount is applied using a Discount Ninja offer.
priceRuleId
string | null
The identifier of the Shopify price rule if the order discount is applied using a Shopify discount code. Null
if the order discount is applied using a Discount Ninja offer.
amount
number
The discount amount, in cents.
percentage
number
The discount percentage.
tier
number
The number of the tier of the offer that is applied. The first tier is 1
.
lineItems
array
The list of line items affected by the order discount.
valueType
"percentage" | "fixed_amount" | "fixed_price"
The type of discount.
shipping
object | undefined
An object containing information about the shipping discount that is applied to the cart. Undefined
if no shipping discount is applied.
offerToken
string
The token of the Discount Ninja offer.
promotionToken
string
The token of the Discount Ninja promotion.
discountCode
string | null
The discount code if the shipping discount is applied using a Shopify discount code. Null
if the shipping discount is applied using a Discount Ninja offer.
priceRuleId
number | null
The identifier of the Shopify price rule if the shipping discount is applied using a Shopify discount code. Null
if the shipping discount is applied using a Discount Ninja offer.
subtotal
object
Overview of the subtotal of the cart, after applying product discounts.
discount
number
The discount in cents. This is the sum of all product discounts.
discountedPrice
number
The subtotal in cents after product discounts.
originalPrice
number
The subtotal in cents before product discounts.
total
object
Overview of the total of the cart, after applying product and order discounts.
discount
number
The discount in cents. This is the sum of all product and order discounts.
discountedPrice
number
The total in cents after product and order discounts.
originalPrice
number
The total in cents before product and order discounts.
token
number
The token of the cart, provided by Shopify.
Last updated