How to remove the Woocommerce sidebar from the cart, checkout and individual product pages?

Like many people using woocommerce for the first time, I need to know how to set them up. In my specific situation, I want to remove the sidebar from the Cart, Checkout pages and individual products. My sidebar is defined and called from sidebar.php using the following code:

<?php dynamic_sidebar('global-sidebar'); ?>

I tried for a long time to find an answer that works, but I can not find the correct code or solution. Perhaps asking the question itself will work. By the way, I really appreciate the answers in other articles and instructions, but they do not work for me.

Before I go any further, I use Bootstrap (latest version from 2014) to build my Wordpress site. Not sure if that matters, but maybe one way or another.

Can someone tell me how I find and then tell Woocommerce not to display any sidebar on the Cart, Checkout, and Single Product pages?

I really hope to find a solution and ask that you burned with me, since I am not a developer, so it would be very clear and easy to follow the instructions.

Yours faithfully,

Oliver

ps The website can be found here> wp.wunderful.co.uk (intermediate site for the client website project)

+4
source share
6 answers

In theory, something like the following should work, but I have not tested it. (To add functions.php to your theme)

function so_25700650_remove_sidebar(){
    if( is_checkout() || is_cart() || is_product() ){
        remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
    }
}
add_action('woocommerce_before_main_content', 'so_25700650_remove_sidebar' );

Woo,

<?php
    /**
     * woocommerce_sidebar hook
     *
     * @hooked woocommerce_get_sidebar - 10
     */
    do_action( 'woocommerce_sidebar' );
?>

: " ". woocommerce_get_sidebar woocommerce_sidebar hook..., , , . , Woo, .

woocommerce_before_main_content, , , , . , , , wp_head -, , , , , , , is_checkout() .., , - WooCommerce. , , WooCommerce, , WooCommerce , , .

:

, . - , .

+4
.woocommerce-cart .sidebar {
    display: none;
}

.woocommerce-cart .content-area {
    width: 100%;
}

custom/style.css.

+2

https://wordpress.org/support/topic/remove-sidebar-for-woocommerce-cart-and-checkout-pages/

, , function.php

add_action('wp_head', 'hide_sidebar' ); function hide_sidebar(){ if(is_cart() || is_checkout()){ ?>
<style type="text/css">
    #secondary {
        display: none;
    }
</style>
<?php
}
+2

, woocomemrce.php , . , , , , . woocommerce.php woocommerce_content(), . . , , , if-statements , .

if( is_post_type_archive( 'product' ) ) :
    //Content to display in the list view (i.e. with sidebar)
else :
    //Content to display all other views (i.e. without sidebar)
endif;
+1

"" , " " → "" " ", .

+1

Cart, Checkout , action-hook function.php -

    add_action('woocommerce_before_main_content', 'remove_sidebar' );
    function remove_sidebar()
    {
        if( is_checkout() || is_cart() || is_product()) { 
         remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
       }
    }

WooCommerce Filter Hook - https://docs.woothemes.com/wc-apidocs/hook-docs.html

0

All Articles