How can i echo alternate message depending on items within a php foreach loop

Freddo

New Member
I am trying to display shipping prices on a product page in Magento. I have managed to do this by using php to echo the shipping prices. However, i am now offering free shipping on certain items and on these products i am getting the free shipping price echoed and another shipping price which looks wrong. How can echo only free shipping when a product has it, and for everything else echo the normal price?I have managed to just echo out the free shipping rule by using the following code:\[code\] <?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
 
Back
Top