This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing issues with conditions being stripped from HTML code during translation in WPML, specifically with the '==' and '!=' conditions in Advanced Product Fields Pro for WooCommerce, this might be due to limitations in the Advanced Translation Editor (ATE).
Solution:
We recommend switching to the Classic Translation Editor for cases where specific conditions like 'equal' are not appearing correctly in ATE. Here’s how you can do it:
1. Navigate to WPML > Settings and switch to the Classic Translation Editor.
2. When translating a product, use the 'Copy all fields from original' option, then manually translate text fields while leaving rule-based fields unchanged.
3. Manually add the 'Equal' condition in the translated product to ensure it functions correctly.
4. If using ATE and encountering issues with automatic translations, you will need to manually update the condition rule for 'equal' in the translation.
5. For issues like the required field marker appearing incorrectly, manually save the translated product to ensure that changes propagate correctly.
If these steps do not resolve your issue or if the solution seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.
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: Exception
This topic contains 11 replies, has 2 voices.
Last updated by Rico Heinrich 5 months ago.
Assisted by: Prosenjit Barman.
Author | Posts |
---|---|
August 23, 2024 at 3:09 pm #16098990 | |
Rico Heinrich |
Background of the issue: Symptoms: Questions: |
August 23, 2024 at 3:12 pm #16099014 | |
Rico Heinrich |
Once again, the relevant code snippet. |
August 26, 2024 at 11:04 am #16104062 | |
Prosenjit Barman Supporter
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello There, I understand the issue you're facing. It appears that the translation preference for the field where you're setting the condition is not configured correctly, which is why the condition is not being copied to the translation. If you can identify the field name in the product editor that is storing the condition (by inspecting the field), you can set the translation preference for that field to "Copy" by navigating to "WPML > Settings > Custom Field Translation." If the field isn't visible in the results, click on the "Show System Fields" link below the Custom Field Translation section and then search for the field again. Please let me know if that helps or if you need any further assistance or clarification. I'll be happy to help. Best regards, |
August 26, 2024 at 1:17 pm #16104669 | |
Rico Heinrich |
Hello Prosenjit, Thank you. I changed the setting for Custom Field Translation from "translate" to "copy". The field is called _wapf_fieldgroup and seems to contain both text and conditions. Now that this field is copied the conditions work but the text is in the original language and is not translated. How can we translate it now as it is not to be found in the Advanced Translation Editor? |
August 26, 2024 at 2:16 pm #16105169 | |
Rico Heinrich |
So this is the content of the field _wapf_fieldgroup. I contains both conditions and text which needs to be translated. If we set the field to "translate", certain conditions are stripped away, like "==" and "generated", probably due to security reasons. If we set the field to "copy", it is not translated. If we could somehow translate manually after it is copied, we would need to recreate all conditions in target languages if we changed those in the original language. So the best solution for us would be to somehow whitelist this field or set allowed field contents so that parts are not stripped. a: 6: { s: 2: "id";s: 7: "p_89347";s: 4: "type";s: 12: "wapf_product";s: 6: "layout";a: 6: { s: 15: "labels_position";s: 5: "above";s: 21: "instructions_position";s: 5: "field";s: 13: "mark_required";b: 0;s: 21: "enable_gallery_images";b: 0;s: 14: "gallery_images";a: 0: {} s: 9: "swap_type";s: 5: "rules"; } s: 9: "variables";a: 0: {} s: 6: "fields";a: 4: { i: 0;a: 12: { s: 2: "id";s: 13: "622a39bc7a392";s: 5: "label";s: 7: "Größe";s: 11: "description";s: 85: "Nur noch wenige Größen verfügbar – die Größe S und M sind bereits ausverkauft!";s: 4: "type";s: 11: "text-swatch";s: 8: "required";b: 1;s: 5: "class";N;s: 5: "width";N;s: 12: "parent_clone";a: 0: {} s: 7: "options";a: 6: { s: 7: "choices";a: 4: { i: 0;a: 6: { s: 4: "slug";s: 5: "8d579";s: 5: "label";s: 2: "XS";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 4: "none";s: 14: "pricing_amount";d: 0; } i: 1;a: 6: { s: 4: "slug";s: 5: "he7c5";s: 5: "label";s: 1: "L";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 150; } i: 2;a: 6: { s: 4: "slug";s: 5: "h7s4k";s: 5: "label";s: 2: "XL";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 150; } i: 3;a: 6: { s: 4: "slug";s: 5: "g8z4w";s: 5: "label";s: 3: "XXL";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 150; } } s: 5: "group";s: 5: "field";s: 4: "meta";s: 0: "";s: 16: "parent_qty_based";s: 0: "";s: 9: "clone_txt";s: 0: "";s: 3: "tax";s: 0: ""; } s: 12: "conditionals";a: 0: {} s: 5: "clone";a: 1: { s: 7: "enabled";b: 0; } s: 7: "pricing";a: 3: { s: 4: "type";s: 5: "fixed";s: 6: "amount";d: 0;s: 7: "enabled";b: 0; } } i: 1;a: 12: { s: 2: "id";s: 13: "66c868bcd366a";s: 5: "label";s: 19: "Für Laufradgröße";s: 11: "description";N;s: 4: "type";s: 11: "text-swatch";s: 8: "required";b: 1;s: 5: "class";N;s: 5: "width";N;s: 12: "parent_clone";a: 0: {} s: 7: "options";a: 3: { s: 7: "choices";a: 2: { i: 0;a: 6: { s: 4: "slug";s: 5: "r006n";s: 5: "label";s: 8: "nur 650B";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 4: "none";s: 14: "pricing_amount";d: 0; } i: 1;a: 6: { s: 4: "slug";s: 5: "hxyay";s: 5: "label";s: 10: "650B/ 700C";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 150; } } s: 5: "group";s: 5: "field";s: 4: "meta";s: 0: ""; } s: 12: "conditionals";a: 1: { i: 0;a: 1: { s: 5: "rules";a: 1: { i: 0;a: 4: { s: 9: "condition";s: 2: "==";s: 5: "value";s: 5: "8d579";s: 5: "field";s: 13: "622a39bc7a392";s: 9: "generated";b: 0; } } } } s: 5: "clone";a: 1: { s: 7: "enabled";b: 0; } s: 7: "pricing";a: 3: { s: 4: "type";s: 5: "fixed";s: 6: "amount";d: 0;s: 7: "enabled";b: 0; } } i: 2;a: 12: { s: 2: "id";s: 13: "622a3a2384694";s: 5: "label";s: 5: "Gabel";s: 11: "description";N;s: 4: "type";s: 11: "text-swatch";s: 8: "required";b: 1;s: 5: "class";N;s: 5: "width";N;s: 12: "parent_clone";a: 0: {} s: 7: "options";a: 6: { s: 7: "choices";a: 2: { i: 0;a: 6: { s: 4: "slug";s: 5: "stcl8";s: 5: "label";s: 4: "ohne";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 4: "none";s: 14: "pricing_amount";d: 0; } i: 1;a: 6: { s: 4: "slug";s: 5: "ey809";s: 5: "label";s: 11: "Carbongabel";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 250; } } s: 5: "group";s: 5: "field";s: 4: "meta";s: 0: "";s: 16: "parent_qty_based";s: 0: "";s: 9: "clone_txt";s: 0: "";s: 3: "tax";s: 0: ""; } s: 12: "conditionals";a: 0: {} s: 5: "clone";a: 1: { s: 7: "enabled";b: 0; } s: 7: "pricing";a: 3: { s: 4: "type";s: 5: "fixed";s: 6: "amount";d: 0;s: 7: "enabled";b: 0; } } i: 3;a: 12: { s: 2: "id";s: 13: "622a3a53f46a2";s: 5: "label";s: 8: "Zubehör";s: 11: "description";N;s: 4: "type";s: 12: "image-swatch";s: 8: "required";b: 0;s: 5: "class";N;s: 5: "width";N;s: 12: "parent_clone";a: 0: {} s: 7: "options";a: 10: { s: 7: "choices";a: 1: { i: 0;a: 8: { s: 4: "slug";s: 5: "lmlc6";s: 5: "label";s: 16: "Ersatzschaltauge";s: 8: "selected";b: 0;s: 7: "options";a: 0: {} s: 12: "pricing_type";s: 5: "fixed";s: 14: "pricing_amount";d: 24.899999999999999;s: 5: "image";s: 84: "<em><u>hidden link</u></em>";s: 10: "attachment";i: 118785; } } s: 5: "group";s: 5: "field";s: 4: "meta";s: 0: "";s: 16: "parent_qty_based";s: 0: "";s: 9: "clone_txt";s: 0: "";s: 3: "tax";s: 0: "";s: 9: "label_pos";s: 7: "default";s: 13: "items_per_row";s: 1: "2";s: 20: "items_per_row_tablet";s: 1: "2";s: 20: "items_per_row_mobile";s: 1: "1"; } s: 12: "conditionals";a: 1: { i: 0;a: 1: { s: 5: "rules";a: 1: { i: 0;a: 4: { s: 9: "condition";s: 6: "!empty";s: 5: "value";s: 0: "";s: 5: "field";s: 13: "622a3a2384694";s: 9: "generated";b: 0; } } } } s: 5: "clone";a: 1: { s: 7: "enabled";b: 0; } s: 7: "pricing";a: 3: { s: 4: "type";s: 5: "fixed";s: 6: "amount";d: 0;s: 7: "enabled";b: 0; } } } s: 11: "rule_groups";a: 1: { i: 0;a: 1: { s: 5: "rules";a: 1: { i: 0;a: 3: { s: 5: "value";a: 1: { i: 0;a: 2: { s: 2: "id";s: 5: "89347";s: 4: "text";s: 0: ""; } } s: 9: "condition";s: 7: "product";s: 7: "subject";s: 7: "product"; } } } } } |
August 27, 2024 at 4:12 am #16107208 | |
Prosenjit Barman Supporter
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello There, If the field is set to "Copy," could you please verify whether the text content within that field can be translated via WPML > String Translation? If the translation is possible, kindly check the frontend after translating to ensure that the translated content is displayed correctly and that the conditions are working as expected. If it still doesn't work after that, I kindly request you to try replicating the issue on our sandbox site. The autologin link to our sandbox is given below. - hidden link WooCommerce, WPML, and their addons are already installed in the sandbox. Please complete the initial setup first. After that, install the Advanced Product Fields plugin, create a product, and configure it exactly as you have on your main site. Then, check if you can replicate the issue. If you're able to replicate the issue, please let me know the steps in your next response. I will review them and let you know the next steps. The sandbox environment is useful for isolating an issue in a minimal setup. If the issue persists there, we can easily escalate it to our 2nd tier team for further investigation. So, please give it a try and update me on the results. I will be happy to help further. Looking forward to your response. Best regards, |
August 27, 2024 at 7:15 am #16107688 | |
Rico Heinrich |
Hello, thank you for your reply. Unfortunately I cannot find the text to be translated in WPML > String Translation. I have rebuilt the issue in the test store. Here is the product in the original language: If you select "S" for "Größe", another option will be displayed below. If you select "M", "L" or "XL", the other option will be hidden. This is the intended behavior. Here is the translated product: As you can see, the option does not behave in the same way. If you select "S" for size, the other option will not be displayed. If you check the source code of the translated page, you can see that the condition value of "==" has been removed (search for wapf[field_66cd78f512e78] and check the data-dependencies attribute which contains the field "condition"). Thank you and best regards Rico |
August 28, 2024 at 5:08 am #16112444 | |
Prosenjit Barman Supporter
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello Rico, I checked and noticed that only the equal condition (==) does not appear in the Advanced Translation Editor, while other conditions like "Empty" or "Not Empty" display correctly. Additionally, the Size element also appears correctly in the Translation Editor. The ATE has a known limitation with displaying certain symbols and punctuation marks. To work around this, you can set the condition in the translation by following these steps: - Edit the translated product and manually add the condition. Simply select the "Equal" condition without making any other changes. I tested this in a sandbox environment and can confirm that everything works properly, including the translation. - Switch to the Classic Translation Editor by navigating to "WPML > Settings" and then try to translate the product. In this editor, the equal sign appears correctly for translation. You can see an example in this screenshot: hidden link. Just copy the value of the condition fields into the translation and then proceed to translate the rest of the content. This approach ensures that the condition functions properly in the translation. I hope you can understand. Please try and let me know how it goes. If you need further assistance or clarification, feel free to let me know. I'll be happy to help. Best regards, |
August 28, 2024 at 8:29 am #16113310 | |
Rico Heinrich |
OK, so the solution is to use the Classic Translation Editor instead of the Advanced Translation Editor. Thank you, this works as expected now! |
August 28, 2024 at 10:57 am #16114317 | |
Rico Heinrich |
Hello Prosenjit, Unfortunately it seems there are still some issues. 1) When we use the Classic Translation Editor we cannot use the automatic translation, right? That is very inconvenient. Can we just use the Classic Editor on a case-by-case basis, like only on products with custom options? 2) When I translate a new product using the Classic Editor, I click on "Copy all fields from original" and afterwards manually translate all text fields and just leave the rules based fields as they are. But this leads to a strange behaviour. Please check this test product: In the original language I set the fields to "required" but also set the option to not show that they are required (the "*" should not be shown). This seems to correspond to the field-_wapf_fieldgroup-2-mark_required set to false as can be seen in the translation editor. This field is set to "false" both in the original and in the translation. However, in the translation the field is marked by "*" while in the original it is not. Please check the attached screenshots. There are even some more of this kind of issues when we use the Classic Translation Editor in our store, this is just one example. We could low level hack this problem by not translating some custom fields but we had to remember which ones and for non-coders this is not a valid solution. This is a new problem with the Classic Translation Editor, it doesn't occur when we use the Advanced Translation Editor. Could you please check again? |
August 29, 2024 at 3:50 am #16117415 | |
Prosenjit Barman Supporter
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello Rico, Yes, indeed, automatic translation cannot be used with the Classic Translation Editor; it only works with the Advanced Translation Editor. If you prefer to translate content automatically, you'll need to keep the Advanced Translation Editor enabled. However, in that case, you'll need to manually update the condition rule (only the equal condition) in the translation. Regarding the required field marker issue, I checked the translated product from the editor and, upon inspecting the button that shows/hides the required marker, I found that the value to keep the marker hidden was added correctly to the button. However, for some reason, the button remained active. Please check the attached screenshot. It seems the button value doesn’t get updated correctly until the user interacts with it. However, when I manually saved the translated product, the value propagated correctly to the button, and the required marker no longer appeared on the frontend. For your information, I saved the translated product without making any changes. If you prefer to continue using the Classic Translation Editor, you may need to manually save the product to ensure that the changes propagate correctly. If you choose to use the Advanced Translation Editor, you'll need to update the condition rule in the translated product manually. Given the limitations of ATE, this is the only way to ensure that the product field functions correctly in translation. Additionally, you also have the option to completely manually update advanced product field data in the translation. To do this, set the "_wapf_fieldgroup" to 'Copy-Once'. Then, make a small change to the default product and update its translation. The default data will be copied to the translated product and you can then manually update the data in the translated product as needed. I hope you can understand. Please feel free to let me know if you have any other questions or need clarification. I will be happy to help. Best regards, |
August 29, 2024 at 5:42 am #16117484 | |
Rico Heinrich |
Thank you very much Prosenjit! Saving the translated product indeed solves the problem. Best regards Rico |