Discount Ninja

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 the version number of the script.
An array of offer objects, representing the offers that are applicable in the current context.
An array of trigger objects, representing the promotions that can trigger in the current context.
An object representing the current cart, with the applicable Discount Ninja offers applied. Note that amounts returned are in dollars, not cents.
A boolean indicating if free shipping is applicable through a Discount Ninja offer.
Adds a discount code or promotion code to the Discount Ninja promotion code field programmatically.
Removes a discount code or promotion code from the Discount Ninja promotion code field programmatically.
A boolean indicating if Discount Ninja will instruct Shopify to apply discounts at checkout.