}> */ public static function zones(): array { if ( ! class_exists( '\WC_Shipping_Zones' ) || ! class_exists( '\WC_Shipping_Zone' ) ) { return array(); } $zones = array(); $all = array_map( static fn( $zone ) => (int) $zone['id'], \WC_Shipping_Zones::get_zones() ); $all[] = 0; foreach ( $all as $id ) { $zone = new \WC_Shipping_Zone( $id ); $methods = $zone->get_shipping_methods( true ); if ( ! $methods ) { continue; } $free = array(); foreach ( $methods as $method ) { if ( 'free_shipping' !== $method->id ) { continue; } $free[] = array( 'requires' => (string) $method->requires, 'min_amount' => (float) wc_format_decimal( $method->min_amount ), 'before_discount' => 'yes' === $method->ignore_discounts, ); } $zones[] = array( 'name' => html_entity_decode( (string) $zone->get_zone_name(), ENT_QUOTES ), 'methods' => count( $methods ), 'free' => $free, ); } return $zones; } }