Zen Cart Logo
Forums / General Questions / Shopping cart in header

Shopping cart in header

Locked

Views: 12,012

Results 1 to 20 of 26
This thread is locked. New replies are disabled.
29 May 2006, 10:04 PM
#1
shopyoungway avatar

shopyoungway

New Zenner

Join Date:
Jul 2005
Posts:
53
Plugin Contributions:
0

Shopping cart in header

help i have searched every piece in the forum and found nothing on adding the shopping cart in the header. i know it can be done with 1.3 because i have seen it done can anyone help me with this.

30 May 2006, 3:54 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,617
Plugin Contributions:
0

Re: Shopping cart in header

<?php
    if (SHOW_TOTALS_IN_CART == '0') {
      echo TEXT_TOTAL_ITEMS . '  ' . $_SESSION['cart']->count_contents() . '    ' . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
    } 
?>
30 May 2006, 4:22 AM
#3
shopyoungway avatar

shopyoungway

New Zenner

Join Date:
Jul 2005
Posts:
53
Plugin Contributions:
0

Re: Shopping cart in header

thank you kim you rock that is why i needed

12 Jun 2006, 4:45 PM
#4
lbrown avatar

lbrown

New Zenner

Join Date:
Oct 2005
Posts:
16
Plugin Contributions:
0

Re: Shopping cart in header

I tried adding the lines above to tpl.header.php but the cart total is not showing in the header. Do I need to do anything else?

thank you,

lbrown

12 Jun 2006, 6:20 PM
#5
businesstoweb avatar

businesstoweb

New Zenner

Join Date:
Jun 2006
Posts:
39
Plugin Contributions:
0

Re: Shopping cart in header

Hi,

I changed a few bits and use this code.

tpl_header ->

<?php if ($_SESSION['cart']->count_contents() > 0) { $products = $_SESSION['cart']->get_products(); echo '<p><a href="/index.php?main_page=shopping_cart">' . $_SESSION['cart']->count_contents().' Item(s) - Total: £'; echo $currencies->format($_SESSION['cart']->show_total()); } if ($_SESSION['cart']->count_contents() == 0) { $products = $_SESSION['cart']->get_products(); echo '<p><a href="/index.php?main_page=shopping_cart"> Item(s) £0.00'; } ?></a></p>

Hope this helps. :thumbsup:

16 Jan 2007, 3:29 PM
#6
sparklefish avatar

sparklefish

New Zenner

Join Date:
Oct 2006
Location:
Scotland
Posts:
53
Plugin Contributions:
0

Re: Shopping cart in header

Kims' code does work but only if you have set your admin settings (configuration>layout settings>Shopping Cart (show totals) to 0, ie OFF. You can easily change this by removing the IF statement altogether so the basket summary always shows in the header OR change the code to read

<?php if (SHOW_TOTALS_IN_CART != '0') { echo TEXT_TOTAL_ITEMS . '  ' . $_SESSION['cart']->count_contents() . '    ' . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total()); } ?>
1 Feb 2007, 12:00 AM
#7
jaz1974 avatar

jaz1974

New Zenner

Join Date:
Aug 2006
Posts:
66
Plugin Contributions:
0

Re: Shopping cart in header

Ok - Im going to show how little I know about this stuff....

Where should I paste this code in order to show the cart summary in my header section ?

Help would be a life saver !

Jaz

7 Feb 2007, 1:41 PM
#8
sparklefish avatar

sparklefish

New Zenner

Join Date:
Oct 2006
Location:
Scotland
Posts:
53
Plugin Contributions:
0

Re: Shopping cart in header

You should update the file includes/templates/template_default/common/tpl_header.php and place in your override directory (ie includes/templates/yourOverrideDirectory/common).

7 Feb 2007, 5:30 PM
#9
jaz1974 avatar

jaz1974

New Zenner

Join Date:
Aug 2006
Posts:
66
Plugin Contributions:
0

Re: Shopping cart in header

thanks sparkle

9 May 2007, 8:56 AM
#10
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: Shopping cart in header

Hey everyone,

I am only getting the total number of different products in the cart. Although, many of my products are quantity based. Is there a way to edit the total number to be of quantity products, and not just products??

thanks in advance.

<li>My Cart: <span class="style1">
	<?php echo sizeof($_SESSION['cart']->get_products()); ?>  items  
 	<?php $header_cart = $currencies->format($_SESSION['cart']->show_total());  
	echo $header_cart;
	?>
</span>
<br class="clearBoth" />
</li>
15 Jun 2007, 9:37 PM
#11
vik007 avatar

vik007

Zen Follower

Join Date:
Feb 2007
Posts:
201
Plugin Contributions:
0

Re: Shopping cart in header

**Hi guys...a totally newbie here...

And getting a little confused with all the different methods..

What files do i need to edit and with what and also where to find them please :oops:

any help will be good.

if possible the art should be in the header and shop - number of Items and Total in cart and link to checkout

thanxs
**

19 Aug 2008, 7:41 AM
#12
scubyfan avatar

scubyfan

New Zenner

Join Date:
Aug 2008
Posts:
2
Plugin Contributions:
0

Re: Shopping cart in header

businesstoweb:

Hi,

I changed a few bits and use this code.

tpl_header ->

<?php if ($_SESSION['cart']->count_contents() > 0) { $products = $_SESSION['cart']->get_products(); echo '<p><a href="/index.php?main_page=shopping_cart">' . $_SESSION['cart']->count_contents().' Item(s) - Total: £'; echo $currencies->format($_SESSION['cart']->show_total()); } if ($_SESSION['cart']->count_contents() == 0) { $products = $_SESSION['cart']->get_products(); echo '<p><a href="/index.php?main_page=shopping_cart"> Item(s) £0.00'; } ?></a></p>

Hope this helps. :thumbsup:

Works perfect, mate! I added a bit of code to make it a little more precise. ;)

<?php if ($_SESSION['cart']->count_contents() > 1) { $products = $_SESSION['cart']->get_products(); echo '' . $_SESSION['cart']->count_contents().' Items - '; echo $currencies->format($_SESSION['cart']->show_total()); } if ($_SESSION['cart']->count_contents() == 1) { $products = $_SESSION['cart']->get_products(); echo '' . $_SESSION['cart']->count_contents().' Item - '; echo $currencies->format($_SESSION['cart']->show_total()); } if ($_SESSION['cart']->count_contents() == 0) { $products = $_SESSION['cart']->get_products(); echo 'Your Cart is Empty!'; } ?>

Basically if there is one item, it now just says "1 item" and if there's more than one it says "2 (or however many) items"

Useless change, really, but I'm a stickler! :P

By the way, I put mine in the main template, since I'm not using the header at all.

26 Aug 2008, 4:08 AM
#13
peeptoe avatar

peeptoe

New Zenner

Join Date:
Aug 2008
Posts:
14
Plugin Contributions:
0

Re: Shopping cart in header

pensive612:

Hey everyone,

I am only getting the total number of different products in the cart. Although, many of my products are quantity based. Is there a way to edit the total number to be of quantity products, and not just products??

thanks in advance.

