Skip Navigation

Open

Reported for: WooCommerce Multilingual & Multicurrency 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 );
    			}
    		}
    //	}
    

8 Responses to “WooCommerce Multilingual - Variable product stock status is not updated when it gets out of stock in the second language”

  1. 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

  2. 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…

  3. 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

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>