Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / hide cart info when empty

hide cart info when empty

Locked

Views: 1,285

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
1 Aug 2008, 8:00 PM
#1
unhappydave avatar

unhappydave

New Zenner

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

hide cart info when empty

http://www.togethersite.com/catalog/

  1. I want to make it so when the cart is empty it does not show
    items: 0 amount: o.oo in myheader but appear when it has contents. or just hide it om the Home page would probably work for me.

2.nd How can I change its font and font color. I can't seem to fix that either.

1 Aug 2008, 8:49 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: hide cart info when empty

Might try:

  if ($_SESSION['cart']->count_contents() > 0) {
// do something
} else {
// do something else
}
1 Aug 2008, 8:58 PM
#3
unhappydave avatar

unhappydave

New Zenner

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

Re: hide cart info when empty

nada- i tried it before i posted

But definetly thanks it could have been it.

1 Aug 2008, 10:41 PM
#4
unhappydave avatar

unhappydave

New Zenner

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

Re: hide cart info when empty

here is what i need.
http://www.liltulips.com/

2 Aug 2008, 1:20 AM
#5
bigbadboy avatar

bigbadboy

Totally Zenned

Join Date:
Apr 2008
Location:
London
Posts:
557
Plugin Contributions:
0

Re: hide cart info when empty

cheer up and try this:

Just add it where you want and you'll get the same as the example:

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
    You have <?php echo $_SESSION['cart']->count_contents(); ?> <?php echo $_SESSION['cart']->count_contents() == "1" ? "item " : "items " ; ?> in your <a href="shopping_cart.html" target="_top">basket</a>
<?php }?>
2 Aug 2008, 3:33 AM
#6
unhappydave avatar

unhappydave

New Zenner

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

Re: hide cart info when empty

Here is what I have so far:::>

<?php } else { if (STORE_STATUS == '0') { ?>
<li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?> <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
You have <?php echo $_SESSION['cart']->count_contents(); ?> <?php echo $_SESSION['cart']->count_contents() == "1" ? "item " : "items " ; ?> in your <a href="shopping_cart.html" target="_top">basket</a>
<?php }?> <?php if (SHOW_TOTALS_IN_CART == '0') { echo TEXT_TOTAL_ITEMS . '  ' . $_SESSION['cart']->count_contents() . '    ' . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total()); } ?> <?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; ?></a></li>
<li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
<?php }?> </ul>

I just added this part of it from BIGboy:

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
You have <?php echo $_SESSION['cart']->count_contents(); ?> <?php echo $_SESSION['cart']->count_contents() == "1" ? "item " : "items " ; ?> in your <a href="shopping_cart.html" target="_top">basket</a>
<?php }?>

It doesn't seem to work unless I delete:::>

if (SHOW_TOTALS_IN_CART == '0') {
echo TEXT_TOTAL_ITEMS . '  ' . $_SESSION['cart']->count_contents() . '    ' . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
}
?>

Then I get what I want- nothing on the home page if cart is empty. EXCEPT I tested it and if not logged in or logged in and add something to cart and then select home. BAM- gone --cart is emptied all together in both options. Also when logged in the logg off options are gone also-

can anyone help fix my code. that tulips site has it perfectly.

No Basket info until something is added to the cart- then its there until you nav away from page or empty cart.

2 Aug 2008, 10:39 AM
#7
unhappydave avatar

unhappydave

New Zenner

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

Re: hide cart info when empty

4am- figured it out- GOT COOKIES?- Need them for this to work!!

Thanks Bigbadboy-

I deleted that code and turned cookies on (my firefox dumpded all my settings some how I didn't even know until i did a re start!) and Wallah!!

Exactly what I needed-:D:D:D:D