WC_Shipping::register_shipping_method
Register a shipping method.
Method of the class: WC_Shipping{}
No Hooks.
Returns
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() WC Shipping::register shipping method code WC 10.5.0
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;
}