Can you display product barcodes on the Shopify front end?

abdulhaq_22
Visitor
1 0 0

Hi guys. Please assist in advising how to go about displaying the barcode of each product on the front end. 

 

I have gotten the SKU to display

Replies 8 (8)

Ninthony
Shopify Partner
2329 350 1023

How did you do the sku? I assume it's through the products variant. It's the same with the barcode.

 

{% for variant in product.variants %}
{{ variant.sku }}
{{ variant.barcode }}
{% endfor %}
If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
justdavenow
Shopify Partner
14 0 4

just to add as it took me a good time to work out and I like to share things in case others have the same question. This is what you need to use in your structured data to display your gtin13 barcode.

 

this should be placed under

"@type": "Product",

 

{% if selected_variant.barcode != blank %}
"gtin13": {{ selected_variant.barcode | json }},
{% endif %}

 

test your product page with the structured data testing tool and look under product for your gtin13 details.

https://search.google.com/structured-data/testing-tool/u/0/

markdc
Shopify Partner
23 0 22

If I choose a different color/size, the first barcode always shows. How can we get this to update with selected variants?

markdc
Shopify Partner
23 0 22

Nevermind, I found a solution and will post it here to answer that exact question asked by another user.

jaym1
Visitor
1 0 0

Hi, ive added this code into my template. but the sku and barcode are both on the same line. how can i make it so that they are on 2 seperate lines. sorry im new to all this coding. any help would be appreciated. 

 

thank you

justdavenow
Shopify Partner
14 0 4

you can wrap each element in a <div> tag

here is an example.

 

<div class="product-vendor" itemprop="gtin13">

the number would go here

 

</div>

<div  itemprop="sku">

what ever this is 

 

</div>

EuronicsIreland
Visitor
3 0 0

Hi there, 

 

Wondering where you place this piece of code to have the barcode display?

enervell
Visitor
1 0 0

I am having the same issue today, can you please tell me if you solved it with the actual theme today?