I'm trying to trigger the WooCommerce Mini Cart to update when someone changes the Shipping Method or Payment Method on the Checkout page.
I tried using the following code:
add_action( 'wp_footer', 'custom_minicart_checkout_jqscript' );
function custom_minicart_checkout_jqscript() {
if ( ! ( is_checkout() && ! is_wc_endpoint_url() ) )
return; // Only Checkout Page
?>
<script type="text/javascript">
jQuery( function($){
$('form.checkout').on('change', 'input', function(){
$(document.body).trigger('wc_fragment_refresh');
});
});
</script>
<?php
}
But it displays the previous total instead of the current total when customer make changes on selected Shipping Method or/and Payment Method.
UPDATE I tested the following solution but I'm getting the same result. You can see it on this video (download video to view in high quality). I removed non-essential plugins and clear the functions.php file. It seems possible but for some reason the mini cart update is delayed by the previous total.