Post by mike_jandreau » Sat Jul 31, 2010 9:39 pm

In the header of my theme, I've got the image of a shopping cart that is empty.

Is it possible to change that image to a full cart when a product has been added to the cart.

Ie;

Code: Select all

if products > 1 echo <div span="emptycart"></div>
else if products < 1 echo <div span="fullcart"></div>
Is something like that possible here? If so, how would I go about knowing whether or not the quantity of products is 1 or more?

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by JAY6390 » Mon Aug 02, 2010 8:18 am

Code: Select all

<img src="<?php $this->cart->hasProducts() ? 'image/image_full.png' : 'image/image_empty.png'; ?>" alt="shopping cart"/>
Hopefully you get the idea. You could use something more simplified if you really aren't sure

Code: Select all

<?php
if($this->cart->hasProducts()) {
?>
<img src="image/image_full.png" alt="full shopping cart" />
<?php } else { ?>

<img src="image/image_empty.png" alt="empty shopping cart" />
?>

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by mike_jandreau » Tue Aug 03, 2010 4:09 am

Thanks again Jay, that's exactly what I wanted.

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by JanneJanne » Tue Aug 03, 2010 5:13 am

Hi,
Could you tell me where to put to code? ... lol.
I tried it in the short_menu.tpl and ended up getting different kinds of error messages.

OpenCart to the Finnish Masses!


New member

Posts

Joined
Sat Jul 03, 2010 10:44 pm

Post by mike_jandreau » Tue Aug 03, 2010 7:13 pm

Janne,

It depends on where in your theme you're using the shopping cart image.

Mine was in my header - so /catalog/view/theme/YOURTHEMENAME/template/common/header.tpl

That could vary for you, because it depends on where in your theme you're showing that image.

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by JasonF » Tue Dec 06, 2011 2:19 am

Does anyone know how to get this working on 1.5.1.X?

I've tried both of the suggestions above but both are returning blank URL's for the image.

New member

Posts

Joined
Sat Oct 01, 2011 12:46 am

Post by JasonF » Mon Dec 12, 2011 4:19 am

Bump.

Any help please?

New member

Posts

Joined
Sat Oct 01, 2011 12:46 am
Who is online

Users browsing this forum: No registered users and 5 guests