Skip to main content

Integrating with back-end accounting systems

Learn how to access discount information from orders

Bart C avatar
Written by Bart C
Updated this week

Standard discounts

Discount Ninja applies product, order and shipping discounts using Shopify functions. This results in standard discounts that are no different from discounts that are applied using out-of-the-box Shopify discount codes or Shopify automatic discounts.

Order object

Shopify provides a GraphQL Admin API that allows developers to query the Order object, documented here: https://shopify.dev/docs/api/admin-graphql/latest/objects/Order

The information provided below is based on the documentation of the 2025-04 version of Shopify's GraphQL Admin API. For any questions or issues with this API, please contact Shopify directly.

Discount information is available from the following properties of this object:

    • A list of discounts that are applied to the order

    • Example JSON:
      ​

  • Product discounts: an order contains an array of LineItem objects, each of which has a property with the Discount Allocations

    • The discounts that have been allocated to the line item by discount applications.

    • The discount allocation documents how the above mentioned discount applications are allocated to each of the line items

    • Example JSON:

  • Order discounts: the cart discount amount property

    • The total order-level discount amount.

  • Shipping discounts: an order contains an array of ShippingLine objects, each of which has a discounted price set property

    • The shipping price after applying discounts.

  • Total discounts: the total discount set property

Additional information

If the information available in the Order object is not sufficient, you can enable additional information to be persisted in metafields associated with the Order.

This can be done in the menu of Discount Ninja: Settings > General > Orders > Metafields.

This feature adds data to orders that are discounted using Discount Ninja to document which offers were applied. The data is stored in JSON format in three metafields that can be used as input for custom integration logic.

These metafields are stored in the 'discountninja' namespace:

  • product_discounts: stores an array of objects with two properties.

    • The first property Key is the unique identifier of the order line item.

    • The second property Applications documents the product discounts that were applied to the line item. Each discount application is represented by an object with the following properties: DiscountCode, OfferToken, TriggerToken, Value

  • order_discounts: stores an array of objects that documents the order discounts that were applied to the order. Each discount application is represented by an object with the following properties: OfferToken, TriggerToken, Value

  • shipping_discounts: stores an array of objects that documents the shipping discounts that were applied to the order. Each discount application is represented by an object with the following properties: DiscountCode, PriceRuleTitle, PriceRuleId, OfferToken, TriggerToken

Did this answer your question?