Background of the issue:
I am presently coding so that I have a countdown of sold products, listed by the product's attribute and slugs. You can see the issue at this link: hidden link.
Symptoms:
I expected to see a login requirement, but instead, I am offering to provide access or a dummy user for you to access it.
Questions:
How can I resolve the issue with product type translations?
What steps should I take to ensure the countdown of sold products works correctly?
I'm not sure I understood the exact issue you're having.
Please provide me with the following information:
1. Where can I see the countdown working? If it's working on default languages, please share the link to a page where it shows;
2. How is the feature implemented? If it is coded, please send me the code;
3. What's behaving unexpectedly on translations? Please provide me with concrete examples of what's not behaving as expected;
This way, I can better understand what might be happening. Please note that we don't offer support for custom code. Nonetheless, I'm not entirely sure this is your case.
Furthermore, please don't share any access credentials on the forum. If I need access to the website, I'll enable a form so you can share data privately.
If you go on the site, you will see on the french version that there are 3 lines counting down the quantity of products needed before production can begin, but only on the products that are on pre-order (you will see a red box over the product's image to let you know).
Right now, I have been able to have it worked but for some reason it only works on the french version. Now I saw this error message I sent you earlier ("We detected that the product_type field was set incorrectly for some product translations. This happened because the product_type taxonomy was translated. You can fix this in the WooCommerce Multilingual & Multicurrency troubleshooting page. "), and of course, I can see that they may be related.
But when I go to the troubleshooting page, I don't see anything that would fix it.
If you want me to send you specs so you can look around let me know.
I can't attach a file to send you the code and it is far too long to put in an image. How do you want me to transmit it to you?
I don't see any countdown on the French product. Check the image attached. Perhaps because I'm logged out. It's likely that your code is not adjusted for multilingual scenarios, I will check that.
In this case, I need the following info:
1. Where I can find the custom code on the website's admin panel. This way, you don't need to share it, and I can check it directly;
2. Access to your website, for analysis;
For this I would need temporary access (WP-Admin and FTP) to your site, preferably to a test/staging site where the problem has been replicated if possible.
The required fields can be found below the comments section. The information you enter is private, i.e. only you and I can see it and have access to it.
I may need to replicate your website locally. To do this, I need to temporarily install a plugin called "Duplicator" or "All in One WP Migration" on your website. This will allow me to create a copy of your website and content. Once the issue is resolved, I will delete the local website. Let me know if this works for you.
IMPORTANT
Please make a backup copy of the site files and database before giving us access.
- If you do not see the wp-admin/FTP fields, this means your post and site login details are being made PUBLIC. DO NOT post your website details if you do not see the required wp-admin/FTP fields. If you do not, ask me to enable the private box. The private box looks like this:
I haven't been able to login, though. When inserting the credentials you shared and clicking "Se connecter", the pages that refreshes and I get back to the login screen.
Can you please check? If you need to share new credentials, the fields are enabled. Thank you.
First, a quick note about scope: we can’t provide support for custom code. That said, I’m happy to share some pointers so you can move forward. Anything deeper would require adjusting and testing the code, which is outside our support scope.
Why it likely only works in the default language
1. Custom field not copied: the `_preorder_goal` value may exist only on the default-language product if the field isn’t set to Copy in WPML’s custom fields settings. If it’s empty on the translation, nothing shows.
2. Attribute/variation language mismatch: you hard-code decoration slugs (default-language) and count only variations for the current product. In WPML each translation has different product/variation IDs and attribute slugs can change per language—so orders placed in other languages won’t be included. You need to map all translations of the product (and its variations) before counting. (See `wpml_element_trid` / `wpml_get_element_translations`.)
You have for example, on line 38 of Pre-Order System:
The slugs are necessarily different on other languages.
Suggestions on how to make it multilingual-safe
1. Check category via translated ID, not slug
Get the base term ID (default language), then resolve the current language term with `wpml_object_id( $base_id, 'product_cat', true )`; pass that term ID to `has_term`.
2. Ensure `_preorder_goal` is available on translations
Go to WPML > Settings > Custom Fields Translations, click on "Show system fields", and set that custom field to Copy so translated products read the same value. Check the image attached.
3. Derive decorations dynamically and in the current language
Don’t hard-code slugs, like I showed on line 38. Read the product’s `pa_decoration` terms for the current language, and render their names (already translated). If you must compare across languages, map term IDs with `wpml_object_id` (or use translated slugs via `wpml_get_translated_slug`).
_____________________________________
Overall, your code is not adapted to work in a mul-lingual scenario, along with WPML. Also, it has hard-coded information, which can lead to errors like the ones you are having. It's always best to use IDs, instead of strings like slug names.
My best suggestion is that you verify the product information (products, slugs, IDs, etc ) that's being pulled, and check how it behaves in terms on language. If it's only pulling single language data, check our hooks reference for developers, so it works with WPML: