WC_Shipping::register_shipping_method()publicWC 1.0

Register a shipping method.

Method of the class: WC_Shipping{}

No Hooks.

Return

true|false|null.

Usage

$WC_Shipping = new WC_Shipping();
$WC_Shipping->register_shipping_method( $method );
$method(object|string) (required)
Either the name of the method's class, or an instance of the method's class.

WC_Shipping::register_shipping_method() code WC 9.4.2

public function register_shipping_method( $method ) {
	if ( ! is_object( $method ) ) {
		if ( ! class_exists( $method ) ) {
			return false;
		}
		$method = new $method();
	}
	if ( is_null( $this->shipping_methods ) ) {
		$this->shipping_methods = array();
	}
	$this->shipping_methods[ $method->id ] = $method;
}