2012-04-04 29 views
0

我有一堆magento产品的层定价设置,并且想要更改它们的显示方式。目前它只是说'购买1的X数量',这并不能很好地解释范围。无论如何要让它说'按照每个x的量买入1 - 9'。例如,我希望每个产品有大约5个层级。magento层定价购买x - x

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']); 
?> 

你将如何循环这个代码,以便它会影响所有层。

感谢

回答

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']); 
?> 
相关问题