Skip Navigation

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

Problem:
If you're experiencing issues with the video function in your product not working, we have identified a solution.
Solution:
We recommend adding the following code into the

add_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10, 4);
add_filter('woodmart_single_product_image_thumbnail_id', 'wpml_compsupp7477_translate_attachment_id', 10, 2);

function wpml_compsupp7477_filter_woodmart_wc_video_gallery($null, $object_id, $meta_key, $single) {
    
    // Target the specific meta key
    if ($meta_key !== 'woodmart_wc_video_gallery') {
        return $null;
    }

    // Prevent recursion by temporarily removing the filter
    remove_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10);

    // Fetch the original meta value
    $video_gallery = get_post_meta($object_id, $meta_key, false);

    // Re-add the filter
    add_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10, 4);

    // Check if we actually got an array
    if (isset($video_gallery[0]) && is_array($video_gallery[0])) {
        foreach ($video_gallery[0] as $key => $value) {
            // Apply the WPML filter to each item (video settings array key)
            $translated_key = apply_filters('wpml_object_id', $key, 'post', true);
            $video_gallery[0][$translated_key] = $value;
        }
    }

    return $video_gallery;
}

function wpml_compsupp7477_translate_attachment_id($attachment_id, $product) {
    return apply_filters('wpml_object_id', $attachment_id, get_post_type($attachment_id), true);
}

Please ensure to backup your database before implementing this code.

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 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.

This topic contains 17 replies, has 2 voices.

Last updated by Andrey 2 months, 2 weeks ago.

Assisted by: Andrey.

Author Posts
June 19, 2024 at 9:07 pm #15758667

johnP-55

Background of the issue:
Hello, after upgrading WPML, Woodmart theme, and WordPress, the video function in the product is not working. If I disable WPML CMS, then it works normally.

Symptoms:
The video function in the product is not working after upgrading WPML, Woodmart theme, and WordPress. It works normally when WPML CMS is disabled.

Questions:
Why is the video function in the product not working after upgrading WPML, Woodmart theme, and WordPress?
How can I fix the video function issue without disabling WPML CMS?

June 20, 2024 at 7:55 am #15761963

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Does it happen with all languages or only with translations?

You mentioned that it works if you disable WPML. What are the results if you turn off all plugins except WPML, WooCommerce Multilingual & Multicurrency?

June 23, 2024 at 5:54 am #15791698

johnP-55

hello and thank you for your answer, I did some tests to see if it happens in all languages ​​and I noticed that in the main language (in my case Greek) the video works, while in the second language (in my case English) it doesn't the video appears

June 24, 2024 at 2:59 pm #15808499

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for your feedback.

The theme feature probably has a custom field responsible for the video settings, and it may not have been carried over to the translated products. This custom field might be called "woodmart_wc_video_gallery." Please try setting this custom field as "Copy" in WPML → Settings → Custom fields and then update the products. To update the products, you can modify the original product, save it, go to the WPML translation editor, and complete the translation.

Similar support ticket:
https://wpml.org/forums/topic/woodmart-released-a-new-feature-to-add-videos-to-products/#post-13175597

June 26, 2024 at 8:47 pm #15837292

johnP-55

hi I did the steps you mentioned, but when I try setting this custom field as "Copy" in WPML → Settings → Custom fields and then update the products. the video does not appear in any language, neither in Greek (main language) nor in English

June 27, 2024 at 8:42 am #15841914

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I need to request temporary access (wp-admin and FTP) to your site – preferably to a test site where the problem has been replicated if possible – in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Please provide the link to the product that works for the original language but not for the secondary language.

July 1, 2024 at 12:27 pm #15868503

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for the information. I noticed that the WPML plugins have not been updated on the staging site you provided.

Could you please update the WPML plugins and try again the steps I recommended earlier? If it still doesn't work, please let me know.

https://wpml.org/account/downloads

July 4, 2024 at 5:13 am #15888790

johnP-55

hello, this is not the fault because on the real website your plugin is updated to the latest version, but it still doesn't work, can you find a solution to my problem without wasting time on useless messages? the response is taking too long.

July 4, 2024 at 6:43 am #15889421

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for your feedback. I understand, but we need to work with the latest available code. Am I allowed to update WPML plugins on your website?

July 5, 2024 at 8:05 pm #15900081

johnP-55

feel free to make any update or changes, just let me know if you want any infos

July 8, 2024 at 8:26 pm #15915596

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I appreciate your patience. I have conducted further testing on this issue and have discovered that the product video feature of this theme does not work if the product was not initially created in the default language of the site.

Here's what I did:

1) I used the product you shared as an example, went to the translation section, and re-linked the product, choosing Greek as the original product language.

https://wpml.org/faq/how-to-disconnect-translations-from-the-default-language-page-or-post/ (from the step 4). You would also need to correct the translation then.

2) I set the custom field 'woodmart_wc_video_gallery' to 'Copy' in WPML → Settings → Custom fields.

3) I made a small modification to the original product, saved it, and then navigated to the WPML translation editor to complete the translation.

You can view the results here hidden link and switch the language.

July 15, 2024 at 4:58 am #15951844

johnP-55

I don't see any change in the product from what you say I will do a test and report back

July 15, 2024 at 4:31 pm #15955699

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I cannot double-check because your staging site isn't available anymore. I have already reported this issue to our compatibility team. For this feature to work, the product needs to be created in the site's default language first.

July 17, 2024 at 5:11 pm #15967621

johnP-55

the website is accessible normally, this website was originally made in English about 3 years ago, this year we decided to make it in Greek and we set Greek as the main language for this and we bought your plugin, so all the products were originally made with the English language, as you understand it is not logical and normal that I have to edit all the products one by one for the video to appear

July 17, 2024 at 5:50 pm #15967780

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

We have a solution for this issue. You should add the following code into the functions.php file of your theme:

add_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10, 4);
add_filter('woodmart_single_product_image_thumbnail_id', 'wpml_compsupp7477_translate_attachment_id', 10, 2);

function wpml_compsupp7477_filter_woodmart_wc_video_gallery($null, $object_id, $meta_key, $single) {
    
    // Target the specific meta key
    if ($meta_key !== 'woodmart_wc_video_gallery') {
        return $null;
    }

    // Prevent recursion by temporarily removing the filter
    remove_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10);

    // Fetch the original meta value
    $video_gallery = get_post_meta($object_id, $meta_key, false);

    // Re-add the filter
    add_filter('get_post_metadata', 'wpml_compsupp7477_filter_woodmart_wc_video_gallery', 10, 4);

    // Check if we actually got an array
    if (isset($video_gallery[0]) && is_array($video_gallery[0])) {
        foreach ($video_gallery[0] as $key => $value) {
            // Apply the WPML filter to each item (video settings array key)
            $translated_key = apply_filters('wpml_object_id', $key, 'post', true);
            $video_gallery[0][$translated_key] = $value;
        }
    }

    return $video_gallery;
}

function wpml_compsupp7477_translate_attachment_id($attachment_id, $product) {
    return apply_filters('wpml_object_id', $attachment_id, get_post_type($attachment_id), true);
}

It works for us. Let me know how it goes. Please backup your database before making any changes.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.