Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $total=0;
- if(isset($_SESSION['carrito'])){
- $datos=$_SESSION['carrito'];
- ?>
- <table class="table table-hover">
- <thead>
- <tr>
- <th>Prod</th>
- <th>Prec.</th>
- <th>Cant.</th>
- <th>Tot(iva)</th>
- </tr>
- </thead>
- <?php
- for($i=0;$i<count($datos);$i++){
- ?>
- <tbody>
- <tr>
- <td>
- <?php echo $datos[$i]['Nombre'];?>
- </td>
- <td>
- <b class="precio"><?php echo number_format($datos[$i]['Precio'],2);</b>
- </td>
- <td>
- <input type="number" value="<?php echo $datos[$i]['Cantidad'];>"
- class="cantidad">
- </td>
- <?php
- $subtotal = $datos[$i]['Cantidad']*$datos[$i]['Precio'];
- $subtotal_iva = ($subtotal*$datos[$i]['Iva'])+$subtotal;
- ?>
- <td>
- <b class="subtotal"><?php echo number_format($subtotal_iva,2);?></b>
- </td>
- </tr>
- <?php
- $total_iva = $total + $subtotal_iva;
- $total= $total+$subtotal_iva;
- ?>
- </tbody>
- <?php
- }
- ?>
- <tr>
- <th colspan="4">
- <b style="float: right;">Total(IVA inc.):<?php echo $total_iva;?></b>
- </tr>
- <tr>
- <th colspan="4">
- <b class="total">Total a pagar:<?php echo $total;?></b>
- </th>
- </tr>
- </table>
- <script>
- $(document).ready(function() {
- $(".cantidad").keyup(function(){
- var acumulado = parseInt(0);
- var cantidad = $(".cantidad").val();
- var monto = $(".precio").val();
- acumulado = acumulado+(monto*cantidad);
- $(".subtotal").html(acumulado);
- //$(".total").html(acumulado);
- });
- });
- </script>
Add Comment
Please, Sign In to add comment