Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Product url metalink into email notifications

Product url metalink into email notifications

Greer_George
Tourist
12 0 2

Hi There,

 

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

Can anyone help me with the coding please? 

 

Screen Shot 2022-10-15 at 11.50.23 am.png

Replies 3 (3)

KetanKumar
Shopify Partner
37133 3648 12061

@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 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

PaulNewton
Shopify Partner
7450 655 1558

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%... 

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.  

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Greer_George
Tourist
12 0 2

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

 

Screen Shot 2022-10-15 at 7.58.53 pm.pngScreen Shot 2022-10-15 at 7.59.17 pm.png