-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstore-orders.php
36 lines (28 loc) · 1023 Bytes
/
store-orders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
session_start();
//Include libraries
require __DIR__ . '/vendor/autoload.php';
//Create instance of MongoDB client
$mongoClient = (new MongoDB\Client);
$db = $mongoClient->perfumefest;
$cart_collection = $db->cart;
// checking if a customer session is active
if (array_key_exists("customer", $_SESSION)) {
$customer_id = $_SESSION["customerID"];
// storing current customer's object id
$findCriteria = [
"cust_id" => $customer_id,
];
// extracting all basket items containing the same customer id
$customer_basket = $cart_collection->find($findCriteria);
echo'<h1>Order Summary....</h1>';
foreach ($customer_basket as $item) {
echo '<div id="order-info">';
echo '<div id="order-img"><img src="'.$item['Img_url'].'" alt=""></div>';
echo '<div id="order-name">Name:<p>'.$item['Name'].'</p> </div>';
echo '<div id="order-price">Price:<p>'.$item['Price'].'</p> </div>';
echo '</div>';
}
} else {
echo 'not logged';
}