Get the remaining amount for free shipping

Posted: January 18, 2015 in How To?, Magento

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;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s