WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Where is 'shop' defined?! Want to remove sidebar (14 posts)

  1. travellers
    Member
    Posted 1 year ago #

    In all the pages created by an install of woocommerce, shortcodes in the pages call the appropriate function, like [woocommerce_cart] in /Cart/, or [woocommerce_checkout] in /Checkout/ for example. But in /Shop/, no shortcode is shown. If I enter content in the page editor, it shows up on the page in the browser, above the shop content, but how does the shop 'pull in' the shop layout if its not called via a shortcode?

    I'm trying to remove the sidebar but it shows regardless. I've tried:

    Wootique Custom Settings>Layout>Full width icon (under post editor)
    Page Attributes>Template>Full Width
    and finally in utter frustration I just removed <?php get_sidebar(); ?> from page.php and the sidebar STILL showed up! Surely that isn't even possible - if its not in the php for the page, how can it ever show up?!

    Clearly /Shop/ pulls its content from elsewhere than in page.php, but I can't find where. Unlike in every other page in my site, Shop has no 'Edit Page' shortcut in the wp-admin-bar - again, no idea why this should be. Please help!

    http://wordpress.org/extend/plugins/woocommerce/

  2. bheadrick
    Member
    Posted 1 year ago #

    the shop layout is defined in the template files - particularly the archive-product.php file.

    in your theme folder, add a woocommerce folder and copy files from the woocommerce/templates folder and then modify the copied files (which are now within your theme).

    Or, if you don't want a sidebar anywhere, you could just add this in your functions.php

    remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar');

  3. travellers
    Member
    Posted 1 year ago #

    I placed that line in my functions.php file after finding it in a different thread, and its not removed the bar. I don't get it - I've removed the sidebar completely, but it still shows?!

  4. travellers
    Member
    Posted 1 year ago #

    LOL This is completely crackers! Thanks bheadrick for the pointer to the relevant file, archive-product.php (why didn't woo name that file shop.php - wouldn't that make life easier for people trying to customise!!!). I've copied that along with all the other template files into my theme folder and started editing it, and it works fine - I've deleted <?php get_footer('shop'); ?> and the footer disappeared as it should do, I've deleted pagination and that element disappeared as it should do, its all great. Well, apart from the fact that removing do_action('woocommerce_sidebar'); didn't remove the freaking sidebar! In fact, removing this whole section:

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

    doesn't remove the sidebar! I can't believe its this complicated to simply remove an element from a page :(

  5. bheadrick
    Member
    Posted 1 year ago #

    (why didn't woo name that file shop.php - wouldn't that make life easier for people trying to customise!!!).

    Funny you should ask that. A couple versions back, it was "loop-shop.php" but they decided to break it up into a couple more generic files - archive product basically controls the loop of the shop and any archives like categories, tags, and attributes, and content-product - which controls the specifics of each item in the loop.
    I was just checking out the theme that I built, and as it turns out, this did work for me:
    remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);

    but I've confirmed that it doesn't work in wootique. I did a grep on that theme and came across something in the changelog that says that they "rehooked the wc sidebar for easier removal"

    You need to do this instead:

    remove_action( 'woo_main_after', 'woocommerce_get_sidebar', 10);

  6. bheadrick
    Member
    Posted 1 year ago #

  7. travellers
    Member
    Posted 1 year ago #

    "something in the changelog that says that they "rehooked the wc sidebar for easier removal""

    LOL! The irony of the change being for the distinct purpose of removing the sidebar hasn't escaped me! But, that isn't the point, which is:
    I T W O R K S ! !

    Having worked my way through every available piece of documentation online looking for a solution to this, and adding a bit of code to try and then removing it when it inevitably didn't work, I wasn't expecting much when I included that line in my functions file. But added it, quick screen refresh, and THE SIDEBAR IS GONE! I was so happy I even stroked the cat, and I hate the damn cat!

    As always, resolving one problem only highlights another though, and now I've got to work out how to make the products span the newly available space. Resizing the <div id="main" class="col-left"> simply resizes the images rather than allowing the first product in the next line to flow up into the space, so it looks as though the 'three products per line' is hardcoded in there and not a fluid layout that blocks the next product up if there's space for it, so now its time to get my hands dirty again and see if I can change it to allow four products per line!

  8. bheadrick
    Member
    Posted 1 year ago #

    css

    .woocommerce #main{width:100%}
    ul.products li {width:20%}

    php

    function set_columns($columns){
    return 4;
    }
    add_filter('loop_shop_columns','set_columns');

  9. travellers
    Member
    Posted 1 year ago #

    Hey you're on form today! Yup, perfect, and thank you very very much for the help. You just became my new favourite person (and the cat's :) )

  10. AeronWarcliffe
    Member
    Posted 1 year ago #

    What page do you add that php code to?

  11. AeronWarcliffe
    Member
    Posted 1 year ago #

    Nevermind... I managed to fix that up, but now my sale and price arrows are messing up... the two arrows have been slightly bigger than the simple background since day one, but now they are not sitting on top of one another, rather, beside, which puts a see-through gap between them. any ideas?

    The code that I changed in the index.php:

    <div id="content" class="layout full" style="background-color:#FFF;">
    
    		<div id="main" class="fullwidth" style="background-color:#FFF;">
    
    			<div class="product-gallery">
    				<h2><?php _e( 'Recent Products', 'woothemes' ); ?></h2>
    				<?php echo do_shortcode( '[recent_products per_page="16" columns="4"]' ); ?>
    			</div><!--/.product-gallery-->
    
    		</div><!-- /#main -->
    
            <?php //get_sidebar(); ?>
    
        </div><!-- /#content -->

    And the code that I changed in the style.css:
    ul.products li { width:20%; float: left; list-style: none; position: relative; margin-right:3.8%; text-align: center; margin-bottom:2.618em; }

    And the "custom CSS" that I added via the wootique layout options:

    #content {
        background: #FFF;
    }

    The CSS shouldn't have changed it too much should it?

  12. alex222
    Member
    Posted 1 year ago #

    Hello,
    I am running into the same problem. I am by no means a web developer and I do not know much about html. I am using the wootique theme and would like to get rid of the sidebar on the shop page. It's driving me nuts.

    I went to appearance->editor->theme functions and under that custom functions thing I pasted the code you said above so it looks like this:

    /* You can add custom functions below */
    /*------------------------------------*/

    remove_action( 'woo_main_after', 'woocommerce_get_sidebar', 10);

    /*------------------------------------*/

    but nothing happened... I also changed the template for the shop page to "full width" and it didn't do anything... the sidebar is still there. What am I missing? Please help me.

    Also please reply step by step way how to do it because I am very new at editing themes.

    Thanks so much.

  13. acknowledged74
    Member
    Posted 1 year ago #

    Crikey I've tried everything I can find on this but still can't get rid of the sidebar.

    1. Tried adding the following to the themes functions.php file

    remove_action( 'woo_main_after', 'woocommerce_get_sidebar', 10);

    2. Tried commenting out do_action('woocommerce_sidebar'); in archive-product.php

    3. I've copied the Template folder over to my theme Woocommerce folder, and in \templates\shop\sidebar.php and commented the content out.

    4. I even deleted the sidebar.php file completely

    but no change at all in my shop.

    Really don't get this please please help, the shop just looks a mess with the sidebar.

  14. treccase
    Member
    Posted 11 months ago #

    Go to Appearance > Widgets and see if you have a Sidebar called Everywhere or something by a different name that basically is on every single possible theme page. If you do , empty it.

    If you also have this in your functions.php file, then you will not have a sidebar on product pages.

    /*------------------------------------*/

    remove_action( 'woo_main_after', 'woocommerce_get_sidebar', 10);

    /*------------------------------------*/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic