我为一堆magento产品设置了套餐定价,并希望改变它们的显示方式。目前它只是说“为x量买1”并没有真正正确地解释范围。反正有没有说“购买1 - 9每个x金额”的说法。我希望每个产品大约有5层,例如。
Buy 10-19 for £3.32 each
Buy 20-49 for £2.99 each
Buy 50-99 for £2.39 each
Buy 100-199 for £2.39 each
Buy 200-299 for £2.39 each
请注意,这些数字会因产品而异。
我找到了一个回答的问题,解释了如何为第一层做得非常出色,但我需要这个才能在我的所有层面上工作。也许在一个循环中?
Magento grouped products label question
<?php
$_format = 'Buy %1$s for %2$s each';
if($index === count($_tierPrices) - 1)
{
$_format = 'Buy %1$s+ for %2$s each';
}
else
{
$_next = $_tierPrices[$index + 1];
$_qty = $_next['price_qty'] - 1;
if($_qty > 0) $_format = 'Buy %1$s-' . $_qty . ' for %2$s each';
}
echo $this->__($_format, $_price['price_qty'], $_price['formated_price']);
?>
如何循环此代码以使其影响所有层。
由于
答案 0 :(得分:1)
简单修复
<?php
$_format = 'Buy %1$s for %2$s each';
if($index === count($_tierPrices) - 1)
{
$_format = 'Buy %1$s+ for %2$s each';
}
else
{
$i = $i + 1;
$_next = $_tierPrices[$index + $i];
$_qty = $_next['price_qty'] -1;
if($_qty > 0) $_format = 'Buy %1$s-' . $_qty . ' for %2$s each';
}
echo $this->__($_format, $_price['price_qty'], $_price['formated_price']);
?>