Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Match Customer shipping address ID with order shipping address ID

Match Customer shipping address ID with order shipping address ID

vicvans20
Shopify Partner
14 1 9

I'm building an app which handle some logic about the Orders shipping address, for such task I need to match the Order's shipping address to the original shipping address registered in the customer's addresses, but while working on it I found out that the IDs of customer addresses doesn't match any order shipping address, the only ID in the GraphQL object seems to be generated for each order address, is there a way to lookup the original customer address from the Order's shipping address or there is no way at all? 

 

Example of GraphQL query with an address where you can see that NONE of the customer registered addresses match the order's one (it was generated based on one of those)

 

Query:

 

 

query($ids: [ID!]!){
  nodes(ids: $ids){
    ... on Order{
      id
      name
      closed
      shippingAddress{
        id
      }
      
      customer{
        id
        addresses{
          id
          name
        }
      }
    } # order
  } # node
}

 

 

 

Response sample:

 

 

{
  "data": {
    "nodes": [
      {
	"id": "gid:\/\/shopify\/Order\/4381820223584",
	"name": "#100",
        "closed": false,
	"shippingAddress": {
	  "id": "gid:\/\/shopify\/MailingAddress\/12046198210656?model_name=Address"
	},
	"customer": {
	  "id": "gid:\/\/shopify\/Customer\/2731576007",
	  "addresses": [
	    {
	      "id": "gid:\/\/shopify\/MailingAddress\/4052305969248?model_name=CustomerAddress",
              "name": "Foo Bar"
	    },
	    {
	      "id": "gid:\/\/shopify\/MailingAddress\/4063216140384?model_name=CustomerAddress",
              "name": "Foo Bar"
	    },
	    {
	      "id": "gid:\/\/shopify\/MailingAddress\/6836149583968?model_name=CustomerAddress",
	      "name": "Foo Bar"
	    }
	  ]
	}
      }
    ]
  },
  "extensions": {...}
}

 

 

Replies 0 (0)