Archived topic
Dequeue menu cart
1 reply · Started by Jason on May 6, 2022
Is there a way to dequeue the menu cart on specific pages? I know I could hide "menu-bar-items" with CSS but looking fora leaner method to avoid cart fragments.
Hi there,
Using PHP - there is the option_generate_woocommerce_settings filter:
https://docs.generatepress.com/article/option_generate_woocommerce_settings/
Which you can use to disable the cart menu: $options[‘cart_menu_item’]
In addition to that you may also need to dequeue wc-cart-fragments which you can do something like this:
add_action( 'wp_enqueue_scripts', 'bbloomer_disable_woocommerce_cart_fragments', 200 );
function bbloomer_disable_woocommerce_cart_fragments() {
if ( some_condtion_is_met() ) {
wp_dequeue_script( 'wc-cart-fragments' );
}
}