Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

Variable product stock status isn't updated when it gets out of stock in the second language.

Solution:

The issue has been reported to our developers. In the meantime, you can check this workaround: https://wpml.org/forums/topic/stock-status-doesnt-change-when-order-placed-on-2nd-language/#post-12896941.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 0.66 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by thomasK-90 1 year, 2 months ago.

Assisted by: Ahmed Mohammed.

Author Posts
January 19, 2023 at 4:00 pm #12852795

thomasK-90

When order is placed on 2nd language and the item become out of stock, it doesn't reflect on the main language. So on the frontend is also 2nd language shows SOLD OUT but the main language not, as in the images.

I tried deactivating all plugins except Woocommerce and WPML plugins, but the issue was still there.

maiami-JP.PNG
maiami-en.PNG
January 20, 2023 at 1:25 pm #12859667

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+03:00)

Hi there,

Thank you for contacting WPML support!

I understand that when a product is sold on your website in the second language, the stock is not updated for the product in the original language. Did I get that right?

If that's the case, please go to the product in the original language by navigating to your WordPress dashboard → Products → and edit the product → Check the Inventory tab. Does it say 1 or 0? This will confirm if the issue is with the stock value or if it is an issue that's only visible on the front end.

If the stock value is not 0 - please send a screenshot of the received order. Please make sure to include the Order Notes section. Similar to the attached one.

Looking forward to hearing back from you.

order-screenshot.png
January 20, 2023 at 1:30 pm #12859707

thomasK-90

The stock value says 0 in the original language. But it shows in stock as in the screenshot.

maiami-jp-backend.PNG
January 20, 2023 at 4:04 pm #12861023

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+03:00)

Hi there,

Thank you for checking that.

So, the stock inside the product data is showing 0, but it is showing "In Stock" on the Products List page.

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to have a testing site where the issue is replicated.

You will find the needed fields below the comment area when you log in to leave your next reply. The information you will enter is private, meaning only you and I can see and access it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved, I will delete the local site. Let me know if this is ok with you.

IMPORTANT

- Please backup site files and database before providing us access.
- If you do not see the wp-admin/FTP fields, your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Looking forward to hearing back from you.

January 23, 2023 at 11:39 am #12872155

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+03:00)

Hi there,

Thank you for providing the login credentials. We're looking into this and will get back to you as soon as possible.

In the meantime, please let us know if you have any further questions. We're always happy to help!

January 25, 2023 at 10:34 am #12888291

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+03:00)

Hi there,

I appreciate your patience while I was looking into this.

I escalated the ticket to the 2nd tier support as I was able to reproduce the issue even after editing the stock status and placing a test order again.

I'll keep you posted whenever I have more information 🙂

In the meantime, please let us know if you have any further questions. We're always happy to help!

January 26, 2023 at 11:25 am #12896941

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+03:00)

Hi there,

Thank you for being so patient while we were working on this.

The issue has been escalated to our development team for a permanent fix. In the meantime, you can use the following workaround to prevent the issue from happening again:

Go to: wp-content/plugins/woocommerce-multilingual/inc/translation-editor/class-wcml-synchronize-product-data.php:

Find the following function:

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 );
			}
		}
	}

and replace it 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 );
			}
		}
//	}

That will prevent the issue from happening in the future. For the current product, you can go to the product edit page and just hit the update button. The stock status will be changed to out of stock.

Hope that helps, and let us know if you have any other questions. We would be happy to assist further.

January 30, 2023 at 8:41 am #12919169

thomasK-90

For now, this workaround seems to work. Thank you so much!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.