I am trying to create an automated Commercial Invoice within Shopify, using the Liquid template language. I have everything working, except for the IMPORT/EXPORT Harmonized Codes (HS Tariff Codes) that are stored as variant meta-fields. Whenever I try to print them out using the following code, I get blanks:
{% for line_item in line_items %}
{{ line_item.variant.metafields.global_harmonized_system_code }}
{% endfor %}
Can someone help me pull these HS Codes for each product variant and print them on the Commercial Invoice using liquid to pull the meta-field?
4
Answers
Your Liquid is insufficient for the task at hand.
That output is not valid. It might point to a set of one or more key value pairs, so you should really iterate on that. Example:
Something like that is more precise and will go through the variant metafields allowning you to choose which ones to print out.
Global is a namespace, try :
The syntax is :
I am able to get the value using this
This will show the HS code