GIF89a php
Current File : /home/hencockfreshchic/public_html/cartTotal2.php
                                 <div class="table-responsive">
                                    <table class="table">
                                       <thead>
                                          <tr>
                                             <th colspan="2">Cart Total</th>
                                          </tr>
                                       </thead>
                                       <tbody>
                                          <?php                                     
                                    include("connect.php");
                                    include("libs.php");
                                    $cVal=coupon($conn,$_COOKIE["user_id"],$_COOKIE["coupon"]);
                                    $TP=0;
                                    $TD=0;
                                    $GST=0;
                                    $SHP=0;
                                    $sqlK="SELECT * FROM `my_cart` WHERE `user_id`='".$_COOKIE["user_id"]."'";
                                    $rsK=mysqli_query($conn,$sqlK);
                                    $checkK=mysqli_num_rows($rsK);
                                    if($checkK>0){
                                    while($rowK=mysqli_fetch_array($rsK)){
                                          // product details
                                       $sqlKP="SELECT * FROM `products` WHERE `sr`='".$rowK['prod_id']."'";
                                       $rsKP=mysqli_query($conn,$sqlKP);
                                       $rowKP=mysqli_fetch_assoc($rsKP);

                                       //get total discount
                                       $sqlKD="SELECT * FROM `prod_discount` WHERE `prod_id`='".$rowK['prod_id']."'";
                                       $rsKD=mysqli_query($conn,$sqlKD);
                                       $checkKD=mysqli_num_rows($rsKD);
                                       $rowKD=mysqli_fetch_assoc($rsKD);

                                       // calculate gst
                                       $GST=(($rowKP["sale_price"]*$rowKP["gst"])/100)+$GST;

                                       // calculate shipping charge
                                          $SHP=($rowKP["ship_chrg"]*$rowK['qty'])+$SHP;
                                          // calculate total price
                                       $TP=($rowKP["sale_price"]*$rowK['qty'])+$TP;
                                       // calculate total discount
                                       if($checkKD>0){
                                          $TD=((($rowKP["sale_price"]*$rowK['qty'])*$rowKD['discounts'])/100)+$TD-$cVal;
                                       }
                                       

                                    }
                                 
                                 ?>
                                          <tr>
                                             <td>Item(s) Subtotal</td>
                                             <td>
                                                <div class="price-box"> <span class="price"><i class="fa fa-inr"></i><?php echo $TP; ?></span> </div>
                                             </td>
                                          </tr>
                                          <tr>
                                             <td>Shipping</td>
                                             <td>
                                                <div class="price-box"> <span class="price"><i class="fa fa-inr"></i><?php echo $SHP; ?></span> </div>
                                             </td>
                                          </tr>
                                          <tr>
                                       <td>Gift Code</td>
                                       <td>
                                          <div class="price-box"> 
                                             <?php
                                             if($_COOKIE["gift_code_value"]<>""){
                                             ?>
                                             <span class="price"><i class="fa fa-inr"></i><?php echo $_COOKIE["gift_code_value"]; ?></span> 
                                             <?php } else { ?>
                                                <span class="price"><i class="fa fa-inr"></i>0.00</span> 
                                             <?php } ?>
                                          </div>
                                       </td>
                                    </tr>
                                    <tr>
                                       <td>Coupon Value</td>
                                       <td>
                                          <div class="price-box"> 
                                             <?php
                                             if($cVal<>""){
                                             ?>
                                             <span class="price"><i class="fa fa-inr"></i> <?php echo $cVal; ?></span> 
                                             <?php } else { ?>
                                                <span class="price"><i class="fa fa-inr"></i>0.00</span> 
                                             <?php } ?> 
                                          </div>
                                       </td>
                                    </tr>
                                           <tr>
                                             <td>Discount</td>
                                             <td>
                                                <div class="price-box"> <span class="price"><i class="fa fa-inr"></i><?php echo $TD; ?></span> </div>
                                             </td>
                                          </tr>
                                          <tr>
                                             <td>GST</td>
                                             <td>
                                                <div class="price-box">
                                                   <span class="price"><i class="fa fa-inr"></i> <?php echo $GST; ?></span>
                                                </div>
                                             </td>
                                          </tr>
                                          <tr>
                                             <td></td>
                                             <td>
                                                <div class="price-box">
                                                   <span class="price">Included GST.</span>
                                                </div>
                                             </td>
                                          </tr>
                                          <tr>
                                             <td><b>Amount Payable</b></td>
                                             <td>
                                                <div class="price-box"> <span class="price"><b><i class="fa fa-inr"></i><?php echo $TP-$TD+$GST-$_COOKIE["coupon_value"]-$_COOKIE["gift_code_value"]+$SHP-$cVal; ?></b></span> </div>
                                             </td>
                                          </tr>
                                       <?php } ?>
                                       </tbody>
                                    </table>
                                 </div>

                                 <?php
                                 if(($TP-$TD+$GST-$_COOKIE["coupon_value"]-$_COOKIE["gift_code_value"])<0)
                                 {
                                 echo '<script>alert("No items in cart");</script>';
                                 echo '<script>window.location.href="index.php";</script>';
                                 }
                        ?>