[Resolved] Sidebar not showing for Single product

This topic contains 4 replies, has 2 voices, and was last updated by  Andrew Misplon 2 months ago.

Tagged: 

  • Author
    Posts
  • #10503

    LazerCats557
    Participant

    Hi guys,

    My client wants a sidebar on the single product page in woocommerce which was on by default on their old site. I can get the sidebar to display on the shop page but I cannot get it to display in the single-product page for the actual product. My client wants this side bar so they can include essential information for the buyer before purchasing.

    It appears that the theme somehow has this hidden or turned off because every attempt to add the sidebar to single product pages has failed. I have tried plugins and even php edit on child theme’s unsuccessfully.

    Thanks in advance,
    Jared

    #10504

    Andrew Misplon
    Keymaster

    Hi Jared

    Thanks for posting. Polestar doesn’t offer a sidebar on single product pages. I’ll get back to you with a child theme solution. Chat then 🙂

    #10509

    Andrew Misplon
    Keymaster

    Please, find a child theme solution here: https://purothemes.com/wp-content/uploads/2018/09/polestar-child-wc-single-sidebar.zip

    If you’re currently using a child theme, download the above and take a look at the changes I’ve made and integrate them into your child theme.

    If you aren’t using a child theme at the moment then you’ll install this child theme from Themes > Add New > Upload Theme. To migrate your settings from the parent to the child, please see: https://purothemes.com/customizer-settings-export-import/.

    #10534

    LazerCats557
    Participant

    Thanks Andrew. It did successfully add the side bar. The only other challenge is that I need it on the right hand side. What do I need to do to make that happened. I tried to change it in customizer and it didn’t work.

    Thanks again man,

    Jared

    #10535

    Andrew Misplon
    Keymaster

    You’ll need to make a small edit to the functions.php file in the child theme. The easiest would be to remove the polestar_child_body_classes function and replace it with the following:

    /**
     * Adds custom classes to the array of body classes.
     *
     * @param array $classes Classes for the body element.
     * @return array
     */
    function polestar_child_body_classes( $classes ) {
    
    	// WooCommerce sidebar.
    	if ( is_active_sidebar( 'sidebar-shop' ) && ( function_exists( 'is_woocommerce' ) && is_woocommerce() && is_product() ) ) {
    		$classes[] = 'woocommerce-sidebar';
    		
    		if ( get_theme_mod( 'woocommerce_sidebar_position' ) == 'right' ) {
    			$classes[] = 'woocommerce-sidebar-right';
    		}	
    	}
    
    	return $classes;
    
    }
    add_filter( 'body_class', 'polestar_child_body_classes' );
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Scroll to top