Personalized checkout and custom promotions with Shopify Scripts
I have some coding that places the SKUs and BARCODEs of products onto the front end of the website. So that customers can see these on the product pages. The admin enters them into the back end fields and they are visible on the front end on product pages.
This works fine for regular products. However we needed a new template for variable products. It is the same coding, but in this case only the SKU is shown properly. The BARCODE is not displayed, and instead the SKU data is there. So although on the front end it has signs for SKU and BARCODE, the SKU data field from the backend is being displayed twice in the frontend.
Here is the working code:
{%- if section.settings.prod_show_sku -%}
<div class="sku {% if product.selected_or_first_available_variant.sku == blank %}sku--no-sku{% endif %}"><span class="product-detail-label">ITEM CODE:</span> <span class="sku__value">{{ product.selected_or_first_available_variant.sku }}</span></div>
{%- endif -%}
<div class="sku "><span class="product-detail-label">BARCODE:</span> <span class="sku__value">{{ product.selected_or_first_available_variant.barcode }}</span></div>
The variable products have different SKUs and BARCODEs variants. When switching between the variants on the front end, the SKUs change as they should. However the BARCODE data is not displayed at all. Rather is replaced by the SKU data.
Any help would be appreciated.
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024