public
Last active

WooCommerce - Show number of items in cart and total

  • Download Gist
gistfile1.aw
PHP
1 2 3
<?php global $woocommerce; ?>
 
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>

If I'm using a child theme, where do I need to place the above code? I'm using Canvas theme.

Thanks so much! I wish they would improve their documentation to make this stuff a little easier to find...

Hi, tnx for the code.
how can I hide the word "item"/"items" and make it display only the number alone?

I need to use the total number of items in cart for my new shipping method, but I dont understand how to use this for that. Using only $woocommerce->cart->cart_contents_count doesnt seem to work?

Perfect! Thanks a million!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.