Add XX to Cart for Free Shipping – Magento
Create Apple’s style of Add XX to your order and get Free Shipping

Paste the following code where you want to add the code.
I would suggest something like:
app/design/frontend/[Your Theme]/template/checkout/cart.phtml
// Change the 290 with your own value
<?php $free_delivery=290-$this->getQuote()->getSubtotal();
if ($free_delivery<0){
echo "This Cart has Free Shipping!";
}else{
echo "Add ".Mage::helper('checkout')->formatPrice($free_delivery)."and you will have Free Shipping";
}
?>
<?php $free_delivery=290-$this->getQuote()->getSubtotal();
if ($free_delivery<0){
echo "This Cart has Free Shipping!";
}else{
echo "Add ".Mage::helper('checkout')->formatPrice($free_delivery)."and you will have Free Shipping";
}
?>
Tip
Related PostsIf you liked Add XX to Cart for Free Shipping – Magento; the posts below might interest you too:
|




July 20, 2011
08:47
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 !
November 15, 2011
03:20
i think it’d better to use
$this->__(‘some texts’);
instead of just echo directly, it comforts you on translation later.
December 31, 2011
16:57
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
December 31, 2011
17:19
Sorry, that was working perfectly well, indeed!
thank you very much for your contribution.
Now I’m trying to display it now on header.
January 5, 2012
15:21
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
January 5, 2012
16:15
Hi Sander,
Try this and let’s see what it returns
January 5, 2012
16:17
Thanks Rick, Sorry but where do I need to put this? Below Subtotal?
January 5, 2012
20:30
In the same place you put the other code.
January 5, 2012
21:56
I only get errors when doing this
January 5, 2012
22:20
The new code I posted?
What does it says?
January 5, 2012
22:37
Sorry Rick but I am not sure what to do. So this is the code I use now
<?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"; } ?>do you mean doing something like this?
<?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"; } ?>January 5, 2012
23:48
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
January 6, 2012
08:05
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.
January 6, 2012
09:19
Jeej I just solved it by adding the 19% tax manually
<?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"; } ?>January 6, 2012
12:07
Well, I’m glad it worked out!
January 27, 2012
02:06
Hi,
had this Topic today…
width this Snippet you can get the amount from the Freeshipping-Modul in the Backend
<?php $freeshipping_data = floatval(Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal')); ?><?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"; } ?>January 28, 2012
18:36
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:
if(Mage::app()->getStore()->getCurrentCurrencyCode() == "EUR") { // show only if currency is EURFebruary 3, 2012
14:13
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.
February 3, 2012
15:34
Hi Peter, I’m not sure what your question is.
Regards
April 28, 2012
22:32
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?