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