|
2 | 2 | <div id="mobnav-btn">Menu <i class="fa fa-bars"></i></div> |
3 | 3 | <ul class="sf-menu"> |
4 | 4 | <li> |
5 | | - <a href="http://localhost/ecomphp/index.php">Home</a> |
| 5 | + <a href="<?php echo getenv('STORE_URL'); ?>/index.php">Home</a> |
6 | 6 | </li> |
7 | 7 | <li> |
8 | 8 | <a href="#">Shop</a> |
9 | 9 | <div class="mobnav-subarrow"><i class="fa fa-plus"></i></div> |
10 | 10 | <ul> |
11 | 11 | <?php |
12 | | - $catsql = "SELECT * FROM category"; |
| 12 | + $catsql = "SELECT * FROM `category`"; |
13 | 13 | $catres = mysqli_query($connection, $catsql); |
14 | 14 | while ($catr = mysqli_fetch_assoc($catres)) { |
15 | 15 | ?> |
|
22 | 22 | <a href="#">My Account</a> |
23 | 23 | <div class="mobnav-subarrow"><i class="fa fa-plus"></i></div> |
24 | 24 | <ul> |
25 | | - <li><a href="http://localhost/ecomphp/my-account.php">My Orders</a></li> |
26 | | - <li><a href="http://localhost/ecomphp/edit-address.php">Update Address</a></li> |
27 | | - <li><a href="http://localhost/ecomphp/logout.php">Logout</a></li> |
| 25 | + <li><a href="<?php echo getenv('STORE_URL'); ?>/my-account.php">My Orders</a></li> |
| 26 | + <li><a href="<?php echo getenv('STORE_URL'); ?>/edit-address.php">Update Address</a></li> |
| 27 | + <li><a href="<?php echo getenv('STORE_URL'); ?>/logout.php">Logout</a></li> |
28 | 28 | </ul> |
29 | 29 | </li> |
30 | 30 | <li> |
|
35 | 35 | <?php $cart = $_SESSION['cart']; ?> |
36 | 36 | <div class="s-cart"> |
37 | 37 | <div class="sc-ico"><i class="fa fa-shopping-cart"></i><em><?php |
38 | | - echo count($cart); ?></em></div> |
39 | | - |
| 38 | + if (!is_null($cart)) { |
| 39 | + echo count($cart); |
| 40 | + } else { |
| 41 | + echo "0"; |
| 42 | + } ?></em></div> |
40 | 43 | <div class="cart-info"> |
41 | | - <small>You have <em class="highlight"><?php |
42 | | - echo count($cart); ?> item(s)</em> in your shopping bag</small> |
| 44 | + <small><?php |
| 45 | + if (!is_null($cart)) { |
| 46 | + echo 'You have <em class="highlight"> ' . count($cart) . ' items</em> in your shopping cart.'; |
| 47 | + } else { |
| 48 | + echo 'Your shopping cart is empty. It\'s pretty lonely over here, why not add something to it?'; |
| 49 | + } ?> |
| 50 | + </small> |
43 | 51 | <br> |
44 | 52 | <br> |
45 | 53 | <?php |
46 | | - //print_r($cart); |
47 | | - $total = 0; |
48 | | - foreach ($cart as $key => $value) { |
49 | | - //echo $key . " : " . $value['quantity'] ."<br>"; |
50 | | - $navcartsql = "SELECT * FROM products WHERE id=$key"; |
51 | | - $navcartres = mysqli_query($connection, $navcartsql); |
52 | | - $navcartr = mysqli_fetch_assoc($navcartres); ?> |
53 | | - <div class="ci-item"> |
54 | | - <img src="admin/<?php echo $navcartr['thumb']; ?>" width="70" alt=""/> |
55 | | - <div class="ci-item-info"> |
56 | | - <h5><a href="single.php?id=<?php echo $navcartr['id']; ?>"><?php echo substr($navcartr['name'], 0, 20); ?></a></h5> |
57 | | - <p><?php echo $value['quantity']; ?> x R <?php echo $navcartr['price']; ?>.00</p> |
58 | | - <div class="ci-edit"> |
59 | | - <!-- <a href="#" class="edit fa fa-edit"></a> --> |
60 | | - <a href="delcart.php?id=<?php echo $key; ?>" class="edit fa fa-trash"></a> |
| 54 | + if (!is_null($total)) { |
| 55 | + foreach ($cart as $key => $value) { |
| 56 | + $navcartsql = "SELECT * FROM `products` WHERE `id`=$key"; |
| 57 | + $navcartres = mysqli_query($connection, $navcartsql); |
| 58 | + $navcartr = mysqli_fetch_assoc($navcartres); ?> |
| 59 | + <div class="ci-item"> |
| 60 | + <img src="admin/<?php echo $navcartr['thumb']; ?>" width="70" alt=""/> |
| 61 | + <div class="ci-item-info"> |
| 62 | + <h5><a href="single.php?id=<?php echo $navcartr['id']; ?>"><?php echo substr($navcartr['name'], 0, 20); ?></a></h5> |
| 63 | + <p><?php echo $value['quantity']; ?> x R <?php echo $navcartr['price']; ?></p> |
| 64 | + <div class="ci-edit"> |
| 65 | + <a href="delcart.php?id=<?php echo $key; ?>" class="edit fa fa-trash"></a> |
| 66 | + </div> |
61 | 67 | </div> |
62 | 68 | </div> |
63 | | - </div> |
64 | | - <?php |
65 | | - $total = $total + ($navcartr['price']*$value['quantity']); |
66 | | - } ?> |
67 | | - <div class="ci-total">Subtotal: R <?php echo $total; ?>.00</div> |
| 69 | + <?php |
| 70 | + $total = $total + ($navcartr['price']*$value['quantity']); |
| 71 | + } ?> |
| 72 | + <div class="ci-total">Subtotal: R <?php echo $total; ?></div> |
68 | 73 | <div class="cart-btn"> |
69 | 74 | <a href="cart.php">View Bag</a> |
70 | 75 | <a href="checkout.php">Checkout</a> |
71 | 76 | </div> |
| 77 | + <?php |
| 78 | + } ?> |
72 | 79 | </div> |
73 | 80 | </div> |
74 | 81 | <div class="s-search"> |
|
0 commit comments