Get customers to choose an option

When a customer visits a product page in your online store, the first available variant is selected by default. You can use the Get customers to choose an option customization to deactivate the auto-selection of the first available variant. This way the customer is prompted to manually select a variant before one displays.

If you use the Get customers to choose an option customization, then your theme might not display a product price until your customer selects a variant. Products with variants don't have a featured price and the price that's displayed is determined by the variant that's selected.

Pick an option

Sectioned and non-sectioned themes

Steps for Sectioned themes

Select your theme

The steps for this customization vary depending on your theme. Click the button for your theme before following the instructions below:

Boundless

Steps for Boundless

Follow these steps to apply the customization to Boundless:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Find the code initVariantSelectors. Below that, find the following code:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
this.simplifyVariantLabels(this.productSingleObject, this.$container);

Add the following code on a new line below:

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}

It should look something like this:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
this.simplifyVariantLabels(this.productSingleObject, this.$container);

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}
  1. Find the following line of code:
$(selectors.addToCartText).html(theme.strings.soldOut);

There are two instances of this line of code, both found within the productVariantCallback function. Replace only the second instance with:

$(selectors.addToCartText).html('Make a Selection');
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{% assign current_variant = product.selected_or_first_available_variant %}

Replace it with:

{% assign current_variant = product.selected_variant %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Debut

Steps for Debut

Follow these steps to apply the customization to Debut:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Add the following code to the bottom of the file:

(function() {
  if (typeof(productOptions) != "undefined") {
    for (i = 0; i < productOptions.length; i++) {
      const vowels = ['a', 'e', 'i', 'o', 'u'];
      const firstOptionLetter = productOptions[i][i][0].toLowerCase();
      let indef = 'a';

      if (vowels.includes(firstOptionLetter)) {
        indef = 'an';
      };

      const select = document.querySelectorAll('.single-option-selector')[i];
      const options = select.querySelectorAll('option');

      if (options.length > 1) {
        let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

        select.add(option, select.firstChild);
        select.selectedIndex = 0;
      }
    }
  }
})();
  1. Find the code _updatePrice: function(variant). Replace the following code:
if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price &&
  variant.unit_price === this.currentVariant.unit_price
) {
  return;
}

with:

/* if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price &&
  variant.unit_price === this.currentVariant.unit_price
) {
  return;
} */

If you can't find the above code, then find the following code:

if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price
) {
  return;
}

Replace it with:

/* if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price
) {
  return;
} */
  1. Find the code this.currentVariant = variant;

Add the following code below:

this._updatePaymentButton(variant);

The result should look something like this:

this.currentVariant = variant;
this._updatePaymentButton(variant);
  1. Find the code _updateImages: function(variant). Replace the following code:
var currentVariantImage = this.currentVariant.featured_image || {};

with:

if (this.currentVariant != undefined) {
  var currentVariantImage = this.currentVariant.featured_image || {};
}
  1. Just below, find the following code:
if (
  !variant.featured_image ||
  variantImage.src === currentVariantImage.src
) {
  return;
}

Replace it with:

/* if (
  !variant.featured_image ||
  variantImage.src === currentVariantImage.src
) {
  return;
} */
  1. Find the code _updateSKU: function(variant). Replace the following code:
if (variant.sku === this.currentVariant.sku) {
  return;
}

with:

