WordPress at Your Fingertips
function is not described

WC_Cart::get_chosen_shipping_methods() protected WC 3.2.0

Given a set of packages with rates, get the chosen ones only.

{} It's a method of the class: WC_Cart{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_chosen_shipping_methods( $calculated_shipping_packages );
$calculated_shipping_packages(array)
Array of packages.
Default: array()

Changelog

Since 3.2.0 Introduced.

Code of WC_Cart::get_chosen_shipping_methods() WC 5.6.0

protected function get_chosen_shipping_methods( $calculated_shipping_packages = array() ) {
	$chosen_methods = array();
	// Get chosen methods for each package to get our totals.
	foreach ( $calculated_shipping_packages as $key => $package ) {
		$chosen_method = wc_get_chosen_shipping_method_for_package( $key, $package );
		if ( $chosen_method ) {
			$chosen_methods[ $key ] = $package['rates'][ $chosen_method ];
		}
	}
	return $chosen_methods;
}