Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZones
ShippingZoneService::create_shipping_zone
Create a new shipping zone.
Method of the class: ShippingZoneService{}
No Hooks.
Returns
WC_Shipping_Zone|WP_Error. Zone object on success, WP_Error on failure.
Usage
$ShippingZoneService = new ShippingZoneService(); $ShippingZoneService->create_shipping_zone( $params );
- $params(array) (required)
Zone parameters.
-
name(string)
Zone name. -
order(int)
Zone order for sorting. - locations(array)
Array of location objects with 'code' and 'type' keys.
-
ShippingZoneService::create_shipping_zone() ShippingZoneService::create shipping zone code WC 10.4.3
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;
}