Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

WooCommercePayments::get_suggestion()public staticWC 1.0

Get the WooPayments payment gateway suggestion.

Method of the class: WooCommercePayments{}

No Hooks.

Return

Object|null. The WooPayments suggestion, or null if none found.

Usage

$result = WooCommercePayments::get_suggestion();

WooCommercePayments::get_suggestion() code WC 9.7.1

public static function get_suggestion() {
	$suggestions       = Suggestions::get_suggestions( DefaultPaymentGateways::get_all() );
	$wcpay_suggestions = array_filter(
		$suggestions,
		function ( $suggestion ) {
			if ( empty( $suggestion->plugins ) || ! is_array( $suggestion->plugins ) ) {
				return false;
			}

			return in_array( 'woocommerce-payments', $suggestion->plugins, true );
		}
	);

	if ( empty( $wcpay_suggestions ) ) {
		return null;
	}

	return reset( $wcpay_suggestions );
}