Simplify Payments task view logic

This commit is contained in:
Vlad Olaru 2024-09-19 19:26:24 +03:00
parent c82d8098e1
commit fbd1464460
No known key found for this signature in database
1 changed files with 5 additions and 6 deletions

View File

@ -76,13 +76,13 @@ class Payments extends Task {
* @return bool
*/
public function can_view() {
$woocommerce_payments = $this->task_list->get_task( 'woocommerce-payments' );
// Make sure the task is mutually exclusive with the WooPayments task.
return Features::is_enabled( 'payment-gateway-suggestions' ) && ! $woocommerce_payments->can_view();
// The task is visible if WooPayments is not supported in the current store location country.
// Otherwise, the WooPayments task will be shown.
return Features::is_enabled( 'payment-gateway-suggestions' ) && ! WooCommercePayments::is_supported();
}
/**
* Check if the store has any enabled gateways, other than WooPayments.
* Check if the store has any enabled gateways.
*
* @return bool
*/
@ -91,8 +91,7 @@ class Payments extends Task {
$enabled_gateways = array_filter(
$gateways,
function( $gateway ) {
// Filter out any WooPayments gateways as this task is mutually exclusive with the WooPayments task.
return 'yes' === $gateway->enabled && 0 !== strpos( $gateway->id, 'woocommerce_payments' );
return 'yes' === $gateway->enabled;
}
);