我試圖在Magento的產品頁面上顯示運費價格。我設法通過使用PHP來回應運費價格。但是,我現在提供免費送貨上某些項目和這些產品我得到的免費送貨價格回聲和另一個運費價格看起來不對。我如何根據php foreach循環中的項目回顯備用郵件
如何回聲只有當產品有它的免費送貨,其他一切迴應正常價格?
我設法只是呼應了通過使用下面的代碼的免費送貨規則:
<?php
if($_product->isSaleable())
{
$quote = Mage::getModel('sales/quote');
$quote->getShippingAddress()->setCountryId('*');
$quote->addProduct($_product);
$quote->getShippingAddress()->collectTotals();
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectShippingRates();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
foreach ($rates as $rate)
if ($rate->getPrice(0.00))
{
echo ('This item qualifies for FREE shipping');
}
else
echo ('Shipping from £' . $rate->getPrice());
}
?>
但這仍顯示其他貨運價格。我怎樣才能阻止其他價格顯示?
太好了 - 非常感謝。完美的作品。 – 2011-05-15 09:49:50