Snippet: Remove Theme Styles from WooCommerce Cart & Checkout
If you are using a plugin that modifies the default WooCommerce cart and checkout pages you may want to remove the theme's styles that modify these to prevent conflicts and/or to slim down the site. Total loads the WooCommerce CSS independently, this means you can easily dequeue it if wanted. Below is a sample snippet that can be used to remove the theme's styles from these pages:
// Remove the theme's WooCommerce CSS on the cart and checkout pages.
add_action( 'wp_enqueue_scripts', function() {
$is_cart = function_exists( 'is_cart' ) && is_cart();
$is_checkout = function_exists( 'is_checkout' ) && is_checkout();
if ( $is_cart || $is_checkout ) {
wp_dequeue_style( 'wpex-woocommerce' );
wp_dequeue_style( 'wpex-woocommerce-shop-table-smallscreen' );
wp_dequeue_style( 'wpex-woocommerce-cart-smallscreen' );
}
}, 100 );
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)
We recommend Code Snippets (100% Free) or WPCode (sponsored)