if (this.currentVariant != undefined ) {
  if (variant.sku === this.currentVariant.sku) {
    return;
  }
}
  1. Find the code _initVariants: function() {. Replace the following code:
if (this.storeAvailability && this.variants.currentVariant.available) {
  this.storeAvailability.updateContent(this.variants.currentVariant.id);
}

with:

/* if (this.storeAvailability && this.variants.currentVariant.available) {
  this.storeAvailability.updateContent(this.variants.currentVariant.id);
} */
  1. Find the following code:
_updateSKU: function(variant) {
  if (this.currentVariant != undefined ) {
    if (variant.sku === this.currentVariant.sku) {
      return;
    }
  }

  this.container.dispatchEvent(
    new CustomEvent('variantSKUChange', {
      detail: {
        variant: variant
      },
      bubbles: true,
      cancelable: true
    })
  );
},

Add the following code, on a new line, below the above code:

_updatePaymentButton: function(variant) {
  if (this.currentVariant != undefined) {
    const paymentButton = document.querySelector('.payment-button');

    if (paymentButton) {
      paymentButton.removeAttribute('class', 'visually-hidden');
     }
  } else {
    document.querySelector('.payment-button').setAttribute('class', 'visually-hidden');
  }
},

It should look something like this:

_updateSKU: function(variant) {
  if (this.currentVariant != undefined ) {
    if (variant.sku === this.currentVariant.sku) {
      return;
    }
  }

  this.container.dispatchEvent(
    new CustomEvent('variantSKUChange', {
      detail: {
        variant: variant
      },
      bubbles: true,
      cancelable: true
    })
  );
},

_updatePaymentButton: function(variant) {
  if (this.currentVariant != undefined) {
    const paymentButton = document.querySelector('.payment-button');

    if (paymentButton) {
      paymentButton.removeAttribute('class', 'visually-hidden');
     }
  } else {
    document.querySelector('.payment-button').setAttribute('class', 'visually-hidden');
  }
},
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{%- assign current_variant = product.selected_or_first_available_variant -%}

Replace it with:

{%- if product.variants.size > 1 -%}
  {%- assign current_variant = product.selected_variant -%}
{%- else %}
  {%- assign current_variant = product.first_available_variant -%}
{%- endif %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}

If you can't find the code above, then find the following code and delete it:

{%- if variant == current_variant %} selected="selected" {%- endif -%}
  1. Find the following code:
{%- assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image -%}

Replace it with:

{%- assign featured_image = current_variant.featured_image | default: product.featured_image -%}

If you can't find the code above, then find the following code:

{%- assign featured_media = product.selected_or_first_available_variant.featured_media | default: product.featured_media -%}

Replace it with:

{%- assign featured_media = current_variant.featured_media | default: product.featured_media -%}
  1. Find the following code:
{% unless current_variant.available %}
  {{ 'products.product.sold_out' | t }}
{% else %}
  {{ 'products.product.add_to_cart' | t }}
{% endunless %}

Replace it with:

{% if current_variant == blank %}
  {{ 'products.product.unavailable' | t }}
{% elsif current_variant.available %}
  {{ 'products.product.add_to_cart' | t }}
{% else %}
  {{ 'products.product.sold_out' | t }}
{% endif %}
  1. Find the following code:
{% if section.settings.enable_payment_button %}
  {{ form | payment_button }}
{% endif %}

Replace it with:

<div class="payment-button {% if current_variant == blank %}visually-hidden {% endif %}">
  {% if section.settings.enable_payment_button %}
    {{ form | payment_button }}
  {% endif %}
</div>
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Edit your product price snippet

To edit your product price snippet:

  1. In the Snippets directory, click product-price.liquid.
  2. Find the following code:
{%- liquid
  if variant.title
    assign compare_at_price = variant.compare_at_price
    assign price = variant.price
    assign available = variant.available
  else
    assign compare_at_price = 1999
    assign price = 1999
    assign available = true
  endif

  assign money_price = price | money
-%}

Replace it with:

{%- liquid
  if variant.title
    assign compare_at_price = variant.compare_at_price
    assign price = variant.price
    assign available = variant.available
  elsif product.title
    assign compare_at_price = product.compare_at_price
    assign price = product.price
    assign available = product.available
  else
    assign compare_at_price = 1999
    assign price = 1999
    assign available = true
  endif

  assign money_price = price | money
-%}

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Minimal

Steps for Minimal

Follow these steps to apply the customization to Minimal:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Find the code initProductVariant: function() {. Below that, find the following code:

// Hide selectors if we only have 1 variant and its title contains 'Default'.
if (
  product.variants.length === 1 &&
  product.variants[0].title.toLowerCase().indexOf('default') !== -1
) {
  $('.selector-wrapper', this.$container).hide();
}

Add the following code on a new line below:

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}

It should look something like this:

// Hide selectors if we only have 1 variant and its title contains 'Default'.
if (
  product.variants.length === 1 &&
  product.variants[0].title.toLowerCase().indexOf('default') !== -1
) {
  $('.selector-wrapper', this.$container).hide();
}

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{% assign variant = product.selected_or_first_available_variant %}

Replace it with:

{% assign variant = product.selected_variant %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}
  1. Find all occurrences of this code:
{% assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image %}

Replace with:

{% assign featured_image = product.selected_variant.featured_image | default: product.featured_image %}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Narrative

Steps for Narrative

Follow these steps to apply the customization to Narrative:

Edit your theme's JavaScript file

  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 Assets directory, click custom.js.

  4. Add the following code to the bottom of the file:

(function() {
  if (typeof(productOptions) != "undefined") {
    for (i = 0; i < productOptions.length; i++) {
      const vowels = ['a', 'e', 'i', 'o', 'u'];
      const firstOptionLetter = productOptions[i][i][0].toLowerCase();
      let indef = 'a';

      if (vowels.includes(firstOptionLetter)) {
        indef = 'an';
      };

      const select = document.querySelectorAll('.single-option-selector')[i];
      const options = select.querySelectorAll('option');

      if (options.length > 1) {
        let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

        select.add(option, select.firstChild);
        select.selectedIndex = 0;
      }
    }
  }
})();
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{%- assign current_variant = product.selected_or_first_available_variant -%}

Replace it with:

{%- if product.variants.size > 1 -%}
  {%- assign current_variant = product.selected_variant -%}
{%- else -%}
  {%- assign current_variant = product.first_available_variant -%}
{%- endif -%}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Simple

Steps for Simple

Follow these steps to apply the customization to Simple:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Find the code initProductVariant: function() {. Below that, find the following code:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
Slate.simplifyVariantLabels(this.productSingleObject, this.$container);

Add the following code on a new line below:

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}

It should look something like this:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
Slate.simplifyVariantLabels(this.productSingleObject, this.$container);

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{% assign current_variant = product.selected_or_first_available_variant %}

Replace it with:

{% assign current_variant = product.selected_variant %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Supply

Steps for Supply

Follow these steps to apply the customization to Supply:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Find the code initProductVariant: function() {. Below that, find the following code:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
this.simplifyVariantLabels(this.productSingleObject);

Add the following code on a new line below:

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}

It should look something like this:

// Clean up variant labels if the Shopify-defined
// defaults are the only ones left
this.simplifyVariantLabels(this.productSingleObject);

if (typeof(productOptions) != "undefined") {
  for (i = 0; i < productOptions.length; i++) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const firstOptionLetter = productOptions[i][i][0].toLowerCase();
    let indef = 'a';

    if (vowels.includes(firstOptionLetter)) {
      indef = 'an';
    };

    const select = document.querySelectorAll('.single-option-selector')[i];
    const options = select.querySelectorAll('option');

    if (options.length > 1) {
      let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

      select.add(option, select.firstChild);
      select.selectedIndex = 0;
    }
  }
}
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{% assign variant = product.selected_or_first_available_variant %}

Replace it with:

{% assign variant = product.selected_variant %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}
  1. Find all occurrences of this code:
{% assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image %}

Replace it with:

{% assign featured_image = product.selected_variant.featured_image | default: product.featured_image %}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Venture

Steps for Venture

Follow these steps to apply the customization to Venture:

Edit your theme's JavaScript file

  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 Assets directory, click theme.js or theme.js.liquid.

  4. Add the following code to the bottom of the file:

(function() {
  if (typeof(productOptions) != "undefined") {
    for (i = 0; i < productOptions.length; i++) {
      const vowels = ['a', 'e', 'i', 'o', 'u'];
      const firstOptionLetter = productOptions[i][i][0].toLowerCase();
      let indef = 'a';

      if (vowels.includes(firstOptionLetter)) {
        indef = 'an';
      };

      const select = document.querySelectorAll('.single-option-selector')[i];
      const options = select.querySelectorAll('option');

      if (options.length > 1) {
        let option = new Option('Pick ' + indef + ' ' + productOptions[i][i], '');

        select.add(option, select.firstChild);
        select.selectedIndex = 0;
      }
    }
  }
})();
  1. Find the following code:
this.currentVariant = this._getVariantFromOptions();

Replace it with:

this.currentVariant = this._getVariantFromOptions() || {};
  1. Find the code _updatePrice: function(variant). Replace the following code:
if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price
) {
  return;
}

