Blog

Magento: Display Amount Until Free Shipping

A client requested their Magento store display at checkout the amount customers need to purchase to qualify for free shipping. This is a quite useful feature that unfortunately Magento does not support out of the box. No worries, as we added it with just a bit of PHP in app/design/frontend/default/yourtheme/template/checkout/cart.phtml:

<?php if ($this->getQuote()->getSubtotal() < 50): ?>
<?php $subtotalamt = $this->getQuote()->getSubtotal(); ?>
<?php $freeshipamt = 50; ?>
<?php $sumtotal = $freeshipamt - $subtotalamt; ?>
<?php Mage::helper('checkout')->formatPrice($sumtotal); ?>
<p>You are just <span>$<?php print ($sumtotal); ?></span> 
away from earning free shipping!</p>
<?php endif ?>

10 Responses to Magento: Display Amount Until Free Shipping

  1. Jeremy says:

    How do we set this up so we can use this on our site header? I know some of the code needs to change, but not sure how to do this. Thanks for the advice!

  2. admin says:

    By “site header” do you mean the title tag that displays as the web browser’s window title?

  3. Paul says:

    How would you put this in the header.phtml file to display on all pages?

  4. admin says:

    Hi Paul, does calling $sumtotal from header.phtml not work? If not, I’d love to come up with a solution for your Magento theme. Just give me a call or email.

    Take care,
    Rob

    • Paul says:

      I was able to add this to the shopping cart. I want to know if there is a way to add a condition that checks sku numbers.

      I have a promotion that is running that I don’t want to show this code to. I want to use their sku numbers to identify which products to not show it on.

      If you go to drcolbert.com and add a product to your cart you will see what I added to the site’s shopping cart. Thanks in advance!

  5. sidlo says:

    Thanks a lot.
    Any can find this useful. Writes currency getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>

  6. Huzan says:

    Hey. This is exactly what I want. But suppose if someone has qualified for free shipping I would like to know a message “Your order qualifies for free shipping”. How can I have that?

  7. loeffel says:

    To display the price formatted and with currency code the line Mage::helper(‘checkout’)->formatPrice($sumtotal); needs to be expanded to actually assign this value to a variable.

  8. loeffel says:

    This is using subtotal value without tax.

    Use

    $totals = Mage::getSingleton(‘checkout/cart’)->getQuote()->getTotals();
    $subtotal = $totals[“subtotal”]->getValue();

    instead

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/svosolutions/public_html/blog/wp-content/plugins/sweetcaptcha-revolutionary-free-captcha-service/library/sweetcaptcha.php on line 81 Warning: fsockopen(): unable to connect to www.sweetcaptcha.com:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/svosolutions/public_html/blog/wp-content/plugins/sweetcaptcha-revolutionary-free-captcha-service/library/sweetcaptcha.php on line 81