I have total cart quantity but I need count of products available in the cart. I donot want to show total quantity but want to show total products/orders in the cart.
Please help!
I have total cart quantity but I need count of products available in the cart. I donot want to show total quantity but want to show total products/orders in the cart.
Please help!
You can get the total number of unique product is using
WC()->cart->cart_contents
. This contains an array of cart items. You can use array_unique() function to avoid repetition of the ids. So finally you can use array_count to get the count of unique products.i had same issue in client project @ jivith.com
But i resolved ...
Use in minicart / cart function replace total products count in the cart - not their quantity items
i getting the total unique total products count in the cart instead of item of their quantity...
My demo code:
I things Following code will help you. I had a issue i want to show total product counts not their quantity in the cart option.
If you change on
class-wc-cart.php
file just change php functionarray_sum()
tocount()
it will work.