Shopify Liquid code examples
Stock keeping units (SKUs) are used to identify products and track inventory. You can display the unique SKU for a product and its variants on the product page.
- Add the following code to the
product-template.liquid
section, just below the product title. - Depending on your theme, ensure that the SKU updates dynamically when you select other variants. If not, then you will need to add a few lines of JavaScript to your theme's JavaScript file.
{%- assign current_variant = product.selected_or_first_available_variant -%}
<span>{{ current_variant.sku }}</span>
Please note: We have intentionally limited CSS and JavaScript, and removed translation strings in order to keep these examples compatible with any theme. Any CSS we have included is for accessibility or rendering purposes.