Post by ianmac » Fri Oct 09, 2009 5:31 am

Hi there

I hope you can help. I would like to display the number of Items
a user has in there basket in the header template. i.e. basket(3)

this there any way to do this.

thanks

mac

Newbie

Posts

Joined
Mon Oct 05, 2009 7:21 pm

Post by Qphoria » Fri Oct 09, 2009 5:36 am

Easy.

1. EDIT: catalog/view/theme/default/template/common/header.tpl
2. FIND:

Code: Select all

<?php echo $text_cart; ?>
3. REPLACE WITH:

Code: Select all

<?php echo $text_cart; ?> (<?php echo $this->cart->countProducts(); ?>)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ianmac » Fri Oct 09, 2009 5:41 am

Hi Qphoria

thats prefect

thanks very much

mac :)

Newbie

Posts

Joined
Mon Oct 05, 2009 7:21 pm

Post by harryo40 » Mon Oct 26, 2009 1:55 am

Hi,
I too would like to add this to the header just as i already have done but how do i get it to update instantly when something is added, just like it does in the cart module? Basically what i am trying to achieve is, moving the cart module in to my header & showing the total count of products just like you have explained here & it does work but it only updates when the page is refreshed or changed to another page. I am also trying to show the sub-total in the header too, with that also instantly updating without the need for refreshing or changing pages. All in all, i am trying to move the cart module to the header but only showing the product count & sub-total. I can do all of this but it does not update instantly when an item is added to cart!
I have seen another website that has achieved this which can be seen here : http://www.mygineration.co.uk/
this is something along the lines of what i am trying to achieve.
cheers
h

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by Qphoria » Mon Oct 26, 2009 4:16 am

Ah sorry.. i had the ajax add off. I see what you mean. I'll think about the best way to do that.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by harryo40 » Mon Oct 26, 2009 4:28 am

Thx for that & i am still messing with the code as we speak & will keep on working at it as the other website seems to have achieved this
cheers for your help ;)

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by harryo40 » Wed Oct 28, 2009 4:01 am

Still trying to work out how to get the cart to update in my header without refreshing the page :(
All i can think of is to somehow try & merge the cart.tpl in with the header.tpl but i'm struggling to get the 'controller' header.php & cart.php combined to work together. This is the only way i can think of to get the cart to update in my header unless somebody else out there knows how to achieve this ;) An example of this has been done on the website here: http://www.mygineration.co.uk/
Any suggestion / ideas / or anybody know how to do this?
If all else fails, i suppose i can contact the designers of the above site :(
cheers
h

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by Qphoria » Wed Oct 28, 2009 4:45 am

I looked at the code. Yes they just moved the cart module to the header.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by harryo40 » Wed Oct 28, 2009 5:03 am

Thts what i thought & so from there code but the problem i'm finding is merging the 'controller/common/header.php with the controller/module/cart.php' :-\
i've tried a few ways but keep getting different errors or the page just vanishes due to the merging of the 2 lots of php codes & i have also merged the header.tpl & cart.tpl & also the langauge files too but its not all that straight forward ???

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by Qphoria » Wed Oct 28, 2009 9:41 pm

Try to think outside the box :)

Instead of merging the elements known as header with cart.... instead change it so that the cart module is by itself above the header. Then remove the outer "box" so that only the insides are there

You will have to edit the layout.tpl file to add a conditional for that box like:

CHANGE:

Code: Select all

<div id="column_right">
    <?php foreach ($modules as $module) { ?>
    <?php if ($module['position'] == 'right') { ?>
    <?php echo ${$module['code']}; ?>
    <?php } ?>
    <?php } ?>
  </div>
TO:

Code: Select all

<div id="column_right">
    <?php foreach ($modules as $module) { ?>
    <?php if ($module['position'] == 'right' && $module['code'] != 'cart') { ?>
    <?php echo ${$module['code']}; ?>
    <?php } ?>
    <?php } ?>
  </div>
Then inside <div id="header"> area add:

Code: Select all

<?php foreach ($modules as $module) { ?>
<?php if ($module['code'] == 'cart') { ?>
<?php echo ${$module['code']}; ?>
<?php } ?>
<?php } ?>
You may still need to edit the code in the controller/module/cart.php callback() function as there is some html in there for the update code.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by harryo40 » Sat Oct 31, 2009 7:27 pm

Thx for getting back & ive nearly got this sorted so that the Ajax add to cart goes to my top right of the header & also the 'sub-total' updates as well as the product count but still a bit to work out yet. I have however noticed another problem which is, on the start page everything displays as it should but if i add an item to the cart then go to any other page, the '£' symbol is proceeded with a capital 'A' with a upside down 'v' above it but if i click the home link the '£' sign displays correctly? Ive looked in to the html & also on the web etc & some other forum says its to do with <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> being missing or something like that. Ive been through the code & found this in the index.php file:-
// Response
$response = new Response();
$response->addHeader('Content-Type', 'text/html; charset=UTF-8');
Registry::set('response', $response);
Dont know if it is anything to do with it or whats causing these characters to display before a '£' sign & im also going to get in touch with the hosts of our site to see if its anything to do with them but thought i would ask here 1st ;)
cheers
h

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by Noam Chomsky » Mon Sep 12, 2011 6:29 pm

Qphoria wrote:Try to think outside the box :)

Code: Select all

<?php foreach ($modules as $module) { ?>
<?php if ($module['code'] == 'cart') { ?>
<?php echo ${$module['code']}; ?>
<?php } ?>
<?php } ?>
Is it possible that this piece of code would work if placed in a div on a page of my own making that was hosted on the same server as opencart version 1.4.9.6? Specifically I'm thinking about this page: floathousebooks.com/addons.php and this opencart: floathousebooks.com/opencart/upload

Cheers! :)

Newbie

Posts

Joined
Mon Aug 29, 2011 11:21 pm
Who is online

Users browsing this forum: Amazon [Bot] and 3 guests