Automattic\WooCommerce\Internal\RestApi\Routes\V4\ShippingZones

ShippingZoneSchema::get_method_settingsprotectedWC 1.0

Get raw method settings for frontend processing.

Method of the class: ShippingZoneSchema{}

No Hooks.

Returns

Array.

Usage

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

ShippingZoneSchema::get_method_settings() code WC 10.4.3

protected function get_method_settings( $method ) {
	$settings = array();

	// Common settings that most methods have.
	$common_fields = array( 'cost', 'min_amount', 'requires', 'class_cost', 'no_class_cost' );

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