Site maintenance: Tuesday 17 Nov, from 10:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / General Questions / Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Started by rlexyd on 8 Aug 2021, 4:36 AM · Views: 1,081

Results 1 to 7 of 7
8 Aug 2021, 4:36 AM
#1
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
496
Plugin Contributions:
0

Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Hi,
I've looked everywhere and only seem to find very old post for much older versions of zc.
I'm running 1.5.7c with PHP 7.3 and OPC using Responsive Classic Template.
I would like to display the (Number of items in Cart) in the Shopping Cart Icon Header and I would like the shopping Cart Icon to display in the Header Always, even when nothing is in it.
I'm sure this can be done I just need help with it.
(Also, how to get the Icon also to always display in the header on mobile view, even without items in cart.)

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!

13 Aug 2021, 6:13 PM
#2
carbonless avatar

carbonless

Zen Follower

Join Date:
Jan 2007
Location:
Illinois, USA
Posts:
329
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

I am using the responsive classic design with ZCA bootstrap colors. The header bar is dynamic and displays the shopping cart as a fixed bar when users scroll. Do you have any error logs being generated?

NTO: building a better network thru collaboration
www.needtoorder.com | www.coffeewitheinstein.com

13 Aug 2021, 11:34 PM
#3
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
496
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Carbonless:

I am using the responsive classic design with ZCA bootstrap colors. The header bar is dynamic and displays the shopping cart as a fixed bar when users scroll. Do you have any error logs being generated?

Thanks for your response, not sure if you got what I meant as there is no error regarding shopping cart or header.

I just would like to **DISPLAY **the shopping cart **icon **in the Header to ALWAYS SHOW, not just when there are items in it (even if it's Empty).
Also, if there ARE items in the shopping cart, I would like to **DISPLAY/SHOW **the NUMBER of items in the cart **next **to the trolley icon!
Thanks.

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!

14 Aug 2021, 1:36 AM
#4
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
496
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Ok I've just figured most of it out but need help from a pro please.
I did as the responsive_classic (tpl_header.php) suggested by replacing:
echo HEADER_TITLE_CART_CONTENTS;
with:
echo $_SESSION['cart']->count_contents().' item(s) '. $currencies->format($_SESSION['cart']->show_total());

So now the Shopping Cart Icon Displays the amount of items in the Cart + the $ value of the total.

This is almost what I wanted, so heading there but I need HELP from a zen pro with php code as I'm clueless there:

  1. I only want to show the (amount of items in cart, NOT their $ value), I tried removing quiet a few different part of the code above and trialing but couldn't get it to work, I managed to remove the text item(s) and the $ symbol and the .00 from the end but could NOT figure out how to remove the actual cost value) - it now shows eg..(cart icon 135), the 1 is for number of items in cart and the 35 is for item cost which I don't want displayed.

  2. How to Force the shopping cart box/icon to display on header ALWAYS, even when Empty!

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!

14 Aug 2021, 7:18 AM
#5
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

rlexyd:

  1. How to Force the shopping cart box/icon to display on header ALWAYS, even when Empty!

The cart icon is wrapped in a conditional statement, i.e. only show if cart has contents. Removing that statement will cause it to always show.

[B]<?php if ($_SESSION['cart']->count_contents() != 0) { ?>[/B]
    <li><a class="navCartContentsIndicator" href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><i class="fa fa-shopping-cart" title="Shopping Cart"></i></a></li>
    <li class="last"><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><i class="fa fa-check-square" title="Checkout"></i></a></li>
[B]<?php }?>[/B]

Simon

14 Aug 2021, 7:31 AM
#6
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

rlexyd:

Ok I've just figured most of it out but need help from a pro please.
I did as the responsive_classic (tpl_header.php) suggested by replacing:
echo HEADER_TITLE_CART_CONTENTS;
with:
echo $_SESSION['cart']->count_contents().' item(s) '. $currencies->format($_SESSION['cart']->show_total());

So now the Shopping Cart Icon Displays the amount of items in the Cart + the $ value of the total.

This is almost what I wanted, so heading there but I need HELP from a zen pro with php code as I'm clueless there:

  1. I only want to show the (amount of items in cart, NOT their $ value), I tried removing quiet a few different part of the code above and trialing but couldn't get it to work, I managed to remove the text item(s) and the $ symbol and the .00 from the end but could NOT figure out how to remove the actual cost value) - it now shows eg..(cart icon 135), the 1 is for number of items in cart and the 35 is for item cost which I don't want displayed.

Not a pro but, does changing,

echo $_SESSION['cart']->count_contents().' item(s) '. $currencies->format($_SESSION['cart']->show_total());

to

echo $_SESSION['cart']->count_contents();

do what you want?

Simon

14 Aug 2021, 8:13 AM
#7
rlexyd avatar

rlexyd

Zen Follower

Join Date:
Nov 2006
Location:
Sydney, Australia
Posts:
496
Plugin Contributions:
0

Re: Display the Shopping Cart ICON on Header ALWAYS plus SHOW Number of items in Cart:

Geez Simon, you ARE the man whether you are a pro or not :bow:
This is Exactly what I wanted, thank you very much!!

*Zen Cart eCommerce Solution - Putting the Dream of Owning an Online Business within reach of anyone!