Is it possible to collect a customer's address as they register?
I have tried using a few variations of customer[addresses][0][address1]
as the input name but with no success. New customers don't have any address data attached.
Thanks
Thanks for replying but I'm still unclear on how to format the name attributes of the address input fields. I know how they are referenced individually in Liquid from a customer object but not how to set them up in a registration form.
For example, here is my current registration form:
{% form 'create_customer' %}
{{ form.errors | default_errors }}
{% comment %} these address fields don't work {% endcomment %}
<input type="text" name="customer[addresses_attributes][0][address1]" id="address1" />
<input type="text" name="customer[addresses_attributes][0][city]" id="city" />
<input type="text" name="customer[addresses_attributes][0][province]" id="province" />
<input type="text" name="customer[addresses_attributes][0][zip]" id="zip" />
<input type="text" name="customer[addresses_attributes][0][country]" id="country" />
<input required type="email" name="customer[email]" id="email" placeholder="{{ 'customer.register.email' | t }}">
<input required type="password" name="customer[password]" id="password" placeholder="{{ 'customer.register.password' | t }}">
<input type="submit" value="Sign Up">
{% endform %}
I have tried a few variations of customer[address][...], customer[default_address][...], customer[addresses][0][...], etc etc.
(I saw an old thread that someone said they had success with [address_attributes], but later replies say it no longer works.)
But no matter what the values are not saved on the customer.
Maybe it's just not supported?
Maybe a better question is: What parameters does the /account route accept for a POST?
I realize Shopify can't open source their controllers' code ;) -- but a whitelist of params would be helpful.
It's probably not a frequently used feature, but adding an address on registration would be a big win for us.
Thanks!
I am using an app to create a customer with the additional address information, and send an email to admins when the account is created.
the app can be found here, and it works great so I don't have to build this functionality. https://apps.shopify.com/customr
If you want to build the form on your own with address information it looks like you can use the following lines of code, have not tested on my own.
customer[addresses][][company]
customer[addresses][][address1]
customer[addresses][][address2]
customer[addresses][][city]
customer[addresses][][country]
customer[addresses][][province]
customer[addresses][][zip]
customer[addresses][][phone]
Shopify has not answered this question? This is a very common use case.
I am assuming Shopify is protecting App vendors here. They will have a market for people that want point and click. And if not, let the market decide if it is a good app. If its solving a real problem. If its in demand. And if none, of those - unfortunately, thats unlucky. Perhaps you just reinvented the wheel - or not.
unless bugs, we've tried:
customer[default_address][..]
customer[addresses_attributes][0][..]
I know this is old but I was trying to figure this out too and this thread confused me and made me try something that can't be done. I believe Shopify made a mistake in this thread by suggesting it is possible.
According to this link below you can't capture a customer's address inside the registration form.
So the link Shopify gave on this thread is misleading.
Also this thread says you can't get the address and mentions you can redirect them after they register to capture their address.
A bit late for a reply but I was able to collect a single piece of information using customer[note].
You can also use customer[phone] and customer[tags] easily.
Take a look at the API docs and you can see what fields you can pass in
https://shopify.dev/docs/admin-api/rest/reference/customers/customer
Though it mentions customer[addresses], it seems to be a JSON array so might not be possible through a POST.
Yes, you can add custom fields, but they only write to the customer note field.
If you want this code, I've uploaded my customers/register.liquid code here: http://share.sqr.fr/YQv46CY
Here is how it looks on the registration page:
Here is how it looks in the Admin:
But it's not part of the Customer's Default Address.
User | Count |
---|---|
501 | |
209 | |
130 | |
80 | |
44 |