【发布时间】:2011-05-14 19:21:27
【问题描述】:
我正在尝试在 Magento 的产品页面上显示运费。我已经设法通过使用 php 来回显运费来做到这一点。但是,我现在为某些商品提供免费送货服务,并且在这些产品上,我得到了与免费送货价格相呼应的免费送货价格和另一个看起来错误的送货价格。
当一个产品有免费送货时,如何才能只呼应,而其他一切都呼应正常价格?
我已经设法通过使用以下代码来呼应免费送货规则:
<?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());
}
?>
但这仍然显示其他运费。如何停止显示其他价格?
【问题讨论】: