Skip Navigation

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

Problem:
Client reported an issue where webhooks are WC Webhook is not triggered when a new product translated.

Solution:
We have confirmed that this is a known issue and it will be addressed in a future update of WPML. However, this fix will take some time to be released. In the meantime, we recommend the following workaround:
1. Ensure you have a complete backup of your site files and database.
2. Add the following code to your theme's functions.php file:

add_action('wp_insert_post', function($post_ID, $post, $update) {
	if ($update || !in_array($post->post_type, ['product', 'product_variation'])) {
		return;
	}
	$elem_details = apply_filters('wpml_element_language_details', null, [
		'element_id' => $post_ID,
		'element_type' => $post->post_type
	]);
	if (
		(isset($elem_details->source_language_code) && !empty($elem_details->source_language_code)) 
		|| (defined('REST_REQUEST') && REST_REQUEST) // For ATE
	) {
		$product = wc_get_product($post_ID);
		do_action('woocommerce_new_product', $post_ID, $product);
	}
}, 10, 3);

If this solution doesn't seem relevant to your situation, please don't hesitate to 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.

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

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Dražen Duvnjak 2 years, 5 months ago.

Assisted by: Dražen Duvnjak.

Author Posts
November 22, 2021 at 10:08 am #10042351

valterC

Hi, i'm trying to receive the webhook when using woocommerce multilingual, actual behaviour is: no webhook sent when woocommerce multilingual is used for translation,

November 23, 2021 at 7:34 am #10048947

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

as said by my colleagues, I am afraid we do not completely understand what exactly is your question and doubt.

Can you please share more info, on what are you trying to achieve and the steps you take? Please share some examples and if possible images/videos.

Are you trying to use some default WooCommerce Hooks together with WPML or?

Please let me know.

Thanks,
Drazen

November 23, 2021 at 8:44 am #10049391

valterC

I created a webhook from WooCommerce->Settings->Advanced->Webhook
Topic is product created, as seen in the screenshot sent
The webhook works fine when i'm using WooCommerce standard product editor, but if i use WooCommerce multilingual the event is not fired, so i can't receive it on webservice.
Other problem: if standard WooCommerce product editor is used, the event is fired but the lang param is not sent with other data, i can only read it from permalink, so it's not the expected behaviour, but this is the minor problem

November 23, 2021 at 9:23 am #10049665

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for getting back to and explaining the issue. I think I get a better idea of the issue, but to be fair I am not sure if this is expected and will need to check further with our 2nd tier/developers.

In order to proceed, can you please help us out and reproduce the issue on minimal with some simple dummy examples, so we can see issue happening.

I created a minimal installation of WordPress, WPML, and all necessary WPML add-ons.

You can access the WordPress dashboard using the link below:
- hidden link

Kindly follow the steps below:
- Set up WPML plugins and WooCommerce
- Try to replicate the issue with some simple dummy example
- Share with me step by step guide on how can I check the issue

Please let m know how it goes.

Thanks,
Drazen

November 23, 2021 at 2:08 pm #10052395

valterC

I've done the setup, you have just to change-->
Change destination url of webhook (WooCommerce->Settings->Advanced->Webhook->URL field) and set any your ws as endpoint to test

Normal behaviour:
If you add a product via Products section (so the standard one, not wpml) you'll receive the webhook, same if you translate it in the same section, but you recommend to use wpml editor instead of that.
The problem is if you use wooCommerce multilingual editor: you can try to translate there any products and you won't receive the webhook, it's just not being sended

I should now if it can be fixed soon or if i have to send my own webhook, it is necessary for our project, thanks

November 23, 2021 at 2:40 pm #10053069

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for getting back and setting up the test site.

If you add a product via Products section (so the standard one, not wpml) you'll receive the webhook

I am afraid I am not familiar with this part of WooCommerce and in what way should I receive webhook or how should we check the issue, that is why I asked you to share with me step by step guide.

Thus is the case can you please share with us a video of the steps you take to reproduce the issue and issue happening when testing on the sandbox website? You can use a free tool like Loom.

That way we can see and it and would be easier to understand.

Thank you.

Kind regards,
Drazen

November 23, 2021 at 4:10 pm #10053929

valterC

Sorry but could you please set the conversation to someone of the it deparment? they surely know what i'm talking about, the only requirment is to have an endpoint for receiving the webhook, i can send you a video but i already told everything, you have to translate a product from (left panel) WooCommerce->WooCommerce Multilingual->Products and see that no webhook is sent

November 24, 2021 at 6:50 am #10057189

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for getting back.

Please understand we can not proceed to the next step or escalate the issue further without an exact step-by-step guide on how to reproduce the issue or a video where we can see these steps.

Please provide step by step guide or video where we can see all steps, and then I can check further on this with our 2nd tier support.

Thank you for understanding.

Kind regards,
Drazen

November 24, 2021 at 8:23 am #10057561

valterC

What i have to exaplain you? how to publish a webservices somewhere? I already told everything, just show this ticket to someone that is developing your plugins... but anyway i'll repeat again
step by step:
"Change destination url of webhook (WooCommerce->Settings->Advanced->Webhook->URL field) and set any your ws as endpoint to test"
"you have to translate a product from (left panel) WooCommerce->WooCommerce Multilingual->Products and see that no webhook is sent" --> hidden link

In the video i can show you how to translate a product and change the url of the webhook but how i can show you that is not working? You can watch the screen for some minutes and figure out that nothing reachs the endpoint

November 24, 2021 at 8:47 am #10057847

valterC

If you can teel me an email i can publish on our ws the endpoint for testing so you can receive an email when it works, if you do not receive the email the webhook were not fired

November 24, 2021 at 9:28 am #10058201

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello Valter,

thanks for getting back.

Please note I have a workflow that we need to follow and information that needs to be gathered before proceeding to the next step or escalating the issue.

Nevertheless, I have checked WC documentation further on this and could see there are WC Webhook logs where I can monitor when and if the hook is triggered.

In these logs, I can see the hook triggered when the product is created, but not when translated, as you described before.

I will now share this issue and ticket with our 2nd tier support to check and advise further.

I will update you soon.

Thanks,
Drazen

November 24, 2021 at 1:58 pm #10060809

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

I just wanted to let you know that I've escalated this ticket to our developer's team.

They are taking a look at the issue and I will let you know as soon as they have updated.

Please note that this process may take a while.

Thank you for your patience.

Regards,
Drazen

December 7, 2021 at 2:51 pm #10141001

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for your patience. Our developers checked further on this and this will be fixed in one of the future versions of WPML.

Please note this will take time.

In the meantime you can use the next workaround:

- Complete backup of site files and DB
- Add this code to theme functions.php

add_action('wp_insert_post', function($post_ID, $post, $update) {
	if ($update || !in_array($post->post_type, ['product', 'product_variation'])) {
		return;
	}
	$elem_details = apply_filters('wpml_element_language_details', null, [
		'element_id' => $post_ID,
		'element_type' => $post->post_type
	]);
	if (
		(isset($elem_details->source_language_code) && !empty($elem_details->source_language_code)) 
		|| (defined('REST_REQUEST') && REST_REQUEST) // For ATE
	) {
		$product = wc_get_product($post_ID);
		do_action('woocommerce_new_product', $post_ID, $product);
	}
}, 10, 3);

Please check and let us know if this works for you.

Thanks and kind regards,
Drazen

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