将购物车详细信息传递给采购订单

时间:2015-04-25 05:42:49

标签: javascript php html shopping-cart

我有一个分为三个框架的产品商店的网页

  • 左侧窗格/框架显示产品
  • 页面中间分为两部分 - top_half - 显示用户在选择产品时要添加的产品详细信息和数量。
  • 当我在上半部分选择“提交”时,框架的
  • bottom_half会显示购物车。

我想从购物车(bottom_half)提交信息以显示top_half中的内容以及客户详细信息的订单表格。这将关闭会话并显示“要完成结账,请填写上面的信息“

Cart.php (bottom_half)

<?php
session_start();
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Grocery Store</title>

<link rel="stylesheet" type="text/css" href="CSS_prod.css">
</head>
<body>

<h2>My Shopping Cart</h2>

<?php 
if(isset($_POST['empty_cart']))
{
    $_SESSION=array();
    session_desrtoy();
}
require_once 'class_product.php'; 

$product = unserialize($_SESSION['product']);
$quantity = $_POST['cart'];
$total_price = 0;

echo '<table class="Checkout">'; 
echo "<tr>";
echo "<th>Product Name</th>";
echo "<th>Product Id </th>";
echo "<th>In Stock</th>";
echo "<th>Price</th>";
echo "<th>Quantity Added</th>";
echo "<th>Cost</th>";
echo "</tr>";

if(!isSet($_SESSION['cart_items']))
{
  $_SESSION['cart_items'] = array();
}

array_push($_SESSION['cart_items'],$product->getProductName()."|".$product->getProductId()."|".$product->getStock()."|".$product->getUnitPrice()."|".$quantity."|".$sub_total);


for($i=0;$i<sizeof($_SESSION['cart_items']);$i++)
{


  $sub_total = $product->getUnitPrice() * $quantity;
  $total_price += $sub_total;
  echo "<tr>";
  //echo $_SESSION['cart_items'][$i]."<br><hr>";
  $params = explode("|",$_SESSION['cart_items'][$i]);


  for($j=0;$j<sizeof($params);$j++)

  {

    if($j == 0)
    {

      echo "<th>".$params[$j]."</th>";  
    }
    else
    {
      echo "<td>".$params[$j]."</td>";

    }        

  }
echo "</tr>";

}

echo"<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td>Total Cost</td>";
echo "<td>$total_price</td>";
echo"</tr>";
echo "</table>";
?>

<form name="endform" method="post">
<button type="submit" name="empty_cart" value="Delete" id="empty_cart">Delete</button>
<button type="submit" name="Checkout" value="Checkout" onlcick="purchase.php">Checkout</button>
</form>

</body>
</html>

0 个答案:

没有答案