Skip to content

Snippet: Display Shop Sidebar for WooCommerce Cart & Checkout

By default the theme uses the is_woocommerce() conditional for displaying the WooCommerce sidebar on the website. However, WooCommerce doesn't treat the cart/shop as actual WooCommerce pages so they will display the standard page or default sidebar instead of the WooCommerce one. However, you can use some custom code if you wanted to display it (although my recommendation would be to set these pages to a no-sidebar layout as this is more common practice).

add_filter( 'totaltheme/sidebars/primary/name', function( $sidebar ) {
	if ( ( function_exists( 'is_cart' ) && is_cart() ) || ( function_exists( 'is_checkout' ) && is_checkout() ) ) {
		$sidebar = 'woo_sidebar';
	}
	return $sidebar;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top