Results 1 to 4 of 4
  1. #1
    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!

  2. #2
    Join Date
    Jan 2006
    Posts
    67
    Plugin Contributions
    0

    Default 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

  3. #3
    Join Date
    Sep 2006
    Posts
    4
    Plugin Contributions
    0

    Default 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


    Quote Originally Posted by 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

  4. #4
    Join Date
    Jan 2006
    Posts
    67
    Plugin Contributions
    0

    Default 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

 

 

Similar Threads

  1. Shopping cart always in view
    By DannyVarley in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 12 Apr 2013, 05:09 PM
  2. Shopping cart info in header
    By katyav in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 16 Nov 2011, 06:06 PM
  3. Always show shopping cart sidebox
    By numinix in forum Customization from the Admin
    Replies: 3
    Last Post: 9 Mar 2009, 05:39 PM
  4. Need shopping cart link to always show in header
    By sandstoner in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Sep 2008, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg