Shopify themes, liquid, logos, and UX
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?
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 }}
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.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025