首页 文章

如何在产品页面和购物车页面magento的下拉列表中显示数量

提问于
浏览
0

我正在使用Magento ver . 1.9.2.1

我只想在产品视图页面和购物车页面中显示简单和可配置产品的下拉数量 .

我替换 app/design/frontend/rwd/default/template/catalog/product/view/addtocart.phtml 页面中的代码

替换下面的代码

<input class="qty-decrease" value="-" type="button" onclick="var qty_el = document.getElementById('qty'); var qty = qty_el.value; if( !isNaN( qty ) && qty > 1 ) qty_el.value--;return false;">
            <input id="qty" class="input-text qty" type="text" maxlength="12" title="<?php echo $this->__('Qty') ?>" size="4" value="1" name="qty" style="padding-top: 0;">
<input class="qty-increase"  value="+" type="button" onclick="var qty_el = document.getElementById('qty'); var qty = qty_el.value; if( !isNaN( qty )) qty_el.value++;return false;">

<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()) ?>
</select>

它适用于简单的产品,但在可配置的产品中,选项没有显示 . 在购物车页面中,我无法看到任何类型的产品 .

1 回答

  • 0

    在可配置产品 qty is not their own 中,在可配置产品 qty come from associated product 中,如果找到可配置产品,则必须为可配置产品设置条件,然后您必须从其关联产品而不是可配置产品获取数量 .

相关问题