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

    Heyho,

    not sure if this is a WooCommerce problem or theme-related.

    In any case, the breadcrumbs are a bit weird (on your theme demo as well, so it is not just my problem).

    On shop overview pages they are correct, like Home > Shop > Category

    On product detail pages they are like Home > Shop > Products > Producttitle , and “Shop” and “Products” are both linked to the shop overview. Instead they should be like Home > Shop > Category > Producttitle with linking to the proper storefront and category page.

    Fix?

    Cheers

    Martin

    #64240

    Those breadcrumbs still make no sense ;-)

    I have tried several of the WooCommerce prefix settings, but the main problems do not go away: the dupe (“shop” and the name of the custom post type for Products) in the breadcrumbs and the missing category on product details pages.

    …and for me it is the final glitch so far before I consider my new Abundance-based site to be suitable for visitors.

    soooo – would love to hear how to fix this or see a minor update with breadcrumbs that make sense.

    CSS-related stuff is inconvenient but can usually be easily fixed / customized.

    This however is PHP-related, most likely in some core-files, and clearly a glitch.

    Thanks!

    Martin

    #64241

    Hey,

    open up abundanceframeworkphpclass-breadcrumb.php and replace:

    /* If there's an archive page, add it to the trail. */
    if ( !empty( $post_type_object->has_archive ) && function_exists( 'get_post_type_archive_link' ) )
    $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';

    with:

    /* If there's an archive page, add it to the trail. */
    if ( !empty( $post_type_object->has_archive ) && function_exists( 'get_post_type_archive_link' ) ){
    if (is_product()){
    $prod_cat = array();
    $prod_cat[] = get_the_term_list(get_the_ID(), 'product_cat');
    $trail[] = $prod_cat[0];
    }else{
    $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';
    }
    }

    #64242

    Thanks Dude, that seems to do the trick!

    #64243

    I have the same issue, implementing the above code does add in the Category however it adds in all categories it is in without spaces, in the following example ” Eco Friendly OptionsPack N PlaysSleepy Time” is 3 categories: Eco Friendly Options, Pack N Plays and Sleepy Time

    You are here: Home » Browse Products » Eco Friendly OptionsPack N PlaysSleepy Time » BABYBJÖRN Travel Crib Light 2

    BABYBJÖRN Travel Crib Light 2

    This code:

    $prod_cat[] = get_the_term_list(get_the_ID(), ‘product_cat’);

    var_dump( $prod_cat);

    Shows:

    array(1) { [0]=> string(333) “Eco Friendly OptionsPack N PlaysSleepy Time” }

    Is there any way around this?

    Thanks for the help

    #64244

    Hi,

    Replace the code with this.

    /* If there's an archive page, add it to the trail. */
    if ( !empty( $post_type_object->has_archive ) && function_exists( 'get_post_type_archive_link' ) ){
    if (is_product()){
    $prod_cat = array();
    $prod_cat[] = get_the_term_list(get_the_ID(), 'product_cat','','','','');
    $trail[] = $prod_cat[0];
    }else{
    $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';
    }
    }

    Regards,

    Ismael

    #64245

    Hi

    Thank you for the response, the above code didn’t change the output. I added some hacks to the code that displayed it correct some of the time but it seems like get_the_term_list doesn’t always return the array in the same parent/child category order so it is a bit flaky. Here is my hack that sorta fixes the problem, is it possible to bullet proof this or maybe it’s not possible to fix this when a product is in multiple categories?

    $prod_cat = array();

    //$prod_cat[] = get_the_term_list(get_the_ID(), ‘product_cat’,”,”,”,”);

    //$trail[] = $prod_cat[0];

    $prod_cat[] = get_the_term_list(get_the_ID(), ‘product_cat’,”,’;’,”,”);

    $cat_array = explode(“;”, $prod_cat[0]);

    $parent = $cat_array[count($cat_array) - 1];

    if(count($cat_array) >= 2) {

    $child = $cat_array[count($cat_array) - 2];

    } else {

    $child = $cat_array[0];

    }

    if(count($cat_array) > 0 ) {

    if($parent == $child) {

    $trail_array = $parent;

    } else {

    $trail_array = $parent . ‘ <span class=”sep”>’ . $separator . ‘</span> ‘ . $child;

    }

    $trail[] = $trail_array;

    }

    #64246

    Hi dunkfu,

    Thanks for posting your end fix. I’m not sure what else you could do with get_the_term_list as it seems to be a bit limited. See: http://codex.wordpress.org/Function_Reference/get_the_term_list

    Regards,

    Devin

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

The topic ‘Breadcrumbs glitching… illogical structure’ is closed to new replies.