- Status
- Resolved
- Reported for
- WPML Multilingual & Multicurrency for WooCommerce 5.3.2
- Topic tags
- WCML
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 ); } } // }