Add XX to Cart for Free Shipping – Magento

Create Apple's style of Add XX to your order and get Free Shipping

In Magento you can do the same in the checkout page. With the snippet below you can retrieve the free delivery amount value from the admin, convert it to the actual currency and do the math.

It's important to convert the currency so the user can switch between EUR, USD or whatever currency you might have active.

Also notice that my input currency is EUR, your might be different depending on the admin configuration.

app/design/frontend/[Your Theme]/template/checkout/cart.phtml

You can either show this on the cart or in the detail page. You could use $_product->getPrice() to retrieve the product price.

Tip

Enable the Magento Path Hints ๐Ÿ˜‰

26 comments
  • Thanks for the Post, thanks for your useful Post. I will come back later !Thanks for the Post, thanks for your useful Post. I will come back later !

  • i think it’d better to use

    $this->__(‘some texts’);

    instead of just echo directly, it comforts you on translation later.

  • Hi, what about when working with multiple currencies? if I set the amount to 100, it will be 100 for $, โ‚ฌ and ยฃ. I’m sure working with some code from the currencies.php should be the answer

    thanks for the comments

  • Do you know how I can get the subtotal inlcuding tax?.
    He is now doing the calculation based on the non tax amount wich is not correct.

    I tried getSubtotalInclTax but that doesn’t work

    Thanks for your help
    Sander

    • Hi Sander,

      Try this and let’s see what it returns ๐Ÿ™‚

      [code]
      $totals = $this->getQuote()->getTotals();
      $subtotal = $totals["subtotal"]->getValue();

      // print everything

      print_r($totals);

      [/code]

  • Thanks Rick, Sorry but where do I need to put this? Below Subtotal?

  • I only get errors when doing this ๐Ÿ™‚

  • Sorry Rick but I am not sure what to do. So this is the code I use now

    [code]<?php $free_delivery=100-$this->getQuote()->getSubtotal();
    if ($free_delivery<0){
    echo "This Cart has Free Shipping!";
    }else{
    echo "Bestel nog ".Mage::helper(‘checkout’)->formatPrice($free_delivery)." aan producten en wij verzenden uw producten gratis";
    }
    ?>[/code]

    do you mean doing something like this?

    [code]<?php $free_delivery=100-$this->getQuote()->getSubtotal();
    $totals = $this->getQuote()->getTotals();
    $subtotal = $totals["subtotal"]->getValue();

    // print everything

    print_r($totals);

    if ($free_delivery<0){
    echo "This Cart has Free Shipping!";
    }else{
    echo "Bestel nog ".Mage::helper(‘checkout’)->formatPrice($free_delivery)." aan producten en wij verzenden uw producten gratis";
    }
    ?>[/code]

  • I again, thank you for clarifying the tax issue.

    Back to the currency thing, anyone got an idea on how to make it work with more currencies? the problem I stated a few comments above is still there.

    thanks

  • Hmm maybe thats my problem. If I put in 100 for free shipping is that then in dollars? Can not understand why my calculation is incorrect.

  • Jeej I just solved it by adding the 19% tax manually

    [code]
    <?php $free_delivery=100-$this->getQuote()->getSubtotal()*1.19;

    if ($free_delivery<0){
    echo "This Cart has Free Shipping!";
    }else{
    echo "Bestel nog ".Mage::helper(‘checkout’)->formatPrice($free_delivery)." aan producten en wij verzenden uw producten gratis";
    }
    ?>
    [/code]

  • Hi,

    had this Topic today…

    width this Snippet you can get the amount from the Freeshipping-Modul in the Backend

    [code]
    <?php
    $freeshipping_data = floatval(Mage::getStoreConfig(‘carriers/freeshipping/free_shipping_subtotal’));
    ?>
    [/code]

    [code]
    <?php
    $freeshipping_data = floatval(Mage::getStoreConfig(‘carriers/freeshipping/free_shipping_subtotal’));

    $free_delivery=$freeshipping_data-$this->getQuote()->getSubtotal()*1.19;

    if ($free_delivery<0){
    echo "This Cart has Free Shipping!";
    }else{
    echo "Bestel nog ".Mage::helper(‘checkout’)->formatPrice($free_delivery)." aan producten en wij verzenden uw producten gratis";
    }
    ?>
    [/code]

    • Ok, this code takes the free shipping amount from backend, but it takes it as amount and is still not respecting the currencies. If I havee free shipping from 100 Euro and change currency to USD, it won’t show the free shipping from 132$ (if 100โ‚ฌ = 132$) but from 100$.
      So by now, what I am doing is showing it only for the main currency I use, which is Euro. I inserted this line on the top of your snippet:
      [code]if(Mage::app()->getStore()->getCurrentCurrencyCode() == "EUR") { // show only if currency is EUR [/code]

    • Hi guys,

      I just wanted to let you know I’ve updated the post above with a better solution. It now converts the currency! ๐Ÿ˜‰

      Cheers.

  • Hi,
    I am new on magento
    I am using magento 1.5 and free-shipping option
    is there a way to set the delivery date to +1 day
    that means if a client buy today it can only select a date from tomorow.

    thank you in advance for the answer.

  • Hi all, I am back ๐Ÿ™‚ I just found out that he is getting the wrong amount. If you have any discount on your products he doesn’t use them.

    Is there a way to get the Grandtotal including discount and tax?

  • Hi all,

    I’m from german, we have 2 Tax 19% and 7% tax, how can I change that in PHP code?

    Regards

    • Hi Alex,

      I guess it depens on the client, right?

      You need to use diffent customer types and assing each Tax type.

      You can do it all using the Admin.

      Let me know how it goes.

      Rick

  • More easier solution for users without free shipping module:

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*