I am using woocommerce and wordpress for an e-commerce website. I want to be able to display the number of items and total price in a user’s cart anywhere on the page.
Normally — and if you use one of the woo themes — this shows up in the menu navigation bar. However, I am using an almost completely blank theme, and I do not know how I can get the item / price total information and display it in html. Their documentation gives this snippet:
http://docs.woothemes.com/document/show-cart-contents-total/
<?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>`<br>
But I do not understand what HTML tag or class I would use to make that display. What sort of element and class id would I need to use to make this appear?
Make sure to include the codes below for your theme’s functions.php file.
And also this will ajaxify your cart to be updated automatically without reloading the page.