<td class="product-name">
<a href="single-product.html">Juan ramon ibañez</a>
</td>
<td class="product-price">
<span class="amount">600.40 €</span>
</td>
<td class="product-quantity">
<div class="quantity buttons_added">
<input type="number" size="4" class="input-text qty text cantidax" title="Qty" value="2" min="0" step="1" >
<a href="" class="btn btn-warning actualizaCantidad" ><i class="fa fa-refresh"></i></a>
</div>
</td>
<td class="product-subtotal">
<span class="amount"></span>
</td>
</tr>
<tr class="cart_item">
<td class="product-remove">
<form method="POST" action="" accept-charset="UTF-8"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="qtviOQDNvRIOVAO0RFUKF4UKfWs9LGrKHpScuzKR">
<input type="submit" value="x" title="Eliminar este elemento" class="remove" >
</form>
</td>
<form method="POST" action="c" accept-charset="UTF-8"><input name="_method" type="hidden" value="PUT"><input name="_token" type="hidden" value="qtviOQDNvRIOVAO0RFUKF4UKfWs9LGrKHpScuzKR">
<td class="product-thumbnail">
<a href="single-product.html"><img width="145" height="145" alt="poster_1_up" class="shop_thumbnail" src="/ima/1.jpg"></a>
</td>
<td class="product-name">
<a href="single-product.html">Manuel Bernal Garcia</a>
</td>
<td class="product-price">
<span class="amount">200.20 €</span>
</td>
<td class="product-quantity">
<div class="quantity buttons_added">
<input type="number" size="4" class="input-text qty text cantidax" title="Qty" value="1" min="0" step="1" >
<a href="" class="btn btn-warning actualizaCantidad" ><i class="fa fa-refresh"></i></a>
</div>
</td>
<td class="product-subtotal">
<span class="amount"></span>
</td>
</tr>
<tr>
<td class="actions" colspan="6">
<input type="submit" value="Actualiza Importes" name="update_cart" class="button actualiza_importe_compra" >
<input type="submit" value="Pagar" name="proceed" class="checkout-button button alt wc-forward">
</td>
</tr>
The idea is this, this is the final source code of a project I'm doing. I have put only two rows since the code is dynamic, and it is a repetition of the tr with the cart_item class.
What I want is that when you click on the button with the class. update_import_buy add up all the totals of each row, but when using an input number to modify the quantity is failing me, that is why to find the total of totals , you would have to find all the prices multiplied by the quantity of each row and go adding them (accumulating them). The problem I have when referencing each price and each quantity using the each, which by the way I have not used much
$('.actualiza_importe_compra').click(function()
{
var inputCantidad = parseInt($(this).parents('tr').find('input.cantidax'));
var precio = parseFloat($(this).parents('tr').find('.product-price.amount'));
$.each(function(index,value)
{
var total = inputCantidad.val() * precio.text();
console.log(total);
});
return false;
});
});
This is what I have but it does not work for me, I have problems to reference when pressing the button the quantity and the dynamic price.