woocommerce_shipping_chosen_method

The WooCommerce woocommerce shipping chosen method hook.

Description

apply_filters( 'woocommerce_shipping_chosen_method', (bool) $this_get_default_method_package_rates_false, (unknown) $package_rates, (unknown) $chosen_method ); 

Parameters (3)

0. $this_get_default_method_package_rates_false (bool)
The this get default method package rates false.
1. $package_rates (unknown)
The package rates.
2. $chosen_method (unknown)
The chosen method.

Usage

To run the hook, copy the example below.
  1. $this_get_default_method_package_rates_false = apply_filters( 'woocommerce_shipping_chosen_method', $this_get_default_method_package_rates_false, $package_rates, $chosen_method ); 
  2.  
  3. if ( !empty( $this_get_default_method_package_rates_false ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_shipping_chosen_method callback 
  2. function filter_woocommerce_shipping_chosen_method( $this_get_default_method_package_rates_false, $package_rates, $chosen_method ) { 
  3. // make filter magic happen here... 
  4. return $this_get_default_method_package_rates_false
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_shipping_chosen_method', 'filter_woocommerce_shipping_chosen_method', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_shipping_chosen_method', 'filter_woocommerce_shipping_chosen_method', 10, 3 ); 

Defined (1)

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

/includes/class-wc-shipping.php  
  1. $chosen_method = apply_filters( 'woocommerce_shipping_chosen_method', $this->get_default_method( $package['rates'], false ), $package['rates'], $chosen_method );