Reputation: 1246
In shopify admin panel ( settings > notifications > Email templates ) it allows you to edit the email sent to my distributor with order information on it like : address, price and the SKU to send that customer. I am trying to add the Barcode UPC to the email template as well.
This is the .liquid code for the SKU
(sku: {{ line.sku }})
Here is a link to the email variable reference guide but I cant find one for the barcode, any ideas?
http://docs.shopify.com/manual/settings/notifications/email-variables
Upvotes: 3
Views: 1046
Reputation: 21
We can simply add this code to show the barcode in the email template:
{% if line.variant.barcode != blank %}
<span class="order-list__item-variant">Barcode: {{ line.variant.barcode }}</span>
{% endif %}
Under:
{% for line in subtotal_line_items %}
So, It should look like:
{% for line in subtotal_line_items %}
<!-- Some Code -->
{% if line.variant.barcode != blank %}
<span class="order-list__item-variant">Barcode: {{ line.variant.barcode }}</span>
{% endif %}
<!-- Some Code -->
{% endfor %}
Reference: https://help.shopify.com/en/manual/fulfillment/setup/notifications/email-variables#line-item
Upvotes: 0
Reputation: 1246
Shopify customer support answered my question. {{ line.variant.barcode }}
Upvotes: 2
Reputation: 66
You could store the upc in an unused product field (e.g. vendor) and then output this field in your email template {{ line.vendor }}.
If there are no unused fields available then you can store the upc in a metafield and output this metafield in your email template:
{{line.product.metafields.some_namespace.your_key}}
Here is the documentation for metafields: metafields
Where is the upc currently stored?
Upvotes: 1
Reputation: 882
So, one of the options would be to set a cart attribute, which you could then output in the email.
Here's a link to setting cart attributes, but in your case you'd probably want the input to be hidden (since the customer doesn't need to type anything in).
It's a bit of a hack, but the alternative is using an app with a webhook to generate a UPC and send it.
Upvotes: 1