From 4b5f5d74677c8db8b67a1f43d00121d0e593a59f Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Tue, 17 Oct 2017 08:28:57 -0400 Subject: [PATCH] Add sidebar for Woocommerce pages --- functions.php | 33 ++++++++++++++++++++++++++++++++- woocommerce.php | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 woocommerce.php diff --git a/functions.php b/functions.php index 35409ba..cea3ad0 100644 --- a/functions.php +++ b/functions.php @@ -374,4 +374,35 @@ function sk_custom_logo() { ) ) ); return $html; -} \ No newline at end of file +} + +//* Register webshop sidebar +genesis_register_sidebar( array( + 'id' => 'woocommerce-sidebar', + 'name' => __( 'Woocommerce Sidebar', 'ycb' ), + 'description' => __( 'This is the WooCommerce sidebar', 'ycb' ), +) ); + +//Remove default sidebar and add Woocommerce sidebar +function themeprefix_remove_default_sidebar() { + if( 'product' == get_post_type() ) {//set which pages + remove_action( 'genesis_sidebar', 'ss_do_sidebar' ); + remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); + add_action( 'genesis_sidebar', 'themeprefix_add_woo_sidebar' ); + } + } + + //Alternative Sidebar +function themeprefix_add_woo_sidebar() { + dynamic_sidebar( 'woocommerce-sidebar' ); //add in the sidebar name +} + +add_action( 'genesis_before_sidebar_widget_area', 'themeprefix_remove_default_sidebar' ); //sets the ball rolling + +//Sidebar-Content Layout on WooCommerce +function themeprefix_cpt_layout() { + if( is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) || is_tax('yith_product_brand') ) { + return 'sidebar-content'; + } +} +add_filter( 'genesis_site_layout', 'themeprefix_cpt_layout' ); \ No newline at end of file diff --git a/woocommerce.php b/woocommerce.php new file mode 100644 index 0000000..6599114 --- /dev/null +++ b/woocommerce.php @@ -0,0 +1,19 @@ +