Site logo

Archived topic

Add to cart banner not showing on bundle products

23 replies · Started by nik9 on February 2, 2021

Viewing posts 1–15 of 24

Hello,

We use a plugin called "WPC Product Bundles for WooCommerce" (https://wordpress.org/plugins/woo-product-bundle/) in order to create product bundles. Works perfect! But we just noticed, that on product bundle single pages the "Add to cart" banner is not showing up. On normal product single pages we do not have that issue.

I guess this is because of a different product type. How can we fix that?

Cheers

Hi there,

the Sticky Add to Cart only works with Simple, variable and external product types.
And i don't think that can be currently changed... if you can find out from the product developer what product_type their using we can take a look at integrating that in a woo update.

Hi,

As far that I can understand the code they use "bundle" or "woosb" for taht type.

if ( ! class_exists( 'WPCleverWoosb' ) && class_exists( 'WC_Product' ) ) {

	class WPCleverWoosb {

		protected static $_instance = null;

		protected static $_types = array(

			'bundle',

			'woosb',

Will need to run some tests here. As of right now, there aren't any filters available that we can use. However, I've added one in 1.13.0 that we should be able to use for this :)

Thanks Tom. :)

Hello Tom,

Any feedback on this? :)

Cheers

An example of how this would work in 2.0.0:

add_filter( 'generate_wc_sticky_add_to_cart_action', function( $action, $product ) {
    if ( $product->is_type( 'bundle' ) ) {
        $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 );

Thanks tom,

When is the public version available? :)

Cheers

Hi there,

we at least another 2 - 3 weeks of testing before we reach a release candidate. So this time in April at the latest would be a good bet.

Hello, We just updated to the new version. How we can now adjust this new settings? :)

add_filter( 'generate_wc_sticky_add_to_cart_action', function( $action, $product ) {
    if ( $product->is_type( 'bundle' ) ) {
        $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 );

Have you tried running the code?

It should've been working once you've updated.

Is the code not working even after the GP Premium update? Let us know.

Hello Elvin,

Yes, i updated Gp theme. GP Premium is on version 1.12.3. I also cleared the cache.. not working :(

Oh, i miss that. I thought i have to update the GP Theme. Sorry.. then I will wait :)

This archived topic is closed to new replies.