Jump to content

Pass the $total and $quantity from my cart to the checkout page


lebexpress

Recommended Posts

I am trying to pass the $total from view_cart.php page to the submit_order.php page with the quantity ordered so I can process the order , I am using SESSIONS, So I was successfully able to get the customer id by using:

$cust_id = $_SESSION['user_id'];

 

But I am not sure how to be able to get the total to go to the checkout page(submit_order.php). I have the total defined as:

 

while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

$quantity = $_POST['quantity']; 

$subtotal = ($_SESSION['cart'][$row['item_id']]['quantity'] * (($_SESSION['cart'][$row['item_id']]['price']))+ $shipping);

$total += $subtotal;

}

 

I tried to use $ftotal = $_POST['($_SESSION[$total])']; and the same thing for the Quantity.

but no results. Please post any suggestions you may have. (if you need to see the form, please look below)

 

 

 

 

 

<td align = \"left\">{$row['p_condition']}</td>

<td align = \"right\">\${$_SESSION['cart'][$row['item_id']]['price']}</td>

<td align =\"center\"><input type=\"text\"size=\"3\" name =\"qty[{$row['item_id']}]\" value=\"{$_SESSION['cart'][$row['item_id']]['quantity']}\" /></td>

<td align = \"right\">$".number_format($shipping,2)." </td>

<td align = \"right\">$" .number_format($subtotal, 2) . "</td></tr>\n";

} // end of the while loop.

echo '<tr><td colspan = "4" align = "right" ><b> Total:<b></td>

<td align="right">$' . number_format($total, 2).'</td></tr> 

</table><div align = "center"> <input type="submit" name = "submit" value = "Update My Cart" />

<input type ="hidden" name = "submitted" value = "TRUE" />

</form> <br /><br /><a href = "submit_order.php"><font size = "+2">Checkout</font></a></div>';//this was checkout.php temporary using submit_order

}

else

{

echo '<br><br><br><p><h3><center><span style="color:red";> Your cart is currently empty</span></h3></p>';

}

 

You already have it here

$subtotal = ($_SESSION['cart'][$row['item_id']]['quantity'] * (($_SESSION['cart'][$row['item_id']]['price']))+ $shipping);

 

Your quantity and prices are stored in the session. If you add the shipping, so:

$_SESSION['shipping']

 

$subtotal = ($_SESSION['cart'][$row['item_id']]['quantity'] * (($_SESSION['cart'][$row['item_id']]['price']))+ $_SESSION['shipping']);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.