Display number of items in cart together with total – WooCommerce
Just place this code in your child theme, usually it is the header.php file.
<?php /* Display number of items in cart and total */ global $woocommerce; echo "Items in cart: ".sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); echo "<br />"; echo "Total: ".$woocommerce->cart->get_cart_total(); ?>
How do I insert a custom message when the cart is empty?
Hi Zeal,
I’m not sure how would you like to format custom message or where do you want to place it.
Perhaps code below could help:
Thanks.
thank you verry much.
Thank you so much!!
This is perfect! Thanks so much.
I modified it to include a link to the cart as well.
My Version:
`<?php
global $woocommerce
echo 'View Cart (‘ . sprintf(_n(‘%d’, $woocommerce->cart->cart_contents_count, ‘woothemes’), $woocommerce->cart->cart_contents_count) . ‘)‘