Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #914047

    I would like to modify breadcrumbs and change the name and url from shop to store. Ive researched the forums and cant find what im needing. is this possible?

    ive tried the code below in functions.php but doesnt seem to work. it puts store in front of shop in breadcrumbs

    add_filter( ‘avia_breadcrumbs_trail’, ‘avia_breadcrumbs_trail_mods’, 50, 2 );

    function avia_breadcrumbs_trail_mods( $trail, $args ) {
    $shopurl = ‘mysite/store’;
    $shoptitle = ‘Store’;
    if ( is_front_page() ) return;
    $trail[0] = ‘‘. $shoptitle .’‘;
    return $trail;
    }

    • This topic was modified 6 years, 9 months ago by lucky7t.
    #914115

    Hey lucky7t,

    Yes, just go to Woocommerce > Settings > Products > Shop, then check what page is set as the Shop Page, go the the page edit it, rename it to Store, change the permalink to store. I have tested this on my end and it works. Hope this helps :)

    Best regards,
    Nikko

    #914478

    yes it does but by doing this it disables the advanced layout editor.

    “This page is set as the default WooCommerce Shop Overview and therefore does not support the Enfold advanced layout editor
    (Learn more)”

    #914699

    Hi,

    Yes it does, can you try to do this instead, make sure you are using a child theme, if you’re not please try to use it, you can find the instructions here: https://kriesi.at/documentation/enfold/using-a-child-theme/ then at the bottom of functions.php of the child theme, add this php code:

    add_action('after_setup_theme','avia_remove_woocommerce_breadcrumb');
    function avia_remove_woocommerce_breadcrumb(){
    	remove_filter('avia_breadcrumbs_trail','avia_woocommerce_breadcrumb');
    	remove_filter('avf_title_args','avia_title_args_woopage');
    }
    
    
    add_filter('avia_breadcrumbs_trail','avia_custom_woocommerce_breadcrumb', 50, 2);
    
    function avia_custom_woocommerce_breadcrumb($trail)
    {
    	global $avia_config;
    
    	if(is_woocommerce())
    	{
    
    		$home 		= $trail[0];
    		$last 		= array_pop($trail);
    		$shop_id 	= get_id_by_slug('store');
    		$taxonomy 	= "product_cat";
    
    		// on the shop frontpage simply display the shop name, rather than shop name + "All Products"
    		if(is_shop())
    		{
    			if(!empty($shop_id) && $shop_id  != -1)  $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $shop_id ) );
    			$last = "";
    
    			if(is_search())
    			{
    				$last = __('Search results for:','avia_framework').' '.esc_attr($_GET['s']);
    			}
    		}
    
    		// on the product page single page modify the breadcrumb to read [home] [if available:parent shop pages] [shop] [if available:parent categories] [category] [title]
    		if(is_product())
    		{
    			//fetch all product categories and search for the ones with parents. if none are avalaible use the first category found
    			$product_category = $parent_cat = array();
    			$temp_cats = get_the_terms(get_the_ID(), $taxonomy);
    
    			if(!empty($temp_cats))
    			{
    				foreach($temp_cats as $key => $cat)
    				{
    					if($cat->parent != 0 && !in_array($cat->term_taxonomy_id, $parent_cat))
    					{
    						$product_category[] = $cat;
    						$parent_cat[] = $cat->parent;
    					}
    				}
    
    				//if no categories with parents use the first one
    				if(empty($product_category)) $product_category[] = reset($temp_cats);
    
    			}
    			//unset the trail and build our own
    			unset($trail);
    
    			$trail[0] = $home;
    			if(!empty($shop_id) && $shop_id  != -1)    $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $shop_id ) );
    			if(!empty($parent_cat)) $trail = array_merge( $trail, avia_breadcrumbs_get_term_parents( $parent_cat[0] , $taxonomy ) );
    			if(!empty($product_category)) $trail[] = '<a href="' . get_term_link( $product_category[0]->slug, $taxonomy ) . '" title="' . esc_attr( $product_category[0]->name ) . '">' . $product_category[0]->name . '</a>';
    
    		}
    
    
    		// add the [shop] trail to category/tag pages: [home] [if available:parent shop pages] [shop] [if available:parent categories] [category/tag]
    		if(is_product_category() || is_product_tag())
    		{
    			if(!empty($shop_id) && $shop_id  != -1)
    			{
    				$shop_trail = avia_breadcrumbs_get_parents( $shop_id ) ;
    				array_splice($trail, 1, 0, $shop_trail);
    			}
    		}
    
    		if(is_product_tag())
    		{
    			$last = __("Tag",'avia_framework').": ".$last;
    		}
    
    
    		if(!empty($last)) $trail[] = $last;
    	}
    
    	return $trail;
    }
    
    add_filter('avf_title_args','avia_title_args_custom_woopage', 10, 4);
    function avia_title_args_custom_woopage($args)
    {
    	if(is_single() && is_product())
    	{
    		$args['heading'] = "strong";
    		$args['title'] = "Store";
    	}
    
    	return $args;
    }
    
    function get_id_by_slug($page_slug) {
        $page = get_page_by_path($page_slug);
        if ($page) {
            return $page->ID;
        } else {
            return null;
        }
    }
    

    If it’s causing any issue please try to copy the code from here: https://pastebin.com/RRjQJ4vC
    Please make sure that the title of the page is Store and the slug is set to store and no parent page, since this will appear in the breadcrumbs. Hope this helps :)

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.