Refresh cached shipping methods on checkout update ajax event in Woocommerce
Updated: There is some mistakes in your code, instead try the following:
add_action('woocommerce_checkout_update_order_review', 'checkout_update_refresh_shipping_methods', 10, 1);function checkout_update_refresh_shipping_methods( $post_data ) { $packages = WC()->cart->get_shipping_packages(); foreach ($packages as $package_key => $package ) { WC()->session->set( 'shipping_for_package_' . $package_key, false ); // Or true }}
Code goes in function.php file of your active child theme (active theme). Tested and works.
But it will refresh shipping methods cache each time on ajax checkout update event.
Related: Custom checkout field and shipping methods ajax interaction in Woocommerce 3