Answer the question
In order to leave comments, you need to log in
How to display the number of items in the cart on the wp-megamenu icon?
How to display the number of items in the cart on the wp-megamenu icon without plugins?
The result should be something like this:
How the basket is displayed in the menu
<li class="top-cart menu-item menu-item-type-post_type menu-item-object-page wp-megamenu-item-11984 wpmm_mega_menu wpmm-fadeindown wpmm-submenu-right">
<a href="http://xxxx.xxx.xx/cart/">
<span class="wpmm-selected-icon wpmm-selected-icon-left"><i class="fa fa-cart-arrow-down"></i>
</span>
</a>
</li>
Answer the question
In order to leave comments, you need to log in
In the storefront theme, it's done like this
<?php /* translators: %d: number of items in cart */ ?>
<?php echo wp_kses_post( WC()->cart->get_cart_subtotal() ); ?>
<span class="count">
<?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) ); ?>
</span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question