Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
up
0
up

Woocommerce Sidebar

Postby dhwanisreejith » Mon Feb 18, 2013 2:03 pm

I'm using the default Twenty-Twelve (1.1) Wordpress (3.5.1) theme with Woocommerce (1.6.6), and would like to use a different sidebar for the shop pages - cart, checkout, my account etc. as opposed to displaying the theme's default sidebar on each of these pages.

Looking over the documentation for the Woocommerce plugin, it says that one of the ways to override the plugin's layouts and settings is by creating a folder in my themes directory called /woocommerce, placing the necessary files or folders into this and then customizing it to suit.

I've now done this, gone into my theme's /woocommerce/archive-product.php folder and placed this at the bottom of the file:

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

Then to create an additional sidebar in my Widgets panel, I've placed this into my functions.php file:

register_sidebar( array(     'name' => __( 'Woocommerce Sidebar', 'mythemename' ),     'id' => 'shop-widgets',     'description' => __( 'Appears on the shop page of your website.', 'mythemename' ),     'before_widget' => '<div id="%1$s" class="widget %2$s shop-widgets">',     'after_widget' => '</div>',     'before_title' => '<h1 class="widget-title">',     'after_title' => '</h1>', ) ); 

Now finally, I've created a sidebar-shop.php file in my themes directory:

if ( ! is_active_sidebar( 'shop-widgets' ) )     return;  // If we get this far, we have widgets. Let do this.  ?> <div id="secondary" class="widget-area" role="complementary">     <?php if ( is_active_sidebar( 'shop-widgets' ) ) : ?>     <div class="first front-widgets">         <?php dynamic_sidebar( 'shop-widgets' ); ?>     </div><!-- .first -->     <?php endif; ?> </div><!-- #secondary --> 

This works great, but only displays the new sidebar on my Shop page and not the other pages - cart, checkout, my account etc. They display the default sidebar.

From what I can tell, this is because the archive-product.php only affects the Shop page and not the others?

So I was wondering where do I locate or make the necessary changes to call the new sidebar on these other pages instead showing the default sidebar, just as I have done with my Shop page?

Thank you.


Actual Content URL:
http://stackoverflow.com/questions/14937474/woocommerce-sidebar


Answers
up
0
up

Re: Woocommerce Sidebar

Postby seahawksean » Mon Aug 26, 2013 2:40 pm

THANK YOU!!!!! I have spent 40 of the past 48 hrs trying to figure out how to get the Woocommerce sidebar to display the widgets properly in the shop pages. I even tried Woosidebars pllugin with no luck. But this simple code you pasted did the trick!!!! I am so elated right now! :D

Just wanted to point out that you forgot to include the <?php at the beginning of the code that makes up the sidebar-shop.php file. It took me a minute to figure out that's what I was missing. But as soon as I put that in, POOF, it worked.

You just saved me from losing my mind. I'm posting this everywhere so others with the same problem, yet with no solution, will now be able to do what they want to their shop sidebars.

Much appreciated.


Topic Tags