Version: 1.0.5
Author: NuoBiT Solutions, S.L.
Contributors: Eric Antones <eantones@nuobit.com>
License: GPLv3 or later
A small WooCommerce + WPML compatibility helper that ensures WooCommerce term lookups are restricted to the currently active WPML language.
This fixes the issue where WPML doesn't take into account the language parameter in REST API queries for categories and attributes, causing term queries to return results from all languages instead of the requested language.
When WPML is active, this plugin:
- Hooks into the
terms_clausesfilter only during REST API requests (REST_REQUEST). - Applies the restriction only for WooCommerce product categories (
product_cat) and attribute taxonomies (pa_*) that are registered as translatable in WPML. - Adds a JOIN to WPML's
icl_translationstable and filters bywpmltr.language_code = <current language>. - Skips filtering when language is set to 'all'.
- Bugfix: Added
REST_REQUESTguard to prevent theterms_clausesfilter from running on frontend and admin pages. The filter was causing attribute dropdown selectors to disappear on product variation pages. - Bugfix: Added
wpml_is_translated_taxonomycheck to skip non-translatable taxonomies. When apa_*taxonomy is not set as translatable in WPML, its terms have no rows inicl_translations. TheINNER JOINthen silently drops all terms, producing empty dropdowns.
- Updated plugin description and metadata.
- Initial release.
This plugin addresses a bug in WPML where the REST API language filtering is not properly implemented for WooCommerce taxonomies. WPML has focused primarily on backend and frontend functionality, but appears to have limited support for REST API operations.
WooCommerce taxonomies (product categories and attributes like pa_color, pa_size, etc.) often use term slugs that can overlap across languages. When querying terms via the REST API, WPML doesn't properly filter by the language parameter, leading to:
- Updating the wrong translation of an attribute term
- Conflicting term resolutions when slugs match across languages
- Incorrect term associations in multilingual contexts
- API responses mixing terms from different languages
This helper forces term lookups to stay within the active WPML language for WooCommerce taxonomies, fixing what WPML should be handling natively.
Note: This is a workaround for WPML's API limitations. Ideally, WPML will address this in future updates, making this plugin unnecessary.
- WordPress
- WooCommerce (for
pa_*attribute taxonomies) - WPML (the filter is a no-op unless WPML is active)
- Place the plugin files in
wp-content/plugins/woocommerce-wpml-rest-api-extension/ - Activate the plugin from Plugins → Installed Plugins
- Ensure WPML is active (otherwise the plugin does nothing)