Conditional listing of Secondary product

Conditional listing of Secondary product

Zameer2024
Visitor
1 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
528 16 36

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>
Click here to Contact and Get Shopify Store Help
E-mail - hi@ecommercesmalltask.com
We are Shopify Experts   from Ecommerce Small Task Company.