Skip Navigation

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

Problem:
You are using YayMail Commerce with the YayMail Conditional Logic addon. While it works correctly in English, the addon does not display product categories in Italian, preventing the conditional logic from triggering. This issue occurs when you switch to Italian to style the mail; the categories listed in the conditional logic remain in English. Additionally, when setting the conditional logic to Product instead of Category, products related to one category are listed twice, indicating that Conditional Logic sees both the English and Italian product versions.
Solution:
We recommend trying the following workaround:
In your WordPress installation, navigate to

/wp-content/plugins/yaymail-pro/includes/Page/Settings.php

. At line 415, right before the code block:

$product_categories = get_terms(
	array(
		'taxonomy'   => 'product_cat',
		'orderby'    => $orderby,
		'order'      => $order_category,
		'hide_empty' => $hide_empty,
	)
);

Add the following code:

// WPML Workaround for compsupp-7838
if (class_exists('Sitepress')) {
	do_action('wpml_switch_language', $active_language);
}

This code snippet ensures that the language context switches to the active language, potentially resolving the issue with category and product translations.

Please note that the free version of YayMail is not compatible with WPML. If this solution does not resolve your issue or seems outdated, 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 the problem persists, please open a new support ticket.

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.

Tagged: 

This topic contains 6 replies, has 0 voices.

Last updated by Dražen 1 week ago.

Assisted by: Dražen.

Author Posts
January 31, 2025 at 10:44 pm #16657378

elenaP-6

Background of the issue:
I am using YayMail Commerce, and it works correctly in both English and Italian. I installed YayMail Conditional Logic to show a specific text in the completed order mail. It works correctly in English, but in Italian, the addon doesn't propose the product categories in the Italian language, so the conditional logic is not triggered. I checked with Products instead of Product Category. For one group of products under a certain category (I work with 3 categories), I can see, in the Italian interface of the Conditional Logic plugin, both products in English and Italian, but not for the products of the other categories. I attach here the debug information.
The strange thing is that it does work with a test email (by clicking on "send test email" in YayMail)

Symptoms:
YayMail Conditional Logic doesn't show product categories in the translated Italian language, preventing the conditional logic from being triggered.

Questions:
How can I solve the issue with product categories not appearing in the Italian language in YayMail Conditional Logic?

February 3, 2025 at 7:55 am #16661238

Dražen
Supporter

Languages: English (English )

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

Hello,

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

You can access the WordPress dashboard using the link below:

- hidden link

Try to replicate the issue with a simple example page / product.
Share full steps of what you did with me.

This will help us to report the probable issue to the compatibility team and solve the possible problem faster.

Please note: The free version of YayMail is not compatible with WPML.

Regards,

Drazen

February 3, 2025 at 9:13 am #16661688

elenaP-6

Hi Drazen, thank you very much. I created three products in your sandbox with 3 different categories. YayMAil is set for the "Completed order" option.
The main problem is that when I switch to Italian to style the mail, the categories listed in the conditional logic are still English category (see image 1 attached). So if I make a order in the Italian version, the text is not triggered as Yay doesn't find in the order the English category, but the Italian one. I was not able to test it completely as the sandbox doesn't send emails (at least I didn't receive anything when trying a purchase).

On my website I tried to switch to Product, instead of Category, when setting the conditional logic. A even stranger thing happens: the products related to one category are listed two times, suggesting that Conditional Logic sees both the English and Italian product. The products related to other categories do not (see images attached 2 to 4)

4-real website.png
3-real website.png
2-real website.png
1-sandbox-website.png
February 3, 2025 at 10:09 am #16662151

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for taking the time.

I have confirmed and escalated the issue with categories to our compatibility team. They will check and advise further, note it may take a day or two.

I will update you when I have some news.

Regards,
Drazne

February 5, 2025 at 7:08 am #16669085

Dražen
Supporter

Languages: English (English )

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

Hello,

please try next workaround:

In /wp-content/plugins/yaymail-pro/includes/Page/Settings.php

Line 415, right before:

$product_categories = get_terms(
				array(
					'taxonomy'   => 'product_cat',
					'orderby'    => $orderby,
					'order'      => $order_category,
					'hide_empty' => $hide_empty,
				)
			);

Add:

			// WPML Workaround for compsupp-7838	
			if ( class_exists('Sitepress') ) { 
				do_action( 'wpml_switch_language', $active_language );
			}

Regards,
Drazen

February 5, 2025 at 8:40 am #16669412

elenaP-6

Thank you very much. Now it works perfectly. However a question. Isn't a way to add the snippet to the file functions.php of my child theme? Otherwise, everytime I update the plugin I have to rewrite the Settings.php file

February 5, 2025 at 10:07 am #16670030

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for the feedback.

That is expected, it is a workaround, and we will update YayMail and you can also share this with the plugin author, so they can apply a permanent fix in the next versions.

Regards,
Drazen