Order number in Graphql API

Hi team, I need help with admin β†’ GQL migration. We run an invoicing application. We want to know the number of the order.

We want to migrate to the Graphql API but order.order_number is not available in Graphql API. Shopify shows a migration help text that order_number is mapped to number in Graphql but that links to nowhere and number does not exist in graphql.

We cannot use Order name because it can contain prefix and suffix. We need a number format so we can do invoice numbering. Order name won’t work because it can be a string with a prefix and suffix and the app would need to figure out a way to extract number from it. Prefix and suffix can also contain numbers making it extra difficult


Another Post in the community for this: Order_number GraphQL Admin API - #5 by Michael_Agra

1 Like

I don’t see a way to get the numeric number for the order in GraphQL, but you can retrieve the configured prefix and suffix from the shop object with this GraphQL query:

{
  shop {
    orderNumberFormatPrefix
    orderNumberFormatSuffix
  }
}

Then you can remove the suffix and prefix from the Order.name value to get the numeric ID.

One edge case to keep in mind is that these settings could be changed over time so you might need to account for that.

Best,
Daniel

Hi @Daniel_Ablestar Thanks, That edge case is huge for us. In India people change their prefix and suffix every year with the financial year in the prefix. This solution is not enough for us