I want to put a shipping cost on the actual product page in Magento, so customers can see how much it will cost them. I can add in the shipping estimator from the basket page. But all i actually want is a line of text under the product price saying shipping from £XX.XX
I have seen this tutorial: http://aneeshsreedharan.wordpress.com/2010/04/28/estimating-shipping-rate-on-product-details-page-in-magento/#comment-10 but it is not working for me on Magento 1.4.2 - i think this an older version is used on this tutorial.
I am using a weight based table rate shipping method at the moment, with only one option.
EDIT: I worked out the problem in the end: Rather embarrasingly I didnt realise the blog was stripping the formatting out. It was changing the ' to a ‘
I can now confirm the code below does display the shipping:
<?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)
{
echo $rate->getPrice();
}
}
?>
I worked out the problem in the end: Rather embarrasingly I didnt realise the blog was stripping the formatting out. It was changing the ' to a ‘
I can now confirm the code below does display shipping:
<?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)
{
echo $rate->getPrice();
}
}
?>
I have edited my original post - but to confirm the code above works.