mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🎨 Make condition easier to understand
This commit is contained in:
parent
d4a11a1346
commit
ab2163a45c
1 changed files with 6 additions and 5 deletions
|
@ -90,15 +90,16 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
|
||||||
return $methods;
|
return $methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
|
||||||
$customer_country = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country();
|
$customer_country = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country();
|
||||||
$site_currency = get_woocommerce_currency();
|
$site_currency = get_woocommerce_currency();
|
||||||
|
|
||||||
$payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
|
// Remove unsupported gateways from the customer's payment options.
|
||||||
foreach ( $payment_methods as $payment_method ) {
|
foreach ( $payment_methods as $payment_method ) {
|
||||||
if (
|
$is_currency_supported = in_array( $site_currency, $payment_method['currencies'], true );
|
||||||
! in_array( $customer_country, $payment_method['countries'], true )
|
$is_country_supported = in_array( $customer_country, $payment_method['countries'], true );
|
||||||
|| ! in_array( $site_currency, $payment_method['currencies'], true )
|
|
||||||
) {
|
if ( ! $is_currency_supported || ! $is_country_supported ) {
|
||||||
unset( $methods[ $payment_method['id'] ] );
|
unset( $methods[ $payment_method['id'] ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue