Marcos Vinicios Barreto
|
Hello,
Thank you for the updates and sorry for the bit of waiting here. Our second level support, provided the following workaround:
IMPORTANT: Please, note, a backup is required for security reasons and to avoid any data loss, you can use the https://wordpress.org/plugins/backupwordpress/ plugin for these backup needs.
1 - Open the functions.php file of your child theme.
2 - Paste the code below and save it:
add_action('wp_head', function(){
if (!isset($_GET['wpml_fix'])) {
return;
}
global $sitepress;
$updates_products = array();
$products = get_posts([
'post_type' => 'product',
'posts_per_page' => -1,
'suppress_filters' => false
]);
foreach ($products as $product) {
$stock_status = get_post_meta($product->ID, '_stock_status', true);
$translations = $sitepress->get_element_translations( $sitepress->get_element_trid( $product->ID, 'post_product' ), 'post_product' );
foreach ($translations as $translation) {
if ( $product->ID != $translation->element_id && $stock_status !== get_post_meta($translation->element_id, '_stock_status', true) ) {
update_post_meta($translation->element_id, '_stock_status', $stock_status);
$updates_products[] = get_the_title($product->ID);
}
}
}
echo "Updated products:-\n\n";
print_r($updates_products);
exit;
});
3 - Now, visit your website url in the primary language and add this suffix (query string) ?wpml_fix for exampe: yourwebsite.com/?wpml_fix then, reload the page.
4 - I applied this same fix for your translated shop page at: hidden link and it seems to be working as it should.
5 - Don't forget to remove the provided custom code above when done.
Please, let me know if it fix the stock issue, when done, we'll proceed with the price issue in a different ticket to keep one topic per issue. Thank you for your collaboration and patience, have a nice day.
|