with:

/* if (
  variant.price === this.currentVariant.price &&
  variant.compare_at_price === this.currentVariant.compare_at_price
) {
  return;
} */
  1. Click Save.

Edit your product page template

To edit your product page template:

  1. In the Sections directory, click product-template.liquid.
  2. Find the following code:
{% assign current_variant = product.selected_or_first_available_variant %}

Replace it with:

{% if product.variants.size > 1 %}
  {% assign current_variant = product.selected_variant %}
{% else %}
  {% assign current_variant = product.first_available_variant %}
{% endif %}
  1. Find the following code and delete it:
{% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %}

If you can't find the code above, then find this code and delete it:

{% if variant == current_variant %} selected="selected" {% endif %}
  1. Find all occurrences of this code:
{% unless current_variant.available %}

Replace it with:

{% unless current_variant.available or product.variants.size == 1 and variant.available %}
  1. Find the following code:
{% unless current_variant.available or product.variants.size == 1 and variant.available %}
  {{ 'products.product.sold_out' | t }}
{% else %}
  {{ 'products.product.add_to_cart' | t }}
{% endunless %}

Replace it with:

{% if current_variant == blank %}
  {{ 'products.product.unavailable' | t }}
{% else %}
  {% unless current_variant.available or product.variants.size == 1 and variant.available %}
    {{ 'products.product.sold_out' | t }}
  {% else %}
    {{ 'products.product.add_to_cart' | t }}
  {% endunless %}
{% endif %}
  1. Find the code {% schema %}. Paste the following code on its own line above that:
{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

It should look something like this:

{% if current_variant == blank %}
  <script>
    var productOptions = [];

    {% for option in product.options -%}
      var optionObj = {};
      optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
      productOptions.push(optionObj);
    {%- endfor %}
  </script>
{% endif %}

{% schema %}
  1. Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Steps for Non-sectioned themes

Add prompts to your variant drop-down menus

  1. In the Snippets directory, click Add a new snippet.
  2. Name your new snippet pick-an-option.
  3. In your new snippet file, paste this code hosted on GitHub.
  4. Click Save.
  5. In the Layout directory, click theme.liquid.
  6. Find the closing </body> tag near the bottom of the file. On a new line right above the closing </body> tag, paste the following code:
{% render 'pick-an-option' %}
  1. Click Save.
  2. Find the file that contains the add to cart form. It will have an action attribute set to /cart/add. It should be in one of these four files:
    • the product.liquid template under Templates
    • the theme.liquid layout under Layout
    • the product.liquid snippet under Snippets
    • the single-product.liquid snippet under Snippets
  3. Find this code inside the form:
  <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

Or find this code inside the form:

  <option {% if variant == current_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

Replace the code with the following code block:

<option {% if forloop.length <= 1 and variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

If you use Minimal, Pop, or Supply, then find all occurrences of this code:

{% assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image %}

Replace the code with the following code block:

{% assign featured_image = product.selected_variant.featured_image | default: product.featured_image %}

If you use any other Shopify vintage theme, then find this code:

{% assign current_variant = product.selected_or_first_available_variant %}

Replace the code with the following code block:

{% assign current_variant = product.selected_variant %}

Click Save.

Change the Add to cart button language settings

You can change the language settings for the Add to cart button so that products don't display as Unavailable before a customer selects a product.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme that you want to edit, and then click ... > Edit default theme content.

  3. In the Filter items search bar, start typing unavailable to display the Unavailable translation.

  4. Replace the text Unavailable with Make a selection.

  5. Click Save.

Can’t find the answers you’re looking for? We’re here to help.