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.

Autofill checkout fields

Autofill checkout fields

Harri_Sarsa
Tourist
3 0 2

Hey,

I'm working with an HTML5 hybrid app. I'm on a page where I have all the fields for the user already known (name, address etc). Is it possible to generate a checkout URL that I could open in a new window that would have everything I want autofilled? I assume https://help.shopify.com/api/tutorials/sell-through-the-checkout-api#creating-a-checkout would work (the JS SDK at least doesn't seem to offer anything for this), but I'm getting unauthorized response (same API token works for other resources tho) – not sure if I got my head around what creds are required for the checkout API.

Replies 2 (2)

Harri_Sarsa
Tourist
3 0 2

Apparently the checkout API is available only for whitelisted sales channel apps. Is there any way around this without e.g. script injection to the form website?

Harri_Sarsa
Tourist
3 0 2

Turns out you can construct the URL like this to autofill the fields:

checkoutUrl = variant.checkoutUrl()
checkoutUrl += "&checkout[email]=#{email}" +
"&checkout[billing_address][first_name]=#{firstName}" +
"&checkout[billing_address][last_name]=#{lastName}" +
"&checkout[billing_address][address1]=#{address}" +
"&checkout[billing_address][city]=#{city}" +
"&checkout[billing_address][country]=#{country}" +
"&checkout[billing_address][zip]=#{postalCode}"

Hope this helps someone else!