Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\PaymentGateways\Schema

AbstractPaymentGatewaySettingsSchema::get_values │ private │ WC 1.0

Get flat key-value mapping of all setting values.

Метод класса: AbstractPaymentGatewaySettingsSchema{}

Хуков нет.

Возвращает

array.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_values( $gateway ): array;
$gateway(WC_Payment_Gateway) (обязательный)
Gateway instance.

Код AbstractPaymentGatewaySettingsSchema::get_values() WC 11.2.2

private function get_values( WC_Payment_Gateway $gateway ): array {
	$values = array();
	$gateway->init_form_fields();

	foreach ( $gateway->form_fields as $id => $field ) {
		$field_type = $field['type'] ?? '';

		// Skip non-data fields.
		if ( in_array( $field_type, array( 'title', 'sectionend' ), true ) ) {
			continue;
		}

		// Get value from gateway settings.
		$values[ $id ] = $gateway->settings[ $id ] ?? ( $field['default'] ?? '' );
	}

	// Add special fields for this gateway.
	$special_fields = $this->get_special_field_values( $gateway );
	$values         = array_merge( $values, $special_fields );

	return $values;
}