Resolved
Reported for: WooCommerce Multilingual & Multicurrency 5.3.2
Overview of the issue
If you have a variable product in WooCommerce, and it goes out of stock with an order made in the second language, the stock is not updated in the other languages. Therefore, it will appear as “out of stock” in the language where the order was made, and available in all other languages.
Workaround
- Create a backup of your site
- Open the file wp-content/plugins/woocommerce-multilingual/inc/translation-editor/class-wcml-synchronize-product-data.php
- Replace
public function sync_stock_status_for_translations( $product_id, $status ) { if ( $this->woocommerce_wpml->products->is_original_product( $product_id ) ) { $translations = $this->post_translations->get_element_translations( $product_id, false, true ); foreach ( $translations as $translation ) { $this->woocommerce_wpml->products->update_stock_status( $translation, $status ); $this->wc_taxonomies_recount_after_stock_change( $translation ); } } }
with:
public function sync_stock_status_for_translations( $product_id, $status ) { // if ( $this->woocommerce_wpml->products->is_original_product( $product_id ) ) { $translations = $this->post_translations->get_element_translations( $product_id, false, false ); foreach ( $translations as $translation ) { $this->woocommerce_wpml->products->update_stock_status( $translation, $status ); $this->wc_taxonomies_recount_after_stock_change( $translation ); } } // }
Hello,
Our website is in English (first language), French and German. We noticed that since quite some time products are not updated when ordered in either French or German. This had lead to many products being out of stock but still appearing available. People order the product we do not have in stock and obviously this causes many issues for us.
I have pasted above code but it seems it only works for variable products. Do you have a similar fix for regular products as well? At the moment we have to manually update our stock when a product is ordered in French or German. This is not workable for us.
Thank you in advance.
Hello there,
I slightly modified the code as there were a few errors on it. Could you try it again?
If the problem persists, could you open a chat in our assistance channel?
We have the required tools to help you there.
Regards
I’ve tried the previous code but it didn’t work with me
Hello Alshaimaa,
If this workaround doesn’t help, please start a chat in our assistance channel, we will analyse your case.
Regards
Is there a update on this?
I seem to be having the same issues with wrong stock on the translated page.
But i dont want to try a “work around” that has been in the works for 8 months by now…
Hello Aaron,
We haven’t released a fix for this issue yet.
We will keep this page updated.
We have exactly the same problem. Woodmart theme (We use Layout Builder https://xtemos.com/docs-topic/woodmart-woocommerce-layout-builder/)
In the main language, variations are displayed with a choice of options, but on the translated page we see only: This product is currently out of stock and unavailable.
Edits in the file //class-wcml-synchronize-product-data.php// did not help to solve this problem
Woo Version 9.2.2
WP Current version: 6.6.1
WPML Multilingual CMS Version 4.6.13
WooCommerce Multilingual & Multicurrency Version 5.3.7
If the workaround here provided doesn’t help, please start a chat in our assistance channel, one of our specialists will investigate your case.