Skip to content

Instantly share code, notes, and snippets.

@codekipple
Created May 11, 2015 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codekipple/89862ec227e39541842b to your computer and use it in GitHub Desktop.
Save codekipple/89862ec227e39541842b to your computer and use it in GitHub Desktop.
<!-- SHOW SHIPPING RATES-->
<?php $quote = Mage::getModel('sales/quote');
$quote->getShippingAddress()->setCountryId('ES'); // Set your default shipping country here
$_product->getStockItem()->setUseConfigManageStock(false);
$_product->getStockItem()->setManageStock(false);
$quote->addProduct($_product);
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectTotals();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
// Find cheapest rate
$cheapestrate = null;
foreach ($rates as $rate) {
if (is_null($cheapestrate) || $rate->getPrice() < $cheapestrate) {
$cheapestrate = $rate->getPrice();
}
}
$corehelper = Mage::helper('core');
if ($cheapestrate) {
echo '<p><strong>Shipping costs:</strong> ' . $corehelper->currency($cheapestrate);?></p>
<?php
}else {
echo "<strong>Free shipping</strong> for this product." ;
}?>
<!-- END SHOW SHIPPING RATES-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment