SitePoint Sponsor

User Tag List

Results 1 to 1 of 1

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    0 Post(s)
    0 Thread(s)

    shopping cart ...can u help?!

    im trying to get a shopping cart working which has been sourced from

    however, on the view cart page when i edit the quantities and press recalculate the order button, the quantities do not refresh.

    i have used the code exactly as seen, but it wont work and yet the demo works fine!

    i've tried emailing the author but with no luck, can anyone help?

    here is the code for 'view_cart.php3'. there are two other files which are required which can be found at the above url.

    any advice would be really helpful...thanks
    PHP Code:
       mysql_select_db( "ethan");
       include( "shoppingcart.php3");
       $table =  "shopping";
       $cart = new Cart;

         $session = $ShoppingCart;

         $result = mysql_query(  "SELECT * FROM inventory WHERE product='$add'");
         $row = mysql_fetch_array($result);


           $session = $ShoppingCart;

         $result = mysql_query(  "SELECT * FROM inventory WHERE product='$remove'");
         $row = mysql_fetch_array($result);
         $contents = $cart->display_contents($table,$session);
         for($i = 0; $i < sizeof($quantity); $i++)
           $oldquan = $contents[quantity][$i];
           $product = $contents[product][$i];
           $newquan = $quantity[$product];
             // End update cart 

    <title>Shopping Cart</title>
    <body bgcolor="#FFFFFF" link="#003399" alink="#FF9933" vlink="#996633" text="#000000">
      $url = $PHP_SELF;
        $url .=  "?session=$session";
      echo  "<FORM ACTION=$url method=post>\n";
    <a name="top"></a>

    <img align=left width=171 height=27 alt="Shopping Cart" src="cart.gif">
    <br clear=left>

    <table align=center border="0" cellpadding="5" cellspacing="0">

    <tr valign="top" bgcolor="#CCCC99">
    <td width=500 valign="TOP"><font face="Verdana,Helvetica,Arial" size="+2"><b><CENTER>Shopping
    Cart Items</b></font></td>
    <TABLE BORDER=1 cellpadding=2>


        $session = $ShoppingCart;

      $contents = $cart->display_contents($table,$session);
      if($contents[product][0] !=  "")
        $x = 0;
        while($x != $cart->num_items($table,$session))
           echo  "<TR><TD>".$contents[product][$x]. "</TD><TD>".$contents[price][$x]. "</TD>\n";
           $product  = $contents[product][$x];
           echo  "<TD><INPUT TYPE=text size=3 name=quantity[$product] ";
           echo  "value=\"".$contents[quantity][$x]. "\"></TD>";
           echo  "<TD>\$".$contents[total][$x]. "</TD>\n";
           echo  "<TD><A HREF=\"view_cart.php3?remove=".urlencode($contents[product][$x]);
           echo  "".(!$ShoppingCart?  "&session=$session": ""). "\">Remove</A>";
           $x ++;
        echo  "</TD><TR></TABLE>";
        echo  "<BR><B>Total Order Amount: \$".$cart->cart_total($table,$session). "</B>";
        echo  "<BR><INPUT TYPE=submit name=modify value=\"Recalculate Order\">";
        echo  "<BR><BR>";
        echo  "Back to the <A HREF=\"store.php3".(!$ShoppingCart?  "?session=$session": ""). "\">";
        echo  "Products</A> page";
        echo  "There are no items in your shopping cart.";
    Last edited by kamstar; Oct 19, 2001 at 19:55.


Posting Permissions

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