Hide empty Shopping cart at header
12 posts
• Page 1 of 1
Hide empty Shopping cart at header
Hi there,
Don`t know if you think it is useful or not, how ever for me it seems that I disturb my visitors with unneeded information. One of the pieces that disturbs people is at header visible Shopping Cart basket, when it is empty. So I made a small modification which changes header.tpl from your common folder and makes the cart visible only when you have added some stuff into your basket.
Demo at http://www.crafts-eu.com and now the modifications:
Open the header.tpl from your catalog/view/theme/*/template/common
Find then "<div id="cart">"
Before it add:
(it might be enough just to use countProducts at if statement, how ever I use this variable at some more checks)
afterwards find where the block ends and close the if statement.
Complete code at my case for a whole block looks like:
Hope it helps for somebody
Don`t know if you think it is useful or not, how ever for me it seems that I disturb my visitors with unneeded information. One of the pieces that disturbs people is at header visible Shopping Cart basket, when it is empty. So I made a small modification which changes header.tpl from your common folder and makes the cart visible only when you have added some stuff into your basket.
Demo at http://www.crafts-eu.com and now the modifications:
Open the header.tpl from your catalog/view/theme/*/template/common
Find then "<div id="cart">"
Before it add:
- Code: Select all
<?php $produktu_skaicius = $this->cart->countProducts();
if ($produktu_skaicius > 0) { ?>
(it might be enough just to use countProducts at if statement, how ever I use this variable at some more checks)
afterwards find where the block ends and close the if statement.
Complete code at my case for a whole block looks like:
- Code: Select all
<?php $produktu_skaicius = $this->cart->countProducts();
if ($produktu_skaicius > 0) { ?>
<div id="cart">
<div class="heading">
<h4> <?php echo $text_cart; ?> </h4>
<a><span id="cart_total"> <?php echo $text_items; ?></span></a></div>
<div class="content"></div>
</div>;
<?php } ?>
Hope it helps for somebody

- Vytenis
- Posts: 40
- Joined: Sun Jul 31, 2011 5:33 pm
Re: Hide empty Shopping cart at header
Thank you so much for this. It is exactly what I am looking for. I can't believe that you were also thinking of this.
All the best
Rob
All the best
Rob
I know my place...!
- robster
- Posts: 374
- Joined: Tue Jul 13, 2010 12:08 pm
Re: Hide empty Shopping cart at header
Thank you so much Vytenis! You're fantastic! Extremely useful!!!
-

grduniam - Posts: 28
- Joined: Wed Apr 11, 2012 11:26 am
- Location: Tasmania
Re: Hide empty Shopping cart at header
@blackhalo
Can you suggest how to implement this page reload code on 1.5.3.1 and 1.5.4.1 as this line of code doesn't exist in these later versions.
Cheers
Robster
Can you suggest how to implement this page reload code on 1.5.3.1 and 1.5.4.1 as this line of code doesn't exist in these later versions.
Cheers
Robster
I know my place...!
- robster
- Posts: 374
- Joined: Tue Jul 13, 2010 12:08 pm
Re: Hide empty Shopping cart at header
I would like to know this as well 
1.5.3.1 and or 1.5.4.1

1.5.3.1 and or 1.5.4.1
- Allochtoon
- Posts: 3
- Joined: Fri Sep 07, 2012 3:59 pm
Re: Hide empty Shopping cart at header
Allochtoon wrote:I would like to know this as well
1.5.3.1 and or 1.5.4.1
For 1.5.4.1 (should be also working for earlier versions of 1.5.x):
search for:
- Code: Select all
<?php echo $cart; ?>
and repace it by:
- Code: Select all
<?php if( $this->cart->countProducts() > 0 ) { ?>
<?php echo $cart; ?>
<?php
} ?>
Or same effect, but simplier code (because only 1 line):
- Code: Select all
<?php echo ( $this->cart->countProducts() > 0 ) ? $cart : ''; ?>
Or - if you do not want to edit files, use this VQMod-file: http://osworx.net/en/downloads/cat_view ... qmod-files
EU-Buttonlösung EU-Cookies OpenCart Rechtskonform
LiveSupport (Chat) Deutsches OpenCart / OCIE Forum
http://osworx.net :: Installation & Update Services for OpenCart, Custom Development
Common modules - Payment modules - Shipping modules - Dt. Sprachpaket
LiveSupport (Chat) Deutsches OpenCart / OCIE Forum
http://osworx.net :: Installation & Update Services for OpenCart, Custom Development
Common modules - Payment modules - Shipping modules - Dt. Sprachpaket
-

OSWorX - Global Moderator
- Posts: 1926
- Joined: Mon Jan 11, 2010 2:52 pm
- Location: Austria
Re: Hide empty Shopping cart at header
Thanks alot, works 

- Allochtoon
- Posts: 3
- Joined: Fri Sep 07, 2012 3:59 pm
Re: Hide empty Shopping cart at header
trouble is it doesnt then immediately reappear when cart added to via ajax
It may be better to hide it with css and then easier to display when required
It may be better to hide it with css and then easier to display when required
-

olimax - Posts: 77
- Joined: Thu Dec 22, 2011 9:08 am
- Location: Barcelona & London
Re: Hide empty Shopping cart at header
olimax wrote:trouble is it doesnt then immediately reappear when cart added to via ajax
It may be better to hide it with css and then easier to display when required
Fine .. it is up to you to post the code for this.
EU-Buttonlösung EU-Cookies OpenCart Rechtskonform
LiveSupport (Chat) Deutsches OpenCart / OCIE Forum
http://osworx.net :: Installation & Update Services for OpenCart, Custom Development
Common modules - Payment modules - Shipping modules - Dt. Sprachpaket
LiveSupport (Chat) Deutsches OpenCart / OCIE Forum
http://osworx.net :: Installation & Update Services for OpenCart, Custom Development
Common modules - Payment modules - Shipping modules - Dt. Sprachpaket
-

OSWorX - Global Moderator
- Posts: 1926
- Joined: Mon Jan 11, 2010 2:52 pm
- Location: Austria
Re: Hide empty Shopping cart at header
Absolutely.
I was rather thinking out load and then got distracted. I'll try and finish it later.
I was rather thinking out load and then got distracted. I'll try and finish it later.
-

olimax - Posts: 77
- Joined: Thu Dec 22, 2011 9:08 am
- Location: Barcelona & London
Re: Hide empty Shopping cart at header
It works for Opencart 1.5.5.1 - thanks a lot !
- KonstantinG
- Posts: 8
- Joined: Sun Jun 10, 2012 3:46 pm
Re: Hide empty Shopping cart at header
I've done a version of this using jquery so it appears when added to and hides if you empty it
It's a bit of a hack but seems to work though I haven't tested it extensively
1.5.2.1
It's a bit of a hack but seems to work though I haven't tested it extensively
1.5.2.1
- Attachments
-
Hide_Empty_Shopping_Cart_olimod.xml- (1.38 KiB) Downloaded 19 times
-

olimax - Posts: 77
- Joined: Thu Dec 22, 2011 9:08 am
- Location: Barcelona & London
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: midgette and 6 guests













