1

I have a music album as a downloadable product type, which lists all songs and the whole album as zipped. So the customer can buy individual songs or just select the whole album. I want to disable individual songs if the customer selects the full album, Like in this music store when you click on "Entire Release" JunoDownload

Please see my screenshot for what I have at the moment. Screenshot

3
  • 1
    Use javascript to disable other checkboxes once you select the checkbox for the entire album.
    – Shatir
    Commented Oct 29, 2013 at 7:27
  • @Shatir Thanks, On which file? what would the JavaScript look like? I have hardly used JS, I'm still new to Magento, this is my first attempt, Any help would be appreciated :-) Thanks Commented Oct 29, 2013 at 8:51
  • I haven't worked with downloadable products yet. But you'd have to add the javascript in the phtml file which displays those options. If you don't know the file, just switch on template path hints from System->Configuration then on left menu bar goto Developer then in Debug you can set template path hints to yes. (Note you'd have to select Current Configuration Scope before you can see the path hints option)
    – Shatir
    Commented Oct 29, 2013 at 12:13

1 Answer 1

1

You don't want to write the JS into the options phtml file.

You want to add a js file to the layout handle: PRODUCT_TYPE_downloadable. On stackoverflow is described how to do it.

And then you have to check how the checkboxes are named and abstract some regex or something (I have no idea how this would look like).

And then you write something like:

$('album_checkbox_find_abstract_name').observer('changed', function(event){
    if(this.checked) {
        $$('.some_class_around_all_the_checkboxes input[type=checkbox]').each(function(elem) {
            if(elem != this) elem.disabled = true;
        });
    } else {
        $$('.some_class_around_all_the_checkboxes input[type=checkbox]').each(function(elem) {
            elem.disabled = false;
        });
    }
});

Hope this helps. No time for testing. Maybe you have a wrong this inside the each functions.

1
  • +1 Nice! Its a more appropriate way go about it (Magento style)... Get to learn new things every now & then from stackexchange. :)
    – Shatir
    Commented Oct 30, 2013 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.