Show number of items in cart and total

22 Apr Show number of items in cart and total

For showing the number of products that added to cart  on any where (probably on top right corner ) please use the following code .

<a class=”cart-contents” href=”<?php echo WC()->cart->get_cart_url(); ?>” title=”<?php _e( ‘View your shopping cart’ ); ?>”><?php echo sprintf (_n( ‘%d item’, ‘%d items’, WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> – <?php echo WC()->cart->get_cart_total(); ?></a>