Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2010
    Posts
    35
    Plugin Contributions
    1

    help question Need simple coding help for Shopping Cart in Header

    v1.3.8a
    This is what I have so far,

    Name:  cart header.jpg
Views: 188
Size:  18.0 KB

    What I would like is to have the word "item(s)" be either "item" or "items" depending on the cart contents being 1 item or multiple items.

    I need coding help to add "echo" and "if" commands to the tpl_header.php to call on the following new defines that I've added to .../custom/english.php

    ..CUSTOM/english.php
    PHP Code:
    // Shopping Cart Totals in Header display
    // only for where one item in cart: 
      
    define('ONE_ITEM_IN_CART''item');
    // only for where multiple items in cart:
      
    define('MULTIPLE_ITEMS_IN_CART''items'); 
    ...templates/CUSTOM/common/tpl_header.php
    PHP Code:
    <!--bof Shopping Cart Totals in Header Add-on-->
        <!--NOTE: this add-on was modified to correct an error in cart totals $$ (check forum post subsciptions for code details)-->
        <!--"//"Comment or Uncomment to use-->
      
          <span class="style1">
            <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART'''NONSSL'); ?>">
                My Cart: <?php echo ($_SESSION['cart']->count_contents()); ?> item(s)&nbsp;
              </a>
              <?php $header_cart $currencies->format($_SESSION['cart']->show_total());  echo $header_cart;?>
            </li>
          </span>
        <!--eof Shopping Cart Totals in Header Add-on-->

        <!--"//" comment or uncomment to hide/use this original code-->
    <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
        <!--keep tag info commented out if php is commented out otherwise it will cause an invisible link to the index next to the LogIn link in nav
        <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 }?>
    I'm not a programmer but I kind of get the idea of what I need, just not sure how to execute the code.

    Any help is greatly appreciated!

  2. #2
    Join Date
    Jan 2010
    Posts
    35
    Plugin Contributions
    1

    Default Re: Need simple coding help for Shopping Cart in Header

    ...templates/CUSTOM/common/tpl_header.php

    I started to add in some code below and labeled it as such,

    PHP Code:
    <!--bof Shopping Cart Totals in Header Add-on-->
        <!--NOTE: this add-on was modified to correct an error in cart totals $$ (check forum post subsciptions for code details)-->
        <!--"//"Comment or Uncomment to use-->
      
          <span class="style1">
            <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART'''NONSSL'); ?>">
                My Cart: <?php echo ($_SESSION['cart']->count_contents()); ?>

    <!--BOF WHAT I ADDED, I'M PRETTY SURE ITS NOT RIGHT BUT MAYBE SOMEONE CAN HELP TO CLEAN IT UP-->

    <?php if ($_SESSION['cart']->count_contents() !<1;
     echo 
    ONE_ITEM_IN_CART;
    {else}
    echo 
    MULTIPLE_ITEMS_IN_CART;?>
              <!--EOF WHAT I ADDED-->
    </a>
              <?php $header_cart $currencies->format($_SESSION['cart']->show_total());  echo $header_cart;?>
            </li>
          </span>
        <!--eof Shopping Cart Totals in Header Add-on-->

        <!--"//" comment or uncomment to hide/use this original code-->
    <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
        <!--keep tag info commented out if php is commented out otherwise it will cause an invisible link to the index next to the LogIn link in nav
        <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 }?>
    Again, I'm not a programmer but I kind of get the idea of what I need, just not sure how to execute the code.

    Any help is greatly appreciated!

  3. #3

    Default Re: Need simple coding help for Shopping Cart in Header

    Quote Originally Posted by georgiepants View Post
    ...templates/CUSTOM/common/tpl_header.php

    I started to add in some code below and labeled it as such,

    PHP Code:
    <!--bof Shopping Cart Totals in Header Add-on-->
        <!--NOTE: this add-on was modified to correct an error in cart totals $$ (check forum post subsciptions for code details)-->
        <!--"//"Comment or Uncomment to use-->
      
          <span class="style1">
            <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART'''NONSSL'); ?>">
                My Cart: <?php echo ($_SESSION['cart']->count_contents()); ?>

    <!--BOF WHAT I ADDED, I'M PRETTY SURE ITS NOT RIGHT BUT MAYBE SOMEONE CAN HELP TO CLEAN IT UP-->

    <?php if ($_SESSION['cart']->count_contents() !<1;
     echo 
    ONE_ITEM_IN_CART;
    {else}
    echo 
    MULTIPLE_ITEMS_IN_CART;?>
              <!--EOF WHAT I ADDED-->
    </a>
              <?php $header_cart $currencies->format($_SESSION['cart']->show_total());  echo $header_cart;?>
            </li>
          </span>
        <!--eof Shopping Cart Totals in Header Add-on-->

        <!--"//" comment or uncomment to hide/use this original code-->
    <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
        <!--keep tag info commented out if php is commented out otherwise it will cause an invisible link to the index next to the LogIn link in nav
        <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 }?>
    Again, I'm not a programmer but I kind of get the idea of what I need, just not sure how to execute the code.

    Any help is greatly appreciated!
    You could set something to $_SESSION['cart']->count_contents() to make it easier to read.

    Code:
    <?php
    $cart_count = $_SESSION['cart']->count_contents();
    
    If ($cart_count == 1){ echo ONE_ITEM_IN_CART;}
    If ($cart_count <> 1){ echo MULTIPLE_ITEMS_IN_CART;}
    ?>
    The above is assuming that you still want "items" to show when there is a zero quantity, like "0 items".

    Hope that helps.
    Owner, Randylion
    http://www.randylion.com

  4. #4
    Join Date
    Jan 2010
    Posts
    35
    Plugin Contributions
    1

    Default Re: Need simple coding help for Shopping Cart in Header

    Yes, that is exactly what I needed, thank you so much!

 

 

Similar Threads

  1. v139h Need Help Coding Search Button For Firefox
    By traytray in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 15 Aug 2013, 06:58 PM
  2. need coding help for google search attribute availability
    By snowsports in forum General Questions
    Replies: 1
    Last Post: 7 Nov 2011, 08:02 PM
  3. Help finding this shopping cart for header
    By gowzel in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 17 Jun 2011, 01:05 PM
  4. Simple Shopping Cart, do I need ZenCart?
    By jamesdavid in forum Basic Configuration
    Replies: 1
    Last Post: 23 Apr 2008, 01:27 PM
  5. need simple php coding help!!!! 5 lines max..
    By waghelak in forum General Questions
    Replies: 4
    Last Post: 10 Sep 2007, 02:59 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR