Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions

Init::get_suggestions()public staticWC 1.0

Go through the specs and run them.

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

Хуков нет.

Возвращает

Массив.

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

$result = Init::get_suggestions( $specs );
$specs(массив|null)
payment suggestion spec array.
По умолчанию: null

Код Init::get_suggestions() WC 8.7.0

public static function get_suggestions( array $specs = null ) {
	$locale = get_user_locale();

	$specs           = is_array( $specs ) ? $specs : self::get_specs();
	$results         = EvaluateSuggestion::evaluate_specs( $specs );
	$specs_to_return = $results['suggestions'];
	$specs_to_save   = null;

	if ( empty( $specs_to_return ) ) {
		// When suggestions is empty, replace it with defaults and save for 3 hours.
		$specs_to_save   = DefaultPaymentGateways::get_all();
		$specs_to_return = EvaluateSuggestion::evaluate_specs( $specs_to_save )['suggestions'];
	} elseif ( count( $results['errors'] ) > 0 ) {
		// When suggestions is not empty but has errors, save it for 3 hours.
		$specs_to_save = $specs;
	}

	if ( count( $results['errors'] ) > 0 ) {
		self::log_errors( $results['errors'] );
	}

	if ( $specs_to_save ) {
		PaymentGatewaySuggestionsDataSourcePoller::get_instance()->set_specs_transient( array( $locale => $specs_to_save ), 3 * HOUR_IN_SECONDS );
	}

	return $specs_to_return;
}