Add support for multiple currencies and countries

This commit is contained in:
Emili Castells Guasch 2024-08-21 15:55:36 +02:00
parent 83cb9d607a
commit 98536361af
2 changed files with 16 additions and 14 deletions

View file

@ -27,33 +27,33 @@ return array(
return array(
'bancontact' => array(
'id' => BancontactGateway::ID,
'country' => 'BE',
'currency' => 'EUR',
'countries' => array('BE'),
'currencies' => array('EUR'),
),
'blik' => array(
'id' => BlikGateway::ID,
'country' => 'PL',
'currency' => 'PLN',
'countries' => array('PL'),
'currencies' => array('PLN'),
),
'eps' => array(
'id' => EPSGateway::ID,
'country' => 'AT',
'currency' => 'EUR',
'countries' => array('AT'),
'currencies' => array('EUR'),
),
'ideal' => array(
'id' => IDealGateway::ID,
'country' => 'NL',
'currency' => 'EUR',
'countries' => array('NL'),
'currencies' => array('EUR'),
),
'mybank' => array(
'id' => MyBankGateway::ID,
'country' => 'IT',
'currency' => 'EUR',
'countries' => array('IT'),
'currencies' => array('EUR'),
),
'p24' => array(
'id' => P24Gateway::ID,
'country' => 'PL',
'currency' => 'EUR',
'countries' => array('PL'),
'currencies' => array('EUR', 'PLN'),
),
);
},

View file

@ -74,7 +74,10 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
$payment_methods = $c->get('ppcp-local-apms.payment-methods');
foreach ($payment_methods as $payment_method) {
if ( $customer_country !== $payment_method['country'] || $site_currency !== $payment_method['currency'] ) {
if (
! in_array($customer_country, $payment_method['countries'], true)
|| ! in_array($site_currency, $payment_method['currencies'], true)
) {
unset( $methods[ $payment_method['id'] ] );
}
}
@ -91,7 +94,6 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
foreach ($payment_methods as $key => $value) {
$payment_method_registry->register( $c->get( 'ppcp-local-apms.' . $key . '.payment-method' ) );
}
$a = 1;
}
);