Hello everyone,
I am trying to get custom fields to display in my shopping cart once a user has added the item with the custom fields to their cart.
Picture below shows the item with the custom fields :
I added this code to the main-product.liquid code block to achieve this. here is the code :
.main-product-property label { display: inline-block; width: 120px; /* Adjust as needed */ margin-right: 10px; /* Adjust as needed */ }{% if product.metafields.custom.name_field %}
{% endif %}
{% if product.metafields.custom.surname %}
{% endif %}
{% if product.metafields.custom.date_of_birth %}
{% endif %}
{% if product.metafields.custom.time_of_birth %}
{% endif %}
{% if product.metafields.custom.weight %}
{% endif %}
{% if product.metafields.custom.height %}
{% endif %}
I also added custom data and added definitions for the different fields I wanted. The definitions are here :
-
Height
product.metafields.custom.heightTrue or false
1 product
-
Weight
product.metafields.custom.weightTrue or false
1 product
-
Time of Birth
product.metafields.custom.time_of_birthTrue or false
1 product
-
Date of Birth
product.metafields.custom.date_of_birthTrue or false
1 product
-
Surname
product.metafields.custom.surnameTrue or false
1 product
-
name field
product.metafields.custom.name_fieldTrue or false
1 product
I am now in my main-cart-items.liquid code editor , however I dont know how I can get these options to display in your cart.
What do I need to add so it will now display the info on the product page ? I need this info to display in the shopping cart :
Name
Surname
Date of Birth
Time of Birth
Weight
Height
Thanks for any help!
Using Dawn theme.
Update
I went to my cart and i added the .json at the end of the url.
It seems like the custom fields are not being saved to the item? And that is why it is not displaying?
I had a chat with chatgpt , here is what it says :
From the JSON response, it appears that the “properties” object for the item is empty. This might be why the custom fields are not displaying in your cart. Make sure that the custom fields are correctly assigned to the product properties in your store’s backend. If the properties are correctly set but still not appearing, there might be an issue with how the properties are being rendered in your cart template.
I am not sure how to ensure the custom properties are being saved???
My store URL is :
https://40f42b-de.myshopify.com/
Password is : saompo