Advertisement
GWibisono

maaf cuma sekedar bantu

Aug 24th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.95 KB | None | 0 0
  1. <!DOCTYPE>
  2. <?php
  3. error_reporting(E_ERROR | E_PARSE);
  4. session_start();
  5.  
  6. include("functions/functions.php");
  7.  
  8.  
  9. ?>
  10. <html>
  11. <head>
  12. <title>Oklisya Shop</title>
  13.  
  14.  
  15. <link rel="stylesheet" href="styles/style.css" media="all" />
  16. </head>
  17.  
  18. <body>
  19.  
  20. <!--Main Container starts here-->
  21. <div class="main_wrapper">
  22.  
  23. <!--Header starts here-->
  24. <div class="header_wrapper">
  25.  
  26. <img id="banner" src="images/hhhhh.png" />
  27. <img id="logo" src="images/logo.png" />
  28. </div>
  29.  
  30. <!--Header ends here-->
  31.  
  32. <!--Navigation Bar starts-->
  33.  
  34.  
  35. <!--Navigation Bar ends-->
  36.  
  37.  
  38.  
  39. <!--Content wrapper starts-->
  40. <div class="content_wrapper">
  41.  
  42. <?php cart(); ?>
  43.  
  44. <div id="shopping_cart">
  45.  
  46. <span style="float:center; font-size:18px; padding:5px; line-height:50px;">
  47.  
  48. <?php
  49. if(isset($_SESSION['customer_email'])){
  50. echo "<b>Welcome : </b>" . $_SESSION['customer_email'] . "<b style='color:orange;'> Your</b>" ;
  51. }
  52. else {
  53. echo "<b> Welcome to the Store</b>";
  54. }
  55. ?>
  56.  
  57. <b style="color:orange">Shopping cart:</b>
  58. Total Items: <?php @$_SESSION['t_item'] ?>
  59. Total Price: Rp.<?php echo @$_SESSION['tagihan'] ?>,-
  60. <a href="index.php" style="color:yellow">Back to Shop</a>
  61.  
  62. <?php
  63. if(!isset($_SESSION['customer_email'])){
  64.  
  65. echo "<a href='checkout.php' style='color:white;'>Login</a>";
  66.  
  67. }
  68. else {
  69. echo "<a href='logout.php' style='color:white;'>Logout</a>";
  70. }
  71.  
  72.  
  73. ?>
  74.  
  75. </span>
  76.  
  77. </div>
  78.  
  79. <div id="sidebar">
  80.  
  81. <div id="form">
  82. <form method="get" action="results.php" enctype="multipart/form-data">
  83. <input type="text" name="user_query" placeholder="search a product" />
  84. <input type="submit" name="search" value="search"/>
  85. </form>
  86. </div>
  87.  
  88. <div id="sidebar_title">categories</div>
  89.  
  90. <ul id="cats">
  91.  
  92. <?php getCats(); ?>
  93.  
  94. </ul>
  95.  
  96.  
  97.  
  98.  
  99. </div>
  100.  
  101. <div id="content_area">
  102.  
  103.  
  104. <ul id="menu">
  105. <li><a href="index.php">Home</a></li>
  106. <li><a href="all_products.php">All Product</a></li>
  107. <li><a href="#">My Account</a></li>
  108. <li><a href="#">Sign up</a></li>
  109. <li><a href="#">Shopping Cart</a></li>
  110.  
  111. </ul>
  112.  
  113. <div id="products_box">
  114.  
  115. <form action="" method="post" enctype="multipart/form-data">
  116.  
  117. <table align="center" width="700" bgcolor="skyblue">
  118.  
  119. <tr align="center">
  120. <th>Remove</th>
  121. <th>Product (s)</th>
  122. <th>Quantity</th>
  123. <th>Price</th>
  124. <th>Total Price</th>
  125. </tr>
  126.  
  127. <?php
  128. $total = 0;
  129. $t_item = 0;
  130.  
  131. global $con;
  132.  
  133. $ip = getIp();
  134.  
  135. $sel_price = "select * from cart where ipadd='$ip'";
  136.  
  137. $run_price = mysqli_query($con, $sel_price);
  138.  
  139. $c = 0;
  140.  
  141. while($p_price=mysqli_fetch_array($run_price)){
  142.  
  143. $pro_id = $c = $p_price['proid'];
  144.  
  145. $pro_price = "select * from products where product_id='$pro_id'";
  146.  
  147. $run_pro_price = mysqli_query($con,$pro_price);
  148.  
  149.  
  150.  
  151. while ($pp_price = mysqli_fetch_array($run_pro_price)){
  152.  
  153. $product_price = array($pp_price['product_price']);
  154.  
  155. $product_title = $pp_price['product_title'];
  156.  
  157. $product_image = $pp_price['product_image'];
  158.  
  159. $single_price = $pp_price['product_price'];
  160.  
  161. $values = array_sum($product_price);
  162.  
  163. $total += $values;
  164.  
  165. ?>
  166.  
  167. <tr align="center">
  168. <td><input type="checkbox" name="remove[]" value="<?php echo $pro_id;?>"/></td>
  169. <td><?php echo $product_title; ?><br>
  170. <img src="admin_area/product_images/<?php echo $product_image;?>" width="60" height="60"/>
  171. </td>
  172. <td>
  173. <input type="text" size="4" name=<?php echo 'qty_'.$c ?>
  174. value="<?php echo @$_SESSION['qty_'.$c];?>"/>
  175. </td>
  176.  
  177. <?php
  178. if(isset($_POST['update_cart'])){
  179.  
  180. @$qty = $_POST['qty'.$c];
  181.  
  182. @$update_qty = "update cart set qty='$qty'"; // where ????
  183.  
  184. $run_qty = mysqli_query($con, $update_qty);
  185.  
  186. $_SESSION['qty'.$c]= $qty;
  187.  
  188. $total = $total*$qty;
  189. }
  190.  
  191.  
  192. ?>
  193.  
  194.  
  195. <td><?php echo "Rp " . @$single_price . ",-"; ?></td>
  196. <td><?php echo "Rp " . @$single_price*@$qty . ",-"; ?></td>
  197.  
  198. <?php @$t_item += $qty;?>
  199. </tr>
  200.  
  201.  
  202.  
  203. <?php }
  204. @$subtotal += @$single_price*@$qty;
  205. $_SESSION["tagihan"] = $subtotal;
  206. $_SESSION["t_item"] += $t_item;
  207. $c += 1;} ?>
  208. <tr align="center">
  209. <td colspan="3"></td>
  210. <td><b>Sub Total:<b></td>
  211. <td><?php echo "Rp " . @$subtotal.',-'; ?></td>
  212. </tr>
  213.  
  214. <tr align="center">
  215. <td colspan="2"><input type="submit" name="update_cart" value="Update Cart"/></td>
  216. <td><input type="submit" name="lanjut" value="Continue Shopping" /></td>
  217. <td><a href="checkout.php" style="text-decoration:none; color:black">
  218. <button type="button">Checkout</button></a></td>
  219. </tr>
  220.  
  221. </table>
  222.  
  223. </form>
  224.  
  225. <?php
  226.  
  227. global $con;
  228.  
  229. $ip = getIp();
  230.  
  231. if(isset($_POST['update_cart'])){
  232.  
  233. foreach(@$_POST['remove'] as $remove_id){
  234.  
  235. $delete_product = "delete from cart where proid='$remove_id' AND ipadd='$ip'";
  236.  
  237. @$run_delete = mysqli_query($con, $delete_product);
  238.  
  239. if($run_delete){
  240.  
  241. echo "<script>window.open('cart.php','_self')</script>";
  242.  
  243. }
  244.  
  245. }
  246. }
  247. if(isset($_POST['lanjut'])){
  248.  
  249. echo "<script>window.open('index.php','_self')</script>";
  250.  
  251. }
  252.  
  253.  
  254. ?>
  255.  
  256.  
  257.  
  258. </div>
  259.  
  260. </div>
  261. </div>
  262.  
  263. <!--Content Wrapper ends-->
  264.  
  265. <div id="footer">
  266.  
  267. <h2 style="text-align:center; padding-top:30px;">&copy; 2016 by www.OklisyaShop.com</h2>
  268. </div>
  269. </div>
  270. <!--Main Container ends here-->
  271.  
  272. </body>
  273. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement