Is there way to detect bad address before completing draft order

ko-lem
Shopify Partner
15 0 7

Here's what I'm doing

  1. Create a draft order, provide a shipping address
  2. Complete the draft order, an order is then completed

 

When a bad address is passed to the draft order creating,

eg

 

"shippingAddress": {
  "street": "Bad Address",
  "unit": null,
  "city": "Dunno City",
  "state": "No State",
  "country": "No Country",
  "zip": null
}

 

the draft order saves this shipping order as is.

 

When the draft order is completed, the created order will change the "bad" country to the store's country.

 

"shippingAddress": {
  "address1": "Bad Address",
  "address2": null,
  "city": "Dunno City",
  "state": null,
  "country": "<Store's country>"
}

 

 

Is there a way to detect this will happen before I mark the draft order as complete?

 

Right now, the only solution I can think of right now is to compare the created order's address with what I originally passed to the draft order. If they are not equal, then I cancel the order. However, I'd prefer the order is not created in the first place and I don't have to request `write_orders` scope from the merchant.

 

 

Reply 1 (1)

ko-lem
Shopify Partner
15 0 7

Oh, never mind. Just saw shippingAddress.coordinatesValidated.

 

Haha all that time thinking and writing before carefully looking at the docs🤦