Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZones
ShippingZoneService::create_shipping_zone
Create a new shipping zone.
Метод класса: ShippingZoneService{}
Хуков нет.
Возвращает
WC_Shipping_Zone|WP_Error. Zone object on success, WP_Error on failure.
Использование
$ShippingZoneService = new ShippingZoneService(); $ShippingZoneService->create_shipping_zone( $params );
- $params(массив) (обязательный)
Zone parameters.
-
name(строка)
Zone name. -
order(int)
Zone order for sorting. - locations(массив)
Array of location objects with 'code' and 'type' keys.
-
Код ShippingZoneService::create_shipping_zone() ShippingZoneService::create shipping zone WC 11.2.2
public function create_shipping_zone( $params ) {
$zone = new WC_Shipping_Zone( null );
$result = $this->update_shipping_zone( $zone, $params );
if ( is_wp_error( $result ) ) {
return $result;
}
return $zone;
}