How to set Maximum Shipping Cost for WooCommerce

Set a maximum shipping cost for WooCommerce by adding code to theme function.php

/**
*** Set maximum shipping cost in WooCommerce
**/
add_filter( 'woocommerce_package_rates' , 'woocommerce_set_maximum_shipping_cost', 10, 2 );
function woocommerce_set_maximum_shipping_cost( $rates, $package ) {
foreach( $rates as $rate ) {
// Change 10 to your maximum shipping cost
if( $rate->cost > 10 ) {
$rate->cost = 10;
}
}
return $rates;
}

Leave a Comment

Your email address will not be published. Required fields are marked *