Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2012
    Posts
    3
    Plugin Contributions
    0

    Default Problem after using shopping cart in header code

    After using scubyfan, post #12 code to add shopping cart totals in header all works good except: if the cart is empty, clicking on the {0 items - $0.00} link brings you to a 404 page not found error. It should just display the text "your cart is empty", but it does not. Thx for the help.

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Problem after using shopping cart in header code

    Scubyfan's code as shown is not complete: it does not include the link creation, just the alternates for correct output. So you had to have added something from other posts in that thread (http://www.zen-cart.com/showthread.p...cart-in-header). What exactly did you use for your cart total bit?

    It would also help for us to see your site and experience the issue live.

  3. #3
    Join Date
    Nov 2012
    Posts
    3
    Plugin Contributions
    0

    Default Re: Problem after using shopping cart in header code

    I used this code in tpl_header.php:

    <?php if ($_SESSION['cart']->count_contents() > 0) {
    $products = $_SESSION['cart']->get_products();
    echo '<p><a href="/shopcart/index.php?main_page=shopping_cart">' . $_SESSION['cart']->count_contents().' Item(s) - Total: ';
    echo $currencies->format($_SESSION['cart']->show_total());
    }

    if ($_SESSION['cart']->count_contents() == 0) {
    $products = $_SESSION['cart']->get_products();
    echo '<p><a href="/index.php?main_page=shopping_cart"> Item(s) 0.00';
    }

    ?></a></p>

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Problem after using shopping cart in header code

    You have one line with
    href="/shopcart/index.php?main_page=shopping_cart">'
    and the other with
    href="/index.php?main_page=shopping_cart">'

    Which one is correct?

    And you don't have scubyfan's code in your post - what you show will not always give the correct item count, and will not give the "empty cart" text when appropriate.

  5. #5
    Join Date
    Nov 2012
    Posts
    3
    Plugin Contributions
    0

    Default Re: Problem after using shopping cart in header code

    I added the below scubyfan code to the previous above code AND added the /shopcart to the last href and it seems to be working now. Only now there are 2 displays showing cart totals. How can I get this to show only one - with the cart total as a hyperlink?
    Thanks much for the good questions as it helped troubleshoot this.

    <?php if ($_SESSION['cart']->count_contents() > 1) {
    $products = $_SESSION['cart']->get_products();
    echo '' . $_SESSION['cart']->count_contents().' Items - ';
    echo $currencies->format($_SESSION['cart']->show_total());
    }

    if ($_SESSION['cart']->count_contents() == 1) {
    $products = $_SESSION['cart']->get_products();
    echo '' . $_SESSION['cart']->count_contents().' Item - ';
    echo $currencies->format($_SESSION['cart']->show_total());
    }

    if ($_SESSION['cart']->count_contents() == 0) {
    $products = $_SESSION['cart']->get_products();
    echo 'Your Cart is Empty!';
    }

    ?>

 

 

Similar Threads

  1. Shopping Cart problem after upgrade - SEO URL
    By marknew in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 11 Mar 2011, 12:44 AM
  2. Replies: 1
    Last Post: 28 Oct 2009, 08:46 AM
  3. Shopping Cart Header and contents display problem
    By fastdc5 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 17 Feb 2009, 10:20 PM
  4. Using Separate Image for Shopping Cart Header
    By Craig Robbo in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 5 Feb 2009, 11:06 AM
  5. moving shopping cart to header problem
    By rickiesdiscount in forum All Other Contributions/Addons
    Replies: 19
    Last Post: 11 Jan 2009, 08:34 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