Answer the question
In order to leave comments, you need to log in
How to display the number of items added to the cart?
How to dynamically show that an item has been added to the cart?
<div class="site-cart">
<?php
global $woocommerce; ?>
<a href="<?php echo $woocommerce->cart->get_cart_url() ?>" class="basket-btn basket-btn_fixed-xs">
<svg viewBox="0 0 23 24">
<path d="M6.56 15.8h13.63A2.77 2.77 0 0023 13.08V7.36a299697653450.92 299697653450.92 0 010-.06h-.18L5.13 4.54V2.2a.17.17 0 000-.07V2h-.2L1 .05a.7.7 0 00-.9.36.66.66 0 00.37.87l3.28 1.36v14.59a2.76 2.76 0 002.44 2.7 2.64 2.64 0 00-.39 1.38 2.77 2.77 0 005.54 0A2.59 2.59 0 0011 20h6.18a2.51 2.51 0 00-.39 1.35 2.78 2.78 0 102.78-2.69h-13a1.41 1.41 0 01-1.44-1.39v-1.8a3 3 0 001.43.33zM10 21.31A1.4 1.4 0 118.57 20 1.37 1.37 0 0110 21.31zm11 0A1.4 1.4 0 1119.53 20a1.37 1.37 0 011.4 1.31zm-.74-6.84H6.56a1.42 1.42 0 01-1.44-1.39v-7.2l16.51 2.21v5a1.42 1.42 0 01-1.44 1.38z" fill="#555"/>
</svg>
</a>
</div>
Answer the question
In order to leave comments, you need to log in
Like this? https://codepen.io/Dmitry_Novik/pen/dyzJMRb
Here you need to develop further, but the point is, hang the script on the class of the add to cart button and display the quantity. Since it is not clear whether you have a choice of quantity when adding to the basket, whether the button is then formed to remove from the basket, and so on, I did it by a simple +1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question