我已经在网站上工作了几个月,现在又回到了一个从未实现过的功能 .
我们从一开始就计划只允许人们以我们的Tier-Price断点结算作为可用的增量数量 . 本网站上的所有产品都是定制的,不保留库存 .
我们希望断点反映层而不是完美的增量(100,250,500,1000,2000,3000,5000,10000),因此设置每个产品基础数量限制的唯一方法是选择设置层 .
我找到的最接近的参考和代码如下,它创建了从分层中断自动生成的单选按钮选项,但是将其转换为下拉列表比我想象的要困难得多 .
如果有人可以帮助解决以下代码,我可能无法将所有这些选项添加到下拉菜单中,并根据设置的数量和选项动态更改价格 .
<div class="retail-price-contain tier-price-tab">
<?php
$_tierPrices=$this->getTierPrices();
$_firstTier = array_slice($_tierPrices, 0, 3);
$c = count($_firstTier);
if($c>0): ?>
<ul class="tier-prices product-pricing">
<?php for ($i = 0; $i < $c; $i++) {
$_firstTierPrice = Mage::helper('core')->currency($_firstTier[$i]['price']); ?>
<li>
<input type="radio" name="tierprice" id="tier-price<?php echo $_firstTier[$i]['price_qty'] ?>" value="<?php echo $_firstTier[$i]['price_qty'] ?>" >
<?php echo $this->__('Buy %1$s for %2$s', $_firstTier[$i]['price_qty'],'<span class="price">'. $_firstTierPrice.'</span>').$this->__(' each Save extra '.$_firstTier[$i]['savePercent'].'%'); ?>
</li>
<?php } ?>
</ul>
<?php endif; ?> </div>
<?php
$_tierPricesqty=$this->getTierPrices();
$_firstTierqty = array_slice($_tierPricesqty, 0, 3);
$d = count($_firstTierqty);
if($d>0): ?>
<?php
for ($i = 0; $i < $d; $i++) {
$_firstTierPrice = Mage::helper('core')->currency($_firstTierqty[$i]['price']); ?>
<script type="text/javascript"> jQuery(function($){
$("#tier-price<?php echo $_firstTierqty[$i]['price_qty'] ?>").change(function() {
$('#qty').val(this.value);
//alert(<?php echo $_firstTierqty[$i]['price_qty'] ?>);
}); }); </script>
我将上面的代码放在mytheme / templates / catalog / product / view.phtml中的以下行代替
<div class="qty-wrapper">
<label for="qty"><?php echo $this->__('Enter Quantity:') ?></label>
<input type="text" name="qty" id="qty" maxlength="18" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /><span class="forinline">for</span>
</div>
和单选按钮层定价工作,但我无法修改此以获取下拉列表而不破坏上述代码的功能 .
有人可以帮助将其修改为下拉列表,我一直在尝试,但要么留下一个无效的下拉列表,要么从列表中遗漏了一些选项(上面的代码缺少100件) .
谢谢,Alexander Countey
1 回答
我没有Magento运行atm . 但我认为这样的事情应该有效:https://jsfiddle.net/f7m5mp40/