I am trying to prepopulate the shipping/billing address in Shopify checkout via URL query params. I've found this is easy to do with the shipping address as referenced here:
https://community.shopify.com/c/Shopify-APIs-SDKs/Autofill-checkout-fields/td-p/318793
But when I try to do the same with the billing info, the "Same as shipping address" radio is always selected on the payment screen and if I manually select the option for a different address, all values are blank
How can I prepopulate both addresses? I've tried adding the billing query params directly to the checkout payment page URL, but that does not work either. Here is the URL I've been trying:
demo-store.myshopify.com/checkout?checkout[email][email protected]&checkout[shipping_address][first_name]=John&checkout[shipping_address][last_name]=Doe&checkout[shipping_address][address1]=333%20Fake%20St.&checkout[shipping_address][city]=San%20Diego&checkout[shipping_address][province]=CA&checkout[shipping_address][country]=USA&checkout[shipping_address][zip]=92116&checkout[shipping_address][phone]=333-333-3333&checkout[different_billing_address]=true&checkout[billing_address][first_name]=Jane&checkout[billing_address][last_name]=Doe&checkout[billing_address][address1]=444%20Fake%20St%20&checkout[billing_address][city]=San%20Diego&checkout[billing_address][province]=CA&checkout[billing_address][country]=USA&checkout[billing_address][zip]=92121&checkout[billing_address][phone]=444-444-4444
Also, bonus question, the shipping state always seems to be populated based on IP address, so even if I pass it a value, it shows the state I'm in. How can I get it to always reflect the value of the query param?
To create a prepopulated checkout on Shopify, you will need to supply the checkout through either the Admin API or the Storefront API
To create a checkout and return the web URL, send a POST request to the admin/checkouts.json endpoint.
Depending on how you choose to do this it can be achieved with many different points of access, as referenced in the Shopify Dev portal, though you will not be able to complete this in the requested manner using only URL parameters.
For further reading, please refer to the Getting started for the Storefront API and the Storefront API Checkout Object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With