0

I'd like to show a "Free Shipping" Incentive in the cart so that customers now that they have to add a certain amount to receive free shipping. I work my free shipping with table rates and not the free shipping module.

I found this script but unfortunately its not really working. Any idea how I can get something like this to work?

<?php if ($this->getQuote()->getSubtotal() < 100): ?>
<?php $subtotalamt = $this->getQuote()->getSubtotal(); ?>
<?php $freeshipamt = 100; ?>
<?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 ?>

It should read the Cart Total incl. tax and then just show the difference to the price I define.

Thanks

Edit: I inserted the script in /app/design/frontend/theme/default/checkout/cart_new.phtml (my cart template) and tried to get it working there. It should then show the sentence: "You are just $XXX,- away from earing free shipping!"

But unfortunately it is not showing anything at all.

  • 1
    Whats not really working about it? – John Cuthbert Jan 26 '16 at 12:09
  • Please edit the question and include: What are you trying (already done), what happens and what did you expect – Fabian Blechschmidt Jan 26 '16 at 12:50
  • Done, hope this is what you wanted to know. – Stefan Jan 26 '16 at 14:01
0

I think your quote object might not be loaded in that scope.

Try this (tested working magento 1.9.0.1);

<?php 
$quote = Mage::getSingleton('checkout/session')->getQuote();
if ($quote->getSubtotal() < 100):
$subtotalamt = $quote->getSubtotal();
$freeshipamt = 100;
$sumtotal = $freeshipamt - $subtotalamt;
Mage::helper('checkout')->formatPrice($sumtotal);?>
<p>You are just <span>$<?php print (number_format($sumtotal, 2, '.', '')); ?></span> 
away from earning free shipping!</p>
<?php endif ?>
  • Thanks for you help, but unfortunately it is still showing nothing. Not even the part in the <p>...</p>. – Stefan Jan 27 '16 at 13:21
  • Could you try it in /app/design/frontend/theme/default/checkout/cart.phtml? – Ricky Odin Matthews Jan 27 '16 at 13:22
  • Unfortunately my theme only uses the cart_new.phtml and not the cart.phtml. I tried cart.phtml but then the page doesn't work at all as there would be more customization need to get it too work. The cart_new.phtml file can be downloaded here: copy.com/noSdVaJ3uwWEp9kN – Stefan Jan 27 '16 at 13:47
  • Do you see anything if you do var_dump($quote); ? – Ricky Odin Matthews Feb 1 '16 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.