Skip to content

@mikejolley /gist:2044101
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
WooCommerce - Show number of items in cart and total
<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>
@chirag-v

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

@EvanAgee

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

@guygolan

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

@danielholm

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?

@Swingline0

Perfect! Thanks a million!

@mohsinoffline

This is exactly what I was looking for. Thanks!

@minitpatil

thank you so much boss! feeling happy..:-)

@amaisbajwa

thanks

@elvinlee

Can this apply in email template?

@ajithrn

thanks :smile:

@WaqarWebz

Hi ! How can I get the number of items of Current Product in cart at product single page?????
like, in my website
http://cartridgemedia.co.uk/beta/shop/brother/compatible-brother-dr2100-brother-dr-2100/
I need to show it in black strip at the right box

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.