Solved

draftOrderComplete with useCustomerDefaultAddress

ozzyonfire
Shopify Partner
47 2 17

I can successfully create a Draft Order that uses a customer's default shipping and billing address when setting the useCustomerDefaultAddress flag on the draftOrderCreate mutation. I can verify this in the draft order, both addresses are populated.

 

However, taking the returned draft order gid and passing it to draftOrderComplete, does not fill in the customer's default address and instead is just a blank shipping and billing address.

 

This seems like a bug to me. If not, what is the proper way to populate the customer's default address using the GraphQL api?

 

Thanks.

Accepted Solution (1)

ozzyonfire
Shopify Partner
47 2 17

This is an accepted solution.

 

Update on this. 

 

The useCustomerDefaultAddress actually does work when the customerId is supplied to the draft order. 

 

I was only supplying the email address, which (for some reason) works when loading the draft order, but not when completing the draft order. 

 

This still seems like a bug to me since when setting useCustomerDefaultAddress to false and only supplying the email to the createDraftOrder mutation, I get blanks for the shipping and billing address. So the useCustomerDefaultAddress flag is doing something, just not the full functionality.

 

Also, when viewing the draft order after only the email is supplied, Shopify successfully loads in the customer Id (i.e. it is returned in the response of the createDraftOrder mutation. 

 

I found a workaround as I was playing around with things.

After creating the draft order with just an email address, use the updateDraftOrder mutation immediately after, and supply

 { useCustomerDefaultAddress: true }

as the input to the mutation.

 

This seems to properly set the address fields using the default address on the customer. It would be nice to have this built into the initial call, but I'll take it.

 

Hopefully this ends up helping out someone else.

View solution in original post

Reply 1 (1)

ozzyonfire
Shopify Partner
47 2 17

This is an accepted solution.

 

Update on this. 

 

The useCustomerDefaultAddress actually does work when the customerId is supplied to the draft order. 

 

I was only supplying the email address, which (for some reason) works when loading the draft order, but not when completing the draft order. 

 

This still seems like a bug to me since when setting useCustomerDefaultAddress to false and only supplying the email to the createDraftOrder mutation, I get blanks for the shipping and billing address. So the useCustomerDefaultAddress flag is doing something, just not the full functionality.

 

Also, when viewing the draft order after only the email is supplied, Shopify successfully loads in the customer Id (i.e. it is returned in the response of the createDraftOrder mutation. 

 

I found a workaround as I was playing around with things.

After creating the draft order with just an email address, use the updateDraftOrder mutation immediately after, and supply

 { useCustomerDefaultAddress: true }

as the input to the mutation.

 

This seems to properly set the address fields using the default address on the customer. It would be nice to have this built into the initial call, but I'll take it.

 

Hopefully this ends up helping out someone else.