[Support request] Dequeue menu cart

Home Forums Support [Support request] Dequeue menu cart

Home Forums Support Dequeue menu cart

  • This topic has 1 reply, 2 voices, and was last updated 3 months ago by David.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2212145
    Jason

    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.

    #2212261
    David
    Staff
    Customer Support

    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' ); 
       }
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.