woocommerce get chosen shipping method price in woocommerce_calculated_total code example
Example 1: get current shipping method woocommerce
$rate_table = array();
$shipping_methods = WC()->shipping->get_shipping_methods();
foreach($shipping_methods as $shipping_method){
$shipping_method->init();
foreach($shipping_method->rates as $key=>$val)
$rate_table[$key] = $val->label;
}
echo $rate_table[WC()->session->get( 'chosen_shipping_methods' )[0]];
Example 2: get shipping price of choosen shipping method woocommerce
$chosen_shipping_method_price = WC()->session->get('cart_totals')['shipping_total'];