Home Forums Basel support forum Replace page category "All", in shop page

Replace page category "All", in shop page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #22266

    hcaves
    Participant

    Hello!

    Due to my small number of products, I would like to replace the Category “All” from my website.

    I’m talking for example about this page: Shop page
    Instead of the tab “All”, that shows all the products, I would like to display a custom page.

    Do you know how this is achievable?

    Thank you in advance!

    #22270

    Artem Temos
    Keymaster

    Hello,

    You can do this only with additional customization of template PHP file. This link is located in the file inc/woocommerce.php. PHP function name – basel_product_categories_nav.

    Regards

    #22357

    hcaves
    Participant

    Thanks for the answer.

    So here is what I’ve done: thanks to the pluggable function you created in the theme, I copy pasted the function in the child theme, to change what I need to change.

    To achieve my objective, I can replace the variable shop_link with
    $shop_link = get_permalink($post = 1750, $leavename = false );
    With $post = the page id I want.

    But this is not a very smooth: the page starts loading as ajax, then redirects…

    I would like to be able to display the content I want under the “All” tab, with keeping the same experience (no page reload, but the loading icon), and keep the Heading bar with the category name.

    I understand this is tricky, but is it achievable?

    Otherwise, is it possible to deactivate the loading icon, and directly go the page after clicking on “All”?

    Thank you!

    #22382

    Artem Temos
    Keymaster

    Could you please write us the function you have at the moment so we can check what is wrong? Or at least lines with your changes (20-30 lines of code).

    Regards

    #22401

    hcaves
    Participant

    I actually only did one change: I changed the variable value $shop_link.

    But it doesn’t really make sense, as I give the link to a full new page. I shouldn’t, right? I should have something with just content, I mean no menu, no page heading, etc, as when I navigate between categories thanks to the page heading of the template.

    function basel_product_categories_nav() {
    		global $wp_query, $post;
    
    		$show_subcategories = basel_get_opt( 'shop_categories_ancestors' );
    
    		$list_args = array(  
    			'taxonomy' => 'product_cat', 
    			'hide_empty' => false 
    		);
    
    		// 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['use_desc_for_title']= false;
    
    		$shop_link = get_permalink($post = 1750, $leavename = false );
    
    		include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' );
    
    		echo '<a href="#" class="basel-show-categories">' . __('Categories', 'basel') . '</a>';
    
    		echo '<ul class="basel-product-categories">';
    		
    		echo '<li class="cat-link shop-all-link"><a href="' . esc_url( $shop_link ) . '">' . __('My custom label', 'basel') . '</a></li>';
    
    		if( $show_subcategories ) {
    			basel_show_category_ancestors();
    		} else {
    			wp_list_categories( $list_args  );
    		}
    
    		echo '</ul>';
    	}
    #22405

    Artem Temos
    Keymaster

    Sorry, we got the problem. Yes, it will not be compatible with AJAX shop functionality and you can’t exclude only this link. So you may disable AJAX shop or remove this ALL link at all.

    Regards

    #22406

    hcaves
    Participant

    Ok, I got it as well.

    I will define what’s the best solution for me.

    Thank you!

    #22408

    Artem Temos
    Keymaster

    OK, contact us if you will have any additional questions.

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