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

Controller::validate_method_typeprotectedWC 1.0

Validate that a shipping method type is valid.

Method of the class: Controller{}

No Hooks.

Returns

true|WP_Error. True if valid, error otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_method_type( $method_id );
$method_id(string) (required)
Shipping method ID.

Controller::validate_method_type() code WC 10.4.3

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;
}