'Empty basket' message for Basket side-bar

Jopho

Joined: 2010-11-27
Posts: 15
Posted: Thu, 2011-06-16 06:45

Hi All,

Has anyone tried to add a message to the Basket side-bar block, which appears only when the basket is empty, such as - "There are 0 items in your basket". Most big online shops have an 'empty basket' message somewhere on their pages.
It would be a small addition - probably just a few lines a code - to make the basket more user friendly.
I'm pretty much a php noob, but I figure the file to add code to would be - basket\views\basket-side-bar.html.php .
I had a stab at what the code might look like -
}
else {
?><p>
title="<?= t("There are 0 items in your basket")?>"
}
I tried this and similar lines, but they produced a blank webpage on my site!
Does anyone know if I'm on the right track here, and how to integrate with the existing code?
Any ideas would be appreciated.
Thanks.

 
jtenkate

Joined: 2010-12-06
Posts: 45
Posted: Thu, 2011-06-16 11:06

That's indeed how I did it:

  if (isset($basket) && isset($basket->contents) && ($basket->size() > 0)) {
    ?>
    <div id="sidebar-basket">
 Original code goes here
  }
  else {?>
    <div id="sidebar-basket">
      <?= t("Shopping Basket is Empty") ?>
    </div><?
  }

Let me know if you need more help.

Jeroen
www.kidsfotos.nl

 
dgfphoto99

Joined: 2009-04-15
Posts: 121
Posted: Thu, 2011-06-16 14:44

I have tried to add this and nothing seems to happen.

Where did you insert the code above?

Thanks

DGF

 
jtenkate

Joined: 2010-12-06
Posts: 45
Posted: Thu, 2011-06-16 14:59

My mistake: you just need to add the 'else'-part before the last curly bracket in file \views\basket-side-bar.html.php.

Jeroen

 
dgfphoto99

Joined: 2009-04-15
Posts: 121
Posted: Thu, 2011-06-16 17:01

I have tried this , although I am not sure where the esle statement goes. I get my page Ok but the sidebar disappears

DGF

 
Jopho

Joined: 2010-11-27
Posts: 15
Posted: Tue, 2011-06-21 02:47

Thanks Jeroen for your quick reply. I have it working now.
Plain text also works between the <div>.

DGF - the code goes between the last two } brackets at end of the original file.
- make sure you still have two }} at the end, - the final } to close the whole file.

else {
?><div id="sidebar-basket">
Shopping Basket is empty
</div><?
<!-- or use php code instead
<?= t("Shopping Basket is empty")?> -->
}

Chris
www.graphicscapes.com