Make use of PaymentGatewaySuggestions logic in WooCommerce Payments task

This commit is contained in:
Lourens Schep 2022-04-05 16:25:42 -03:00
parent 7d76d4a1a6
commit 4ad2f4ceed
1 changed files with 10 additions and 17 deletions

View File

@ -5,6 +5,7 @@ namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile; use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task; use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
use Automattic\WooCommerce\Admin\PluginsHelper; use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\Init as Suggestions;
/** /**
* WooCommercePayments Task * WooCommercePayments Task
@ -146,22 +147,14 @@ class WooCommercePayments extends Task {
* @return bool * @return bool
*/ */
public static function is_supported() { public static function is_supported() {
return in_array( $suggestions = Suggestions::get_suggestions();
WC()->countries->get_base_country(), $suggestion_plugins = array_merge( ...array_filter( array_column( $suggestions, 'plugins' ), function( $plugins ) {
array( return is_array( $plugins );
'US', } ) );
'PR', $woocommerce_payments_ids = array_search( 'woocommerce-payments', $suggestion_plugins, true );
'AU', if ( false !== $woocommerce_payments_ids ) {
'CA', return true;
'DE', }
'ES', return false;
'FR',
'GB',
'IE',
'IT',
'NZ',
),
true
);
} }
} }