• Zen Cart Experts
  • Web Sites
  • Training & Support
  • Content Management
  • Other Services
  • Editing the Login – Shopping Cart – Checkout links in Zen Cart

    The default Zen Cart template has some hidden functionality that I like to bring out of the shadows.  You know, the two links, Home and Login, right up top in the header?

    What you may not realize is that there is also the links for the Shopping Cart, My Account, Checkout and Logoff mixed into that coding.  So many folks get rid of that coding when redoing the template and that’s a really bad idea – these are necessary navigation aids to get the buyer through the buying process.

    So let’s look at that coding to see what changes will make the hidden links visible.

    The code is contained in the templates/your_template/common/tpl_header.php file.  (If you don’t have that file or folder in your template, grab it from the default template.) If you don’t have a custom template or are using the classic template, stop right now and go read about template overrides in Zen Cart. When you get your cart set up properly, come back to this article.

    My minimal change is to move the shopping cart link.

    The lines in tpl_header.php that we are concerned about are 47  – 61 and this is the shopping cart line:

    <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>

    Just move that line up above the previous line :

    <?php if ($_SESSION['cart']->count_contents() != 0) { ?>

    so that the code now looks like this:
    <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
    <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
    <?php }?>

    Your shopping cart link becomes visible and the my account link (CHECKOUT_SHIPPING) is left to become visible once you put something in the cart.

    You want the Checkout link visible, too?

    Remove the lines of php code. Change this:

    <?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 }?>

    to this:

    <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>

    To make the My Account link visible move lines 50-51

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

    to after lines 55-56

    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
    <?php } } ?>

    That will place the My Account  link before the shopping cart and checkout links.

    Author: Delia Wilson Lunsford, Founder & CEO, WizTech, Inc.