Community Forums

Hide empty Shopping cart at header

Free manual modifications can be contributed here. Modifications are manual snippets of code that are pasted into the forums for others to use.

Hide empty Shopping cart at header

Postby Vytenis » Mon Feb 06, 2012 1:20 pm

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:
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

Postby robster » Thu Mar 29, 2012 5:05 pm

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
I know my place...!
robster
 
Posts: 374
Joined: Tue Jul 13, 2010 12:08 pm

Re: Hide empty Shopping cart at header

Postby grduniam » Fri Apr 27, 2012 9:17 am

Thank you so much Vytenis! You're fantastic! Extremely useful!!!
User avatar
grduniam
 
Posts: 28
Joined: Wed Apr 11, 2012 11:26 am
Location: Tasmania

Re: Hide empty Shopping cart at header

Postby robster » Mon Aug 20, 2012 11:25 am

@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
I know my place...!
robster
 
Posts: 374
Joined: Tue Jul 13, 2010 12:08 pm

Re: Hide empty Shopping cart at header

Postby Allochtoon » Fri Dec 07, 2012 4:56 pm

I would like to know this as well :)

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

Postby OSWorX » Fri Dec 07, 2012 8:31 pm

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
User avatar
OSWorX
Global Moderator
 
Posts: 1926
Joined: Mon Jan 11, 2010 2:52 pm
Location: Austria

Re: Hide empty Shopping cart at header

Postby Allochtoon » Sat Dec 08, 2012 11:00 am

Thanks alot, works :)
Allochtoon
 
Posts: 3
Joined: Fri Sep 07, 2012 3:59 pm

Re: Hide empty Shopping cart at header

Postby olimax » Sun Dec 30, 2012 5:29 pm

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
User avatar
olimax
 
Posts: 77
Joined: Thu Dec 22, 2011 9:08 am
Location: Barcelona & London

Re: Hide empty Shopping cart at header

Postby OSWorX » Sun Dec 30, 2012 9:41 pm

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
User avatar
OSWorX
Global Moderator
 
Posts: 1926
Joined: Mon Jan 11, 2010 2:52 pm
Location: Austria

Re: Hide empty Shopping cart at header

Postby olimax » Sun Dec 30, 2012 10:18 pm

Absolutely.
I was rather thinking out load and then got distracted. I'll try and finish it later.
User avatar
olimax
 
Posts: 77
Joined: Thu Dec 22, 2011 9:08 am
Location: Barcelona & London

Re: Hide empty Shopping cart at header

Postby KonstantinG » Fri Feb 22, 2013 2:11 pm

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

Postby olimax » Tue Apr 09, 2013 8:12 am

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
Attachments
Hide_Empty_Shopping_Cart_olimod.xml
(1.38 KiB) Downloaded 19 times
User avatar
olimax
 
Posts: 77
Joined: Thu Dec 22, 2011 9:08 am
Location: Barcelona & London


Return to Modifications

Who is online

Users browsing this forum: midgette and 6 guests

Hosted by Arvixe Web Hosting