Created
October 22, 2014 08:29
-
-
Save mklooss/24515432019ec8b65d13 to your computer and use it in GitHub Desktop.
Show Attribute Name in Select Box on an Configurable Product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
Product.Config.prototype.fillSelect = function(element){ | |
var attributeId = element.id.replace(/[a-z]*/, ''); | |
var options = this.getAttributeOptions(attributeId); | |
this.clearSelect(element); | |
element.options[0] = new Option('', ''); | |
element.options[0].innerHTML = this.config.attributes[attributeId].label + ' <?php echo $this->__('Choose') ?>'; | |
var prevConfig = false; | |
if(element.prevSetting){ | |
prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex]; | |
} | |
if(options) { | |
var index = 1; | |
for(var i=0;i<options.length;i++){ | |
var allowedProducts = []; | |
if(prevConfig) { | |
for(var j=0;j<options[i].products.length;j++){ | |
if(prevConfig.config.allowedProducts | |
&& prevConfig.config.allowedProducts.indexOf(options[i].products[j])>-1){ | |
allowedProducts.push(options[i].products[j]); | |
} | |
} | |
} else { | |
allowedProducts = options[i].products.clone(); | |
} | |
if(allowedProducts.size()>0){ | |
options[i].allowedProducts = allowedProducts; | |
element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id); | |
if (typeof options[i].price != 'undefined') { | |
element.options[index].setAttribute('price', options[i].price); | |
} | |
element.options[index].config = options[i]; | |
index++; | |
} | |
} | |
} | |
}; | |
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment