WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::get_shipping_packages() public WC 1.0

Get shipping packages from the cart with calculated shipping rates.

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

No Hooks.

Return

Array.

Usage

$CartController = new CartController();
$CartController->get_shipping_packages( $calculate_rates );
$calculate_rates(true|false)
Should rates for the packages also be returned.
Default: true

Code of CartController::get_shipping_packages() WC 5.6.0

public function get_shipping_packages( $calculate_rates = true ) {
	$cart = $this->get_cart_instance();

	// See if we need to calculate anything.
	if ( ! $cart->needs_shipping() ) {
		return [];
	}

	$packages = $cart->get_shipping_packages();

	// Add extra package data to array.
	if ( count( $packages ) ) {
		$packages = array_map(
			function( $key, $package, $index ) {
				$package['package_id']   = isset( $package['package_id'] ) ? $package['package_id'] : $key;
				$package['package_name'] = isset( $package['package_name'] ) ? $package['package_name'] : $this->get_package_name( $package, $index );
				return $package;
			},
			array_keys( $packages ),
			$packages,
			range( 1, count( $packages ) )
		);
	}

	return $calculate_rates ? wc()->shipping()->calculate_shipping( $packages ) : $packages;
}