Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Can shopping cart go in header?

    I can't seem to find a config or a mod to have the shopping cart contents appear in the header whether there's something in them or not. Though I have seen this done on other ZC sites.

    I can only get it to appear in a column (and only appears when there is something in it.)

    Can someone direct me please?

    Thanks.
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  2. #2
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    I'm not sure if there's a MOD etc ... but if anyone else is looking to do this, I just added a few images into the header manually, and then put links on it:

    catalog/index.php?main_page=checkout_payment
    catalog/index.php?main_page=shopping_cart


    But I'm still looking for a way to view the cart contents in the header (how many items etc)
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  3. #3
    Join Date
    Feb 2007
    Location
    Vienna
    Posts
    38
    Plugin Contributions
    0

    Default Re: Can shopping cart go in header?

    to get the same display as in the shopping_cart sidebox, add this code at the bottom (or anywhere else) of "YOUR_TEMPLATE_DIR/common/tpl_header.php"

    the cart-content is wrapped in a <div> tag with the id "header_cart".
    you'd need to position and format it to your needs.

    PHP Code:
    $header_cart "<div id='header_cart'>"
      if (
    $_SESSION['cart']->count_contents() > 0) {
      
    $header_cart .= '<ul>' "\n";
        
    $products $_SESSION['cart']->get_products();
        for (
    $i=0$n=sizeof($products); $i<$n$i++) {
          
    $header_cart .= '<li>';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['quantity'] . BOX_SHOPPING_CART_DIVIDER '</span><a class="font_green" href="' zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' $products[$i]['id']) . '">';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['name'] . '</span></a></li>' "\n";

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $_SESSION['new_products_id_in_cart'] = '';
          }
        }
        
    $header_cart .= '</ul>' "\n";
      } else {
        
    $header_cart .= '<div id="cartBoxEmpty">' BOX_SHOPPING_CART_EMPTY '</div>';
      }

      if (
    $_SESSION['cart']->count_contents() > 0) {
        
    $header_cart .= '<hr />';
        
    $header_cart .= '<div class="cartBoxTotal">' $currencies->format($_SESSION['cart']->show_total()) . '</div>';
    //    $header_cart .= '<br class="clearBoth" />';
      
    }

    $header_cart .= "</div>";
    echo 
    $header_cart

  4. #4
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    Thanks ... I was thinking of doing that if there was nothing in the admin panel. I just wasn't sure if I was making it too complex!

    Thanks for the reply!

    Gin
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  5. #5
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    This code will list every item.

    Can I change it to instead say # of items?

    PHP Code:
    <li>Cart Contents: 
    <?php
    $header_cart 
    "<div id='header_cart'>"
      if (
    $_SESSION['cart']->count_contents() > 0) {
      
    $header_cart .= '<ul>' "\n";
        
    $products $_SESSION['cart']->get_products();
        for (
    $i=0$n=sizeof($products); $i<$n$i++) {
          
    $header_cart .= '<li>';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['quantity'] . BOX_SHOPPING_CART_DIVIDER '</span><a class="font_green" href="' zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' $products[$i]['id']) . '">';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['name'] . '</span></a></li>' "\n";

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $_SESSION['new_products_id_in_cart'] = '';
          }
        }
        
    $header_cart .= '</ul>' "\n";
      } else {
        
    $header_cart .= '<div id="cartBoxEmpty">' BOX_SHOPPING_CART_EMPTY '</div>';
      }

      if (
    $_SESSION['cart']->count_contents() > 0) {
        
    $header_cart .= '<hr />';
        
    $header_cart .= '<div class="cartBoxTotal">' $currencies->format($_SESSION['cart']->show_total()) . '</div>';
    //    $header_cart .= '<br class="clearBoth" />';
      
    }

    $header_cart .= "</div>";
    echo 
    $header_cart;  ?>
    </li>
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  6. #6
    Join Date
    Feb 2007
    Location
    Vienna
    Posts
    38
    Plugin Contributions
    0

    Default Re: Can shopping cart go in header?

    sure

    this is line 5:
    PHP Code:
        for ($i=0$n=sizeof($products); $i<$n$i++) { 
    change it to:
    PHP Code:
        for ($i=0$n=sizeof($products); (($i<$n) && ($i YOUR_MAX_NUMBER)); $i++) { 

  7. #7
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    The list is now gone which is good.

    But I'm not seeing the total number of products appearing.

    Do I now need to echo out $n?

    PHP Code:
    <li>Cart Contents: 
    <?php
    $header_cart 
    "<div id='header_cart'>"
      if (
    $_SESSION['cart']->count_contents() > 0) {
      
    $header_cart .= '<ul>' "\n";
        
    $products $_SESSION['cart']->get_products();
        for (
    $i=0$n=sizeof($products); (($i<$n) && ($i YOUR_MAX_NUMBER)); $i++) {  
          
    $header_cart .= '<li>';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['quantity'] . BOX_SHOPPING_CART_DIVIDER '</span><a class="font_green" href="' zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' $products[$i]['id']) . '">';

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $header_cart .= '<span class="cartNewItem">';
          } else {
            
    $header_cart .= '<span class="cartOldItem">';
          }

          
    $header_cart .= $products[$i]['name'] . '</span></a></li>' "\n";

          if ((
    $_SESSION['new_products_id_in_cart']) && ($_SESSION['new_products_id_in_cart'] == $products[$i]['id'])) {
            
    $_SESSION['new_products_id_in_cart'] = '';
          }
        }
        
    $header_cart .= '</ul>' "\n";
      } else {
        
    $header_cart .= 'Total Items: 0 &nbsp;&nbsp;&nbsp;  $0.00';
      }

      if (
    $_SESSION['cart']->count_contents() > 0) {
        
    // $header_cart .= '<hr />';  // commented out the HR above the total spent.
        
    $header_cart .= '<div class="cartBoxTotal">' $currencies->format($_SESSION['cart']->show_total()) . '</div>';
    //    $header_cart .= '<br class="clearBoth" />';
      
    }

    $header_cart .= "</div>";
    echo 
    $header_cart;  ?>
    </li>
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  8. #8
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    This might be another way to do it:

    PHP Code:
    <?php if (!empty($totalsDisplay)) { ?>
      <div class="cartTotalsDisplay important"><?php echo $totalsDisplay?></div>
      <br class="clearBoth" />
    <?php ?>
    ??
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  9. #9
    Join Date
    Oct 2006
    Posts
    152
    Plugin Contributions
    1

    Default Re: Can shopping cart go in header?

    Okay this works:

    PHP Code:
    <li>Cart Contents: 
      <div class="cartTotalsDisplay important"><?php echo $totalsDisplay?></div>
      <br class="clearBoth" />

    </li>
    I just need to remove the WEIGHT.
    Have I thanked you yet today? I LOVE ZEN!

    Zen Cart Projects: 3 Buck Audio
    Nash Jewellers
    Enseka Solutions
    Bagpipe Solutions

  10. #10
    Join Date
    Feb 2007
    Location
    Vienna
    Posts
    38
    Plugin Contributions
    0

    Default Re: Can shopping cart go in header?

    hey, sorry; i think i misunderstood your question.

    forget about "(($i<$n) && ($i < YOUR_MAX_NUMBER))"

    if you just want to output the total number of displayed products, this piece of code should be sufficient (placed somewhere after the cart-display code):
    PHP Code:
    <?php echo $n?>
    you could output the number of products in the cart anywhere (without the cart-code) like that:
    PHP Code:
    <?php echo sizeof($_SESSION['cart']->get_products()); ?>

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 Add a View Cart link to my shopping cart header, in 12leaves template?
    By Serg in forum All Other Contributions/Addons
    Replies: 10
    Last Post: 22 Aug 2012, 02:49 AM
  2. Shopping Cart Totals in Header - can I make it a hyperlink?
    By top hatt in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 3 Aug 2011, 12:39 AM
  3. How can I display the number of items in shopping cart in header
    By sharontan in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 1 Dec 2010, 02:03 PM
  4. Replies: 1
    Last Post: 10 Sep 2009, 09:14 PM
  5. Replies: 2
    Last Post: 9 Sep 2008, 11:35 PM

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