Draft Order - Shipping Address - Province Code/Country Code not recognized

Jamie_M1
New Member
13 0 0

When i try to create a draft order with the following payload

{
  "draft_order": {
    "email": "james1978789456@gmail.com",
    "tax_exempt": "true",
    "line_items": [
      {
        "variant_id": "28255260805",
        "quantity": 1
      }
    ],
    "note": "Exchange for order #1091",
    "use_customer_default_address": false,
    "shipping_address": {
      "first_name": "James",
      "last_name": "Test",
      "address1": "3462 Paxton St",
      "city": "Harrisburg",
      "country_code": "US",
      "province_code": "PA",
      "zip": "17101"
    }
  }
}

I get this response

{
  "draft_order": {
    "id": 83661189,
    "note": "Exchange for order #1091",
    "email": "james1978789456@gmail.com",
    "taxes_included": false,
    "currency": "USD",
    "subtotal_price": "60.00",
    "total_tax": "0.00",
    "total_price": "60.00",
    "invoice_sent_at": null,
    "created_at": "2017-08-28T09:57:20-04:00",
    "updated_at": "2017-08-28T09:57:20-04:00",
    "tax_exempt": true,
    "completed_at": null,
    "name": "#D169",
    "status": "open",
    "line_items": [
      {
        "variant_id": 28255260805,
        "product_id": 7595270341,
        "title": "Kitteh Mech",
        "variant_title": null,
        "sku": "KITMECH000001",
        "vendor": "HANHAI MFG",
        "price": "60.00",
        "grams": 1361,
        "quantity": 1,
        "requires_shipping": true,
        "taxable": true,
        "gift_card": false,
        "fulfillment_service": "manual",
        "tax_lines": [],
        "applied_discount": null,
        "name": "Kitteh Mech",
        "properties": [],
        "custom": false
      }
    ],
    "shipping_address": {
      "first_name": "James",
      "address1": "3462 Paxton St",
      "phone": null,
      "city": "Harrisburg",
      "zip": "17101",
      "province": null,
      "country": null,
      "last_name": "Test",
      "address2": null,
      "company": null,
      "latitude": null,
      "longitude": null,
      "name": "James Test",
      "country_code": null,
      "province_code": null
    },
    "billing_address": null,
    "invoice_url": "https://checkout.shopify.com/17657155/invoices/0c3eba19f1e25d4567b036bb097a7aa4",
    "applied_discount": null,
    "order_id": null,
    "shipping_line": null,
    "tax_lines": [],
    "tags": "",
    "note_attributes": [],
    "customer": {
      "id": 5618334597,
      "email": "james1978789456@gmail.com",
      "accepts_marketing": false,
      "created_at": "2017-08-28T09:36:00-04:00",
      "updated_at": "2017-08-28T09:36:00-04:00",
      "first_name": "James",
      "last_name": "Test",
      "orders_count": 0,
      "state": "disabled",
      "total_spent": "0.00",
      "last_order_id": null,
      "note": null,
      "verified_email": true,
      "multipass_identifier": null,
      "tax_exempt": false,
      "phone": null,
      "tags": "",
      "last_order_name": null,
      "default_address": {
        "id": 5923953477,
        "customer_id": 5618334597,
        "first_name": "James",
        "last_name": "Test",
        "company": null,
        "address1": "3462 Paxton St",
        "address2": null,
        "city": "Harrisburg",
        "province": null,
        "country": null,
        "zip": "17101",
        "phone": null,
        "name": "James Test",
        "province_code": null,
        "country_code": null,
        "country_name": null,
        "default": true
      }
    }
  }
}

where the province_code and counbtry_code is not being set even though a value was passed for it. 

What is the appropriate method for setting the province_code/country_code for a draft orders shipping address?

0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 293

Hey Jamie,

I don't think that country_code and province_code are meant to be the set parameters. Creatinga  draft order while specifying country and province by their full names works and also propagates the country_code and province_code fields respectively.

Cheers.

Jamie_M1
New Member
13 0 0

Thanks Alex, I've been playing with it now and noticed that. I don't believe that it does set the code fields and that they need to be set manually as well. Again, thank you for the answer.

0 Likes
Brett_Knights
Shopify Partner
7 0 3

Any idea where this is documented that setting the province_code is unsupported?

 This seems like an odd issue. If I am using the API to bring in external orders I may not have the correct "official" name of a state but only the state code. Not accepting the state code means that I have to maintain another lookup -- this is problematic when a store ships to multiple countries since the api consumernow has to maintain lookups for multiple code-to-name systems but clearly Shopify already maintains those lists internally. 

JohnAtBonify
Shopify Partner
131 7 31

The documentation is wrong.

You can send the province code or name to province. And you can send either the country code or country name to country. They both work fine. Sending anything to province_code or country_code doesn't do anything.

0 Likes