How can I show the cart in the menu outside the shop area?

If you have a shop on your web­site, you may want to dis­play a cart but­ton on the top side menu. You already can do this by sim­ply going to Appear­ance → Cus­tomize → WooCom­merce → Options area and check the Show cart menu in main nav­i­ga­tion option. How­ev­er, this will only dis­play the cart when you’re in the shop area (shop archive or sin­gle prod­uct).

If you want to dis­play this cart on the top side all over your web­site (when check­ing a web­site or maybe the con­tact page), you just need to use the fol­low­ing code:

function pile_show_mini_cart() {
	return class_exists( 'WooCommerce' ) &&  && pile_option( 'show_cart_menu' );
}

You can add this code to the child theme. This way, you can make sure that the changes won’t dis­ap­pear when a new update of the theme will be avail­able.

Updated on September 26, 2017

Was this article helpful?

Related Articles