• Found a bug:

    When creating a product using the REST API which is the translation of an existing one (determined by WPML attribute ‘translation_of’) it is not possible to set the same SKU (otherwise API will return 400 Bad Request).

    It only works if duplicate SKUs in plugin settings are allowed. But I would not consider a translation as a duplicated SKU, of course it has the same SKU.

    When creating the translation over WP admin, the SKU is correctly set (same in all languages) and marked as locked (expected behavior).

    • This topic was modified 1 year, 2 months ago by luk100r.
    • This topic was modified 1 year, 2 months ago by luk100r.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Dan Zakirov

    (@alexodiy)

    Thank you for reporting this issue. I appreciate your feedback.

    I have reviewed your report about the REST API SKU conflict when creating translations with WPML. I understand the inconvenience this is causing when maintaining consistent SKUs for translated products.

    Rest assured, I take this matter seriously and have added it to my priority list. I will allocate time to address it promptly.

    As part of my debugging and testing process, I will explore potential solutions to resolve the SKU conflict without compromising product data integrity. I will also assess the feasibility of aligning the REST API behavior with the expected behavior in the WP admin.

    I will keep you updated on my progress and notify you as soon as a solution is available.

    Hello @alexodiy and @luk100r,

    But I would not consider a translation as a duplicated SKU, of course it has the same SKU.

    @luk100r

    A word of caution on this matter: while @luk100r would understandably not have different SKUs for their product translations, other stores would.

    Using Woocommerce, WPML and Easy Auto SKU Generator for WooCommerce, stores may/should have different SKUs for certain translated product/services that are indeed different product/services but are the translated version of each other (like a course available multiple languages, a technical book with one product per language, etc.).

    This would affect the creation of products (using REST, translation, editor) but also features like the “bulk regenerate SKUs”.

    I would recommend either:

    • keeping the behavior as is (as expected, and compatible with the various translation plugins currently on the market or that might be released in the future) by requiring the “Duplicate SKUs” to be enabled, with some documentation/explanation on this setting’s implication on translated products
    • or going the extra mile for WPML specifically and, when a duplicate is encountered while “Duplicate SKUs” is set to false, checking if the duplicate is a translation of the product and that the translation setting of _sku in WMPL is set to “Copy” or “Copy Once” (and not “Translatable”) before allowing that duplicate SKU
      See: https://wpml.org/forums/topic/different-sku-for-different-languages/ for this setting

    Thread Starter luk100r

    (@luk100r)

    Hi @verbalpixel

    I appreciate your input.

    …translated product/services that are indeed different product/services…

    Do you have a real life example for this case? Why are different product/services not represented as such? So, as an example, you are offering:
    – Introduction to C++ in English
    – Introducción a C++ in Spanish
    …as the same product? Just as translation? Without knowing your case exactly, this doesn’t really make sense to me. What if a Spanish speaking customer wants to do the course in English, do they have to switch the shop to Spanish? Different products/services should imo represented as such and not as a related translation.

    …keeping the behavior as is (as expected, and compatible with the various translation plugins currently on the market or that might be released in the future)…

    I don’t consider this behavior as expected. The behavior should be consistent between the WP admin and the REST API.
    Currently you can create a translation with the same SKU via WP admin without the option “Allow duplicated SKU” checked, the same operation is not possible via the REST API. Either way, this should be consistent.

    Basically my post is only about the REST API, there is no need to change the behavior in the WordPress admin.

    Cheers

    Do you have a real life example for this case?

    Yes, an example :

    A Microsoft Excel course is given in two languages. Same syllabus, price, category, tags etc, but different class schedule, materials (handbook, exercise files, etc). Tracking them with different SKUs make sense, while still allowing visitors (and search engine) to be able to switch languages.

    – Introduction to C++ in English
    – Introducción a C++ in Spanish

    You’re right, one way of doing it would be two different products, two different SKUs, each translated (so 4 posts).

    But others could/would choose to have only the Spanish version offered on the Spanish side (while being able to stay on the same product when switching languages).
    Imagine this store has 5 languages and offers this same guide (course?) in 5 languages. 5 different products translated in 5 languages would require 25 posts (and prevent visitors from finding another version by simply switching language). That would fill the store with XXX guide in XXX language, which would render navigation quite cumbersome.

    Furthermore, WPML also allows to match languages with currencies, creating even more need (for some stores) for such flexibly with translation.

    In short, your use case is 100% valid and probably the most common, but, in my humble opinion, should not be considered “default/normal” to the extent of overriding the “Allow duplicated SKU” setting without the WPML-aware “extra mile” option described above.

    Currently you can create a translation with the same SKU via WP admin without the option “Allow duplicated SKU” checked, the same operation is not possible via the REST API. Either way, this should be consistent.

    Agreed ??

    • This reply was modified 1 year, 1 month ago by verbalpixel.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug: Allow duplicate SKU for translated products’ is closed to new replies.