Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZoneMethod

ShippingMethodSchema::get_method_settingsprotectedWC 1.0

Get shipping method settings with title included.

Method of the class: ShippingMethodSchema{}

No Hooks.

Returns

Array. Method settings including title.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_method_settings( $method ): array;
$method(object) (required)
Shipping method instance.

ShippingMethodSchema::get_method_settings() code WC 10.4.3

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;
}