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
Change image variations in different languages with Polylang
JUAN MARTINEZ NUÑEZ
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!!