Skip Navigation

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

Problem:
The client is experiencing issues with stock synchronization for imported products in a secondary language using the REST API. The stock status updates from an external system every 15 minutes, but the translations for product variations are not automatically synchronizing when only the "stock_status" is updated.

Solution:
1. We recommend using the bulk options to re-save the products in the original language after the import.
2. Alternatively, triggering the "save_post" hook for the specific product when the stock status changes might help to synchronize the translations.
3. We also suggest checking our hooks documentation for WooCommerce Multilingual at https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/.

Please note that the solution provided might be outdated or not applicable to your case. If the issue persists, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket with us.

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.

This topic contains 5 replies, has 2 voices.

Last updated by Carlos Rojas 1 year, 4 months ago.

Assisted by: Carlos Rojas.

Author Posts
February 12, 2024 at 12:30 pm #15293153

canA-7

Stock sync problem for imported products in the secondary language

February 12, 2024 at 12:36 pm #15293178

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hi there,

I'm sorry for converting the chat into a forum ticket, but it seems there was an issue with your chat and you appeared disconnected on my end.

In this case, I recommend you use the bulk options to re-save the products in the original language after the import.

Regards,
Carlos

February 12, 2024 at 12:49 pm #15293196

canA-7

Hi Carlos,

this is unfortunately not possible as the stock status is imported from another system every 15 minutes. The best way would be, if we could update the translations as soon as the stock status is changed for a product.
Our Setup is:
- Middleware checks for changes in stock in System A
- When change for a product is detected, that product is updated in Woocommerce (We generally only sync "in stock" and "out of stock", no specific numbers, so changes dont happen that often)

Ideally the middleware would just run another hook for that specific product so the translations are updated for it. Would somehow triggering "save_post" work for that purpose?

We have 1k+ products and as I said Updates happen every 15 minutes so manually running bulk updates is not an option.

Kind regards
Samuel

February 12, 2024 at 1:08 pm #15293240

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hi Samuel,
Thank you for your message.

I would suggest you use "save_post" and check the results 🙂

I'd also recommend you to check our hooks in this link: https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/

Regards!

February 12, 2024 at 2:44 pm #15293722

canA-7

I think, I have found the solution:
In woocommerce-multilingual/inc/translation-editor/class-wcml-synchronize-product-data.php we have add_action( 'woocommerce_product_set_stock_status', [ $this, 'sync_stock_status_for_translations' ], 100, 2 );
add_action( 'woocommerce_variation_set_stock_status', [ $this, 'sync_stock_status_for_translations' ], 10, 2 );

So in theory, the translations should automatically synchronize, when the stock status is changed. I just tested. When only updating "stock_status" with REST, the translations dont synchronize.
But when you update "stock_status" and "stock_quantity", the hook seems to be working and the translation is synced.

February 12, 2024 at 5:59 pm #15294399

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Great!

Is there anything else I can help you with?