Post by Vytenis » Mon Feb 06, 2012 9: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 ;)

New member

Posts

Joined
Mon Aug 01, 2011 1:33 am

Post by robster » Fri Mar 30, 2012 1:05 am

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...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

User avatar
New member

Posts

Joined
Wed Apr 11, 2012 7:26 pm
Location - Tasmania

Post by robster » Mon Aug 20, 2012 7:25 pm

@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...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by Allochtoon » Sat Dec 08, 2012 12:56 am

I would like to know this as well :)

1.5.3.1 and or 1.5.4.1

Newbie

Posts

Joined
Fri Sep 07, 2012 11:59 pm

Post by OSWorX » Sat Dec 08, 2012 4:31 am

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

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Allochtoon » Sat Dec 08, 2012 7:00 pm

Thanks alot, works :)

Newbie

Posts

Joined
Fri Sep 07, 2012 11:59 pm

Post by olimax » Mon Dec 31, 2012 1:29 am

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
New member

Posts

Joined
Thu Dec 22, 2011 5:08 pm
Location - Barcelona & London

Post by OSWorX » Mon Dec 31, 2012 5:41 am

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.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by olimax » Mon Dec 31, 2012 6:18 am

Absolutely.
I was rather thinking out load and then got distracted. I'll try and finish it later.

User avatar
New member

Posts

Joined
Thu Dec 22, 2011 5:08 pm
Location - Barcelona & London

Post by KonstantinG » Fri Feb 22, 2013 10:11 pm

It works for Opencart 1.5.5.1 - thanks a lot !

Newbie

Posts

Joined
Sun Jun 10, 2012 11:46 pm

Post by olimax » Tue Apr 09, 2013 4:12 pm

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


User avatar
New member

Posts

Joined
Thu Dec 22, 2011 5:08 pm
Location - Barcelona & London
Who is online

Users browsing this forum: No registered users and 2 guests