Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created June 16, 2015 11:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikejolley/67580b9e8b1c2ed1081f to your computer and use it in GitHub Desktop.
Save mikejolley/67580b9e8b1c2ed1081f to your computer and use it in GitHub Desktop.
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'] .= ':' . 'custom_rate_name'; // Append a custom ID
$new_rate['label'] = 'Rushed Shipping'; // Rename to 'Rushed Shipping'
$new_rate['cost'] += 2; // Add $2 to the cost
// Add it to WC
$method->add_rate( $new_rate );
}
@cadoo
Copy link

cadoo commented Jun 21, 2016

For international flat delivery rate you can use this:

add_action( 'woocommerce_international_delivery_shipping_add_rate', 'add_another_int_custom_flat_rate', 10, 2 );

function add_another_int_custom_flat_rate( $method, $rate ) {
    $new_rate          = $rate;
    $new_rate['id']    .= ':' . 'custom_rate_2_name'; // Append a custom ID
    $new_rate['label'] = 'Rushed International Shipping';
    $new_rate['cost']  += 13; // Add $13 to the cost

    // Add it to WC
    $method->add_rate( $new_rate );
}

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