WordPress at a glance
function is not described

wc_get_default_shipping_method_for_package() WC 3.2.0

Choose the default method for a package.

Hooks from the function
Return

String. Nothing.

Usage

wc_get_default_shipping_method_for_package( $key, $package, $chosen_method );
$key(int) (required)
Key of package.
$package(array) (required)
Package data array.
$chosen_method(string) (required)
Chosen method id.

Changelog

Since 3.2.0 Introduced.

Code of wc_get_default_shipping_method_for_package() WC 5.3.0

<?php
function wc_get_default_shipping_method_for_package( $key, $package, $chosen_method ) {
	$rate_keys = array_keys( $package['rates'] );
	$default   = current( $rate_keys );
	$coupons   = WC()->cart->get_coupons();
	foreach ( $coupons as $coupon ) {
		if ( $coupon->get_free_shipping() ) {
			foreach ( $rate_keys as $rate_key ) {
				if ( 0 === stripos( $rate_key, 'free_shipping' ) ) {
					$default = $rate_key;
					break;
				}
			}
			break;
		}
	}
	return apply_filters( 'woocommerce_shipping_chosen_method', $default, $package['rates'], $chosen_method );
}