Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Last active June 7, 2017 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/e06b62e57a71c94835467ac2306e1ebb to your computer and use it in GitHub Desktop.
Save harishankerr/e06b62e57a71c94835467ac2306e1ebb to your computer and use it in GitHub Desktop.
Add Handling Fee To Flat Rate Shipping Method
function wc_ninja_change_flat_rates_cost( $rates, $package ) {
// Make sure flat rate is available
if ( isset( $rates['flat_rate'] ) ) {
// Adds a $3 handling fee to the existing flat rate shipping method.
$rates['flat_rate']->cost += 3;
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'wc_ninja_change_flat_rates_cost', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment