They have Removed global enqueue of wc-cart-fragments. Moved to the cart widget (its main consumer). [#35530]
try add this in your functions.php file
function mytheme_enqueue_styles()
{
// Check if ‘wc-cart-fragments’ script is already enqueued or registered
if ( ! wp_script_is( ‘wc-cart-fragments’, ‘enqueued’ ) && wp_script_is( ‘wc-cart-fragments’, ‘registered’ ) ) {
// Enqueue the ‘wc-cart-fragments’ script
wp_enqueue_script( ‘wc-cart-fragments’ );
}
}
add_action(‘wp_enqueue_scripts’, ‘mytheme_enqueue_styles’);
Call the WC_AJAX::get_refreshed_fragments() at the end of your PHP coode responder; if it comes from an AJAX call.
Then Call in your js file like this
var fragments = response.fragments;
if ( fragments ) {
jQuery.each(fragments, function(key, value) { jQuery(key).replaceWith(value);
});
}
-
This reply was modified 2 years, 9 months ago by
woocoders.
Hey there, @kishankothari! Did the suggestions that were provided here work for you?
This works, tested with woocommerce version 8.0.1
if ( !wp_script_is( ‘wc-cart-fragments’, ‘enqueued’ ) && wp_script_is( ‘wc-cart-fragments’, ‘registered’ ) ) {
// Enqueue the wc-cart-fragments script
wp_enqueue_script( ‘wc-cart-fragments’ );
}
Howdy @mobi5965 👋
This works, tested with woocommerce version 8.0.1
Thank you so much for adding your input! Some of our customers might indeed find this guide helpful!
We appreciate you being an active part of the community 🙂
Have a wonderful day!