Filter Shopify GraphQL admin Orders query by shippingAddress country code

Filter Shopify GraphQL admin Orders query by shippingAddress country code

Moorthi
Shopify Partner
2 0 0

I want to filter orders by shipping address country code (such as SE, US, IN etc.,) from 

{
orders(first: 10, reverse: true, query: "created_at:>=1900-01-01") {
edges {
node {
id
name
createdAt
shippingAddress {
countryCode
}
customer {
firstName
lastName
}
totalPriceSet {
shopMoney {
currencyCode
amount
}
}
currentTotalPriceSet {
shopMoney {
amount
currencyCode
}
}
displayFinancialStatus
metafields(first: 10) {
edges {
node {
key
value
}
}
}
shippingLine {
title
code
source
}
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}

Reply 1 (1)

Brian_McKinley
Shopify Partner
29 0 7

Hi Moorthi,


You can filter using country name.

 

Query:

 

query OrdersByCountry($query: String!) {
  orders(first: 10, query: $query) {
    edges {
      node {
        id
        name
        createdAt
        shippingAddress {
          countryCodeV2
        }
        customer {    
          firstName
          lastName
        }
      	totalPriceSet {
          shopMoney {
            currencyCode
            amount
          }
        }
        currentTotalPriceSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        displayFinancialStatus
        metafields(first: 10) {
          edges {
            node {
              key
              value
            }
          }
        }
        shippingLine {
          title
          code
          source
        }
      }
    }
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }  
  }
}

 

 Variables:

 

{
  "query": "shipping_address:country:'United States'"
}

 

 

Best Regards,

 

Brian McKinley