ResolvedSub product add-ons

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28376
    SapMan
    Participant

    Hi all,
    Is it possible to hide/unhide a product add-on when a different add-on has been selected?
    Thanks.

    #28388
    Althemist
    Keymaster

    Hello SapMan,

    I am afraid that would not be possible. The addons can not be displayed conditionally. They are available on per product basis or category based.

    #28400
    SapMan
    Participant

    With a bit of research I found a simple JS which makes it possible to hide/show a section based on if the checkbox is selected or not. I was able to hide the specific section by default, with the following css code:

    
    div.product-addon:nth-child(7) {
     display: none;
    }
    

    But I’m not able connect the code to the specific checkbox.

    Can you help me make it possible?

    Thanks in advanced.

    #28412
    SapMan
    Participant

    I’m trying to run the following custom code, but it is not working. I hope you can help me with it:

    <script>
    var checkbox = document.querySelector("input[name='addon-354-menu-5[]']");
    var text = document.getElementsByClassName("div.product-addon:nth-child(7)");
    checkbox.addEventListener('change', function() {
      if (this.checked) {
        text[0].style.display = "block";
      } else {
        text[0].style.display = "none";
      }
    });
    </script>
    <style>	div.product-addon:nth-child(7) {display: none;} </style>
    <?php } );
    #28422
    Althemist
    Keymaster

    This would not work, because the addons are dynamically loaded via AJAX call. As I already explained, what you need just just can’t be done and even if manage you hide/show some of the options dynamically, that would lead to errors in the cart/order data.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register