woocommerce_package_rates
WooCommerce applies the woocommerce_package_rates filter after calculating shipping options for a package. The callback receives $rates, an array of WC_Shipping_Rate objects keyed by rate ID, and $package, an array describing the shipment. It must return the rates array after any changes. To read both arguments, register the filter with an accepted-argument count of 2.
Rename flat-rate delivery options
add_filter( 'woocommerce_package_rates', function ( $rates ) {
foreach ( $rates as $rate ) {
if ( 'flat_rate' === $rate->get_method_id() ) {
$rate->set_label( 'Standard delivery' );
}
}
return $rates;
} );
The example updates the customer-facing label of every available flat-rate option without changing its cost or method ID. The flat_rate method ID identifies a shipping method type; get_instance_id() identifies a particular configured instance. Use the instance ID if you want to rename only one flat-rate option. See the WooCommerce shipping calculation for where the filter runs.
Caching and checkout compatibility
WooCommerce caches calculated rates for a shipping package in the customer session. After changing a filter, request a fresh shipping calculation or enable shipping debug mode while testing; otherwise a previously cached rate may continue to appear. Put the callback in a site-specific plugin or child theme's functions.php and check the intended destinations and shipping methods on a staging store.
This server-side filter applies to calculated rates used by classic cart/checkout pages and the Cart and Checkout blocks. It does not change how a block displays those rates. If the goal is only to hide paid methods when free shipping is available, check WooCommerce's built-in shipping options first; the free shipping guide explains that configuration.