Hi Philipp!
How did you initialize the $form constant?
I should put this code on line 11 of the file woo-variation-swatches/assets/js/frontend.js, right?
We are using the woo-variation-swatches plugin version 1.0.80.
Many Thanks!
Thread Starter
Philipp
(@philippmuenchen)
It should just stop executing the script if the $form element is already there.
So it would be in frontend.js e.g.:
var $form = $( this );
if( $form.hasClass('swatches-support')) {
return;
}
$form
.addClass( 'swatches-support' )
.on( 'click', '.swatch', function ( e ) {
[...]
Hi Philipp,
No luck so far.
I have added your code at line 11: https://ibb.co/v44X3KM
and I am getting this error: https://ibb.co/dBNnWhh
I have tried to put this snippet in other parts of the code and the error disappears, but the swatches plugin is still not working with product bundles.
Hey Phillip, I have solved the issue.
I’ve put this code in the Product Bundle plugin:
//Put in the Woocommerce Product Bundle plugin.
function hide_out_of_stock_option( $option ){
return 'yes';
}
add_action( 'woocommerce_before_template_part', function( $template_name ) {
if( $template_name !== "single-product/add-to-cart/bundle.php" ) {
//var_dump($template_name);
return;
}
add_filter( 'pre_option_woocommerce_hide_out_of_stock_items', 'hide_out_of_stock_option' );
} );
add_action( 'woocommerce_after_template_part', function( $template_name ) {
if( $template_name !== "single-product/add-to-cart/bundle.php" ) {
return;
}
remove_filter( 'pre_option_woocommerce_hide_out_of_stock_items', 'hide_out_of_stock_option' );
} );