Customer fill zip code at cart

Uysim
Shopify Partner
1 0 0

I am working on an app. I want customer to input zip code in cart which is already done by add it to cart attributes. 

When customer click on checkout button. On page checkout I want the shipping address to come from the cart attributes. How can I do that?

Replies 2 (2)

hassain
Shopify Staff (Retired)
624 104 187

Hey @Uysim ,

 

Use the Storefront API to create the customer first and set-up their address to have the Zip Code plus all of the additional information. (https://shopify.dev/docs/storefront-api/reference/mutation/customercreate?api[version]=2020-04)

 

Then use the Storefront API to create the checkout/cart (https://shopify.dev/docs/storefront-api/reference/mutation/checkoutcreate?api[version]=2020-04), and the following mutation to associate the customer with that checkout/cart: https://shopify.dev/docs/storefront-api/reference/mutation/checkoutcustomerassociatev2?api[version]=...

 

Now once the user is taken to the 'webUrl' of the checkout object (e.g. the Shopify checkout page), they will already have their email address and Zip code filled in. 

 

To learn more visit the Shopify Help Center or the Community Blog.

hassain
Shopify Staff (Retired)
624 104 187

Alternatively, you could more simply just use the Storefront API to create the checkout (https://shopify.dev/docs/storefront-api/reference/mutation/checkoutcreate?api[version]=2020-04) and then use this mutation to update the Shipping Address of that checkout with the correct Zip code: https://shopify.dev/docs/storefront-api/reference/mutation/checkoutshippingaddressupdatev2?api[versi...

 

This way you can skip all the steps and processes for customer creation

To learn more visit the Shopify Help Center or the Community Blog.