2012-04-04 30 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']); 
?> 
相關問題