GIF89a php
Current File : /home/hencockfreshchic/public_html/loadCart.php
<?php
         // cart items  
         include("connect.php");       
         $sqlCart="SELECT * FROM `my_cart` WHERE `user_id`='".$_COOKIE["user_id"]."'";
         $rsCart=mysqli_query($conn,$sqlCart);
         $checkCart=mysqli_num_rows($rsCart);
         ?>
<div class="row">
                  <div class="col-12">
                     <div class="cart-item-table commun-table">
                        <div class="table-responsive">
                           <table class="table">
                              <thead>
                                 <?php if($checkCart>0){ ?>
                                 <tr>
                                    <th>Product</th>
                                    <th>Product Name</th>
                                    <th>Price</th>
                                    <th>Quantity</th>
                                    <th>Sub Total</th>
                                    <th>Action</th>
                                 </tr>
                              <?php } ?>
                              </thead>
                              <tbody>
                                 <?php
                                 if($checkCart>0){
                                    while($rowCart=mysqli_fetch_array($rsCart)){
                                       $sqlCP="SELECT * FROM `products` WHERE `sr`='".$rowCart['prod_id']."'";
                                       $rsCP=mysqli_query($conn,$sqlCP);
                                       $rowCP=mysqli_fetch_assoc($rsCP);

                                       // get discount on products
                                       $sqlDis="SELECT * FROM `prod_discount` WHERE `prod_id`='".$rowCart['prod_id']."'";
                                       $rsDis=mysqli_query($conn,$sqlDis);
                                       $checkDis=mysqli_num_rows($rsDis);
                                       $rowDis=mysqli_fetch_assoc($rsDis);
                                       if($checkDis>0)
                                       {
                                          $sprice=$rowCP["sale_price"]-(($rowCP["sale_price"]*$rowDis["discounts"])/100);
                                       }
                                       else
                                       {
                                          $sprice=$rowCP["sale_price"];
                                       }
                                 ?>
                                 <tr id="<?php echo $rowCart['sr']; ?>">
                                    <td>
                                       <a href="product-page.php?prod_id=<?php echo $rowCP["sr"]; ?>&product=<?php echo $rowCP['p_name']; ?>&category=<?php echo $rowCP['subcat_name']; ?>">
                                          <div class="product-image cart-img-box">
                                             <img alt="<?php echo $website_name; ?>" src="<?php echo "admin.cpanel/".$rowCP["image"]; ?>">                                             
                                          </div>
                                          <input type="hidden" id="count" value="<?php echo $checkCart; ?>">
                                       </a>
                                    </td>
                                    <td>
                                       <div class="product-title"> 
                                          <a href="product-page.php?prod_id=<?php echo $rowCP["sr"]; ?>&product=<?php echo $rowCP['p_name']; ?>&category=<?php echo $rowCP['subcat_name']; ?>"><?php echo $rowCP["p_name"]; ?></a> 
                                       </div>
                                    </td>
                                    <td>
                                       <ul>
                                          <li>
                                             <div class="base-price price-box"> 
                                                <span class="price" id="<?php echo "sprice".$rowCart['sr']; ?>"><i class="fa fa-inr"></i><?php echo $sprice; ?></span> 
                                             </div>
                                          </li>
                                       </ul>
                                    </td>
                                    <td>
                                       <div class="product-qty">
                                             <label for="qty">Qty:</label>
                                             <div class="custom-qty">
                                                <button onclick="minus('qty<?php echo $rowCart['sr']; ?>','<?php echo "sprice".$rowCart['sr']; ?>','<?php echo "subTotal".$rowCart['sr']; ?>','<?php echo $rowCart['sr']; ?>','<?php echo $rowCart['prod_id']; ?>')" class="reduced items" type="button"> <i class="fa fa-minus"></i> </button>
                                                <input type="text" class="input-text qty" title="Qty" value="<?php echo $rowCart['qty']; ?>" maxlength="8" id="qty<?php echo $rowCart['sr']; ?>" name="qty<?php echo $rowCart['sr']; ?>">
                                                <button onclick="plus('<?php echo "qty".$rowCart['sr']; ?>','<?php echo "sprice".$rowCart['sr']; ?>','<?php echo "subTotal".$rowCart['sr']; ?>','<?php echo $rowCart['sr']; ?>','<?php echo $rowCart['prod_id']; ?>')" class="increase items" type="button"> <i class="fa fa-plus"></i> </button>
                                             </div>
                                          </div>
                                    </td>
                                    <td>
                                       <div class="total-price price-box"> 
                                         <i class="fa fa-inr"></i> <span class="price" id="<?php echo "subTotal".$rowCart['sr']; ?>"><?php echo $sprice*$rowCart["qty"]; ?></span> 
                                       </div>
                                    </td>

                                    <td>
                                       <i title="Remove Item From Cart" data-id="100" class="fa fa-trash cart-remove-item" onclick="delCartItem2('<?php echo $rowCart['sr']; ?>')"></i>
                                    </td>
                                 </tr>
                                 <?php }} else { ?>
                                    No items found in the cart
                                 <?php } ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                  </div>
               </div>