Forums / Templates, Stylesheets, Page Layout / Shopping cart totals on all pages?

Shopping cart totals on all pages?

Locked

Views: 1,379

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
31 Oct 2008, 1:40 PM
#1
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Shopping cart totals on all pages?

Hi All
I'm trying to display the cart totals in navmain on all pages. eg. Total Items: 1 Amount: £38.29. I can get it to work if I paste

<li class="cartTotalsDisplay important"> <?php echo $totalsDisplay; ?></li>

into the navmain div in tpl_header. But, it only appears on the shopping cart page. I'm guessing that $totalsDisplay isn't available in pages other than the shopping cart - is this correct?. How can I ensure it always appears in navmain on any page?

The site is here

NB you have to add something to the cart to get to the Shopping Cart page.
Thank you!, Steve

31 Oct 2008, 2:18 PM
#2
jarsa avatar

jarsa

New Zenner

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

Re: Shopping cart totals on all pages?

for number of items in cart:

<li><?php echo $_SESSION['cart']->count_contents() . HEADER_TITLE_CART_ITEMS; ?></li>
```for total amount in cart:

```html
<li><?php echo HEADER_TITLE_CART_AMOUNT . $currencies->format($_SESSION['cart']->show_total()); ?></li>
```These are not copied/pasted, so there might be mistakes. Hope this helps though.
31 Oct 2008, 4:05 PM
#3
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Re: Shopping cart totals on all pages?

Thanks jarsa

That almost worked but I needed to define HEADER_TITLE_CART_ITEMS and HEADER_TITLE_CART_AMOUNT. I used your suggestion with a slight modification. ie I added

<li><?php echo TEXT_TOTAL_ITEMS, $_SESSION['cart']->count_contents(); ?></li> <li><?php echo TEXT_TOTAL_AMOUNT, $currencies->format($_SESSION['cart']->show_total());

to the navmain section in tpl_header and then copy and pasted the definitions from shopping_cart.php to my custom english.php

define('TEXT_TOTAL_ITEMS', 'Total Items: ');
define('TEXT_TOTAL_AMOUNT', '  Amount: ')

Thanks for your help!

1 Nov 2008, 8:52 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Shopping cart totals on all pages?

There's a cart-contents addon in the Free Addons area which can be used as content for your header or as a sidebox. You might look at it for inspiration.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Nov 2008, 9:27 AM
#5
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Re: Shopping cart totals on all pages?

Thanks DrByte. Will do
Steve

23 Nov 2008, 10:41 PM
#6
hmmdinger avatar

hmmdinger

New Zenner

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

Re: Shopping cart totals on all pages?

Very helpful answer for pages within zen cart, but how would I go about displaying this information on pages on my website outside of the zencart folder?

I am putting ```

<p>Shopping Cart [ <?php echo $_SESSION['cart']->count_contents(), TEXT_TOTAL_ITEMS; ?> ]</p> ```

but this only outputs "Shopping Cart [", basically getting stuck at the php code.

What can I put in the code of these external pages to tell them where to find the zencart data/variables?

Thanks!

23 Nov 2008, 11:25 PM
#7
Kim avatar

Kim

Obaa-san

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

Re: Shopping cart totals on all pages?

Are your outside pages .php?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

24 Nov 2008, 5:20 AM
#8
hmmdinger avatar

hmmdinger

New Zenner

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

Re: Shopping cart totals on all pages?

Yes, they are all .php pages.