Archived topic
Add WooCommerce cart item indicator to custom icon
3 replies · Started by Tim on August 25, 2021
I am using a custom icon added to the primary navigation as my shopping cart icon because I needed a custom CSS class on it to open a slideout cart + remove the href.
See this thread for details:
https://generatepress.com/forums/topic/remove-the-url-from-the-menu-cart-icon
I am wondering if there is any way to add WooCommerce's number-of-items-in-the-cart indicator to my icon?
Hi there,
Woo uses this function to get the cart count:
<?php WC()->cart->get_cart_contents_count(); ?>
More info on that here:
https://docs.woocommerce.com/document/show-cart-contents-total/
Every single Google Search result I've visited shows how to add this to the stock WooCommerce Cart icon. But I need to add it to my custom icon :/
You could try asking in a general forum like this:
https://wordpress.stackexchange.com/
Or check with WooCommerce' support to see if they've seen similar requests.