What's your biggest current challenge? Have your say in Community Polls along the right column.

How to display product barcode (NOT SKU) on front end (Dawn 2.0 theme)?

How to display product barcode (NOT SKU) on front end (Dawn 2.0 theme)?

ace51
Tourist
5 0 4

I need a way to show the product barcode on the front end product pages of my website. I do not want to display my SKU numbers. 

 

Does anyone have any experience with this and where/how to edit the code?

 

 

Replies 2 (2)

ace51
Tourist
5 0 4

Here it is- just go to your normal theme editor (not code). 

 

go to product --> default product--> in the template section hit add block, select </> custom liquid. Enter the code {{ product.variants[0].barcode }}

 

 

rm-philmells
Shopify Partner
16 0 7

This is bad code. You should be using

 

 

{{ product.selected_or_first_available_variant.barcode }}

 

 

to get this kind of data out for display on the product page. Actually, whenever you need to display product data that's linked to a variant you should be using that, this is because it will interact properly for products with options as well when a variant is selected or linked to via query string. The code above will only ever show the barcode for the first variant, even if the customer has selected a different option.