Answer the question
In order to leave comments, you need to log in
Counting the number of goods how to implement?
Hello, how to implement a count of the number of all products, let's say I added 3 products to the cart, the total number is 3, I displayed the field in a div, how can I now implement the count of the number of products?
The field that displays the quantity of the product:
Js which I did, but I think it's not correct.echo $ids[$product->id]['count']
<script type="text/javascript">
jQuery("#count_qty").html('<strong>' + ids.count + '</strong>');
</script>
<div class="obsheall">
<div class="obsheekolvo"><strong>
Общее количество </strong></div>
<div class="obsheekolvooo" id="count_qty">
<strong><?php echo $total->count ?></strong>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
open browser console (F12). look at the errors there.
It will say that the ids variable does not exist. And this is not surprising, because. $ids that was in php remained on the server, and js works on the client - in the browser.
<script type="text/javascript">
;(function(w,$){
$("#count_qty").text(ids.count);//зачем вам менять html? вам нужно лишь изменить текст, то есть количество
})(window,jQuery)
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question