WC_REST_Shipping_Zones_V2_Controller::delete_item()publicWC 1.0

Delete a single Shipping Zone.

Метод класса: WC_REST_Shipping_Zones_V2_Controller{}

Хуков нет.

Возвращает

WP_REST_Request|WP_Error.

Использование

$WC_REST_Shipping_Zones_V2_Controller = new WC_REST_Shipping_Zones_V2_Controller();
$WC_REST_Shipping_Zones_V2_Controller->delete_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код WC_REST_Shipping_Zones_V2_Controller::delete_item() WC 9.3.3

public function delete_item( $request ) {
	$zone = $this->get_zone( $request->get_param( 'id' ) );

	if ( is_wp_error( $zone ) ) {
		return $zone;
	}

	$force = $request['force'];

	$response = $this->get_item( $request );

	if ( $force ) {
		$zone->delete();
	} else {
		return new WP_Error( 'rest_trash_not_supported', __( 'Shipping zones do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
	}

	return $response;
}