Skip Navigation

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

Problem:
You want the translation column to always be visible on the WooCommerce product list in the admin area, but even after using a code snippet to unhide the column, no data is displayed in it.
Solution:
We recommend implementing a custom function to ensure the 'icl_translations' column is always visible and contains data. Here's a step-by-step guide:
1. Add the following function to your theme's functions.php file or a custom plugin:

function force_wpml_languages_column_visibility() {<br />    if (!function_exists('get_current_screen') || !is_admin()) {<br />        return;<br />    }<br />    $screen = get_current_screen();<br />    if ($screen && $screen->id === 'edit-product') {<br />        $user_id = get_current_user_id();<br />        $hidden_columns = get_user_meta($user_id, 'manageedit-productcolumnshidden', true);<br />        if (is_array($hidden_columns) && ($key = array_search('icl_translations', $hidden_columns)) !== false) {<br />            unset($hidden_columns[$key]);<br />            update_user_meta($user_id, 'manageedit-productcolumnshidden', $hidden_columns);<br />        }<br />    }<br />}<br />add_action('admin_init', 'force_wpml_languages_column_visibility', 20);

2. To ensure the translation icons are reinitialized correctly, add this additional function:

function reinitialize_wpml_translation_icons() {<br />    $screen = get_current_screen();<br />    if ($screen && $screen->id === 'edit-product') {<br />        ?><br />        <script type="text/javascript"><br />            jQuery(document).ready(function($) {<br />                setTimeout(function() {<br />                    if (typeof WPML_Translate_Link_Targets !== 'undefined') {<br />                        WPML_Translate_Link_Targets.init();<br />                    }<br />                }, 500);<br />            });<br />        </script><br />        <?php<br />    }<br />}<br />add_action('admin_footer', 'reinitialize_wpml_translation_icons');

Please test this solution in a staging environment before applying it to your live site, as this custom code is a courtesy and not officially supported by us.

If this solution does not resolve your issue or seems outdated, 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: 

This topic contains 3 replies, has 0 voices.

Last updated by alexisR-11 1 hour, 1 minute ago.

Assisted by: Osama Mersal.

Author Posts
January 28, 2025 at 3:58 pm #16643029

alexisR-11

Background of the issue:
I want the translation column to be always shown on the product list in the admin area of my site under development. When I'm on the product list in WooCommerce, I can go to 'Screen Options' to check and show the column 'Language'. I want it to be always enabled or at least enabled by default. I've used the following code (from hidden link): function unhide_column($hidden, $screen) { if (($key = array_search('icl_translations', $hidden)) !== false) { unset($hidden[$key]); } return $hidden; } add_filter('default_hidden_columns', 'unhide_column', 10, 2); It does make the column appear but no data is shown in it 🙁

Symptoms:
The column appears but no data is shown in it.

Questions:
How can I ensure the translation column shows data when enabled by default?
Is there a different method to make the translation column always visible with data?

January 30, 2025 at 8:44 am #16649906

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

I'm afraid the only option is to enable the language from the screen options and click Apply.

After that, the language column should be shown for your account whenever you visit the products page.

Best regards,
Osama

January 30, 2025 at 8:57 am #16649971

alexisR-11

Ok.
Could this feature be added later on?
Or is there any trigger or filter or action I can use to make it happen?

I'm trying to simplify the UI for users.
It doesn't make sense that you can translate pages, posts, or events from the post list but for products you have to either click the button "Translate WooCommerce products" or do to a different menu ("WooCommerce Multilingual & Multicurrency").

January 30, 2025 at 9:51 am #16650263

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I created a function for you and tested it on this hidden link">sandbox site.

/**
 * Force the "icl_translations" column to be visible by default.
 */
function force_wpml_languages_column_visibility() {
    // Only run on the Products admin page
    if (!function_exists('get_current_screen') || !is_admin()) {
        return;
    }
    
    $screen = get_current_screen();
    if ($screen && $screen->id === 'edit-product') {
        $user_id = get_current_user_id();
        $hidden_columns = get_user_meta($user_id, 'manageedit-productcolumnshidden', true);
        
        // Remove 'icl_translations' from hidden columns
        if (is_array($hidden_columns) && ($key = array_search('icl_translations', $hidden_columns)) !== false) {
            unset($hidden_columns[$key]);
            update_user_meta($user_id, 'manageedit-productcolumnshidden', $hidden_columns);
        }
    }
}
add_action('admin_init', 'force_wpml_languages_column_visibility', 20); // Higher priority

/**
 * Reinitialize WPML's translation icons after forcing the column to show.
 */
function reinitialize_wpml_translation_icons() {
    $screen = get_current_screen();
    if ($screen && $screen->id === 'edit-product') {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($) {
                // Reinitialize WPML's translation manager after a slight delay
                setTimeout(function() {
                    if (typeof WPML_Translate_Link_Targets !== 'undefined') {
                        WPML_Translate_Link_Targets.init();
                    }
                }, 500); // Adjust delay if needed
            });
        </script>
        <?php
    }
}
add_action('admin_footer', 'reinitialize_wpml_translation_icons');

Please note that this custom code is a courtesy and is not officially supported by the WPML team. Before applying it to a live site, please test it in a staging environment.

Best regards,
Osama

February 2, 2025 at 10:33 am #16659774

alexisR-11

Thanks a lot.
For some reason your code doesn't work out of the box for me but there are things in it that works for me!