I need to calculate the cost of shipping without reloading the cart page. I'm trying to do this via AJAX but I did not succeed.
I started the code below and could not continue
var $warp_fragment_refresh = {
url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments' ),
type: 'POST',
success: function( data ) {
if ( data && data.fragments ) {
jQuery.each(data.fragments, function(key, value){
jQuery(key).replaceWith(value);
});
jQuery( document.body ).trigger( 'wc_fragments_refreshed' );
}
}
};
jQuery( function( $ ){
$('form.woocommerce-cart-form').on('submit', function (e)
{
e.preventDefault();
$(".btn-calc-ship").addClass("loading");
var ship_calc = window.location,
form = $(this);
$(".btn-calc-shipp").removeClass("loading");
});
});