Draft Order API not setting shipping address

Highlighted
Shopify Partner
41 0 8

I have mentioned pass the shipping_address in draftOrder API but when I open the invoice url Shopify checkout is not pre filled with the shipping address passed to the API.

 

The shipping_address is present in the JSON response of draftOrder API.

 

When I use cart permalinks to preload cart with shipping address, it automatically prefilled in the checkout page.

 

draftOrder doesn't have a shipping address prefill option?

 

Am I missing anything?

0 Likes
Highlighted
Shopify Partner
41 0 8

On trial and error, what I noticed in I am not passing province and country code to shipping_address field. That may be the issue.

 

Because i added province and country to the shipping address in same draft order created via api and it works. Customer address is prefilled.

 

BTW, My app enable customer to enter address in our address form and we are passing it to draft order.

 

So how can we present list of countries and its provinces in our form like in shopify checkout?

 

Thanks in advance

0 Likes
Highlighted
Shopify Partner
55 5 22

@captainzero We are using https://github.com/Shopify/quilt/tree/master/packages/address . It's shopify's recommended way of showing Country+Province fields for your address form.

 

 I would recommend you check out their entire "quilt" repository. Its a set of loosely related packages, with very handy things in between.

0 Likes
Highlighted
Shopify Partner
41 0 8

That's definitely will help us to overcome our challenge.

 

Thanks a ton.

Lots of love

0 Likes
Highlighted
Shopify Partner
41 0 8

@tolgapaksoy I look into the package now, Unfortunately it only formats address what we need is the data of countries and its provinces to show to the customer

 

Any ideas are welcome.

 

Thanks in advance

0 Likes
Highlighted
Shopify Partner
55 5 22

Hi @captainzero 

 

We do use this package to fetch supported countries, and their provinces (if required by Shopify).

 

It's all in this file: https://github.com/Shopify/quilt/blob/master/packages/address/src/loader.ts

0 Likes
Highlighted
New Member
1 0 1

Hey,

 

On trial and error, what I noticed in I am not passing province and country code to shipping_address field. That may be the issue.

 

Because i added province and country to the shipping address in same draft order created via api and it works. Customer address is prefilled.

 

I'm stuck with this same issue. The draft order API returns an invoice_url where I want the shipping address to be pre-populated.

The address isn't getting pre-populated there. How did you do this?



This is my API request body:

{
  "draft_order": {
    "line_items": [
      {
        "variant_id": 32132908154934,
        "quantity": 1
      }
    ]
  },
   "shipping_address": {
     "address1": "123 Amoebobacterieae St",
     "address2": "",
    "city": "Ottawa",
    "company": null,
    "country": "Canada",
    "first_name": "Bob",
    "last_name": "Bobsen",
     "latitude": "45.41634",
     "longitude": "-75.6868",
     "phone": "555-625-1199",
     "province": "Ontario",
     "zip": "K2P0V6",
     "name": "Bob Bobsen",
     "country_code": "CA",
     "province_code": "ON"
  }
}
1 Like
Highlighted
Shopify Partner
2 0 0

I am experiencing the same issue

0 Likes
Highlighted
Shopify Partner
2 0 0

So, through testing I have discovered that passing the long country name in the "country" element for the draft order will result in the desired outcome of having the shipping address pre-populated automatically when clicking through to the checkout page.  Example: "country": "United States"

0 Likes