Add other payment methods link when the store is in WC Payments eligible country

This commit is contained in:
moon 2022-03-30 21:03:20 -07:00
parent 721ff37095
commit 08e5883246
1 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,7 @@
namespace Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\WooCommercePayments;
use Automattic\WooCommerce\Admin\Features\TransientNotices;
defined( 'ABSPATH' ) || exit;
@ -21,6 +22,7 @@ class PaymentGatewaysController {
add_filter( 'woocommerce_rest_prepare_payment_gateway', array( __CLASS__, 'extend_response' ), 10, 3 );
add_filter( 'admin_init', array( __CLASS__, 'possibly_do_connection_return_action' ) );
add_action( 'woocommerce_admin_payment_gateway_connection_return', array( __CLASS__, 'handle_successfull_connection' ) );
add_filter( 'woocommerce_payment_gateways_setting_additional_rows', array( __CLASS__, 'add_other_payment_methods_link' ), 10, 2 );
}
/**
@ -145,4 +147,22 @@ class PaymentGatewaysController {
wp_safe_redirect( wc_admin_url() );
}
/**
* Add "Other payment methods" link in WooCommerce -> Settings -> Payments
* When the store is in WC Payments eligible country.
* See https://github.com/woocommerce/woocommerce/issues/32130 for more details.
*
* @return void
*/
public static function add_other_payment_methods_link( $rows, $no_of_cols ) {
if ( WooCommercePayments::is_supported() ) {
$link = 'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations';
$link_text = __( 'Other payment methods', 'woocommerce' );
$external_link_icon = '<svg style="margin-left: 4px" class="gridicon gridicons-external needs-offset" height="18" width="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M19 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h6v2H5v12h12v-6h2zM13 3v2h4.586l-7.793 7.793 1.414 1.414L19 6.414V11h2V3h-8z"></path></g></svg>';
$row = "<tr><td style='border-top: 1px solid #c3c4c7; background-color: #fff' colspan='{$no_of_cols}'><a href='{$link}' target='_blank' class='components-button is-tertiary'>{$link_text} {$external_link_icon}</a></td>";
$rows[] = $row;
}
return $rows;
}
}