fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Change image variations in different languages with Polylang

Hi, Im using woocommerce and Polylang, and I want to have different images of the variations extra gallery in each language.

Im using code in functions.php child theme, so the thumbnail and gallery aren´t syncronazed :

add_filter( ‘pll_copy_post_metas’, function ( $metas ) { unset( $metas[‘_thumbnail_id’] ); unset( $metas[‘_product_image_gallery’] ); return $metas; });

And it works, but not with the extra images of your plugin..

I also tried this:

add_filter(‘woo_variation_gallery_product_images_meta’, ‘disable_additional_gallery_image_sync’, 10, 3); function disable_additional_gallery_image_sync($meta_value, $post_id, $variation_id) { // Verificar si Polylang está activo y estamos en el contexto de una traducción if (function_exists(‘pll_current_language’)) { // Desactivar la sincronización de las imágenes adicionales de la galería return null; } return $meta_value; }

And this:

add_filter(‘pll_copy_post_metas’, ‘disable_image_sync_for_additional_variation_images’, 10, 3); function disable_image_sync_for_additional_variation_images($metas, $sync, $from) { // Campos meta que NO queremos sincronizar $metas_to_exclude = [ ‘_thumbnail_id’, // Imagen destacada del producto ‘_wc_variation_thumbnail_id’, // Imagen de la variación ‘woo_variation_gallery_images’, // Imágenes adicionales de la variación (plugin) ]; // Eliminar los campos de la sincronización foreach ($metas_to_exclude as $meta_key) { if (($key = array_search($meta_key, $metas)) !== false) { unset($metas[$key]); } } return $metas; }

But nothing worked.. Is the hook name: woo_variation_gallery_images

Is there a better way to get wat I nwant?

Thanks!!

Hakik Zaman

Hi JUAN,

Thanks for reaching out to us.

As per your code, you want to unset the Variations Images meta.

You can try the following:

add_filter( ‘pll_copy_post_metas’, function ( $metas ) {
unset( $metas[‘woo_variation_gallery_images’] ); 
return $metas;
});

Thank You

Thanks, but that code makes a critical error and breaks the wp.

Any other ideas?

Thanks

Hakik Zaman

Hi JUAN,

We keep our image id’s inside this woo_variation_gallery_images meta.

You can try other filters of Polylang to unset our meta woo_variation_gallery_images

Thank You