WordPress at Your Fingertips
function is not described

WC_Shipping_Flat_Rate::find_shipping_classes() public WC 1.0

Finds and returns shipping classes and the products with said class.

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

No Hooks.

Return

Array.

Usage

$WC_Shipping_Flat_Rate = new WC_Shipping_Flat_Rate();
$WC_Shipping_Flat_Rate->find_shipping_classes( $package );
$package(mixed) (required)
Package of items from cart.

Code of WC_Shipping_Flat_Rate::find_shipping_classes() WC 5.9.0

public function find_shipping_classes( $package ) {
	$found_shipping_classes = array();

	foreach ( $package['contents'] as $item_id => $values ) {
		if ( $values['data']->needs_shipping() ) {
			$found_class = $values['data']->get_shipping_class();

			if ( ! isset( $found_shipping_classes[ $found_class ] ) ) {
				$found_shipping_classes[ $found_class ] = array();
			}

			$found_shipping_classes[ $found_class ][ $item_id ] = $values;
		}
	}

	return $found_shipping_classes;
}