Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZoneMethod

Controller::validate_method_typeprotectedWC 1.0

Validate that a shipping method type is valid.

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

Хуков нет.

Возвращает

true|WP_Error. True if valid, error otherwise.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_method_type( $method_id );
$method_id(строка) (обязательный)
Shipping method ID.

Код Controller::validate_method_type() WC 10.5.2

protected function validate_method_type( $method_id ) {
	$available_methods = WC()->shipping()->get_shipping_methods();

	if ( ! isset( $available_methods[ $method_id ] ) ) {
		return $this->get_route_error_by_code( self::INVALID_METHOD_TYPE );
	}

	return true;
}