Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created October 13, 2014 00:33
Show Gist options
  • Save ChromeOrange/b11a74ef8d6968973c3d to your computer and use it in GitHub Desktop.
Save ChromeOrange/b11a74ef8d6968973c3d to your computer and use it in GitHub Desktop.
Set maximum shipping cost for specific Table Rate shipping methods - add to theme functions.php
/**
* Set maximum shipping cost for specific Table Rate shipping methods
*/
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 and the label to match your Method Title
* shown here https://dl.dropboxusercontent.com/s/5q9hfei3hgnbnt9/2014-10-13%20at%2001.25%20%281%29.png?dl=0
*/
if( $rate->cost > 10 && $rate->label == "Zone Rate One") {
$rate->cost = 10;
}
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment