Skip to content

Instantly share code, notes, and snippets.

@aliciaiceland
Created May 24, 2017 06:20
Show Gist options
  • Save aliciaiceland/06eafad312f006c657e278376ab3b236 to your computer and use it in GitHub Desktop.
Save aliciaiceland/06eafad312f006c657e278376ab3b236 to your computer and use it in GitHub Desktop.
Modify flat rate shipping cost
function flat_rates_cost( $rates, $package ) {
foreach($rates as $key => $rate){
if($rate->method_id == 'flat_rate'){
// Put your logic and modify
$rates[$key]->cost = 25;
}
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'flat_rates_cost', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment