fbpx
Enjoy Year-End Sale: 50% Off All Plugins! Coupon Code: NewYear2025

Issue with product with 38 variations

Hello, we are facing issue when our products has more then 30 variations. We get this errore and swatches doesn’t work.

 

Uncaught TypeError: e.$form.block is not a function
at HTMLFormElement.<anonymous> (add-to-cart-variation.min.js?ver=9.3.3:1:4388)
at HTMLFormElement.dispatch (jquery-3.6.0.min.js:2:43064)
at HTMLFormElement.<anonymous> (jquery-3.6.0.min.js:2:41048)
at Object.trigger (jquery-3.6.0.min.js:2:71515)
at HTMLFormElement.<anonymous> (jquery-3.6.0.min.js:2:72110)
at Function.each (jquery-3.6.0.min.js:2:3003)
at S.each (jquery-3.6.0.min.js:2:1481)
at S.trigger (jquery-3.6.0.min.js:2:72086)
at add-to-cart-variation.min.js?ver=9.3.3:1:1492

If we delete 10 variations it works again.

How should we fix?

 

 

 

Hakik Zaman

Hi Lorenzo,

You seem to be experiencing the issue due to a conflict of multiple jQuery versions.

On your site, additional jQuery is being added – https://paste.pics/3563c625ec56211ded709264d3fa0109

The current version of jQuery in WordPress core is 3.7.1.

WordPress Core already offers jQuery by default so, you don’t need to enqueue it again from a CDN.

Here is a default list of JS libraries that WP offers:
https://developer.wordpress.org/reference/functions/wp_enqueue_script/#default-scripts-and-js-libraries-included-and-registered-by-wordpress

You can enqueue the built-in jQuery library like this:
wp_enqueue_script( 'jquery' );

Rather than:
wp_register_script( 'jquery', 'https://code.jquery.com/jquery-3.4.1.js');

Our plugin uses the built-in jQuery library of WordPress. Please remove the additional CDN for jQuery.

This should resolve the issue.

Thanks a lot

Ok thanks, it was probably loaded by elementor pro. I have arranged like this

function rimuovi_jquery_esterno() {
ob_start(function($buffer){
$buffer = str_replace(‘<script src=”https://code.jquery.com/jquery-3.6.0.min.js”></script>’, ”, $buffer);
return $buffer;
});
}
add_action(‘get_header’, ‘rimuovi_jquery_esterno’);

Seems working now.

Thank you.