WC_Shipping_Method::get_instance_option
Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
Метод класса: WC_Shipping_Method{}
Хуки из метода
Возвращает
Разное. The value specified for the option or a default value for the option.
Использование
$WC_Shipping_Method = new WC_Shipping_Method(); $WC_Shipping_Method->get_instance_option( $key, $empty_value );
- $key(строка) (обязательный)
- Key.
- $empty_value(разное)
- Empty value.
По умолчанию:null
Код WC_Shipping_Method::get_instance_option() WC Shipping Method::get instance option WC 10.7.0
public function get_instance_option( $key, $empty_value = null ) {
if ( empty( $this->instance_settings ) ) {
$this->init_instance_settings();
}
// Get option default if unset.
if ( ! isset( $this->instance_settings[ $key ] ) ) {
$form_fields = $this->get_instance_form_fields();
$this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] );
}
if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) {
$this->instance_settings[ $key ] = $empty_value;
}
$instance_option = apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_option', $this->instance_settings[ $key ], $key, $this );
return $instance_option;
}