Posts Tagged ‘Free Shipping’

How to get the remaining amount for free shipping?

On the checkout/cart.phtml add the following function and create a div to put the value.

function getRemainingAmount() {
      // Without TAX
      $total = Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal();

      // With TAX
      $totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals(); 
      $total = $totals["subtotal"]->getValue();  
     
     // From free shipping method 
     $minimum = Mage::getStoreConfig("carriers/freeshipping/free_shipping_subtotal");

     // From table rate free
     $tablerateColl = Mage::getResourceModel('shipping/carrier_tablerate_collection');
     $minimum = 0;
     foreach ($tablerateColl as $tablerate) {
           $line = $tablerate->getData();
           if ($line['price'] == 0) $minimum = $line['condition_value'];
     }

      // return <0 if already free
      // Format returned value using Mage::helper('checkout')->formatPrice(<remaining value>)
      return $minimum - $total;
}

If you offer Free Shipping to your customers, then you may have noticed that the default Shipping Methods are still displayed when the Free Shipping Method activates. This can be confusing for the shopper and they need another click to select the “Free Shipping” over the existing rates.

The following code will hide the other shipping methods from the shopping cart page, the default magento checkout and one page checkout.

The file you need to adjust is: app/ design/ frontend/ default/ YOURTEMPLATE/ template/ checkout/ onepage/ shipping_method/ available.phtml

Place the following code right before the <dl> tag that displays the different options.

<?php
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
$_shippingRateGroups = array('freeshipping' => $_shippingRateGroups['freeshipping']);
}
?>

You can even just unset specific Shipping Methods such as the “Flat Rate Method” using:

<?php
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
unset($_shippingRateGroups["flatrate"]);
}
?>