WC_Shipping_Method::get_option
Get_option function.
Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
Method of the class: WC_Shipping_Method{}
Hooks from the method
Returns
Mixed. The value specified for the option or a default value for the option.
Usage
$WC_Shipping_Method = new WC_Shipping_Method(); $WC_Shipping_Method->get_option( $key, $empty_value );
- $key(string) (required)
- Key.
- $empty_value(mixed)
- Empty value.
Default:null
WC_Shipping_Method::get_option() WC Shipping Method::get option code WC 10.7.0
public function get_option( $key, $empty_value = null ) {
// Instance options take priority over global options.
if ( $this->instance_id && array_key_exists( $key, $this->get_instance_form_fields() ) ) {
return $this->get_instance_option( $key, $empty_value );
}
// Return global option.
$option = apply_filters( 'woocommerce_shipping_' . $this->id . '_option', parent::get_option( $key, $empty_value ), $key, $this );
return $option;
}