Site logo

Archived topic

Add to cart banner not showing on bundle products

23 replies · Started by nik9 on February 2, 2021

Viewing posts 16–24 of 24

Sounds good. We are in beta two now so hopefully not too too long.

Hello, Now GP 2.0 is available. I also already added the snipped. But it is not working as expected. Do I miss here something again? :)

Cheers

Hello, Now GP 2.0 is available. I also already added the snipped. But it is not working as expected. Do I miss here something again?

Have you installed it and then tested the code?

IF yes and it didn't work, can you make a copy of your site on a staging site and let us take a look on the backend? This is so if we do any change on the site, it doesn't affect the live one.

Let us know.

Hello Elvin,

Yes. Please see system infos in the note field :)

Hi there,

Is it ok if I add some debug code to the snippet to see where the point of failure is? I see this is a live site, so perhaps a staging site would be better?

Hello Tom,

This is a staging site. So you can play around :)

Definitely something strange going on. Even my var_dump() functions aren't outputting anything at all.

Is there any server caching going on? Caching plugins maybe?

I think on staging no caching is on. Hmm.. We use WP Rocket on prod system. But on staging this should be turned off.

So I installed that plugin on my localhost and did some testing. This ended up working for me:

add_filter( 'generate_wc_sticky_add_to_cart_action', function( $action, $product ) {
    if ( $product->is_type( 'woosb' ) ) {

        $quantity_buttons = '';

        if ( generatepress_wc_get_setting( 'quantity_buttons' ) ) {
            $quantity_buttons = ' do-quantity-buttons';
        }

        $args = array(
            'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
            'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
        );

        $action = sprintf(
            '<form action="%1$s" class="cart%2$s" method="post" enctype="multipart/form-data">
                %3$s
                <button type="submit" class="button alt">%4$s</button>
            </form>',
            esc_url( $product->add_to_cart_url() ),
            $quantity_buttons,
            woocommerce_quantity_input( $args, $product, false ),
            esc_html( $product->add_to_cart_text() )
        );
    }

   return $action;
}, 10, 2 );

add_filter( 'generate_wc_show_sticky_add_to_cart', function( $show ) {
	$product = wc_get_product( get_the_ID() );

	if ( $product->is_type( 'woosb' ) ) {
		$show = true;
	}

	return $show;
} );

However, the same code isn't working on your site. In fact, nothing is output in the panel even if I manually add some content in there. My guess is that one of your plugins is confusing/breaking one of the core WooCommerce conditionals we rely on. There are a ton of plugins on the site, so I'm not sure which one. My advice would be to keep the snippet I added and deactivate your plugins one by one to see if you can find the offending plugin.

If it's not a plugin, it could be one of your custom functions as well.

This archived topic is closed to new replies.