Re: Display product metafield on order

Solved

How can I display a product metafield on the order summary page?

Xythia
Shopify Partner
18 2 0

I've not been able to find a working answer for me. In my store I have a product metafield for item number needed internally for documentation. I need to show this number on our order summary, I can display it on product page without problem but how do I do it on order page? Are you required to be on the plus plan? I'm not afraid to code but need to know what and where to put the code or atleast a hint

Accepted Solution (1)
jazz-jay
Shopify Partner
96 14 17

This is an accepted solution.

Hi Xythia,

 

This should do the trick:

 

<input type="text" id="modellnummer" name="properties[_Modellnummer]" value="{{ product.metafields[YOUR_METAFIELD_NAMESPACE][YOUR_METAFIELD_KEY]}}">

 

 

banned

View solution in original post

Replies 9 (9)

jazz-jay
Shopify Partner
96 14 17

Hi,

 

Simple, add the metafield value as a line item property for that product. Hint, if you do not want the customer to view that property, use _ before the line item property name. 

 

Ref: https://shopify.dev/api/liquid/objects#line_item

banned
Xythia
Shopify Partner
18 2 0

So I've tried adding this code but it's still not working. Feels like I've just missed something but can't figure out what. Thank you for helping

 

In product-template

{% form 'product', product %}
<input type="text" id="modellnummer" name="properties[_Modellnummer]">
{% endform %}

 

In customer/order under line_item.title in the for loop

{{ line_item.properties('Modellnummer') }}

Xythia
Shopify Partner
18 2 0

To add to this I realized you might need that label too as in the example code in your reference but struck out on that one aswell

jazz-jay
Shopify Partner
96 14 17

This is an accepted solution.

Hi Xythia,

 

This should do the trick:

 

<input type="text" id="modellnummer" name="properties[_Modellnummer]" value="{{ product.metafields[YOUR_METAFIELD_NAMESPACE][YOUR_METAFIELD_KEY]}}">

 

 

banned
Xythia
Shopify Partner
18 2 0

Yes, already figured it out. Was a bit angry with myself when I realized the reason I got no value was because I never assigned one 🙂

 

Thank you for your help

amandaatremix
Excursionist
21 2 7

I am customizing the Refresh Theme and would like a Product metafield I created called "custom.known_issues" to show up as a product line item on the admin order page (not for the customer to see! But for us to do quality checks when we pull the order). 
I read your reply to Xythia but need more assistance. Where/how/what? 😉 Thank you in advance for any help you can provide!

jazz-jay
Shopify Partner
96 14 17

Hi Amandaatremix,

 

You do not need metafield for this. Just use product line properties to achieve this.

If you need more assistance, you can PM me.

 

Thanks.

banned
as01
Tourist
4 0 2

hello @jazz-jay  I have a custom product meta field called Warehouse Location. Can you help me show this meta field to admin order page? I am ready to make code changes if required.

 

Can you please help?

truemoroz1
Shopify Partner
3 0 0

It helps only to display metafield on product page. How to save this metafield to order metafield?