wc-shipping-method
Installation
SKILL.md
WooCommerce shipping method
WooCommerce calculates shipping per package. A method receives one package and adds zero or more rates for that package.
Load and register
With Composer PSR-4 autoloading, defer registration until WooCommerce has loaded its shipping base class:
add_action( 'woocommerce_shipping_init', static function (): void {
add_filter( 'woocommerce_shipping_methods', static function ( array $methods ): array {
$methods['myplugin_carrier'] = MyPlugin\Shipping\CarrierMethod::class;
return $methods;
} );
} );
The array key must match the class $id. Register a class name; WooCommerce creates one object per zone-method instance.