0
誰能告訴我如何更新Magento中購物車中已有的可配置產品的選項(使用下拉選擇)。更新Magento 1.6.2購物車中已配置產品的選項
我把代碼顯示在以下文件中的可配置產品的超級屬性選項(使用下拉列表):magento\app\design\frontend\default\theme-name\template\checkout\cart\item\default.phtml
。
我發現這個代碼行:
<?php if ($_options = $this->getOptionList()):?>
在那之後,我把我的代碼,以示對配置的產品,其做工精細屬性下拉列表中,但我需要更新超級屬性選項當我從超級屬性下拉列表中選擇另一個選項時,該產品的值。下面是我的代碼來顯示下拉列表:
<?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
}
}
?>
請告訴我如何更新所選可配置產品的超級屬性選項。