Setting up minimum shipping cost customization will let you to replace the shipping costs for the methods which is less than the defined minimum amount. Regardless of the initial cost set for the shipping methods, the code ensures it meets the defined minimum cost uniformly applying for all shipping methods.
add_filter('woocommerce_package_rates', 'ts_custom_shipping_costs', 20, 2); function ts_custom_shipping_costs($rates, $package) { // New minimum shipping cost $minimum_cost = 10; foreach ($rates as $rate_key => $rate) { // Excluding free shipping methods if ($rate->method_id !== 'free_shipping') { // Set minimum rate cost $rates[$rate_key]->cost = max($minimum_cost, $rates[$rate_key]->cost); } } return $rates; }
Output
This is how the cost of Flat rate and local pickup shipping methods are assigned.
once the code is implied you can see that the cost of a flat rate which is less than the defined amount gets changed . If the shipping cost is greater than the defined amount then the cost remains unchanged.
Alternatively, want to set a maximum shipping cost based on shipping zone? This post guides you well to set maximum shipping cost based on delivery country in WooCommerce which will dynamically adjusts shipping rates for all methods.