Advertisement
jamesmva

Untitled

Oct 20th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. $total = 0;
  2.  $all_products=0;
  3.     foreach ($_SESSION as $name => $value) {
  4.         if($value > 0){
  5.             if(substr($name, 0, 8 ) == "product_"){
  6.                 $length = strlen($name) -8;
  7.                 $item_id = substr($name,8 , $length);
  8.  
  9.                 $query = "SELECT *
  10.                          FROM gallery2
  11.                          WHERE gallery2.id =".escape_string($item_id). "";
  12.                 $run_item = mysqli_query($conn,$query);
  13.  
  14.         while($rows = mysqli_fetch_assoc($run_item)){
  15.         $vari   = $rows['variante'];
  16.         $num    = $rows['title'];
  17.         $id     = $rows['id'];
  18.  
  19.        
  20.        if(!isset($_SESSION['icms'.$id])) {
  21.         $_SESSION['icms'.$id]='0';
  22.         }else{
  23.         $_SESSION['icms'.$id];
  24.         }
  25.  
  26.          $btn_add ='<button type="button" class="btn btn-success actions plus" data-action="plus" product_id="'.$id.'"><i class="fa fa-plus fa-lg" aria-hidden="true" add_btn></i></button>';
  27.          $btn_remove ='<button type="button" class="btn btn-warning actions less" data-action="remove" product_id="'.$id.'"><i class="fa fa-minus fa-lg" aria-hidden="true" remove_btn></i></button>';
  28.          $btn_delete ='<button type="button" class="btn btn-default actions" data-action="delete" product_id="'.$id.'" onclick="deleteRow(this)"><i class="fa fa-times fa-lg" aria-hidden="true"></i></button>';
  29.  
  30.         if($rows['variante'] < 1){
  31.         $dash="";
  32.          $vari="";
  33.         }else{
  34.           $dash="-";
  35.          $vari =$rows['variante'];
  36.         }
  37.  
  38.         $subtotal=$value * $_SESSION['icms'.$id];
  39.         $cost=$_SESSION['icms'.$id];
  40.         $all_products +=$value;
  41.  
  42.         $_SESSION['Products_cart'] = '
  43.        <tr>
  44.          <td style="width:100px; "><img src="../'.$rows['image'].'" style="width:90%;border: 1px solid black;"></td>
  45.          <td>'.$num.''.$dash.''.$vari.'</td>
  46.  
  47.          <input type="hidden" value="'.$num.'" name="numero[]">
  48.          <input type="hidden" value="'.$vari.'" name="vari[]">
  49.          <input type="hidden" value="'.$rows['image'].'" name="desenho[]">
  50.  
  51.          <td style="width:15%;" class="row">
  52.            <select name="fabric[]" class="fabric select form-control selectpicker" required="" data-id="'.$id.'"  >
  53.                '. $fabric_options . '  
  54.            </select>
  55.          </td>
  56.            
  57.          <td class="row">
  58.            <select  data-id="'.$id.'" class="select size form-control selectpicker" required style="width:80%;"  name="size[]">
  59.              <option value="'.$t50.'" name="'.$t50.'">50x'.$t50.'</option>
  60.              <option value="'.$t45.'" name="'.$t50.'">45x'.$t45.'</option>
  61.                  
  62.            </select>
  63.          </td>
  64.          
  65.  
  66.          <td name="qnty[]" class="product'.$id.' " value="'.$value.'" type="text" >'.$value.'</td>
  67.          <input  type="hidden" name="qnty[]" value="'.$value.'"/>
  68.  
  69.          <td name="cost[]"  class="cost" data-id="'.$id.'" name="'.$cost.'">R$:'.$cost.'</td>
  70.          <input type="hidden" name="cost[]" value="'.$cost.'"/>
  71.  
  72.          <td name="subtotal[]" class="subtotal" data-id="'.$id.'" >R$:'.number_format($subtotal, 2, '.', '') .'</td>
  73.          <input class="subtotal" type="hidden" name="subtotal[]" value="'.number_format($subtotal, 2, '.', '') .'"/>
  74.          <td>
  75.             '.$btn_add.' '.$btn_remove.' '.$btn_delete.'
  76.          </td>
  77.            <input type="hidden" name="all[]" value="'. $_SESSION['total'].'"/>
  78.        </tr>';
  79.         echo $_SESSION['Products_cart'];  
  80. ////closing brackets
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement