Show SKU numbers on product pages

SKUs (stock keeping units) are numbers, typically alphanumeric, that are used to help identify products and track inventory. If a store uses SKUs, then a unique number is assigned to each individual product variant. You can show SKU numbers for variants on your product pages by editing your theme code:

Variant SKU example

Sectioned and non-sectioned themes

Steps for Sectioned themes

Show SKU numbers on product pages

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  3. In the Sections directory, click product.liquid or product-template.liquid.
  4. Find the following Liquid tag:
{{ product.title }}

This is the code that renders your product titles on the product page.

  1. On a new line below the line of code that includes {{ product.title }}, paste the following code:
{% assign current_variant = product.selected_or_first_available_variant %}
<span class="variant-sku">{{ current_variant.sku }}</span>
  1. Click Save.

Select your theme

The next steps for this customization vary depending on your theme. Click the button for your theme and follow the instructions.

Add SKU numbers to your product variants from the admin

To have SKUs appear on your product pages, you must add SKU numbers to your product variants from in Shopify admin.

  1. From your Shopify admin, go to Products.

  2. Click the product that you want to edit.

  3. For products with multiple variants, in the Variants section, add your SKU numbers:

    SKUs

    For products without variants, in the Inventory section, add your SKU number:

    SKU for products without variants

  4. Click Save.

Steps for Non-sectioned themes

Show SKU numbers on product pages

Steps:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  3. In the Templates directory, click product.liquid.
  4. Find the following Liquid tag:
{{ product.title }}

This is the code that renders your product titles on the product page.

  1. On a new line below the line of code that includes {{ product.title }}, paste the following:
{% assign current_variant = product.selected_or_first_available_variant %}
<span class="variant-sku">{{ current_variant.sku }}</span>
  1. Click Save.
  2. If you're using a free Shopify theme that isn't Brooklyn or Venture, then find the following line of code:
var selectCallback = function(variant, selector) {

If you cannot find the above line of code in product.liquid, then you will find it in theme.liquid, in the Layout directory.

  • Brooklyn and Venture: If you are using Brooklyn or Venture, then you will need to find and edit a different line of code. In the Assets directory, click theme.js.liquid, and find the following line of code:
theme.productVariantCallback = function (variant, selector) {
  1. On a new line below, paste the following code:
    if (variant) {
      document.querySelector('.variant-sku').innerText = variant.sku;
    }
    else {
      document.querySelector('.variant-sku').innerText = '';
    }

Your code should look something like this:

    var selectCallback = function(variant, selector) {

      if (variant) {
        document.querySelector('.variant-sku').innerText = variant.sku;
      }
      else {
        document.querySelector('.variant-sku').innerText = '';
      }

        self.productPage({
          money_format: theme.moneyFormat,
          variant: variant,
          selector: selector,
          translations: {
            add_to_cart : theme.productStrings.addToCart,
            sold_out : theme.productStrings.soldOut,
            unavailable : theme.productStrings.unavailable
          }
        });
      };
  1. Click Save.

Add SKU numbers to your product variants from the admin

To have SKUs appear on your product pages, you must add SKU numbers to your product variants from in Shopify admin.

  1. From your Shopify admin, go to Products.

  2. Click the product that you want to edit.

  3. For products with multiple variants, in the Variants section, add your SKU numbers:

    SKUs
    For products without variants, in the Inventory section, add your SKU number:
    SKU for products without variants

  4. Click Save.

Ready to start selling with Shopify?Try it free