Commit 073c76fd5f8 for woocommerce

commit 073c76fd5f85aa4eb7b551d2edbbbf37862bb5ea
Author: Rubens Castro <rubens.castro@a8c.com>
Date:   Tue Oct 6 06:04:00 2026 -0300

    Add the business location country to the More payment options link (#68717)

    * Add the business location country to the More payment options link

    The marketplace filters payment extensions by country name, so the link
    now carries the business location selected on the Payments settings page,
    matching the suggestions already shown in the same card.

    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

    * Add changelog entry for the More payment options country filter

    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

    * Only filter the marketplace link when the admin runs in English

    The marketplace turns whatever country it receives into a search filter, so a
    translated name narrows the results instead of falling back to the full list.
    Guard on the admin locale, so a non-English admin gets the unfiltered URL the
    link used before.

    Also assert the link by role rather than by text, per the admin client's
    accessibility query guidance.

    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

    * Send the business country code to the marketplace link

    The marketplace now accepts country codes in the query string, so the
    link no longer needs the English country name lookup, the GB/US
    overrides, entity decoding, or the English-admin-only guard.

    Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

    * Reset the Payments business location profile after every test

    Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
    Co-authored-by: Herman <KokkieH@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/country-parameter-on-more-payment-options-link b/plugins/woocommerce/changelog/country-parameter-on-more-payment-options-link
new file mode 100644
index 00000000000..b2afe3e9f02
--- /dev/null
+++ b/plugins/woocommerce/changelog/country-parameter-on-more-payment-options-link
@@ -0,0 +1,4 @@
+Significance: patch
+Type: enhancement
+
+Filter the "More payment options" marketplace link by the business location selected on the Payments settings page.
diff --git a/plugins/woocommerce/client/admin/client/settings-payments/constants.ts b/plugins/woocommerce/client/admin/client/settings-payments/constants.ts
index 8989e1a5f20..80cc153b6db 100644
--- a/plugins/woocommerce/client/admin/client/settings-payments/constants.ts
+++ b/plugins/woocommerce/client/admin/client/settings-payments/constants.ts
@@ -8,3 +8,7 @@ export const wooPaymentsOnboardingSessionEntrySettings = 'settings_payments';
 export const wooPaymentsOnboardingSessionEntryLYS = 'lys';

 export const WC_SETTINGS_PAYMENTS_NAMESPACE = '/wc-admin/settings/payments';
+
+// The WooCommerce.com marketplace page the "More payment options" link points to.
+export const morePaymentOptionsBaseUrl =
+	'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations';
diff --git a/plugins/woocommerce/client/admin/client/settings-payments/settings-payments-main.tsx b/plugins/woocommerce/client/admin/client/settings-payments/settings-payments-main.tsx
index cf431f26558..7faf547d4d9 100644
--- a/plugins/woocommerce/client/admin/client/settings-payments/settings-payments-main.tsx
+++ b/plugins/woocommerce/client/admin/client/settings-payments/settings-payments-main.tsx
@@ -44,6 +44,7 @@ import {
 	recordPaymentsOnboardingEvent,
 	getPluginActionErrorMessage,
 	getFailedPluginAction,
+	getMorePaymentOptionsUrl,
 } from '~/settings-payments/utils';
 import { WooPaymentsPostSandboxAccountSetupModal } from '~/settings-payments/components/modals';
 import WooPaymentsModal from '~/settings-payments/onboarding/providers/woopayments';
@@ -502,7 +503,7 @@ export const SettingsPaymentsMain = () => {
 			variant={ 'link' }
 			target="_blank"
 			rel="noopener noreferrer"
-			href="https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations"
+			href={ getMorePaymentOptionsUrl( businessCountry ) }
 			className="more-payment-options-link"
 			onClick={ trackMorePaymentsOptionsClicked }
 		>
diff --git a/plugins/woocommerce/client/admin/client/settings-payments/test/settings-payments-main.test.tsx b/plugins/woocommerce/client/admin/client/settings-payments/test/settings-payments-main.test.tsx
index 8d1fcc08daa..a3619689232 100644
--- a/plugins/woocommerce/client/admin/client/settings-payments/test/settings-payments-main.test.tsx
+++ b/plugins/woocommerce/client/admin/client/settings-payments/test/settings-payments-main.test.tsx
@@ -19,6 +19,10 @@ jest.mock( '~/utils/features', () => ( {
 } ) );

 describe( 'SettingsPaymentsMain', () => {
+	afterEach( () => {
+		delete window.wcSettings.admin.woocommerce_payments_nox_profile;
+	} );
+
 	it( 'should record settings_payments_pageview event on load', () => {
 		render(
 			<Router>
@@ -89,4 +93,23 @@ describe( 'SettingsPaymentsMain', () => {
 			expect.stringContaining( 'noreferrer' )
 		);
 	} );
+
+	it( 'should filter the marketplace link by the selected business location', () => {
+		window.wcSettings.admin.woocommerce_payments_nox_profile = {
+			business_country_code: 'BR',
+		};
+
+		render(
+			<Router>
+				<SettingsPaymentsMain />
+			</Router>
+		);
+
+		expect(
+			screen.getByRole( 'link', { name: 'More payment options' } )
+		).toHaveAttribute(
+			'href',
+			'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations&country=BR'
+		);
+	} );
 } );
diff --git a/plugins/woocommerce/client/admin/client/settings-payments/test/utils.test.ts b/plugins/woocommerce/client/admin/client/settings-payments/test/utils.test.ts
index cbe51cad7a9..ef7979f8359 100644
--- a/plugins/woocommerce/client/admin/client/settings-payments/test/utils.test.ts
+++ b/plugins/woocommerce/client/admin/client/settings-payments/test/utils.test.ts
@@ -1,7 +1,11 @@
 /**
  * Internal dependencies
  */
-import { getPluginActionErrorMessage, getFailedPluginAction } from '../utils';
+import {
+	getPluginActionErrorMessage,
+	getFailedPluginAction,
+	getMorePaymentOptionsUrl,
+} from '../utils';

 describe( 'getPluginActionErrorMessage', () => {
 	const reason =
@@ -86,3 +90,19 @@ describe( 'getFailedPluginAction', () => {
 		).toBe( 'activate' );
 	} );
 } );
+
+describe( 'getMorePaymentOptionsUrl', () => {
+	const baseUrl =
+		'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations';
+
+	it( 'filters the marketplace by the business location country code', () => {
+		expect( getMorePaymentOptionsUrl( 'BR' ) ).toBe(
+			`${ baseUrl }&country=BR`
+		);
+	} );
+
+	it( 'leaves the filter off when no business location is selected', () => {
+		expect( getMorePaymentOptionsUrl( null ) ).toBe( baseUrl );
+		expect( getMorePaymentOptionsUrl( '' ) ).toBe( baseUrl );
+	} );
+} );
diff --git a/plugins/woocommerce/client/admin/client/settings-payments/utils.ts b/plugins/woocommerce/client/admin/client/settings-payments/utils.ts
index 397e8eed449..5f23128e58c 100644
--- a/plugins/woocommerce/client/admin/client/settings-payments/utils.ts
+++ b/plugins/woocommerce/client/admin/client/settings-payments/utils.ts
@@ -10,12 +10,14 @@ import { getAdminLink } from '@woocommerce/settings';
 import { __, sprintf } from '@wordpress/i18n';
 import { recordEvent } from '@woocommerce/tracks';
 import { parseAdminUrl } from '@woocommerce/navigation';
+import { addQueryArgs } from '@wordpress/url';

 /**
  * Internal dependencies
  */
 import { getAdminSetting } from '~/utils/admin-settings';
 import {
+	morePaymentOptionsBaseUrl,
 	wooPaymentsProviderId,
 	wooPaymentsProviderSuggestionId,
 	wooPaymentsSuggestionId,
@@ -499,3 +501,17 @@ export const getPluginActionErrorMessage = (

 	return message || frame;
 };
+
+/**
+ * Build the WooCommerce.com marketplace link for the "More payment options" entry.
+ *
+ * @param businessCountryCode The selected business location, as an ISO 3166-1 alpha-2 country code.
+ * @return The marketplace URL, filtered by country when a business location is selected.
+ */
+export const getMorePaymentOptionsUrl = (
+	businessCountryCode: string | null
+): string =>
+	addQueryArgs(
+		morePaymentOptionsBaseUrl,
+		businessCountryCode ? { country: businessCountryCode } : {}
+	);