Conditional listing of Secondary product

Conditional listing of Secondary product

Top_Finds_Store
New Member
9 0 0

I have primary & secondary products. I need to get the selections for secondary product displayed only after at least making 1 item selection in the primary product. Is it possible to do that directly from shopify.com or if there are any applicable shopify apps to it. I request a specific response please.

Reply 1 (1)

Small_Task_Help
Shopify Partner
1103 51 108

Hi,

 

First ensure your Shopify product template includes both primary and secondary product selection inputs.

After that use javascript

Example code

<script>
document.addEventListener('DOMContentLoaded', function() {
  var primaryProductSelector = document.querySelector('#primary-product-selector');
  var secondaryProductSelections = document.querySelector('.secondary-product-selections');

  primaryProductSelector.addEventListener('change', function() {
    if (primaryProductSelector.value) {
      secondaryProductSelections.style.display = 'block';
    } else {
      secondaryProductSelections.style.display = 'none';
    }
  });
});
</script>
To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad