How to change Woocommerce breadcrumbs content?

That is due to the fact, that your filter woocommerce_breadcrumb doesn’t even exist.

This filter here works and pulls out all the elements, that are currently in the breadcrumb (as an array):

add_filter( 'woocommerce_get_breadcrumb', 'change_breadcrumb' );
function change_breadcrumb( $crumbs ) {
    var_dump( $crumbs );

    return $crumbs;
}

And this filter pulls out the main term (as an object).

add_filter( 'woocommerce_breadcrumb_main_term', 'change_breadcrumb' );
function change_breadcrumb( $main_term ) {
    var_dump( $main_term );

    return $main_term;
}

The ‘main term’ is just the first element that is returned by this function (reference):

$terms = wc_get_product_terms( $post->ID, 'product_cat', array( 'orderby' => 'parent', 'order' => 'DESC' ) )

See the Action and Filter Hook Reference by woothemes for all hooks & filters.

Leave a Comment