Can anyone tell me how to update the options (using a dropdown select) of a configurable product that is already in the cart in Magento.
I put the code to show the super attributes options (using a dropdown list) of a configurable product in the following file: magento\app\design\frontend\default\theme-name\template\checkout\cart\item\default.phtml
.
I found a line with this code:
<?php if ($_options = $this->getOptionList()):?>
After that, I put my code to show the attribute dropdown list for configurable products, and its working fine, but I need to update the super attribute option values for that product when I select another option from the super attribute dropdown list. Below is my code to show the dropdown:
<?php
if($this->getProduct()->isConfigurable()){
$_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
Mage::getBlockSingleton('catalog/product_view_type_configurable')->unsetData();
$_configurable = Mage::getBlockSingleton('catalog/product_view_type_configurable')->setData('product', $_product);
$_cdata = json_decode($_configurable->getJsonConfig());
$_current = array();
foreach((array)$this->getOptionList() as $_option) {
$_current[$_option['label']]=$_option['value'];
}
foreach($_cdata->attributes as $attribute) {
?>
<strong><?php echo $attribute->label;
$catchlabel = $attribute->label;
if($catchlabel == 'Clipboard Color'):
$SelectOptions = "selectAtt";
else:
$SelectOptions = "selectFont";
endif;
?>
</strong>
<select style="width: 150px;"
name="cart[<?php echo $_item->getId() ?>][option][<?php echo $attribute->id ?>]"
id="<?php echo $_item->getId(); ?>_<?php echo $attribute->id; ?>"
class="<?php echo $SelectOptions; ?>">
<?php
foreach($attribute->options as $option) {
?>
<option
<?php echo ($_current[$attribute->label]==$option->label) ? ' selected' : '' ?>
value="<?php echo $option->id ?>">
<?php echo $option->label ?>
</option>
<?php
}
?>
</select>
<script type="text/javascript">
jQuery('#<?php echo $_item->getId(); ?>_<?php echo $attribute->id; ?>').change(function() {
var getOption = jQuery('#<?php echo $_item->getId(); ?>_<?php echo $attribute->id; ?>').val();
// something to do here for update attibute options for current product
alert(getOption);
});
</script> <?php
}
}
?>
please tell me how to update the super attribute options of the selected configurable product.