This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: Custom Work, Documentation request
This topic contains 5 replies, has 2 voices.
Last updated by Andreas 1 year, 11 months ago.
Assisted by: Andreas.
Author | Posts |
---|---|
December 2, 2022 at 3:03 pm #12579397 | |
olivierA-13 |
My problem is the same one that has been described here but using the default WooCommerce taxonomies, not custom ones: https://wpml.org/forums/topic/translate-custom-taxonomy-via-api-rest/ |
December 2, 2022 at 7:37 pm #12580651 | |
Andreas |
Hello there Thank you for contacting us. I am happy to help you. So to understand, you are using our REST API , try to add in secondary language a term with the same name and you are getting error? Here is the documentation just in case : If the above is true, I need to show me the data that you are trying to pass in creating and translating a term in order to replicate the issue locally. Regards, |
December 7, 2022 at 2:27 pm #12607841 | |
olivierA-13 |
Hi Andreas I have narrowed down the issue in meantime, and I am not actually sure if this is even a WPML related issue. Now here is a program flow that fails: { "name": "Coimbra", "description": null, "lang": "en", "acf": { "directus_id": "113", "tile_image": null }, } => Creates tag with id 374 and slug 'coimbra' 2. Update the acf fields using the wordpress REST API (/wp-json/wp/v2/product_tag/374) { acf: { "directus_id": "113", "tile_image": null } } => Works just fine 3. Create a translation (lang: pt) using the wpml REST API (products/tags) { "name": "Coimbra", "description": null, "lang": "pt", "acf": { "directus_id": "113", "tile_image": null }, "translation_of": 374, } => creates tag with id 375 and slug 'coimbra-2' 4. Update the acf fields using the wordpress REST API (/wp-json/wp/v2/product_tag/375) { acf: { "directus_id": "113", "tile_image": null } } => Fails with the following error: { "code": "duplicate_term_slug", "message": "The slug "coimbra-2" is already in use by another term.", "data": null } The tags are created and are recognized by wpml as translations. And the error doesn't really make sense to me because the slug that is supposedly duplicated is the one that belongs to the tag I just created and am trying to update... Best regards |
December 7, 2022 at 7:50 pm #12609695 | |
Andreas |
Thank you for the detailed explanation. First of all, I would like to inform you that I have never tested a scenario with ACF fields in the taxonomies of WooCommerce. Also, we only have official support WooCommerce Rest API with a combination of WooCommerce Multilingual. WPML is not officially supported Rest API so I am not sure about the results you are getting. From my point of view , you are trying to update ACF fields with WordPress Rest API endpoint, so I am not sure if this is related to WPML. What can I suggest to you is this : When you create the taxonomy in the rest call, pass also the slug attribute and define something specific for the taxonomy, right now the slug created automatically. For example try to define the slug as coimbra for ENG and coimbra-pt for PT and see if this can help you. Regards, |
December 10, 2022 at 11:34 am #12625629 | |
olivierA-13 |
I have tried your suggestion and created the slugs in that format. Unfortunately that didn't make any difference. Regards, |
December 12, 2022 at 11:13 am #12633745 | |
Andreas |
Thank you very much for your reply and appreciate that you shared your solution. If you need anything else do not hesitate to contact us. Closing this ticket now. Regards, |