Home Forums WoodMart support forum Different layout for main categories

Different layout for main categories

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #149398

    Laurence27220
    Participant

    Hello,
    I have two requests:

    1 / I would like to display in their main categories their subcategories.
    it does not change anything when I choose the type of display “subcategory”.

    2 / So, when I click on one of these pages main categories appears a line indicating that there is no product corresponding to my selection. I would like this pop-up does not appear.

    How can I solve both of these problems?

    Thanking you

    #149418

    Hello,

    If you want to display the subcategories inside the main categories then enable the “Show current category ancestors” from Theme Settings >> Shop >> SIDEBAR & PAGE TITLE.

    Also in your second point you asking that you do not want that popup (which is drop down in actual) for that you have to enable the “Show current category ancestors” so in the category page shown that line if there is no sub categories as in the screenshot: https://jmp.sh/e53DOew

    While creating a sub category from Products >> Categories. You need to make sure that you select a Parent category for this child.

    You are using an older version of theme and outdated theme requires plugins. Kindly also update your theme as well as plugins.

    Best Regards.

    #149433

    Laurence27220
    Participant

    Thank you for your answer Aizaz.
    Actually, activating the option “Show current category ancestors” will solve part of my problem but if there is no product in a subcategory then it is not visible and, as you show on your image, it is indicated that there is no product.
      
    All my subcategories have their parent selected and my theme and extensions are up to date 😉

    It seemed to me to have seen the possibility to hide or make visible categories that have no product but I can not find where it is …

    #149448

    Most Welcome,

    In my screenshot that I provided to you displaying a message that “No product categories exist.” not only the products. It’s about the product categories.

    If the product category does not have any products inside it then it does not shown any message it just simply shown the empty category page as in the screenshot: https://jmp.sh/nMbE70G

    Also by default the empty product category does not hidden. But you can hide the categories that have no products. Try to paste the below code in funtions.php:

    function woodmart_product_categories_nav() {
    		global $wp_query, $post;
    		$show_subcategories = woodmart_get_opt( 'shop_categories_ancestors' );
    		$show_categories_neighbors = woodmart_get_opt( 'show_categories_neighbors' );
    		$list_args = array(  
    			'taxonomy' => 'product_cat', 
    			'hide_empty' => true 
    		);
    		// Menu Order
    
    		$list_args['menu_order'] = false;
    		$list_args['menu_order'] = 'asc';
    
    		// Setup Current Category
    
    		$current_cat   = false;
    		$cat_ancestors = array();
    
    		if ( is_tax( 'product_cat' ) ) {
    
    			$current_cat   = $wp_query->queried_object;
    			$cat_ancestors = get_ancestors( $current_cat->term_id, 'product_cat' );
    		}
    
    		$list_args['depth']            = 5;
    		$list_args['child_of']         = 0;
    		$list_args['title_li']         = '';
    		$list_args['hierarchical']     = 1;
    		$list_args['show_count']       = woodmart_get_opt( 'shop_products_count' );
    		$list_args['walker'] = new WOODMART_Walker_Category();
    
    		$class = ( woodmart_get_opt( 'shop_products_count' ) ) ? 'has-product-count' : 'hasno-product-count';
    
    		$shop_link = get_post_type_archive_link( 'product' );
    
    		include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' );
    		
    		if( is_object( $current_cat ) && !get_term_children( $current_cat->term_id, 'product_cat' ) && $show_subcategories && !$show_categories_neighbors ) return;
    		
    		echo '<div class="woodmart-show-categories"><a href="#">' . esc_html__('Categories', 'woodmart') . '</a></div>';
    
    		echo '<ul class="woodmart-product-categories ' . esc_attr( $class ). '">';
    		
    		echo '<li class="cat-link shop-all-link"><div class="category-nav-link"><a href="' . esc_url( $shop_link ) . '">
    				<span class="category-summary">
    					<span class="category-name">' . esc_html__('All', 'woodmart') . '</span>
    					<span class="category-products-count">
    						<span class="cat-count-label">' . esc_html__('products', 'woodmart') . '</span>
    					</span>
    				</span>
    		</a></div></li>';
    
    		if( $show_subcategories ) {
    			woodmart_show_category_ancestors();
    		} else {
    			wp_list_categories( $list_args );
    		}
    	echo '</ul>';
    }

    Best Regards.

    #150107

    Laurence27220
    Participant

    The code does not change anything.

    You say that by default the categories are visible when there are no products and we can hide them.
    Where can we do it? I may have checked a box by mistake. I can not find the place where I can do it.

    #150168

    Hello,

    With the theme options we can not hide the empty product categories.

    I used the same code in my site funtions.php and it works just fine:

    Screenshot before hiding the empty categories: https://jmp.sh/DUjI4QR

    Screenshot after hiding: https://jmp.sh/Ger8vFn

    Best Regards.

    #150241

    Laurence27220
    Participant

    That’s exactly what I want!
    Unfortunately it does not work on my site.

    The code is installed. Should something be changed in this code?

    Attachments:
    You must be logged in to view attached files.
    #150279

    aliyilmaz
    Participant

    I’m trying to remove it too https://prnt.sc/pjpfmq

    #150284

    aliyilmaz
    Participant

    Ok,

    If you want to remove the yellow bar (alert message) for your empty category page. You can hide with custom css :

    body.term-83 .woocommerce-info {
    display: none;
    }

    You should change “term-83” to your own class. You can get from there : https://prnt.sc/pjppsu

    #150379

    Hello,

    @aliyilmaz I appreciate your help and thank you for sharing the solution that might help the others. But it’s not relevant to this topic.

    @Laurence27220 I have provided you the CSS code to hide the empty categories from the Shop Page Title banner. Not from the categories menu. You need to check my screenshots that I have provided as before and after hiding those categories.

    And it is not possible to remove the empty categories from that menu which is in the header. You can only remove the empty categories manually from the Appearance >> Menus.

    Best Regards.

    #150381

    Laurence27220
    Participant

    Thank you for this information @aliyilmaz but my concern in the visibility of categories in the header where is the title

    As you can see in the photo, in the “Parcourir les catégories” menu, the “Bureau” link is expanded and you can see a number of categories. These do not have a product.
    I would like these categories to be visible under the title, as Aizaz showed me in the previous link (https://jumpshare.com/v/M6sSVSqMt9dxQR4E3cDI).
    The php code he offered me does not work at home.

    Attachments:
    You must be logged in to view attached files.
    #150388

    Laurence27220
    Participant

    Hello,

    @Aizaz, as I just said, the link you gave me showing the empty categories is the result I want to get.

    The php code you gave me does not change anything on my site.
    Would there be a change I should make in this code?

    #150470

    Hello,

    Yes, my provided code will not hide the empty categories from the search result.

    Because that code which I provided to you is just to hide the empty categories from the “Shop” page where all the products exists. And after the title the categories list is shown.

    Screenshot for better understanding: https://jmp.sh/TVjcUR9

    Best Regards.

    #150664

    Laurence27220
    Participant

    But then I do not need code because what I want is that the empty categories are visible but, on my site it is not the case.

    Between your photo and mine, we can see the difference. I made a mix of both.

    How come, since it’s automatic, I can not see the empty categories?
    I may have unchecked a box but which one?

    Anyway, thank you for the time you give me

    Attachments:
    You must be logged in to view attached files.
    #150710

    Most Welcome,

    As you said that you do not want to hide the empty categories.

    Actually those empty categories by default shown and can’t be hide with the theme options like as you said by unchecking an option.

    So it might be due to your custom code or may be due to some third party plugins.

    You can also try “Reset Default” option shown in the theme settings at the bottom of every page.

    Best Regards.

    #151603

    Laurence27220
    Participant

    I thank you for all your attention. I will test the reset or find the plugin that would be causing this problem.

    #151612

    Hello,

    Sound’s Good!..

    We are thrilled that you loved your experience with XTEMOS, We put customer experience and satisfaction as our priority, and your words reaffirms the hard work we put in every day. So thanks for your kind words and we look forward to seeing you again.

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Best Regards.

Viewing 17 posts - 1 through 17 (of 17 total)