Product url metalink into email notifications

Hi There,

I am trying to insert a product metafiled url link into email notifications.

Can anyone help me with the coding please?

1 Like

@Greer_George

oh sorry for that issue your i think your meta wrong bt can you please share store url so i will check and let you know

Hi @Greer_George

I am trying to insert a product metafiled url link into email notifications.

Keywords for logic: product and it’s metafield property

In the notification image of it’s code your trying to access a metafield(MF) by name directly but metafields only exist on other resources(products,collections,pages,etc) they are not global objects in liquid. Global metafields would cause issues in logic, namespace, and scope for instance a collection could also have the same MF and the system would have no idea whether it’s the collection or a product it should look at..

https://shopify.dev/api/liquid/objects#metafield:~:text=attached%20to%20a%20parent%20object

https://shopify.dev/api/liquid/objects#metafield-access-metafields

Further in the area of notification you code shows you are dealing with a line item, line_item, and not products.

Line items are the purchase information for a variant of a product.

Line items do have a reference to the product it’s based on. Then through the products it’s metafield.

https://help.shopify.com/en/manual/orders/notifications/email-variables#line-item:~:text=a%20single%20item.-,line.product.metafields,-The%20Metafields%20at

Note: in some areas line may be replace with line_item .

So going through the objects property chain: line.product.metafields.my_fields.product_link

{{ line.product.metafields.my_fields.product_link }}

To output the metafield url as an html link with custom text use the link_to filter:

https://shopify.dev/api/liquid/filters#link_to

{{ 'Link text' | link_to:line.product.metafields.my_fields.product_link }}

to output the metafield url as an html link with the url also as the text use the metafield_tag filter which automatically uses the metafield type to render html appropriate to the type.

https://shopify.dev/api/liquid/filters#metafield_tag

https://shopify.dev/api/liquid/filters#metafield_tag-url

{{ line.product.metafields.my_fields.product_link | metafield_tag }}

note: metafield_tag does not accept parameters to change the link text.

Hi @PaulNewton , thank you so much. This is very helpful.

I’ve added in this code and i can see the text but no clickable link through the the metafield url