WC_Shipping_Method::get_option()publicWC 1.0

Get_option function.

Gets and option from the settings API, using defaults if necessary to prevent undefined notices.

{} It's a method of the class: WC_Shipping_Method{}

Hooks from the method


Mixed. The value specified for the option or a default value for the option.


$WC_Shipping_Method = new WC_Shipping_Method();
$WC_Shipping_Method->get_option( $key, $empty_value );
$key(string) (required)
Empty value.
Default: null

Code of WC_Shipping_Method::get_option() WC 6.8.2

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;