Skip to content

Conversation

@anktd
Copy link
Collaborator

@anktd anktd commented Jan 5, 2026

Issue

This issue/feature request was reported via freshdesk ticket 338848

With WPML active, WC()->api_request_url() returns URL with language prefix:
- German context: https://example.com/de/wc-api/WC_Gateway_Blockonomics/
- French context: https://example.com/wc-api/WC_Gateway_Blockonomics/

The method findMatchingStore() compares this against the callback URL stored on Blockonomics dashboard (which was set up in English, i.e. without /de/)


Fix

The following 2 patterns cover 99% of Polylang or WPML setups:

Pattern Example Usage
/xx/ /de/, /fr/, /es/ Standard ISO 639-1 (most common)
/xx-xx/ /en-us/, /fr-ca/, /pt-br/ Language + region

To tackle both, the fix uses regex verification: /^([^\/]+)\/[a-z]{2}(-[a-z]{2})?\//$1/


What it won't handle:

  • Subdomains (de.example.com)
  • Different TLDs (example.de)
  • 3-letter language codes (/chi/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant