Localization when using Woocommerce API
-
Hey guys,
I’m currently working on the Woocommerce API and especially localization.
As far as I’ve come, every product and product category contains a field ‘translations’ which contains IDs with which one can request the translated item, e.g. when ‘/products/42’ contains ‘”en”: 1337’ I can request the English version of the same item with ‘/products/1337’.This works well for products, but when used for product categories I only get redirected to the original item, e.g. for ‘/products/categories/42’ which contains ‘”en”: 1337’ I request ‘/products/categories/1337’ but it returns me the original, not translated item with ID 42.
So I’ve got 2 questions for you:
Does someone have an idea why it works for products, but currently not for product categories? The translations exist and work on the website, but the API seems to just redirect to the untranslated version of the item.
And secondly, what would be the best way to retrieve all items for a specific locale? If I’m requesting ‘/products’ it only returns the items of the original locale – so I would have to request every single item with the translated locale like ‘/products/13’ and so on to get a list of all of the English items. I would love to just be able to do ‘/products’ and retrieve all items regardless of the ‘lang’ field or to only get items with a specific value set for the ‘lang’ field.
If anyone of you knows something helpful, I’d love to hear from you, thanks for any help!
The topic ‘Localization when using Woocommerce API’ is closed to new replies.