Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //ignore the inputs,there are there so i can post the values,because <td> does not post.
- function cart(){
- global $conn;
- $fabric_options = '';
- $query2 = "SELECT * FROM almofadas";
- $result = mysqli_query($conn,$query2);
- while($rows = mysqli_fetch_assoc($result)){
- $tecido=$rows['tecido'];
- $id_price=$rows['id_price'];
- $t50='50';
- $t45='45';
- $fabric_options .= '<option value="'.$id_price.'" >'.$tecido.'</option>';
- }
- $total = 0;
- $all_products=0;
- foreach ($_SESSION as $name => $value) {
- if($value > 0){
- if(substr($name, 0, 8 ) == "product_"){
- $length = strlen($name) -8;
- $item_id = substr($name,8 , $length);
- $query = "SELECT *
- FROM gallery2
- WHERE gallery2.id =".escape_string($item_id). "";
- $run_item = mysqli_query($conn,$query);
- while($rows = mysqli_fetch_assoc($run_item)){
- $vari = $rows['variante'];
- $num = $rows['title'];
- $id = $rows['id'];
- if(!isset($_SESSION['icms'.$id])) {
- $_SESSION['icms'.$id]='0';
- }else{
- $_SESSION['icms'.$id];
- }
- $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>';
- $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>';
- $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>';
- if($rows['variante'] < 1){
- $vari="";
- }else{
- $vari =$rows['variante'];
- }
- $subtotal=$value * $_SESSION['icms'.$id];
- $cost=$_SESSION['icms'.$id];
- $all_products +=$value;
- $product = '
- <tr>
- <td style="width:100px; "><img src="../'.$rows['image'].'" style="width:90%;border: 1px solid black;"></td>
- <td>'.$num.'-'.$vari.'</td>
- <input type="hidden" value="'.$num.'" name="numero">
- <input type="hidden" value="'.$vari.'" name="vari">
- <input type="hidden" value="'.$rows['image'].'" name="desenho">
- <td style="width:15%;">
- <select name="fabric" class="fabric select form-control selectpicker" required="" data-id="'.$id.'" >
- '. $fabric_options . '
- </select>
- </td>
- <td>
- <select data-id="'.$id.'" class="select size form-control selectpicker" required style="width:80%;" name="size">
- <option value="'.$t50.'" name="'.$t50.'">50x'.$t50.'</option>
- <option value="'.$t45.'" name="'.$t50.'">45x'.$t45.'</option>
- </select>
- </td>
- <td class="product'.$id.' " value="'.$value.'" type="text" >'.$value.'</td>
- <input type="hidden" name="qnty" value="'.$value.'"/>
- <td class="cost" data-id="'.$id.'" name="'.$cost.'">R$:'.$cost.'</td>
- <input type="hidden" name="cost" value="'.$cost.'"/>
- <td class="subtotal" data-id="'.$id.'" >R$:'.number_format($subtotal, 2, '.', '') .'</td>
- <input class="subtotal" type="hidden" name="subtotal" value="'.number_format($subtotal, 2, '.', '') .'"/>
- <td>
- '.$btn_add.' '.$btn_remove.' '.$btn_delete.'
- </td>
- </tr>';
- echo $product;
- /// closing brackets
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement