Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

REST API support for limiting returned language versions #514

Open
richard-grosjean opened this issue Sep 17, 2020 · 1 comment
Open

REST API support for limiting returned language versions #514

richard-grosjean opened this issue Sep 17, 2020 · 1 comment

Comments

@richard-grosjean
Copy link

Using the REST API, the WooCommerce products endpoint returns all language versions.

Based on #23 and my measly testing, it seems like using a parameter like "lang" to filter the language versions that the products endpoint returns is not currently possible.

Adding support for a param like this seems trivial, but I haven't looked into where and how to best place it in this plugin or even if the maintainer feels like a feature like this is desirable in this plugin (❤️ this plugin hyyan, hope you find your maintainer).

There might be a better (less general) hook to use, but here is some example code to help illustrate the feature:

add_action('parse_query', 'add_lang_support', 1);

function add_lang_support($query) {
  $lang = $_GET['lang'];
    if ($lang) {
    $lang = sanitize_text_field($lang);
    $query->set('lang', $lang);
  }
}
@Jon007
Copy link
Contributor

Jon007 commented Feb 4, 2021

I agree, the code suggested looks along the right lines, you are welcome to submit a pull request..!
as there isn't rest customisation currently I'd suggest a new file.
To follow the existing plugin scheme it would be a new class file in src/Hyyan/WPI and a line to create it in registerCore() in Plugin.php... potentially also added as a setting in Features.php which allows the various features to be turned on and off.
at least that's how the other bits are implemented in this plugin.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants