Please
try again.';
$data = $_REQUEST;
// Include the address collection /
// registration info page again
include("order_step3.inc.php");
return;
}
}
?>
If everything is alright, we can go ahead and insert complete order details in the
database. The following code illustrates how we do this.
// We pass the products & variations objects to the order to refer to
// product pricing and names. Are needed for total calculation and
// order printing. The $orderDetail array contains the
// delivery address,
// userId, order time and order status
$orderObj = new Order($products, $variations, "orders", $orderDetail);
// If there are no selected items, can't proceed
if (!is_array($_SESSION["orderInfo"]["pizza"]))
{
echo '
Did not find any pizzas to
order. Please select again!
';
return;
}
// Add pizzas to the order
foreach ($_SESSION["orderInfo"]["pizza"] as $key=>$prodId)
{
$itemData = array();
$varData = array();
Building Pizza On The Run
[ 68 ]
$itemData["productId"] = $prodId;
$itemData["orderId"] = 0;
foreach($_SESSION["orderInfo"]["variation"][
$key] as $variationKey=>$varId)
{
$varData[]["variationId"] = $varId;
$varData[]["orderItemId"] = 0;
}
// This will add orderItem and orderItemVariation
$orderObj->addItem($itemData, $varData);
}
// Add Side dishes
foreach ($_SESSION["orderInfo"]["sideItems"] as $prodId=>$qty)
{
$itemData = array();
$itemData["productId"] = $prodId;
$itemData["quantity"] = $qty;
$itemData["orderId"] = 0;
if ($qty > 0)
{
$orderObj->addItem($itemData);
}
}
// Save the order, and notify the user
// The Order class saves data to orders, orderItems and
// orderItemVariations
// tables.
Pages:
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106