Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hey there,
so I added a custom meta field for accounts, where namespace and key is "custom.question1".
Now I added the following code to my main-register.liquid:
<select
name="customer[custom.question1]"
id="RegisterForm-customQuestion1"
required
>
<option value="" disabled>Please choose</option>
<option>Answer1</option>
<option>Answer2</option>
<option>Answer3</option>
</select>
But that doesn't work. I guess the name property "customer[custom.question1]" is the problem. What do I have to enter in the name attribute so that it gets saved to the created meta field? I already tried "customer[question1]" and "customer[custom][question1]".
Thanks in advance!
Hi @snoopus , you can get the value of metafields in liquid like this
<select
name="{{ customer.metafields.custom.question1 }}"
id="RegisterForm-customQuestion1"
required
>
<option value="" disabled>Please choose</option>
<option>Answer1</option>
<option>Answer2</option>
<option>Answer3</option>
</select>
Hope this will help you ❤️
If our suggestions are useful, please let us know by giving it a like, marking it as a solution.
SIMICART: Mobile App Builder |Ironwork Theme - Coming Soon | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
@BSSCommerce-TA Thanks for your reply! I copied the code but it still doesn't work, unfortunately. In the form's source code the name attribute is empty. But no error is shown on submit. But in the shopify backend under customers the field will be empty. I also tried to use a simple input instead of a select. Didn't work either.
Maybe the following screenshots help (although they're in German).
Hi @snoopus , you should use metaobjects instead of metafields, because customer metafields only exist if a user logged in.
Here is the step to add metaobjects:
1. Go to "Content" section in your admin store, then select metaobjects
2. Add definition and save
3. Then go to Content => Metaobjects again
Select your definition and add entry
4. Then you can access metaobjects every where in your themes like this:
<select
name="{{ shop.metaobjects['form_question']['question-1'].question_name }}"
placeholder="{{ shop.metaobjects['form_question']['question-1'].question_content }}"
id="RegisterForm-customQuestion1"
required
>
<option value="" disabled>Please choose</option>
<option>Answer1</option>
<option>Answer2</option>
<option>Answer3</option>
</select>
Note: "question-1" is your entry handle, you can get it after create an entry
"form_question" is your metaobjects type
The result will be like this:
Hope this will help you
SIMICART: Mobile App Builder |Ironwork Theme - Coming Soon | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Hey @snoopus!
Unfortunately it is actually not possible to save values directly into customer metafields directly through Liquid, this has to be done through the APIs (with an app). That's why we built the Customer Fields app, a no-code solution to allow merchants to build custom registration forms, and easily save all of your custom data directly into Shopify's customer metafields.
@Brett_Helium Thanks for your reply. I was afraid of that. Generally, I don't mind creating my own app, but I'm not really sure how I could hook into the registration process. With other tools (e.g., WordPress), I'm used to having extensive tutorials/documentation available, but with Shopify, it seems that the majority of users don't have coding skills, so all the helpful resources are behind a paywall. Which is great for them, but not for devs like me.
I read elsewhere that you build your own form for this purpose, is that correct? And then, upon submitting the form, there is presumably some registration endpoint that can be called via JavaScript/PHP/Anything?