I’ve written a little script to sync the stock between the languages, maybe you could adapt something like that
simple products:
function abBulkStockSimpleProducts($id) {
global $sitepress;
$languageIDs = array();
$active_languages = apply_filters( 'wpml_active_languages', false );
foreach($active_languages as $code => $data) :
if($code != 'de') :
$languageIDs[] = icl_object_id($id,'product',false,$code);
endif;
endforeach;
$new_quantity = get_post_meta($id, '_stock', true);
if (is_numeric($new_quantity)) :
$new_stock_status = ($new_quantity > 0) ? "instock" : "outofstock";
wc_update_product_stock_status($id, $new_stock_status);
if(count($languageIDs) > 0) :
foreach($languageIDs as $langProd) :
update_post_meta($langProd, '_stock', $new_quantity);
wc_update_product_stock_status($langProd, $new_stock_status);
endforeach;
endif;
endif;
}
Variation Products:
function abBulkStockAfterProcessQtyActionVariables($id){
global $sitepress;
if(ICL_LANGUAGE_CODE != 'de') :
$germanID = get_post_meta($id, '_wcml_duplicate_of_variation', true);
else :
$germanID = $id;
endif;
$new_quantity = get_post_meta($germanID, '_stock', true);
if (is_numeric($new_quantity)) :
$new_stock_status = ($new_quantity > 0) ? "instock" : "outofstock";
wc_update_product_stock_status($germanID, $new_stock_status);
/* Use the TRID to find the translated Product ids */
$trid = $sitepress->get_element_trid($germanID, 'post_product');
if (is_numeric($trid)) :
$translations = $sitepress->get_element_translations($trid, 'post_product');
if (is_array($translations)) :
/* Loop through each existing translation */
foreach($translations as $translation) :
if (!isset($translation->element_id) || $translation->element_id == $germanID) :
continue;
endif;
/* set the stock status and quantity in the translated by updating the post-meta info */
update_post_meta($translation->element_id, '_stock', $new_quantity);
wc_update_product_stock_status($translation->element_id, $new_stock_status);
endforeach;
endif;
endif;
endif;
}