Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZoneMethod
ShippingMethodSchema::get_method_settings
Get shipping method settings with title included.
Метод класса: ShippingMethodSchema{}
Хуков нет.
Возвращает
Массив. Method settings including title.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_method_settings( $method ): array;
- $method(объект) (обязательный)
- Shipping method instance.
Код ShippingMethodSchema::get_method_settings() ShippingMethodSchema::get method settings WC 10.5.2
protected function get_method_settings( $method ): array {
$settings = array();
// Get the method title (moved from root to settings per Ismael's feedback).
$settings['title'] = $method->get_title();
// Get common method settings.
$common_fields = array( 'cost', 'min_amount', 'requires', 'class_cost', 'no_class_cost', 'tax_status' );
foreach ( $common_fields as $field ) {
if ( isset( $method->$field ) ) {
$settings[ $field ] = $method->$field;
}
}
// Return all available settings for maximum flexibility.
if ( isset( $method->instance_settings ) && is_array( $method->instance_settings ) ) {
$settings = array_merge( $settings, $method->instance_settings );
}
return $settings;
}