• Resolved Kishan Kothari

    (@kishankothari)


    We added below script in ajax fuction. Below code is working fine with woocommerce.7.7.2

    Yesterday, I update with latest version woocommerce.7.8.0 but below code is not working.

    jQuery(document.body).trigger(‘wc_fragment_refresh’);

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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 1 year, 5 months ago by woocoders.
    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fragment Refresh not working’ is closed to new replies.