Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Shopping Cart / Sessions - 2 simple questions.

    Hi again everyone!

    I have two simple questions. I have created a basic shopping cart for my site and having a couple minor issues. The cart so far functions properly, removes, adds items etc.

    1. I would like the cart to display (0) items in cart, while right now it is only displaying () when the cart is empty. I tried a few different methods and clearly I cannot get the cart to display the "(0)".

    2. I have adapted the cart to be visible throughout the site so when the user is searching the site (shopping), it will always show the cart total running tally, etc. in the "right container div". I also have a link to the cart in my "navigation bar". Both files are retrieved externally through the index page.
    When I am in cart.php, the right container displays the cart information correctly. The problem is when I navigate throughout the site the cart shows its empty with no price total, etc. I know it has something to do with sessions and retrieving the data from the cart page/database and simply displaying it in the "right container". Do I also have to add something to the index and navigation?

    I am not sure if I need to show any other code because from what I understand it is just a session code I need to apply somewhere..

    Thanks again and have a great Sunday!

    (1.) This is the code for the first question. (I hate tables but for the cart its okay? right!?!?

    PHP Code:
    <?php 
    $cartOutput 
    "";
    $cartTotal "";
    $cartWeight "";
    $cartQty "";
    if (!isset(
    $_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput "<h3>Your shopping cart is empty</h3>";
    } else {
    $i 0
        foreach (
    $_SESSION["cart_array"] as $each_item) { 

    $item_id$each_item['item_id'];
        
    $sql mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while (
    $row mysql_fetch_array($sql)) {
        
    $product_name $row["product_name"];
        
    $price $row["price"];
        
    $subpartnumber $row["subpartnumber"];
        
    $grams $row["grams"];
        
    }
    $pricetotal$price $each_item['quantity'];
    $weighttotal$grams $each_item['quantity'];
    $cartWeight$weighttotal $cartWeight;
    $cartQty$each_item['quantity'] + $cartQty;
    $cartTotal $pricetotal $cartTotal;

    setlocale(LC_MONETARY"en_US");
    $pricetotal money_format("%10.2n",$pricetotal);

    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name'<br/><img src="../store/inventory_images/' $item_id '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'
    .$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' 
    $item_id '" type="submit" value="Change" />
    <input name="quantity_to_adjust" type="hidden" value="' 
    $item_id '" /></form></td>';   
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' $item_id '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i'" /></form></td>';  
    $cartOutput .= '</tr>'
        
    $i++;
        }
        
    setlocale(LC_MONETARY"en_US");
        
    $cartTotal money_format("%10.2n",$cartTotal);
        
    $cartTotal="".$cartTotal." USD";
    }
    ob_end_flush();
    ?>
    Last edited by tonygot; 11-25-2012 at 10:58 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't see anywhere in that script where it displays "( something )".

    There's a line that says "Your shopping cart is empty" ??

    I'm guessing there are other scripts involved. Perhaps we need to see more?

  • #3
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hello, well I guess I can say I have spent most of the day reading and to say the least, I have made some progress. I have adjusted the code to show the quantity throughout the site. "Almost" every page displays the current quantity in the cart. The one page does not show the quantity without throwing errors at me is the product page.

    If I change session_register('final'); it displays errors, so I have commented it out until I figure out a solution. I also think I did the coding wrong because all I did was copy/paste my code from my cart.php to my product.php file. That being said I believe amongst other things I am not properly retrieving the correct information in a "legal" manner.

    This is the product page code with issues of either;
    Always showing a 0
    or Showing the proper quantity but with errors thrown at the top on the lines for session_register.
    PHP Code:
    <?php 
    ob_start
    ();
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors''1');
    ?>

    <?php if (!isset($_SESSION['final']) )
    {
        
    //session_register('final'); 
     
    $_SESSION['final'] = 0;}
     
    ?>
     
    <?php 
    // Check to see the URL variable is set and that it exists in the database
    if (isset($_GET['id'])) {
        
    // Connect to the MySQL database  
    include_once"store/storescripts/connect_to_mysql.php";
        
    $id preg_replace('#[^0-9]#i'''$_GET['id']); 
        
    // Use this var to check to see if this ID exists, if yes then get the product 
        // details, if no then exit this script and give message why
        
    $sql mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
        
    $productCount mysql_num_rows($sql); // count the output amount
        
    if ($productCount 0) {
            
    // get all the product details
            
    while($row mysql_fetch_array($sql)){ 
                 
    $product_name $row["product_name"];
                 
    $partnumber $row["partnumber"];
                 
    $subpartnumber $row["subpartnumber"];
                 
    $yearavail $row["yearavail"];
                 
    $category $row["category"];
                 
    $subcategory $row["subcategory"];
                 
    $details $row["details"];
                 
    $grams $row["grams"];
                 
    $sealed $row["sealed"];
                 
    $price $row["price"];
                 
    $date_added strftime("%b %d, %Y"strtotime($row["date_added"]));
             }
        } else {
            echo 
    "That item does not exist.";
            exit();
        }
    } else {
        echo 
    "Data to render this page is missing.";
        exit();
    }
    $_SESSION['final'] = 0;
    $show ""$display ""$count2""// NEW test again for the zeroes.
    $cartOutput "";
    $cartTotal "";
    $cartWeight "";
    $cartQty "";
    if (!isset(
    $_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput "<h3>Your shopping cart is empty</h3>";
    } else {
    $i 0
        foreach (
    $_SESSION["cart_array"] as $each_item) { 

    $item_id$each_item['item_id'];
        
    $sql mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while (
    $row mysql_fetch_array($sql)) {
        
    $product_name $row["product_name"];
        
    $price $row["price"];
        
    $subpartnumber $row["subpartnumber"];
        
    $grams $row["grams"];
        
    }
    $pricetotal$price $each_item['quantity'];
    $weighttotal$grams $each_item['quantity'];
    $cartWeight$weighttotal $cartWeight;
    $cartQty$each_item['quantity'] + $cartQty;
    $cartTotal $pricetotal $cartTotal;

    setlocale(LC_MONETARY"en_US");
    $pricetotal money_format("%10.2n",$pricetotal);

    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name'<br/><img src="../store/inventory_images/' $item_id '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'
    .$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' 
    $item_id '" type="submit" value="Change" />
    <input name="quantity_to_adjust" type="hidden" value="' 
    $item_id '" /></form></td>';  
    //$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$each_item['quantity']."</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' $item_id '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i'" /></form></td>';  
    $cartOutput .= '</tr>'
        
    $i++;    
    $loop $i ;// New code to test the zero function STARTS here.
    $count $each_item['quantity'];
    //session_register('final');  
     
    if ($loop == )
     {
     
    $_SESSION['final'] = $count
     }
     else if (
    $loop )
     {
     
    $display $_SESSION['final'];
     
    $count2 $display;
     
    $display $count2 $count;
     
    $_SESSION['final'] = $display;
     }
     
    $show $_SESSION['final'];// New code to test the zero function ENDS here.    
        
    }
        
    setlocale(LC_MONETARY"en_US");
        
    $cartTotal money_format("%10.2n",$cartTotal);
        
    $cartTotal="".$cartTotal." USD";
    // Added to avoid the "Cart" showing errors
    mysql_close();
    ob_end_flush();
    ?>

    This is the cart.php code which is not having any current issues.
    PHP Code:
    <?php
    ob_start
    (); 
    session_start();
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors''1');
    include_once
    "store/storescripts/connect_to_mysql.php";
    ?>
    <?php 
    $_SESSION
    ['final'] = 0;
    ?>
    <?php

    [B]I REMOVED LINES 13-104 to show less code that is not relative to the issue.[/B]

    $show ""$display ""$count2""// NEW test again for the zeroes.
    $cartOutput "";
    $cartTotal "";
    $cartWeight "";
    $cartQty "";
    if (!isset(
    $_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput "<h3>Your shopping cart is empty</h3>";
    } else {
    $i 0
        foreach (
    $_SESSION["cart_array"] as $each_item) { 

    $item_id$each_item['item_id'];
        
    $sql mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while (
    $row mysql_fetch_array($sql)) {
        
    $product_name $row["product_name"];
        
    $price $row["price"];
        
    $subpartnumber $row["subpartnumber"];
        
    $grams $row["grams"];
        
    }
    $pricetotal$price $each_item['quantity'];
    $weighttotal$grams $each_item['quantity'];
    $cartWeight$weighttotal $cartWeight;
    $cartQty$each_item['quantity'] + $cartQty;
    $cartTotal $pricetotal $cartTotal;

    setlocale(LC_MONETARY"en_US");
    $pricetotal money_format("%10.2n",$pricetotal);

    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name'<br/><img src="../store/inventory_images/' $item_id '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'
    .$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' 
    $item_id '" type="submit" value="Change" />
    <input name="quantity_to_adjust" type="hidden" value="' 
    $item_id '" /></form></td>';  
    //$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$each_item['quantity']."</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' $item_id '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i'" /></form></td>';  
    $cartOutput .= '</tr>'
        
    $i++;    
    $loop $i ;// New code to test the zero function ENDS here.
    $count $each_item['quantity'];
    //session_register('final');  
     
    if ($loop == )
     {
     
    $_SESSION['final'] = $count
     }
     else if (
    $loop )
     {
     
    $display $_SESSION['final'];
     
    $count2 $display;
     
    $display $count2 $count;
     
    $_SESSION['final'] = $display;
     }
     
    $show $_SESSION['final'];// New code to test the zero function ENDS here.    
        
    }
        
    setlocale(LC_MONETARY"en_US");
        
    $cartTotal money_format("%10.2n",$cartTotal);
        
    $cartTotal="".$cartTotal." USD";
    }
    ob_end_flush();
    ?>

  • #4
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    I don't see anywhere in that script where it displays "( something )".

    There's a line that says "Your shopping cart is empty" ??

    I'm guessing there are other scripts involved. Perhaps we need to see more?
    Yes you are correct. The "your shopping cart is empty" is there so if you goto the shopping cart page it will show the words too. Maybe if I post a link to the site that might help also just incase someone wants to physically test/look at it. I also noticed when I browse the site with my iPhone, the quantity is always showing (0) unless I am in the cart page- there it will show the correct quantity. Next I have to add the total $ and shipping. Yikes.

  • #5
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I have tried many different combinations to get the quantity to show up on all pages but I am having lots of trouble calculating the logic of this code. I can get the quantity in the right container to show (0). If I adjust the code to get the correct quantity on all the pages, when the cart is emptied it will still show the amount that was in the cart. I have been trying this for so long that I honestly forgot how to get it work some what correct again.

    I have been messing with the index, right container, cart and product page and it is just turning into a giant mess. I started all of this about a month ago so my knowledge on coding is limited (hence why I joined here.) I will also include a link to the site because perhaps someone would like to see the live version in progress.


    Index Page Top code.
    Code:
    <?php
    session_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    	<title>Welcome to gotminifigures.com! </title>
    
    <link rel="stylesheet" type="text/css" href="main.css"/>
    <link  rel="stylesheet" type="text/css" href="style.css">
    <meta name="viewport" content="width=1200, height=800, initial-scale=1" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script language="JavaScript" src="crumb.js"></script>
    <script type="text/javascript" src="bannerRotator.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    bannerRotator('#bannerRotator', 3000, 6000, true);
    });
    </script>
                
    </head>
    <body>
    <!-- Start Page Container -->
    <div class="pagecontainer">                   
    <?php include('php/header.php'); ?>                    
    <?php include('php/navagation.php'); ?>                  
    <div class="wrapcontent"> <!-- Start wrapcontent-->


    Right Container Page code. (Where cart will be displayed on all pages)
    Code:
    <?php
    if (!isset($_SESSION['final']) )
    {session_register('final'); 
     $_SESSION['final'] = 0;}
    ?>
    
    <html>
    <head>
    <body>
    
    <!-- Start RIGHT container-->    
    <div class="rightcontainer"> 
         
         <div class="shoppingcart"><!-- Start Shopping Cart-->
         <h1 class="buttonheadersmall"></h1>
         <img class="scart" src="images/BLshoppingcart.png" width="177" height="24" alt="shopping cart" />
         <div class="cartContentMain">
         <div class="cartQuantityMain">Items in Cart: (<strong><?php echo $_SESSION['final']; ?></strong>)</div>
         <div class="cartShippingMain"></div>
         <div class="cartTotalMain">Total: <strong><?php echo $cartTotal; ?></strong></div>
         </div><!-- End cartContentMain-->
     </div><!-- End Shopping Cart-->
            <div class="lastviewed"><!-- Start Last Viewed Item-->

    Cart Page code.
    Code:
    <?php
    ob_start(); 
    session_start();
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    include_once"store/storescripts/connect_to_mysql.php";
    ?>
    
    <?php 
    $_SESSION['final'] = 0;
    ?>
    
    /////////// LINES 13-107 ARE TAKEN OUT TO SHORTEN CODE A BIT /////////
    $show = ""; $display = ""; $count2= ""; 
    $cartOutput = "";
    $cartTotal = "";
    $cartWeight = "";
    $cartQty = "";
    if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput = "<h3>Your shopping cart is empty</h3>";
    } else {
    $i = 0; 
        foreach ($_SESSION["cart_array"] as $each_item) { 
    
    $item_id= $each_item['item_id'];
    	$sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
    	while ($row = mysql_fetch_array($sql)) {
    	$product_name = $row["product_name"];
    	$price = $row["price"];
    	$subpartnumber = $row["subpartnumber"];
    	$grams = $row["grams"];
    	
    }
    $pricetotal= $price * $each_item['quantity'];
    $weighttotal= $grams * $each_item['quantity'];
    $cartWeight= $weighttotal + $cartWeight;
    $cartQty= $each_item['quantity'] + $cartQty;
    $cartTotal = $pricetotal + $cartTotal;
    
    setlocale(LC_MONETARY, "en_US");
    $pricetotal = money_format("%10.2n",$pricetotal);
    
    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name. '<br/><img src="../store/inventory_images/' . $item_id . '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'.$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' . $item_id . '" type="submit" value="Change" />
    <input name="quantity_to_adjust" type="hidden" value="' . $item_id . '" /></form></td>';  
    //$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$each_item['quantity']."</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i. '" /></form></td>';  
    $cartOutput .= '</tr>'; 
    	$i++;	
    	$loop = $i ;// New code to test the zero function ENDS here.
    $count = $each_item['quantity'];
    //session_register('final');  
     if ($loop == 1 )
     {
     $_SESSION['final'] = $count; 
     }
     else if ($loop > 1 )
     {
     $display = $_SESSION['final'];
     $count2 = $display;
     $display = $count2 + $count;
     $_SESSION['final'] = $display;
     }
     $show = $_SESSION['final'];
    	}
    	setlocale(LC_MONETARY, "en_US");
        $cartTotal = money_format("%10.2n",$cartTotal);
    	$cartTotal="".$cartTotal." USD";
    }
    ob_end_flush();
    ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    <title>Your Shopping Cart</title>
    <link rel="stylesheet" type="text/css" href="content.css"/>
    <link rel="stylesheet" type="text/css" href="main.css"/>
    <link  rel="stylesheet" type="text/css" href="style.css">
    <meta name="viewport" content="width=1200, height=800, initial-scale=1" />
    
              
    </head>
    <body>
    <!-- Start Page Container -->
    <div class="pagecontainer">                   
    <?php include('php/header.php'); ?>                    
    <?php include('php/navagation.php'); ?>                  
    <div class="wrapcontent"> <!-- Start wrapcontent--> 
    <!--<div class="bct">  <script language="JavaScript"><!-- Start BCT Bread Crumb Trail-->
    <!--
    breadcrumbs();
     -->
    <!--</script></div><!-- END BCT Bread Crumb Trail--> 
    <?php include('php/l_contain.php'); ?>      <!-- Left Container -->                                                
    <!-- Start CENTER container-->     
    <div class="centercontainer">
    
    <!-- INSERT CENTER CONTAINER DYNAMIC INFORMATION BELOW HERE ONLY. DO NOT CHANGE ANYTHING ABOVE. -->  
    
    <div class="productWrap">									<!-- Start Product WRAP-->
    <div class="productTitleLarge">Welcome To Your Shopping Cart!</div>
    
    
    
    
    
    <div id="productCartInfo">
      <table width="513" border="1" align="center" cellspacing="0" cellpadding="1" bordercolor="#CCCCCC">
        <tr>
          <td width="94" align="center"><strong>Product Name</strong></td>
          <td width="72" align="center"><strong>Part Number</strong></td>
          <td width="54" align="center"><strong>Quantity</strong></td>
          <td width="55" align="center"><strong>Weight</strong></td>
          <td width="75" align="center"><strong>Unit Price</strong></td>
          <td width="71" align="center"><strong>Total Price</strong></td>
          <td width="62" align="center"><strong>Remove</strong></td>
        </tr>
        <?php echo $cartOutput; ?>
        <!--<tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr> -->
      </table>
      <p>&nbsp;</p>
      <div id="emptyCart"><ul><li><a href="cart.php?cmd=emptycart"><img src="images/emptycart1.jpg" width="208" height="24" alt="empty cart" /></a></li></ul></div>
    </div>
    
    <div class="productButtons"> <!-- Start Product Buttons-->
     <div id="cartOutputTotal"> 
       <table width="513" border="1" align="center" cellspacing="0" cellpadding="1" bordercolor="#206691">
        <tr>
          <td width="64" align="center"><strong>Total Qty</strong></td>
          <td width="105" align="center"><strong>Total Weight</strong></td>
          <td width="91" align="center"><strong>Shipping Price</strong></td>
          <td width="89" align="center"><strong>Total Price</strong></td>
          <td width="88" align="center"><strong>Grand Total</strong></td>
        </tr>
        
        <tr>
          <td><?php echo $cartQty; ?></td>
          <td><?php echo $cartWeight; ?>&nbsp;(g)</td>
          <td>&nbsp;</td>
          <td><?php echo $cartTotal; ?></td>
          <td>&nbsp;</td>
        </tr>
      </table>
       </div>
     </div><!-- END Product Buttons-->
    </div>													
    <!-- END Product WRAP-->
    <!-- THIS ENDS INSERT CENTER CONTAINER DYNAMIC INFORMATION ABOVE HERE ONLY. DO NOT CHANGE ANYTHING BELOW.-->     
    </div>  <!-- End CENTER container-->
    <?php include('php/r_container.php'); ?>    <!-- Right Container -->       
    <?php include('php/footer.php'); ?> 
    </div><!-- End wrapcontent-->
    </div><!-- End pagecontainer-->
    </body>
    </html>

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    How about this idea?

    Create a single small PHP script that echoes the cart count.
    That is all the script does.

    Then, when you get that working, include it in the HTML of
    anywhere you wish to display it.

    Example.

    The cart contains <?php include("count.php");?> items.

    That way, you only code it one time and use it everywhere.

  • Users who have thanked mlseim for this post:

    tonygot (11-26-2012)

  • #7
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    How about this idea?

    Create a single small PHP script that echoes the cart count.
    That is all the script does.

    Then, when you get that working, include it in the HTML of
    anywhere you wish to display it.

    Example.

    The cart contains <?php include("count.php");?> items.

    That way, you only code it one time and use it everywhere.
    This idea worked well! I am using it right now and every page works. Well almost every page, my product page still shows the cart is empty when a user views a product, also the Total $ Cart amount does not load.

    Could this be because in the product script is has something to do with - only run if the "product" is 0 or greater? I cannot think of any other reason why I cant get the product page to display items in the cart...

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Now repost the "small include script" you made, and the "product page" script.

    I think you're getting real close now ... maybe we can see where it's not working.

  • #9
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    It doesn't matter where I add it to the script, it will always show up zero and the total does not show like the other pages. I tried also making the product page a unique include.php and that also does not work. You can see about 7 lines down on the product page I added the "count.php". It works like a charm on all the other pages, but only the product page it resets, or does not acknowledge it is there. I believe it has something to with the "if ($productCount > 0) {" but if I tamper with that, it will not display properly.

    I am so close I can taste it! I just can't get past this part! Here is a link to the site again to see the live version if interested.


    PRODUCT PAGE SCRIPT
    PHP Code:
    <?php 
    ob_start
    ();
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors''1');
    ?>
    <?php 
    include("php/count.php");?>
    <?php 
    // Check to see the URL variable is set and that it exists in the database
    if (isset($_GET['id'])) {
        
    // Connect to the MySQL database  
    include_once"store/storescripts/connect_to_mysql.php";
        
    $id preg_replace('#[^0-9]#i'''$_GET['id']); 
        
    // Use this var to check to see if this ID exists, if yes then get the product 
        // details, if no then exit this script and give message why
        
    $sql mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
        
    $productCount mysql_num_rows($sql); // count the output amount
        
    if ($productCount 0) {
            
    // get all the product details
            
    while($row mysql_fetch_array($sql)){ 
                 
    $product_name $row["product_name"];
                 
    $partnumber $row["partnumber"];
                 
    $subpartnumber $row["subpartnumber"];
                 
    $yearavail $row["yearavail"];
                 
    $category $row["category"];
                 
    $subcategory $row["subcategory"];
                 
    $details $row["details"];
                 
    $grams $row["grams"];
                 
    $sealed $row["sealed"];
                 
    $price $row["price"];
                 
    $date_added strftime("%b %d, %Y"strtotime($row["date_added"]));
             }
        } else {
            echo 
    "That item does not exist.";
            exit();
        }
    } else {
        echo 
    "Data to render this page is missing.";
        exit();
    }
    mysql_close();
    ob_end_flush();
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title><?php echo $category?> - <?php echo $subcategory?> - <?php echo $product_name?></title>
    <link rel="stylesheet" type="text/css" href="content.css"/>
    <link rel="stylesheet" type="text/css" href="main.css"/>
    <link  rel="stylesheet" type="text/css" href="style.css">
    <meta name="viewport" content="width=1200, height=800, initial-scale=1" />

              
    </head>
    <body>
    <!-- Start Page Container -->
    <div class="pagecontainer">                   
    <?php include('php/header.php'); ?>                    
    <?php include('php/navagation.php'); ?>                  
    <div class="wrapcontent"> <!-- Start wrapcontent--> 
    <?php include('php/l_contain.php'); ?>      <!-- Left Container -->                                                
    <!-- Start CENTER container-->     
    <div class="centercontainer">

    <!-- INSERT CENTER CONTAINER DYNAMIC INFORMATION BELOW HERE ONLY. DO NOT CHANGE ANYTHING ABOVE. -->  

    <div class="productWrap">                                    <!-- Start Product WRAP-->
    <div class="productTitleLarge"><?php echo $category?> - <?php echo $subcategory?> - <?php echo $product_name?></div>


    <div class="pictureContent"><!-- Start Picture CONTENT WRAP -->
    <div class="productPicture"><!-- Start Picture -->
    <img src="../store/inventory_images/<?php echo $id?>.jpg" width="253" height="311" alt="<?php echo $product_name?>"/> </div><!-- END Product Picture-->
    <div class="productPictureEnlarge"><!-- Start Picture Enlarge--></div><!-- END Picture Enlarge-->
    </div><!-- END Picture CONTENT WRAP -->

    <div class="productInfoWrap"><!-- Start Product Information WRAP -->
    <div class="productInfo"><!-- Start Product Information-->
    <div class="productHeader"></div>
    <div class="productPrice">$<?php echo $price?></div>
    <div class="productQuantity"></div>
    <div class="productAddtoCartLarge">
    <form id="form1" name="form1" method="post" action="cart.php">
    <input type="hidden" name="pid" id="pid" value="<?php echo $id?>"/>
    <input type="image" src="images/addtocartup.jpg" id="button" alt="Add to Shopping Cart"/>
    </form>

    </div>
    <div class="productGap"></div>
    <div class="productInfoTitle">Product Information</div>
    <div class="productYearReleased">Year Released: <?php echo $yearavail?></div>
    <div class="productPartNumber">Part Number: #<?php echo $partnumber?></div>
    <div class="productSubPartNumber">Item Number: <?php echo $subpartnumber?></div>
    <div class="productCategory">Category: <?php echo $category?></div>
    <div class="productSubCategory">Sub-Category: <?php echo $subcategory?></div>
    <div class="productWeight">Weight in grams: <?php echo $grams?>(g)</div>
    </div><!-- END Product Information-->
    </div><!-- END Product Information WRAP -->

    <div class="productDetails">Product Details</div>
    <div class="productDetailsInfo"> <?php echo $details?></div>

    <div class="productButtons"> <!-- Start Product Buttons-->

      
    </div><!-- END Product Buttons-->


    </div>                                                        <!-- END Product WRAP-->




    <!-- THIS ENDS INSERT CENTER CONTAINER DYNAMIC INFORMATION ABOVE HERE ONLY. DO NOT CHANGE ANYTHING BELOW.-->     
    </div>  <!-- End CENTER container-->
    <?php include('php/r_container.php'); ?>    <!-- Right Container -->       
    <?php include('php/footer.php'); ?> 
    </div><!-- End wrapcontent-->
    </div><!-- End pagecontainer-->
    </body>
    </html>

    COUNT PAGE (Include) SCRIPT
    PHP Code:
    <?php 
    ob_start
    (); 
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors''1');
    include_once
    "store/storescripts/connect_to_mysql.php";
    $show ""$display ""$count2""
    $cartOutput "";
    $cartTotal "";
    $cartWeight "";
    $cartQty "";
    if (!isset(
    $_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput "<h3>Your shopping cart is currently empty!</h3>";
    } else {
    $i 0
        foreach (
    $_SESSION["cart_array"] as $each_item) { 

    $item_id$each_item['item_id'];
        
    $sql mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while (
    $row mysql_fetch_array($sql)) {
        
    $product_name $row["product_name"];
        
    $price $row["price"];
        
    $subpartnumber $row["subpartnumber"];
        
    $grams $row["grams"];
        
    }
    $pricetotal$price $each_item['quantity'];
    $weighttotal$grams $each_item['quantity'];
    $cartWeight$weighttotal $cartWeight;
    $cartQty$each_item['quantity'] + $cartQty;
    $cartTotal $pricetotal $cartTotal;

    setlocale(LC_MONETARY"en_US");
    $pricetotal money_format("%10.2n",$pricetotal);

    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name'<br/><img src="../store/inventory_images/' $item_id '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'
    .$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' 
    $item_id '" type="submit" value="Change" />
    <input name="quantity_to_adjust" type="hidden" value="' 
    $item_id '" /></form></td>';  
    //$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$each_item['quantity']."</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' $item_id '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i'" /></form></td>';  
    $cartOutput .= '</tr>'
        
    $i++;    
        
    $loop $i ;// New code to test the zero function ENDS here.
    $count $each_item['quantity'];
    //session_register('final');  
     
    if ($loop == )
     {
     
    $_SESSION['final'] = $count
     }
     else if (
    $loop )
     {
     
    $display $_SESSION['final'];
     
    $count2 $display;
     
    $display $count2 $count;
     
    $_SESSION['final'] = $display;
     }
     
    $show $_SESSION['final'];
        }
        
    setlocale(LC_MONETARY"en_US");
        
    $cartTotal money_format("%10.2n",$cartTotal);
        
    $cartTotal="".$cartTotal." USD";
    }
    ob_end_flush();
    ?>
    Thanks again for your help so far!!!
    Last edited by tonygot; 11-28-2012 at 01:30 PM.

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I see you 'building' the variable: $cartOutput .=

    But I don't see it being echoed or printed anywhere.

    Same with $cartTotal ...

    Where are these being echoed?
    Or am I just not seeing it?


    .

  • #11
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Those variables would be echoed on the cart page. I suppose I am "building" those variables on this script for absolutely no reason. I obviously have to spend a day or two (maybe more) to completely go over all the code and pages to avoid errors like this.

    This is the entire CART php page
    PHP Code:
    <?php
    ob_start
    (); 
    session_start();
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors''1');
    include_once
    "store/storescripts/connect_to_mysql.php";
    ?>

    <?php 
    $_SESSION
    ['final'] = 0;
    ?>


    <?php
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 1 (if user attempts to add something to the cart from the product page)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['pid'])) { 
        
    $pid $_POST['pid'];    
        
    $wasFound false;    
        
    $i 0;                
        
    // If the cart session variable is not set or cart array is empty
        
    if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {    
            
    // RUN IF THE CART IS EMPTY OR NOT SET
            
    $_SESSION["cart_array"] = array(=> array("item_id" => $pid"quantity" => 1));      
        } else {
            
    // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
            
    foreach ($_SESSION["cart_array"] as $each_item) {        
                  
    $i++;                                           
                  while (list(
    $key$value) = each($each_item)) {  
                      if (
    $key == "item_id" && $value == $pid) {    
                          
    // That item is in cart already so let's adjust its quantity using array_splice()
                          
    array_splice($_SESSION["cart_array"], $i-11, array(array("item_id" => $pid"quantity" => $each_item['quantity'] + 1)));  
                          
    $wasFound true;   
                      } 
    // close if condition
                  
    // close while loop
               
    // close foreach loop
               
    if ($wasFound == false) {  
                   
    array_push($_SESSION["cart_array"], array("item_id" => $pid"quantity" => 1));   
            }
        }
        
    header("location: cart.php");
        exit();
    }
    ?>

    <?php 
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 2 (if user chooses to empty their shopping cart)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") {
        unset(
    $_SESSION["cart_array"]);
    }
    ?>

    <?php 
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 3 (if user chooses to adjust item quantity)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['quantity_to_adjust']) && $_POST['quantity_to_adjust'] != "") {
       
    //Execute some code
          
    $quantity_to_adjust $_POST['quantity_to_adjust'];
          
    $quantity $_POST['quantity'];
          
    $quantity preg_replace('#[^A-Za-z0-9]#i'''$quantity); // filter everything but numbers and letters
          
    if($quantity >=10) {$quantity=9;}
          if(
    $quantity <1) {$quantity=1;}
          if(
    $quantity =="") {$quantity=1;}
          
    $i=0;
               foreach (
    $_SESSION["cart_array"] as $each_item) {      
                  
    $i++;                                           
                  while (list(
    $key$value) = each($each_item)) {   
                      if (
    $key == "item_id" && $value == $quantity_to_adjust) {   
                          
    // That item is in cart already so let's adjust its quantity using array_splice()
                          
    array_splice($_SESSION["cart_array"], $i-11, array(array("item_id" => $quantity_to_adjust"quantity" => $quantity))); 
         } 
    // close if condition
        
    // close while loop
      
    // close foreach loop
          
    header("location: cart.php");
        exit();
    }
    ?>

    <?php 
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 4 (if user chooses to remove an item from the cart)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") {
        
    // Access the array and run code to remove that array index
         
    $key_to_remove $_POST['index_to_remove'];
        if (
    count($_SESSION["cart_array"]) <= 1) {
            unset(
    $_SESSION["cart_array"]);
        } else {
            unset(
    $_SESSION["cart_array"]["$key_to_remove"]);
            
    sort($_SESSION["cart_array"]);
        }
            
    header("location: cart.php");
        exit();
    }
    ?>



    <?php 
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 5 (Render the cart for the user to view on the page)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $show ""$display ""$count2""
    $cartOutput "";
    $cartTotal "";
    $cartWeight "";
    $cartQty "";
    if (!isset(
    $_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput "<h3>Your shopping cart is currently empty!</h3>";
    } else {
    $i 0
        foreach (
    $_SESSION["cart_array"] as $each_item) { 

    $item_id$each_item['item_id'];
        
    $sql mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while (
    $row mysql_fetch_array($sql)) {
        
    $product_name $row["product_name"];
        
    $price $row["price"];
        
    $subpartnumber $row["subpartnumber"];
        
    $grams $row["grams"];
        
    }
    $pricetotal$price $each_item['quantity'];
    $weighttotal$grams $each_item['quantity'];
    $cartWeight$weighttotal $cartWeight;
    $cartQty$each_item['quantity'] + $cartQty;
    $cartTotal $pricetotal $cartTotal;

    setlocale(LC_MONETARY"en_US");
    $pricetotal money_format("%10.2n",$pricetotal);

    //Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name'<br/><img src="../store/inventory_images/' $item_id '.jpg" width="58" height="59" </td>';  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
    <input name="quantity" type="text" value="'
    .$each_item['quantity'].'" size="1" maxlength="1" />
    <input name="adjustBtn' 
    $item_id '" type="image" src="images/change.jpg" />
    <input name="quantity_to_adjust" type="hidden" value="' 
    $item_id '" /></form></td>';  
    //$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$each_item['quantity']."</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";  
    $cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";  
    $cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";  
    $cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' $item_id '" align=\"center\"  type="image" src="images/crossx.jpg" /><input name="index_to_remove" type="hidden" value="' .$i'" /></form></td>';  
    $cartOutput .= '</tr>'
        
    $i++;    
        
    $loop $i ;// New code to test the zero function ENDS here.
    $count $each_item['quantity'];
    //session_register('final');  
     
    if ($loop == )
     {
     
    $_SESSION['final'] = $count
     }
     else if (
    $loop )
     {
     
    $display $_SESSION['final'];
     
    $count2 $display;
     
    $display $count2 $count;
     
    $_SESSION['final'] = $display;
     }
     
    $show $_SESSION['final'];
        }
        
    setlocale(LC_MONETARY"en_US");
        
    $cartTotal money_format("%10.2n",$cartTotal);
        
    $cartTotal="".$cartTotal." USD";
    }
    ob_end_flush();
    ?>



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title>Your Shopping Cart</title>
    <link rel="stylesheet" type="text/css" href="content.css"/>
    <link rel="stylesheet" type="text/css" href="main.css"/>
    <link  rel="stylesheet" type="text/css" href="style.css">
    <meta name="viewport" content="width=1200, height=800, initial-scale=1" />

              
    </head>
    <body>
    <!-- Start Page Container -->
    <div class="pagecontainer">                   
    <?php include('php/header.php'); ?>                    
    <?php include('php/navagation.php'); ?>                  
    <div class="wrapcontent"> <!-- Start wrapcontent--> 
    <!--<div class="bct">  <script language="JavaScript"><!-- Start BCT Bread Crumb Trail-->
    <!--
    breadcrumbs();
     -->
    <!--</script></div><!-- END BCT Bread Crumb Trail--> 
    <?php include('php/l_contain.php'); ?>      <!-- Left Container -->                                                
    <!-- Start CENTER container-->     
    <div class="centercontainer">

    <!-- INSERT CENTER CONTAINER DYNAMIC INFORMATION BELOW HERE ONLY. DO NOT CHANGE ANYTHING ABOVE. -->  

    <div class="productWrap">                                    <!-- Start Product WRAP-->
    <div class="productTitleLargeCart">My Shopping Cart Detailed Information!</div>





    <div id="productCartInfo">
      <table width="513" border="1" align="center" cellspacing="0" cellpadding="1" bordercolor="#CCCCCC">
        <tr>
          <td width="94" align="center"><strong>Product Name</strong></td>
          <td width="79" align="center"><strong>Part Number</strong></td>
          <td width="47" align="center"><strong>Quantity</strong></td>
          <td width="55" align="center"><strong>Weight</strong></td>
          <td width="75" align="center"><strong>Unit Price</strong></td>
          <td width="71" align="center"><strong>Total Price</strong></td>
          <td width="62" align="center"><strong>Remove</strong></td>
        </tr>
        <?php echo $cartOutput?>
        <!--<tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr> -->
      </table>
      <p>&nbsp;</p>
      <div id="cartContentButton">
     
     <div id="emptyCart"><a href="cart.php?cmd=emptycart">
       <img src="images/emptycart1.jpg" width="189" height="24" alt="Empty Cart" /> </a></li></ul></div>
      
      <div id="checkoutProceed">
      <a href="cart.php?cmd=checkout">
       <img src="images/checkout.jpg" width="189" height="24" alt="Empty Cart" /> </a></li></ul>
      </div>
      
      
      </div><!-- End Empty CartContentButton Div-->



    </div>

    <div class="productButtons"> <!-- Start Product Buttons-->
     <div id="cartOutputTotal"> 
       <table width="513" border="1" align="center" cellspacing="0" cellpadding="1" bordercolor="#206691">
        <tr>
          <td width="64" align="center"><strong>Total Qty</strong></td>
          <td width="105" align="center"><strong>Total Weight</strong></td>
          <td width="91" align="center"><strong>Shipping Price</strong></td>
          <td width="89" align="center"><strong>Total Price</strong></td>
          <td width="88" align="center"><strong>Grand Total</strong></td>
        </tr>
        
        <tr>
          <td><?php echo $_SESSION['final']; ?></td>
          <td><?php echo $cartWeight?>&nbsp;(g)</td>
          <td>&nbsp;</td>
          <td><?php echo $cartTotal?></td>
          <td>&nbsp;</td>
        </tr>
      </table>
       </div>
     
     
     
     </div><!-- END Product Buttons-->


    </div>                                                        
    <!-- END Product WRAP-->




    <!-- THIS ENDS INSERT CENTER CONTAINER DYNAMIC INFORMATION ABOVE HERE ONLY. DO NOT CHANGE ANYTHING BELOW.-->     
    </div>  <!-- End CENTER container-->
    <?php include('php/r_container.php'); ?>    <!-- Right Container -->       
    <?php include('php/footer.php'); ?> 
    </div><!-- End wrapcontent-->
    </div><!-- End pagecontainer-->
    </body>
    </html>

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    When it goes to "product.php" I wonder if it's missing a session_start();

    That's why the cart shows empty.

    If you put this at the top of each script: <?php include("php/count.php");?>

    put your session_start(); in that script, and remove it elsewhere.

    But I'm thinking "product.php" doesn't ever see a session_start();


    EDIT:
    I would be cool if a zoomed image appeared when you mouse over a lego figure.
    Something JQuery-ish so I could see visual details without clicking on it.


    .
    Last edited by mlseim; 11-28-2012 at 08:40 PM.

  • #13
    New Coder
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I tried that and it doesn't work. I also tried eliminating the display SESSION_Final and using the cartQty output, that also does not work and eliminates the (0) when the cart is empty. When I tried putting the session start in the count.php file and adding that to all my scripts, my index page fills up with lines and lines of errors.

    The other thing is, the cart total, quantity etc is displayed in the r_container, so technically it has nothing do with the cart page, product page, index page. The right container always loads on its own, doesn't matter which page is loading. You would think the product page and r_container do not interact with each other when loaded, but "technically" they are loading and interacting with each other.

    I have tried so many combinations now, I loose count. The closest I came was when the product page loaded, the cart displayed errors pertaining to the r_container script. So they can load together and also interact separately.

    As for the enlarge image as you suggested, yes it is a wonderful idea and when you are on the product page, you may have noticed a giant ugly button under the image. That is to remind me that I want to do a mouse over - enlarge image with perhaps another image or two under in little thumbnails. That in my opinion will be tricky to get each "id" to load two or three pictures each and then using JS or Jquery allowing them to double size/enlarge on mouse over.

    I have learned in this last month that if I jump all over the place and try to work on too many things at once that my head explodes so I have to one thing at a time now. (search bar script,payment system,getting the buttons to change also on mouse over[JS form issues are keeping me back!], shipping total set to minimum rate and also displayed in cart, shipping calculations for total weight added onto total). -I have some work cut out for me and I made it this far, no turning back now!!

  • #14
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    For the page that isn't working ...

    Make a safe copy of it so you can get it back later.

    Now, remove small sections of the script, one at a time, leaving the right part there (the cart section that says zero).

    See if you can make it read correctly at some point ... when a certain part of the script has been removed or commented-out.


  •  

    Posting Permissions

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