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 3 months, 2 weeks ago.

Assisted by: Andrey.

Author Posts
July 17, 2024 at 7:45 pm #15968320

johnP-55

I found another solution, I go into the product editing, set the translation language to none, save and re-enter the translation language in order to connect the product to the 2 languages ​​and then the video works normally in both languages, the only problem is that I have to do this process on all the products one by one. do you think there is any solution to be done en masse?

July 17, 2024 at 8:05 pm #15968351

johnP-55

I tried the code you sent me in the php functions of the theme and it works, the only problem now is that I will have to add the video in the second language, English, that is, in which the products were originally made. Is there any way to add the video to the Greek language, which is currently the main language? or do you have any way to convert the products to have Greek and not English as their main language?

July 18, 2024 at 8:06 am #15970728

Andrey
Supporter

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

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

The solution I provided earlier means you don't have to convert your products for the video feature of your theme to work. You need to add the video to your product's default language, which should be English if the product was created in English. This is the expected behavior.

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