Hi everybody. I have been searching for how to display SKU code and EAN code on the product pages. I found a way to make those 2 codes display on the product page BUT EAN code is not changing when you select a different variant
SKU code changes with no issues.
Does anybody know how to make it change as SKU does?
The code you are showing is perfect code but that will only work when the page is loading. once the page is loaded after data will change based on the selector code.
in your theme, you will be able to find a theme. js or product.js or may be at the end of the product. liquid
Where you will find the selector code, on the variant change event code you have to run.
each theme has diff classes and IDs but below I am writing the ideal code which can give you a barcode/EAN number on the change event of the variant.
var selectCallback = function(variant, selector) {
console.log(variant.barcode);
}
new Shopify.OptionSelectors('jsvariants_custom', {
product: {{ product | json }},
onVariantSelected: selectCallback,
enableHistoryState: true
});
Where it say "jsvariants_custom" you can replace that with your variation ID or class.
Thank you
I also struggle with the SKU/barcode issue, as the SKU doesn’t update after changing the variant, and I can’t find the correct solution. I’m using the Dawn theme, and I also want to display the price without tax below the taxed price. It works fine with a product without variants, but with variants, I’m encountering the same issue as with the SKU.