Woocommerce cart empty when BB activated

Hi all,

This is weird. We have this live site that uses woocommerce for a small shop. This works fine (without BB). For another part of the site, we want to user BB + Pods to make a nice pods lay-out.

So then this happens:
When BB is activated (just activated, nothing done), the woocommerce cart is empty and stays empty. When we add a product it says “is added” (without any product name) and the cart show empty.
When BB is deactivated, the add product button works like before.

So, we don’t even want to use BB with woocommerce, only with a pods archive. Has anyone encountered this before?

Regards, Jelmer

Yes, I have seen it one other time but we didn’t get to the bottom of it. And in that case it seemed related to caching.

Can you talk more about what else you are using - what theme? Any Woo add-ons?

Also if you can provide your URL that would be helpful.

Hi Jamie,

Sure. The site is https://honigbreethuis.nl. It runs on a child theme of Baskerville, quite a basic theme, that we heavily override in the child. For woocommerce we have two small plugins and some overloaded code (hooks) and templates. No caching plugin.

So this brought me to an idea: I’ve remove all our coded hooks and this helps to keep the cart filled (although the ‘add to cart’ button is gone). So let me try and debug this further, I’ll keep you posted.

Thanks, Jelmer

Got it,

I just debugged all our woocommece hooks and filters, and this one did it. The developer who made this part (this was before we moved to BB) hooked a generic gettext filter to change the translation of ‘Total’ in woocommece, but forgot to check to domain:

Faulty code:

add_filter( 'gettext', 'hbh_extra_vertalingen', 20, 3 );
switch ( $text ) {
                                case 'Total':
                                        $translated_text = sihw_category_in_cart() ? __( 'Totaal (incl. verzendkosten en btw)', 'woocommerce' ) : __( 'Totaal (incl. btw)', 'woocommerce' );
                                        break;
}
 return $translated_text;
}

With BB active, gettext is also called for text ‘Total’ with domain fl-builder. The code above returns some other text (longer? with parenthesis?) This somehow crashes the woocommerce cart shortcode in combination with BB.

Code changed to:

add_filter( 'gettext', 'hbh_extra_vertalingen', 20, 3 );
function hbh_extra_vertalingen( $translated_text, $text, $domain ) {
        if ($domain == 'woocommerce')
        {
                switch ( $text ) {
                        case 'Total':
                                $translated_text = sihw_category_in_cart() ? __( 'Totaal (incl. verzendkosten en btw)', 'woocommerce' ) : __( 'Totaal (incl. btw)', 'woocommerce' );
                                break;
                }
        }
        return $translated_text;
}

And BB works fine again. I’m still not happy with this generic gettext, but that’s another problem.

Maybe this might hint you to a solution the next time this comes around.

Thanks for thinking along!

Jelmer

Thanks so much for posting your solution. I’ll go back and check the other site if I can to see if they have anything similar!

1 Like