Hi:
Here is a way to solve the $total shopping cart problem.
1) you will need to add a new field to the cartemp table.
carttemp_price
2) add the following in to getprod.php
this will be in the add to cart form.
<input type="hidden" name="products_price"
value="<?php echo $products_price ?>">
3) add this line to modcart.php
if (isset($_POST['products_price'])) {
$price = $_POST['products_price'];
}
now change the query that add a product to the carttemp table
case "add":
$query = "INSERT INTO carttemp (
carttemp_sess,
carttemp_quan,
carttemp_price,
carttemp_prodnum
)
VALUES ('$sess','$qty','$price','$prodnum')";
4) Add the following to the cart.php file
$query1 = "SELECT SUM(carttemp_price * carttemp_quan) AS total_amount FROM carttemp WHERE carttemp_sess = '$sessid'";
$results1 = mysql_query($query1)
or die ('error');
while ($rows1 = mysql_fetch_array($results1))
{
$total_amount = $rows1['total_amount'];
}
5) add the following line to cart.php where the total is calculated..
Your total before shipping is:</td>
<td align=\"right\">$<?php echo number_format($total_amount, 2); ?></td>
this line will replace ---->
Your total before shipping is:</td>
<td align=\"right\"> <?php echo $total; ?></td>
Now you are all set.. make similar changes to checkout3.php when calculating the totals..
but this solves that pesky cart total issue.. and you can add as many products and prices as you like!
|