lebexpress Posted August 1, 2008 Share Posted August 1, 2008 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>'; } Quote Link to comment https://forums.phpfreaks.com/topic/117686-pass-the-total-and-quantity-from-my-cart-to-the-checkout-page/ Share on other sites More sharing options...
JasonLewis Posted August 1, 2008 Share Posted August 1, 2008 $_SESSION['total'] = $total; Then you can just call it on the other page: $total = $_SESSION['total']; Is that what your after, or did I miss something? Quote Link to comment https://forums.phpfreaks.com/topic/117686-pass-the-total-and-quantity-from-my-cart-to-the-checkout-page/#findComment-605348 Share on other sites More sharing options...
JonnoTheDev Posted August 1, 2008 Share Posted August 1, 2008 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']); Quote Link to comment https://forums.phpfreaks.com/topic/117686-pass-the-total-and-quantity-from-my-cart-to-the-checkout-page/#findComment-605352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.