Discount Ninja
Search
K

discountNinja object

Documentation regarding the core JavaScript object used by Discount Ninja.
Note that the properties of the object should be considered read-only. To modify the state of the object's properties, the user should:
  • call the functions of the object
  • or leverage the events the object subscribes to
The discountNinja JavaScript object is available in the global scope.

Public API: properties and functions

The properties and functions documented below are part of the public API and can be used for integration purposes. When extending Discount Ninja, please only use methods that are part of the Public API. Using undocumented functions or objects will result in issues as your custom code break may break when Discount Ninja's script is updated.
The documentation below describes the Public API as of version 9 of the script. Properties or functions that are marked as obsolete will be removed in the next major version release.
All public properties and functions are available from the discountNinja.public namespace:
Property / Function
Returns
version
Returns the version number of the script.
offers
An array of offer objects, representing the offers that are applicable in the current context.
triggers
An array of trigger objects, representing the promotions that can trigger in the current context.
cart
An object representing the current cart, with the applicable Discount Ninja offers applied. Note that amounts returned are in dollars, not cents.
hasFreeShipping()
A boolean indicating if free shipping is applicable through a Discount Ninja offer.
addDiscountCode(string)
Adds a discount code or promotion code to the Discount Ninja promotion code field programmatically.
removeDiscountCode(string)
Removes a discount code or promotion code from the Discount Ninja promotion code field programmatically.
requiresAdvancedCheckout()
A boolean indicating if Discount Ninja will instruct Shopify to apply discounts at checkout.
getPromotionForDiscountCode(string)
publishEvent(string)