snarlecp,
Yes, this is possible using jquery. I must say first, that i cannot guarantee this will work. This is quite the workaround and will make your attributes/options NOT FLEXIBLE. When you want to change attributes, you'll have to do it in this code too.
And setting this up in the first place could be a LOT of work, depending on how many attributes you want to show/hide. Also, BACKUP BACKUP BACKUP!!! Dont do this on a live site. Work thru the code, make sure it works first before you implement it on a live site. That said, here we go! :smile:
The file that controls the display of the product page is includes/templates/TEMPLATENAME/templates/tpl_product_info_display.php
Find that file and put this code down at the bottom after everything else:
<script type="text/javascript">
function updateCustomPanel()
{
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_1'))").hide();
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_2'))").hide();
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_3'))").hide();
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_4'))").hide();
if (jQuery("option:contains('MAIN_SELECTION')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_SHOWME'))").show();
}
if (jQuery("option:contains('MAIN_SELECTION')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_SHOWME'))").show();
}
if (jQuery("option:contains('MAIN_SELECTION')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_SHOWME'))").show();
}
if (jQuery("option:contains('MAIN_SELECTION')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('HIDDEN_ATTRIBUTE_SHOWME'))").show();
}
else{}
}
jQuery("select:has(option:contains('Custom Size'))").change(updateCustomPanel);
jQuery(document).ready(updateCustomPanel);
</script>
Now, first declare every attribute you would want to show/hide up in the first lines. To do this, replace HIDDEN_ATTRIBUTE_1, HIDDEN_ATTRIBUTE_2, etc. with the EXACT names of all the attribute NAMES you will want to hide & show. (of course, you need to setup these attributes in your admin first)
For example, you may want to hide "Pick A Material" and "Pick A Color" like so:
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('Pick A Material'))").hide();
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('Pick A Color'))").hide();
Now, you want to name the options and which attributes go with them. MAIN_SELECTION is where you would place the EXACT name of the attribute OPTION you want tied to the action of hiding & showing. HIDDEN_ATTRIBUTE_SHOWME is where you'll put the EXACT name of the attribute NAME you want to appear.
For example, you may have a main dropdown for size. When the customer selects "Medium" or "Small" you would want "Pick A Material" or "Pick A Color" to appear. You would put that in the code like so:
if (jQuery("option:contains('Medium')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('Pick A Material'))").show();
}
if (jQuery("option:contains('Small')").attr('selected')) {
jQuery("div.wrapperAttribsOptions:has(label.attribsInput:contains('Pick A Color'))").show();
}
Copy and paste additional lines of code as needed, until you've declared all of your attributes and the options to be hidden.
Now, keep in mind since this is all name-based, you'll need to have unique names for your attributes. So you can't have a "Pick A Material" for both "Small" and "Medium". Maybe you can name them "Pick A Material S" or "Pick A Material M". That's also why this is NOT flexible. If you want to change the names of any of your attributes or options, you'll need to get into this code and change it here too.
Maybe someday I'll work this into a mod and put it in the downloads section. Perhaps at that point I'll figure a way to tie it into the admin as well :blink:
But till then, hope this helps you out!