Skip to content

Commit

Permalink
Merge pull request #120 from degica/20240731-examine-current-currency…
Browse files Browse the repository at this point in the history
…-only

Examine currency before recognizing as an available payment method
  • Loading branch information
Dinwy authored Aug 2, 2024
2 parents f93a6a8 + 95fc946 commit 87c6b4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions class-wc-settings-page-komoju.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,23 @@ private function fetch_all_payment_methods()
try {
$all_payment_methods = $api->paymentMethods();
$methods_by_slug = [];
$wc_currency = get_woocommerce_currency();

foreach ($all_payment_methods as $payment_method) {
$slug = $payment_method['type_slug'];
if (isset($methods_by_slug[$slug])) {
continue;
$slug = $payment_method['type_slug'];
$pm_currency = $payment_method['currency'];

// If $slug is not set, register
if (!isset($methods_by_slug[$slug])) {
$methods_by_slug[$slug] = $payment_method;
} else {
// If $slug is already registered and
// the payment currency matches the WooCommerce currency then override it
if ($pm_currency === $wc_currency) {
$methods_by_slug[$slug] = $payment_method;
}
}

$methods_by_slug[$slug] = $payment_method;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Cypress.Commands.add('installWordpress', () => {

Cypress.Commands.add('signinToWordpress', () => {
cy.visit('/wp-admin');
cy.wait(1000);

cy.get('body').then(($body) => {
if (!$body.find('#loginform').length) {
Expand All @@ -60,6 +61,7 @@ Cypress.Commands.add('signinToWordpress', () => {
cy.get('#user_pass').should('be.visible').clear().type('deg1kaX7reme!');
cy.get('#wp-submit').should('be.visible').click();
});
cy.wait(1000);
});

Cypress.Commands.add('installWooCommerce', () => {
Expand Down

0 comments on commit 87c6b4b

Please sign in to comment.