Discount code at line level- how to identify discount code for each line item in shopify order api

Topic summary

A developer is struggling to identify which discount codes apply to specific line items in Shopify order API responses. They have an order with multiple discount codes applied (product-level discounts, order-level discounts, and free shipping), but cannot determine which discount corresponds to each individual line item.

Key Issue:

  • The order API returns discount codes at the order level
  • No clear identifier exists linking discount codes to specific line items
  • Sample payload shows discount applications but lacks line-item-level attribution

Discount Types in Question:

  • Product-specific discounts (e.g., “SALE2024”, “MegaSale”)
  • Order-wide discounts (“YearEndSale”)
  • Free shipping discounts

Current Status:
Another user (Liam) has begun responding, acknowledging the issue and referencing the shared code/image, but the discussion appears ongoing with no solution provided yet. The developer needs guidance on mapping discount codes to individual line items in the order payload.

Summarized with AI on November 12. AI used: claude-sonnet-4-5-20250929.

Hi MayurDhumal,

So is your issue that you’re seeing discount codes returned for the order, but not the line items? I see the discounts here in the code you’ve shared: