Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Shopping Cart/Customer Info Always on in Header

Shopping Cart/Customer Info Always on in Header

Locked

Views: 1,169

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
15 Sep 2006, 3:01 AM
#1
radish avatar

radish

New Zenner

Join Date:
Jan 2006
Posts:
67
Plugin Contributions:
0

Shopping Cart/Customer Info Always on in Header

Hi,

I'm inching closer towards a complete cart! Many thanks to the answers from the people on this board.

I have question, but due to my complete lack of php, I can't solve this on my own. I would like to keep the home, shopping cart, checkout, my account, etc. links always displaying. If a user isn't logged in, they would be directed to the login page when clicking on the appropiate links.

I found a way to keep all of the links displaying except my account by changing this code in tpl_header.php:

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>">Items in Cart: <?php echo ($_SESSION['cart']->count_contents()); ?></div>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></div>
		<div class="navLeft"><a href="/index.php?main_page=contact_us">Contact Us</a></div>
	<?php }?>

to this:

<?php if ($_SESSION['cart']->count_contents() == 0) { ?>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>">Items in Cart: <?php echo ($_SESSION['cart']->count_contents()); ?></div>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></div>
		<div class="navLeft"><a href="/index.php?main_page=contact_us">Contact Us</a></div>
	<?php }?>

This works, except 'my account' is no longer displayed and it throws the balance of links off (I have two columns with three links each).

I'm a designer first and web guy second, so this is nagging at me!

15 Sep 2006, 4:56 AM
#2
radish avatar

radish

New Zenner

Join Date:
Jan 2006
Posts:
67
Plugin Contributions:
0

Re: Shopping Cart/Customer Info Always on in Header

Hello,

So, I moved some things around, broke pages in the process but in the end I figured it out. However, I would like to know if I created any sort of problems for myself...

For anyone else looking to do something similar, this is what I did:

I took this piece of code:

<?php } else { if (STORE_STATUS == '0') { ?>
		<div><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></div>
		<?php } } ?>

and copied this line from the section above it:

<div><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></div>

So it now reads like this:

<?php } else { if (STORE_STATUS == '0') { ?>
		<div><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></div>
		<div><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></div>
	<?php } } ?>

I also altered this:

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>">Items in Cart: <?php echo ($_SESSION['cart']->count_contents()); ?></a></div>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></div>
		
	<?php }?>

to this: ('==0' instead of '!=0')

<?php if ($_SESSION['cart']->count_contents() == 0) { ?>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>">Items in Cart: <?php echo ($_SESSION['cart']->count_contents()); ?></a></div>
		<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></div>
		
	<?php }?>

Now, whether you're logged in or not the shopping cart info and my account links display.

Cheers,

Colin

18 Sep 2006, 4:28 AM
#3
ilovetrance avatar

ilovetrance

New Zenner

Join Date:
Sep 2006
Posts:
5
Plugin Contributions:
0

Re: Shopping Cart/Customer Info Always on in Header

Since the count_contents() set to '0', your links will be seen only when there is nothing in the cart. Did you add an item to try this? If you don't see the links after adding items to cart, try changing it to count_contents()>=0
I'm not a programmer but it seems to be wrong.
cheers

Radish:

to this: ('==0' instead of '!=0')

<?php if ($_SESSION['cart']->**count_contents() == 0** ){ ?>
  	<div class="navLeft"><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>">Items in Cart: <?php echo ($_SESSION['cart']->count_contents()); ?></a></div>

Colin

18 Sep 2006, 5:38 AM
#4
radish avatar

radish

New Zenner

Join Date:
Jan 2006
Posts:
67
Plugin Contributions:
0

Re: Shopping Cart/Customer Info Always on in Header

Hi ilovetrance,

Sorry, shoulda posted back earlier, you're completely right. I figured this out about 10 minutes after I made the switch - '>=0' - was definitely the way to go.

Cheers