Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
woocommerce_flat_rate_shipping_add_rate example for theme functions.php
<?php
add_action( 'woocommerce_flat_rate_shipping_add_rate', 'add_another_custom_flat_rate', 10, 2 );
function add_another_custom_flat_rate( $method, $rate ) {
$new_rate = $rate;
$new_rate['id'] .= ':' . 'next_day'; // Append a custom ID
$new_rate['label'] = 'Next Day'; // Rename to 'Rushed Shipping'
$new_rate['cost'] += 2; // Add $2 to the cost
// Add it to WC
$method->add_rate( $new_rate );
}
@jeanneandersen

This comment has been minimized.

Copy link

@jeanneandersen jeanneandersen commented Aug 25, 2015

So I have to hire a programmer to update my site? I don't understand how this code should be used for overnight and 2 day air. It was easy before, but now I feel annoyed because I can't select this through a menu.

@cjwd

This comment has been minimized.

Copy link

@cjwd cjwd commented Jan 14, 2016

Do you need to write separate functions for every custom flat rate?

@karneaud

This comment has been minimized.

Copy link

@karneaud karneaud commented Oct 1, 2020

Do you need to write separate functions for every custom flat rate?

ever got it figured out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment