Developers can add additional flat rates based on this one via this action since @version 2.


do_action( 'woocommerce_flat_rate_shipping_add_rate', (unknown) $instance, (unknown) $rate ); 

Previously there were (overly complex) options to add additional rates however this was not user. friendly and goes against what Flat Rate Shipping was originally intended for.

This example shows how you can add an extra rate based on this flat rate via custom function:

add_action( woocommerce_flat_rate_shipping_add_rate,, add_another_custom_flat_rate , woocommerce/3.0.6/constants/10" title="10" class="code constant">10, 2 );

function add_another_custom_flat_rate( $method, $rate ) .

Parameters (2)

0. $instance (unknown)
The instance.
1. $rate (unknown)
The rate.


To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'woocommerce_flat_rate_shipping_add_rate', $instance, $rate ); 
The following example is for adding a hook callback.
  1. // define the woocommerce_flat_rate_shipping_add_rate callback 
  2. function action_woocommerce_flat_rate_shipping_add_rate( $instance, $rate ) { 
  3. // make action magic happen here... 
  4. }; 
  6. // add the action 
  7. add_action( 'woocommerce_flat_rate_shipping_add_rate', 'action_woocommerce_flat_rate_shipping_add_rate', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'woocommerce_flat_rate_shipping_add_rate', 'action_woocommerce_flat_rate_shipping_add_rate', 10, 2 ); 

Defined (1)

The action is defined in the following location(s).

  1. do_action( 'woocommerce_flat_rate_shipping_add_rate', $this, $rate );