- This topic has 23 replies, 5 voices, and was last updated 2 years, 10 months ago by Tom.
-
AuthorPosts
-
April 1, 2021 at 8:44 am #1718125LeoStaffCustomer Support
Sounds good. We are in beta two now so hopefully not too too long.
April 27, 2021 at 11:25 pm #1752074nik9Hello, 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
April 28, 2021 at 10:44 pm #1754572ElvinStaffCustomer SupportHello, 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.
April 29, 2021 at 1:55 am #1754914nik9Hello Elvin,
Yes. Please see system infos in the note field π
April 30, 2021 at 7:45 am #1757799TomLead DeveloperLead DeveloperHi 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?
May 5, 2021 at 12:18 am #1764975nik9Hello Tom,
This is a staging site. So you can play around π
May 5, 2021 at 8:41 am #1766052TomLead DeveloperLead DeveloperDefinitely 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?
May 5, 2021 at 9:48 pm #1766639nik9I think on staging no caching is on. Hmm.. We use WP Rocket on prod system. But on staging this should be turned off.
May 6, 2021 at 9:30 am #1767772TomLead DeveloperLead DeveloperSo 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.
-
AuthorPosts
- You must be logged in to reply to this topic.