Discount Code Sales not provided

Is anyone else having issues with DiscountCodeBasic.totalSales always being null? I’m hoping to use this field for reporting. The field is nullable in the Admin API docs, but it’s unclear when or why it might be null.

Hi @jonathanchen.levanta

Simplified Explanation of DiscountCodeBasic.totalSales

1. When it returns a non-null value

totalSales returns a MoneyV2 object when all conditions below are met:

  1. The discount code has been applied to actual orders at checkout.

  2. The relevant orders are fully paid valid orders; draft and fully canceled orders are excluded.

  3. Shopify’s asynchronous background statistics finish updating (delay ranges from seconds to minutes, not real-time).

2. When it returns null

  1. The discount code has never been used by any order.

  2. Just used but the background statistics have not been refreshed yet (temporary null).

  3. Edge case: Store or discount data is migrating to a new statistics model.

Core Summary

  • Used + valid orders + statistics updated → Non-null value

  • Unused / newly used without statistics synced → Null