JS error: wc_add_to_cart_params
-
Since updating to the newest version (4.8.10 theme, 4.8.11 pro, did upgrade from I believe 4.8.8), I am getting the following error in the browser console:
Uncaught ReferenceError: wc_add_to_cart_params is not defined
at HTMLBodyElement. (mobile-cart.min.js?ver=4.8.10:1:3576)
Looks like the following code got added to the mobile-cart.min.js file:// Using jQuery here because WooCommerce and the variation swatches plugin rely on jQuery for AJAX handling and DOM updates.
jQuery(document).ready(function ($) {
// Listening for WooCommerce's default 'added_to_cart' and 'cfvsw_ajax_add_to_cart' both events.
$(document.body).on('added_to_cart cfvsw_ajax_add_to_cart', function (event, fragments, cart_hash) {
// Refreshing WooCommerce cart fragments.
$.get(wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'get_refreshed_fragments'), function (data) {
if (data && data.fragments) {
$.each(data.fragments, function (key, value) {
$(key).replaceWith(value);
});
}
});
});
// Triggering the 'added_to_cart' event if needed elsewhere on page reload in the flow.
$(document.body).trigger('added_to_cart');
});“Enable AJAX add to cart buttons on archives” is turned off in the WooCommerce settings. When turned on, the error in the console is replaced with a different one.
After removing the code above from the minified file, the console error is gone and the website works as it is supposed to.
Do you mind looking into this?
Thank you!
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.