Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing an issue where links under the 'Add to cart' button are pointing to the original language version (Danish) instead of the translated version (Norwegian) on their e-commerce site.
Solution:
We recommend the following steps to resolve this issue:
1. Ensure that the "Adjust IDs for multilingual functionality" option is enabled. You can find this setting by navigating to WPML -> Languages.
2. After enabling this option, it is advisable to clear your site's cache to ensure changes take effect, although this may not always be necessary.

The "Adjust IDs for multilingual functionality" setting in WPML helps ensure that content elements like posts, pages, media, and taxonomies are correctly linked across different languages. This setting is crucial for maintaining the integrity of ID-based content across your site, facilitated by themes, plugins, or custom fields. While enabling this feature might introduce a slight performance overhead due to additional database queries, proper caching strategies can effectively minimize this impact.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your specific 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 problems persist, please do not hesitate to open a new support ticket with us for further assistance. You can do so 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: 

This topic contains 18 replies, has 2 voices.

Last updated by Bruno Kos 2 weeks, 2 days ago.

Assisted by: Bruno Kos.

Author Posts
October 23, 2024 at 1:01 pm #16321914

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Thank you, I downloaded the package. I am checking this with our 2nd tier and will keep you posted.

October 24, 2024 at 9:34 am #16325318

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Can you please try the following:

1. Make sure the "Adjust IDs for multilingual functionality" option is enabled on the live site. You can find this option by navigating to **WPML -> Languages**.
2. After enabling the option, clear the cache, although this may not be required.

Does it work?

October 24, 2024 at 10:10 am #16325516

piaP-6

Hi Bruno,

Yes, that does actually seem to solve the issue for the products that had the issue. However, should this setting be necessary for a compatible theme as Flatsome? I would prefer not setting that option due to performance.

Best Regards,
P

October 24, 2024 at 11:54 am #16325966

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

The "Adjust IDs for multilingual functionality" setting in WPML ensures that content elements like posts, pages, media, and taxonomies are correctly linked across different languages, whether they're referenced by themes, plugins, or custom fields. It’s not exclusively related to themes, but applies to any ID-based content across the site. While it may add a slight performance overhead due to additional database queries, proper caching can minimize this impact.

Are you noticing any performance overhead or slower load times since enabling this feature?

October 28, 2024 at 9:54 am #16336865

piaP-6

Hi Bruno,

The links in the post meta section is coming from the theme, so I thought it was related to the theme.

I have not tested how much the setting impacts the performance. However, I generally prefer sticking to the ideal settings for performance. Isn't there another way to fixed the issue in the theme files?

Best Regards,
P

October 29, 2024 at 12:03 pm #16341952

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

To dynamically translate category URLs in Flatsome using WPML, you can utilize the `wpml_object_id()` function. Here’s a code example to guide you:

<?php
if ( class_exists('Sitepress') ) {
 
    // Fetch all categories
    $categories = get_categories();
 
    foreach ($categories as $category) {
        // Translate the category ID for the current language
        $translated_cat_id = apply_filters( 'wpml_object_id', $category->term_id, 'category', TRUE  );
 
        // Generate the translated category URL
        $translated_cat_link = get_category_link($translated_cat_id);
 
        // Output the translated category link
        echo '<a href="' . esc_url($translated_cat_link) . '">' . esc_html($category->name) . '</a>';
    }
}
?>

However, note the following:

1. WPML's "Auto adjust IDs" functionality is highly efficient, filtering terms by language directly at retrieval. This minimizes the need for additional requests in your code and is generally preferable unless you encounter specific performance issues. If performance remains unaffected, it’s best to leave this setting enabled.

2. This code requires careful placement in the correct template within Flatsome. While it may work initially, future updates in theme could affect its behavior (e.g., changes in function names or term filtering processes).

3. Adjustments for WPML compatibility can be complex, as various developers have unique approaches to term filtering. If you need further customization, consider checking with the Flatsome developers to see if they can integrate this solution. Alternatively, you may want to consult our https://wpml.org/contractors/ for help in adjusting templates to work without relying on this function.