woocommerce_get_breadcrumb Filter: Watch Out for Null in WooCommerce 10.6

WooCommerce 10.6 is introducing a subtle but dangerous change to the woocommerce_get_breadcrumb filter. If you’ve been working with WooCommerce as long as I have, you know that even minor “advisories” can lead to a long night of debugging when a client’s site goes dark after an update. Specifically, the integration with the WordPress Core Breadcrumbs block means your filter callback might soon receive a null value where it previously expected an object.

The Integration: Gutenberg meets WooCommerce

Historically, the woocommerce_get_breadcrumb filter only applied to WooCommerce’s own Store Breadcrumb block. However, thanks to Gutenberg PR #74169, WooCommerce now integrates with the WordPress Core Breadcrumbs block via the block_core_breadcrumbs_items filter. This is great for consistency across the site, but it fundamentally changes the filter’s signature context.

Previously, the second parameter ($breadcrumb) was guaranteed to be an instance of WC_Breadcrumb. In WooCommerce 10.6, when the filter is triggered by the Core Breadcrumbs block, that second parameter will be null.

Is your woocommerce_get_breadcrumb implementation safe?

You need to audit your codebase if you use the core/breadcrumbs block and have custom logic hooked into this filter. Similar to how WooCommerce 10.5.1 broke “Add to Cart” buttons for some due to unexpected changes, this update will cause fatal errors if you try to call methods on a null object.

Here is an example of the “Naive Approach” that will break your site:

add_filter( 'woocommerce_get_breadcrumb', function( $crumbs, $breadcrumb ) {
    // ❌ Fatal Error: Calling a method on null when using Core Breadcrumbs
    $breadcrumb->add_crumb( 'Promo', '/sale/' );

    return $crumbs;
}, 10, 2 );

Refactoring for WooCommerce 10.6

To fix this, you must refactor your code to verify the existence of the object. Using instanceof is the cleanest way to ensure you are actually dealing with a WC_Breadcrumb instance before attempting to use it. This pattern is becoming increasingly common as WooCommerce modernizes its block architecture, much like we saw in the removal of accessible private methods in 10.5.

Here is the “Senior Dev” fix:

add_filter( 'woocommerce_get_breadcrumb', function( $crumbs, $breadcrumb ) {
    // ✅ Safe: Check the object type before using methods
    if ( $breadcrumb instanceof WC_Breadcrumb ) {
        $breadcrumb->add_crumb( 'Custom Crumb', '/custom-url/' );
    }

    return $crumbs;
}, 10, 2 );

If you only need to modify the $crumbs array itself, you don’t even need the second parameter. The array-based modification remains safe regardless of whether the filter is called from a Core block or a WooCommerce block.

Look, if this woocommerce_get_breadcrumb stuff is eating up your dev hours, let me handle it. I’ve been wrestling with WordPress since the 4.x days.

Takeaway: Defensive Coding is Mandatory

This change is officially scheduled for March 10, 2026, as part of WooCommerce 10.6. You can track the progress in WooCommerce PR #62770. The lesson here is simple: never assume a filter parameter is an object just because it was in the past. Always check your types, refactor early, and ship code that won’t blow up during a routine update.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment