Created
October 12, 2014 14:54
-
-
Save ChromeOrange/56ce4571836429af330d to your computer and use it in GitHub Desktop.
Set a maximum shipping cost for WooCommerce, add this to functions.php - works with all shipping methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} |
Thank you. This works perfectly for what we needed. Selling handmade cotton masks and trying not to gouge for shipping.
Worked perfectly for me using WooCommerce 4.7.1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just added this today and it's still working. Thanks a lot! :)