Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::get_shipping_zones()
Retrieves formatted shipping zones from WooCommerce.
Метод класса: CartCheckoutUtils{}
Хуков нет.
Возвращает
Массив
. An array of formatted shipping zones.
Использование
$result = CartCheckoutUtils::get_shipping_zones();
Код CartCheckoutUtils::get_shipping_zones() CartCheckoutUtils::get shipping zones WC 9.5.1
public static function get_shipping_zones() { $shipping_zones = \WC_Shipping_Zones::get_zones(); $formatted_shipping_zones = array_reduce( $shipping_zones, function ( $acc, $zone ) { $acc[] = [ 'id' => $zone['id'], 'title' => $zone['zone_name'], 'description' => $zone['formatted_zone_location'], ]; return $acc; }, [] ); $formatted_shipping_zones[] = [ 'id' => 0, 'title' => __( 'International', 'woocommerce' ), 'description' => __( 'Locations outside all other zones', 'woocommerce' ), ]; return $formatted_shipping_zones; }