This is my problem. I try to insert in _product_attributes meta_value field the names of each language. When I print out my query, I am getting only the products in the right language, so theoretically I should have my update_post_meta _product_attributes only work with the correct language, but this is not the case. I will then do the same thing for the meta_values but I need this to work first. This works sometimes which leaves me even more perplexe. Here is my code for one language (French). Any and all help appreciated.
global $wpdb;
$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'post_status' => 'publish',
'lang' => 'en'
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) :
$query->the_post();
$post_id = get_the_ID();
$sku = get_post_meta($post_id, '_sku');
print("<pre>" . print_r($sku, true) . "</pre>");
$languagechoice = get_post_meta(get_the_ID(), 'language', true);
$sku = get_post_meta(get_the_ID(), '_sku', true);
echo " ".$languagechoice."<br>";
$thedata = Array('references-en' => Array(
'name' => 'References',
'slug' => 'references-en',
'value' => '0',
'is_visible' => '1',
'is_variation' => '1',
'is_taxonomy' => '0'
));
update_post_meta(get_the_ID(), '_product_attributes', $thedata);
endwhile;
endif;
wp_reset_query();