<li>My Cart: <span class="style1"> <?php echo sizeof($_SESSION['cart']->get_products()); ?>  items   <?php $header_cart = $currencies->format($_SESSION['cart']->show_total()); echo $header_cart; ?> </span> <br class="clearBoth" /> </li> ```

I used the code above to add the shopping cart to my header(http://dropyourdrawers.net/shop), how do I get it to move all the way to the right of the header? I've been playing around with it for an hour and can't figure it out. Thank you!

15 Sep 2008, 4:42 PM
#14
pet_herbal_remedies avatar

pet_herbal_remedies

Zen Follower

Join Date:
Aug 2008
Posts:
162
Plugin Contributions:
0

Re: Shopping cart in header

Can someone please advise where in the code I put this new code? Do I replace code or do I add it and where?

Much much appreciated :smile:,
Lynn

http://www.PetHerbalRemedies.com

21 Oct 2008, 11:02 AM
#15
jarsa avatar

jarsa

New Zenner

Join Date:
May 2006
Posts:
45
Plugin Contributions:
0

Re: Shopping cart in header

Hi Lynn,

put following code or some of the earlier examples to your template_header.php. If you want your cart to be for example inside navCatTabsWrapper, then put this code inside those divs and just under the navCatTabs closing div. Or you can put it anywhere you like.

<div id="headerCart">

    <ul class="hCart">

      <li><?php echo $_SESSION['cart']->count_contents() . HEADER_TITLE_CART_ITEMS ;?></li>

      <li><?php echo HEADER_TITLE_CART_AMOUNT . $currencies->format($_SESSION['cart']->show_total());?></li>

      <li class="cartLink"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>

    </ul>

    </div>

If you are using code above, you have to define those TEXTs in languages/english/your_template/header.php.

Depending of where you put your code, you need to use css to float new #headerCart div to its place. And if above code is used, css also needs this

#headerCart ul li{

display: inline;

}
to show list inline.

22 Nov 2008, 1:20 AM
#16
1kell avatar

1kell

Zen Follower

Join Date:
Jul 2008
Posts:
151
Plugin Contributions:
0

Re: Shopping cart in header

Is this right? I have this code in my header:

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
<li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?>
<?php if (!empty($totalsDisplay)) { ?> <div class="cartTotalsDisplay important"><?php echo $totalsDisplay; ?></div> <br class="clearBoth" /> <?php } ?>

</a></li>
<li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>

<?php }?> </ul> </div>

It seems to be working. Only I want to remove the "Weight" and "Check Out" options from the header. I just want the Shopping Cart, Total Items, and Price. What and how should I blankout the other two?

22 Nov 2008, 1:23 AM
#17
1kell avatar

1kell

Zen Follower

Join Date:
Jul 2008
Posts:
151
Plugin Contributions:
0

Re: Shopping cart in header

Actually its still not quite working right. When I add products to the cart, it show in the header the quantity, price etc, but when I click on "continue shopping" all of that info dissappears except for the "Shopping Cart" link.:huh:

12 Mar 2009, 1:41 PM
#18
barricades avatar

barricades

Inactive

Join Date:
May 2007
Posts:
150
Plugin Contributions:
0

Re: Shopping cart in header

pensive612:

Hey everyone,

I am only getting the total number of different products in the cart. Although, many of my products are quantity based. Is there a way to edit the total number to be of quantity products, and not just products??

thanks in advance.

<li>My Cart: <span class="style1"> <?php echo sizeof($_SESSION['cart']->get_products()); ?>  items   <?php $header_cart = $currencies->format($_SESSION['cart']->show_total()); echo $header_cart; ?> </span> <br class="clearBoth" /> </li> ```

Hi there, sorry to drag this old thread up but I have the "shopping cart total in header" mod - which is just the bit of code in the above post - installed and I'm having the same problem that if you add 2 of one kind of a product it gives the total as 1 rather than 2. In otherwords it counts the number of different types of product inthe cart rather than the number of items.

Does anyone know how to fix this?

cheers

heres the cart - https://www.babyclothingcentral.co.uk

12 Mar 2009, 6:54 PM
#19
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Shopping cart in header

The code by scubyfan, post #12 gives you number of Items, not number of Products.

Hats Off to scubyfan for sharing. :smile:

6 Apr 2009, 9:34 PM
#20
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Shopping cart in header

Good stuff scubyfan. Thank you.

Did anybody manage to add a little shopping cart image to this code? I would like the cart to be clickable, just like the text link. Any input would be appreciated.