Flat rate shipping charges a fixed amount per order or item within the shipping zone. Since the flat rate is set to $5, that is the cost applied.
The 'woocommerce_shipping_methods' filter expects a function that receives the existing methods array, adds the new method keyed by an ID, and returns the updated array.
class WC_Custom_Shipping_Method extends WC_Shipping_Method { public function calculate_shipping($package = array()) { $rate = array( 'id' => $this->id, 'label' => $this->title, 'cost' => 10 ); $this->add_rate($rate); } }
If the shipping method is not registered with WooCommerce, its calculate_shipping method will never run, so no cost is added.
WooCommerce applies free shipping when the order meets the minimum amount, overriding flat rate costs.
WooCommerce finds the first shipping zone that matches the customer's shipping address and applies only its shipping methods.
