Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello I wrote some code which fixes an issue:

    	if( is_product() ) {
    		$permalinks = wc_get_permalink_structure();
    		$current_title = end($breadcrumb)[0];
    		if ( $_SERVER['HTTP_REFERER'] ) {
    			$url_parts = explode( '/', trim( wp_parse_url( $_SERVER['HTTP_REFERER'] )['path'], '/' ) );
    			$url = site_url() . '/' . $permalinks['category_base'];
    			$breadcrumb = array(
    				array( __( 'Homepage', 'woocommerce-multilingual' ), site_url(), ),
    				array( __( 'Catalog', 'woocommerce' ), site_url() . $permalinks['product_base'] . '/', ),
    			);
    			foreach( $url_parts as $url_part ) {
    				if( $term = get_term_by( 'slug', $url_part, 'product_cat' ) ) {
    					$url .= '/' . $url_part;
    					$breadcrumb[] = array( $term->name, $url );
    				}
    			}
    			$breadcrumb[] = array( $current_title );
    		} else {
    			$breadcrumb = array(
    				array( __( 'Homepage', 'woocommerce-multilingual' ), site_url(), ),
    				array( __( 'Products', 'woocommerce-multilingual' ), site_url() . $permalinks['product_base'] . '/', ),
    				array( $current_title ),
    			);
    		}
    	}
    

    You should put it in ‘your_theme/woocommerce/global/breadcrumb.php’ just after ‘if ( ! empty( $breadcrumb ) ) {‘.

    Hope it’ll help.

    Thread Starter Serge Sysoev

    (@sergesysoev)

    I’ve already translated all lines that I found in https://translate.wordpress.org/locale/ru/default/wp-plugins/simple-tooltips.

Viewing 2 replies - 1 through 2 (of 2 total)