Hi Shopify team ,
Starting from either a cart object (received in the browser through the Cart API) or an Order object (received using the orders/created webhook or via a GraphQL request), how can a developer identify the app linked to a discount allocation when the discount is applied using an automatic discount (either a standard one set up in the Shopify discounts module or a custom one created by a discount function)?
Use cases
- Downstream back-end integration: inform back-end systems about details of the discount that was applied after an order has come in; developers should have access to the discount code node id to query Shopify or their own repository for additional information
- Ensuring compatibility with other discount apps: detect which app applied a discount to the cart (app id); understand combinations associated with the applied discount (can be queried using the discount code node id).
Problem
Shopify does not provide information in its discount allocation objects (neither in the cart nor in the order) that allows developers to understand which app (or discount code node) created an automatic discount. The title and value fields are insufficient to understand which app generated the discount.
Solution
The cart’s discount_allocation (Liquid objects) and the Order’s Discount Application (DiscountApplication - GraphQL Admin) should be extended to provide information about a) the app that generated the discount and b) the discount code node (DiscountCodeNode - GraphQL Admin) that generated the discount.
Alternatively, an additional output field for discount functions could be made available so that developers can add custom data to the discount allocation.