Determining First Time Order

Determining First Time Order

mds_dev
Visitor
1 0 0

Has there been a change to the customer property that gets returned with the shopify Order object? Before there used to be properties like last_order and orders_count properties of the order.customer that we could use to determine if the order was the customer's first order or not. We use this logic to determine if we should send a little welcome gift, so it is something that we really rely on and suddenly it disappeared. 

Reply 1 (1)

lizk
Shopify Staff
246 58 78

Hi there 👋

To keep the APIs efficient that data is available when accessing the customer resource directly. You will need to make a second request to the customer object, after receiving the customer_id in the order resource if you need that data.

Alternatively option would be to make a single request with the GraphQL Admin API. A query could look like the following. 

 

{
  orders(first: 3) {
    nodes {
      id
      createdAt
      discountCode
      customer {
        lastOrder {
          id
        }
        numberOfOrders
      }
    }
  }
}

 

 

To learn more visit the Shopify Help Center or the Community Blog.