I Want update the total of all the products in the cart page when quantity is updated. what I tried is
$d=$table.each(function(){
return Number($(this).find('.cart_price>p>span').html())*Number($(this).find('.cart_quantity_input').val());
}).toArray();
alert($d.length);
but seems its only taking the value from the first product only
I tried .map() yet same result.
I even tried total+= instead of return (total=0 initialized at first) yet its returning value only from first <tr>.
<tr>'s of my HTLM inside <table> looks like:
<tr>
<td class="cart_product">
...
</td>
<td class="cart_description">
...
</td>
<td class="cart_price">
<p>₹<span>20</span></p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<a class="cart_quantity_up" href="#"> + </a>
<input class="cart_quantity_input" type="text" name="quantity" value="8" autocomplete="off" size="2">
<a class="cart_quantity_down" href="#"> - </a>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price"> ₹<span>160</span></p>
</td>
<td class="cart_delete">
...
</td>
</tr>
I just need the sum of each (cart_price>span>p)*(.cart_quantity_input.val()).
PS:alert($d.length); is just to check no of tr's while testing but I need sum not count