I'm creating a signup form on my Shopify store, for customers. I'm willing to have them enter their basic credentials (email) plus additional info. I'd like to have that additional info stored in the customer's metafields.
I've seen here: http://docs.shopify.com/manual/configuration/store-customization/capture-additional-information-in-the-account-registration-form I can ask customers for additional information in the form of notes, but found no path to insert metafields.
I think this is possible, but I don't know how I could do.
Could someone help me, please?
See here:
For the time being, you can only add these metafields and edit them using the Shopify API. Some time from now, we will make it possible for a shop owner to manage them from the admin interface.
As far as I am aware this is still the case, and you must use the API to create/access metafields. See the Shopify doco on Metafields here.
Alternatively, there are apps that can help with the process.
Since it isn't possible to create a new area in the admin to hold the user's information, so technically you can't add a metafield to a customer.
But you can add a new field on registration page as a customer note.
All additional collected information will be displayed on the customer account page.
Add following lines inside {% form 'create_customer' %} and {% endform %} to add your custom field. Replace the [Label] with your own unique label.
<label>The text shown as label in the form</label>
<input type="text" name="customer[note][Label]" placeholder="Placeholder text" />
The attribute name="customer[note][Label]" is essential here. With it, the information will be submitted as a customer note. Without it, nothing will be submitted.
Related
I'm trying to display the item data from the metafield on the checkout page using this code-
{{ pages.package-urls.metafields.custom.checkout_message }} on checkout.liquid file.
We are using Shopify Plus and the metafields are displaying on other templates fine.
As usual, you are falling victim to the documentation. Since you want to display a metafield, if you truly know it has a value, you have to express you want the value. I think your attempt at using the pages object is mis-guided, as checkout is not a page, but, you may be right there, and it may in fact be available in checkout. Anyway, tack on a value.
{{ pages.package-urls.metafields.custom.checkout_message.value }}
As you read your metafield out backwards though, you will see that you are breaking all kinds of rules. Specifically. A metafield resource has a value. It has a key (checkout_message), it has a namespace (custom) and it has a parent resource (metafields in Shop, or Product, or Page).
So what are you doing with package-urls and pages? Strange stuff. I think you might want to anchor this to the Shop. That will likely work a lot better.
I'm trying to display discount codes that have been applied via the URL on the cart page in a Shopify theme prior to checkout.
Example URL would be store.com/discount/DISCOUNTCOUPON
I have verified the discount exists, and if I click on Checkout and proceed to Shopifys built in checkout process then I can see the automatic discount was in fact applied - it just will not display on the cart page. Discount type is a % that applies to entire cart.
I have tried the below snippet as per this guide: https://shopify.dev/themes/pricing-payments/discounts
I am using the Dawn theme also as per the guide. (And applying the code to a section within the cart object).
{% if cart.cart_level_discount_application.size > 0 %}
Discounts:
<ul>
{% for discount_application in cart.cart_level_discount_applications %}
<li>
{{ discount_application.title }}-{{ discount_application.total_allocated_amount | money }}
</li>
{% endfor %}
</ul>
{% endif %}
I have also tried using some variations such as:
{{ discount.title }}
{{ discount.total_allocated_amount | money }})
Nothing seems to work to display the discount.
Anybody come across this before and have any ideas why? Also for extra clarification I am not using Shopify Plus however I cant find anywhere that this is a requirement.
There are 3 types of discounts in Shopify:
Automatic Discounts: When creating discounts in the Shopify admin dashboard, you have the option to make it automatically apply to all or certain orders/customers.
Shopify Scripts: This is a Shopify app available to Shopify Plus users. Using ruby code, you can implement more customized cart/checkout behavior.
I believe the UX seen in the screenshots from the documentation was being achieved using one of the 2 above methods.
Manual Discount Codes: When creating discounts in the Shopify admin dashboard, pick "Discount code" instead of "Automatic discount". These codes are only visible in the checkout section of the website, regardless if the store is Shopify Plus or not.
Most people just write a disclaimer in the cart page, like "Discounts will be calculated during checkout".
Adding discount codes via url generates a cookie named "discount_code", that can be displayed via JS in the cart page for a better user experience, but it only contains the name of the discount.
Other solutions include various Shopify Apps built by third parties, for example: https://apps.shopify.com/discount-coupon-field-in-cart-page.
They generally use the Shopify GraphQL Storefront API to create carts and display them, but this solution involves a lot more complexity: https://shopify.dev/api/examples/cart
A late response, but want to answer your questions and share another solution for this.
I thin your code snippet has some typos, i.e cart_level_discount_application needs an s at the end (Make sure there is no typos, and I think the snippet should work just fine, good luck)
If you want to add an discount form (like the one in checkout) in your cart, or anywhere in your store you can check out this free Shopify Discounter Web Component
Shopify Discounter Web Component supports:
Discount codes
Automatic discounts
Gift cards
Discount combinations
Multi currencies
Internalization
Style customization using css variables
Place it anywhere in your store
Hope this helps.
I am working on shopify and my requirement is to add some extra information of user and I did that following this link :-
http://docs.shopify.com/manual/configuration/store-customization/communicating-with-customers/accounts-and-newsletters/capture-additional-information-in-the-account-registration-form
But now I want to know how to get values from customer[note][label] field in my liquid code.
Like I am able to get customer's name using {{customer.name}} which is store in customer[name] field but unable to get values from customer[note][label] field.
customer.note is not exposed via the the customer Liquid object. It is currently only available via the Shopify API. This is because customer notes are not meant for displaying in your store, they are for shop owners to manage customers in the admin area. An alternative is to use metafields instead.
Relevant discussions on the Shopify forums:
Accessing Customer Note in Account.liquid template
how to access to the customer.note with Liquid
I am having trouble with adding a Product to my Shopify store's shopping cart from an external domain. I have created a product which has a variant id of 264554714. There are other variants, but I have reduced it to one and still cannot get it to work. I have followed all examples in the Shopify forums and on Stackoverflow, but to no avail. My form looks like what is stated to work.
<form id="submitProduct" action="http://mydomain.com/cart/add" method="post" style="display: none;">
<input type="hidden" name="id" value="264554714">
<input type="submit" name="add" value="Add to Cart">
</form>
I have tried many different methods of submitting the form and/or variation combinations. It feels like there is something simple missing. I am hosting this Shopify app on Google App Engine, using Python and Django. I have ensured that the Product exists with the exact variant ID. Please let me know if there is something I haven't thought of to try.
Thank you.
I'm a little late to this party. But if you want to post to the shopify shopping cart you only need to include the product variant ID in a permalink to your store as a key-value pair... it isn't a form submission, shopify will parse the custom URL and add the product to your cart automagically.
buy now
Where 70881412 is the product variant's ID and 1 is the quantity.
I just wanted to put in what I stated in my comment. I was never able to get the post to store.com/cart/add to work using even a single variant ID, let alone multiple variant options. I realized, though, that the permalinks provided by Shopify work just fine for what I need.
Try looking at the Shopify tutorial on this subject: http://wiki.shopify.com/Adding_to_the_Cart_from_a_remote_website
I'm a first-time Shopify developer looking for a way to let customers enter additional data about themselves in Shopify. Specifically, I'd like to add a page or modify the account info page so the customer can enter measurements. I'd then like to take that measurement information, process it, and return a recommended size for products in the shop.
Is this possible in Shopify? I am trying to figure out how to add metafields for customers to record their measurements, but I'm a bit lost.
This should work, but would require a fair bit of customization on the merchant's part and is a bit of a hack:
When a customer is logged in their info is available through Liquid.
This allows you to reference that customer's data when rendering shop pages, e.g. a Product page.
You can assign Metafields to customers using the API. These are also available through Liquid.
Putting this all together, you can have a form on the shopfront asking the customer for info once they're logged in. The form submits to your server where you add the info to the Customer object as Metafields using the API. Then you have some clever Liquid on the Product page that either does the necessary calculations itself or embeds the relevant info into javascript to be processed client-side.