The Side Cart is convenient in any store to help users access the products they are about to purchase.
But at the same time, it may also be convenient not to have it on all pages on your website.
Some pages require more attention from the user.
So a simple way you have to prevent CheckoutWC’s Side Cart from appearing in specific pages is using the cfw_disable_side_cart filter.
In short, the cfw_disable_side_cart filter intercepts the on/off option that dictates if the Side Cart is enabled or disabled.
Following the filter’s name, you need to set it to true, and the Side Cart won’t pop up.
To dynamically change the value while detecting the page, you can use a preg_match function to check if certain slug is part of the URL.
Then wrap the preg_match evaluation in a boolval() function so it returns explicitly a boolean.
For example, if you want to disable the Side Cart on your About Us page, and the slug is yourwebsite.com/about-us/, you can do so as follows:
add_filter(
'cfw_disable_side_cart',
function() {
return boolval( preg_match( "/^\/about-us/", $_SERVER['REQUEST_URI'] ) );
}
);