Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 0 replies, has 0 voices.

Last updated by geertP 2 hours, 35 minutes ago.

Assisted by: Bruno Kos.

Author Posts
January 27, 2025 at 12:58 pm #16637777

geertP

Background of the issue:
I am working on a site at hidden link where we created a custom sync to import and update WooCommerce products using data from an external PIM. The sync works well except when a product variant is only available in a language that is not the main language. We use the wpml_copy_post_to_language hook to translate a product or a product variant and after copying, we update the content to the correct language.

Symptoms:
We encounter a PHP Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, bool given in /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php:319 when updating a variant that exists only in a non-main language.

Stack trace:
#0 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(319): array_filter(false)
#1 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(92): WPML_Element_Translation_Package->add_custom_field_contents(Array, NULL, Array, Array)
#2 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-action-helper.class.php(13): WPML_Element_Translation_Package->create_translation_package(NULL)
#3 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-post-actions.class.php(72): WPML_TM_Action_Helper->create_translation_package(‘5841’)
#4 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/functions-load-tm.php(947): WPML_TM_Post_Actions->save_post_actions(5844, Object(WP_Post), 9)
#5 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(324): wpml_tm_save_post(5844, Object(WP_Post), 9)
#6 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(‘’, Array)
#7 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#8 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(213): do_action(‘wpml_tm_save_po...’, 5844, Object(WP_Post), false)
#9 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-frontend-post-actions.class.php(61): WPML_Post_Translation->after_save_post(‘19003’, Array, ‘nl’, NULL)
#10 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(326): WPML_Frontend_Post_Actions->save_post_actions(5844, Object(WP_Post))
#11 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#12 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#13 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/post.php(5060): do_action(‘save_post’, 5844, Object(WP_Post), true)
#14 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/post.php(5162): wp_insert_post(Array, false, true)
#15 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php(247): wp_update_post(Array)
#16 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(196): WC_Product_Variation_Data_Store_CPT->update(Object(WC_Product_Variation))
#17 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(1469): WC_Data_Store->update(Object(WC_Product_Variation))
#18 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/woocommerce/product-variation.php(44): WC_Product->save()
#19 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/woocommerce/product.php(134): set_product_variation(5843, Array, 5844)
#20 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/xml.php(32): set_wc_product(Array, 5843)
#21 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/sync.php(38): xml_product_sync(‘/data/sites/web...‘)
#22 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/themes/ics/templates/tpl-product-sync.php(13): product_sync()
#23 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/themes/ics/base.php(80): include(‘/data/sites/web...‘)
#24 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/template-loader.php(106): include(‘/data/sites/web...‘)
#25 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-blog-header.php(19): require_once(‘/data/sites/web...‘)
#26 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/index.php(17): require(‘/data/sites/web...’)
#27 {main}
thrown in /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php on line 319

The inriver-sync plugin is our custom sync.
The error happens when we updated a value of the variant (for example the title) en we call the WC Product Variant save-function from woocommerce.
I guess there is a WPML hook that gets triggered when that function is called.
We use the wpml_copy_post_to_language hook to translate a product or a product variant and after we copied the product or variant, we update the content to the correct language.

Questions:
Is it not possible to have different variants in a product in different languages or is there something we do wrong?
Is this just not possible when coding a sync like this?

January 28, 2025 at 9:24 am #16640483

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Thank you for contacting WPML support!

It seems the issue arises due to incomplete or unexpected data when product variants exist only in non-main languages, leading to WPML hooks failing during synchronization.

To investigate further, could you provide us with access to a staging site where such products with errors are present, the code triggering the issue, and database access (e.g., via a plugin like https://wordpress.org/plugins/pexlechris-adminer/?

It would be helpful if you could share steps or a method to reproduce this issue, such as calling the relevant function.

Regards,
Bruno Kos

January 30, 2025 at 12:06 pm #16651256

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

I am checking this with our 2nd tier and will keep you posted.

January 31, 2025 at 8:16 am #16654189

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Based on our initial review, it appears that the issue may be related to how the custom plugin handles translation packages for product variations. To better understand and assist you effectively, could you please provide the following details?

1. Can you share more information about the custom plugin in use? Does it manage variations in any specific way that could interfere with WCML’s automatic handling?
2. If possible, please outline the steps that lead to the issue so we can try to replicate it on our end.
3. If convenient, a visual reference of the issue could help us diagnose the behavior more quickly. You can record a video using tool such as hidden link.

Looking forward to your response.

February 3, 2025 at 10:28 am #16662210

geertP

Below you can find our answers to your questions:

In our custom plugin, we do the following steps
We create or get an existing product (depending on if there already is a product with the SKU)
If a new product, we use the WPML-hook ‘wpml_copy_post_to_language’ to copy the product to the language(s) where it should also be available.
If product already exists, we get the product by SKU in each language an update the content fields
We do the same for each variant as well
You can see all the settings we update for a product variant in ‘wp-content/plugins/inriver-sync/functions/woocommerce/product-variation.php’
Like I mentioned in the previous mail, you can replicate the issue in the sync as followed:
The sync can be triggered manually by going to: hidden link
When the problem occurs, the sync stops on the XML-file where the problem occurs.

The XML-file where the problem occurs will not be moved to the done folder on the mp-server.

If you trigger the sync again, it will try to continue with that file and crash again so you don’t have to move the files during debugging.

There is no visual reference since everything works in the background. The only thing we have is the error log where we get the next error:
[28-Jan-2025 11:53:32 UTC] PHP Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, bool given in /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php:319

Stack trace:

#0 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(319): array_filter(false)

#1 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php(92): WPML_Element_Translation_Package->add_custom_field_contents(Array, NULL, Array, Array)

#2 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-action-helper.class.php(13): WPML_Element_Translation_Package->create_translation_package(NULL)

#3 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/actions/wpml-tm-post-actions.class.php(72): WPML_TM_Action_Helper->create_translation_package('5841')

#4 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/functions-load-tm.php(947): WPML_TM_Post_Actions->save_post_actions(5844, Object(WP_Post), 9)

#5 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(324): wpml_tm_save_post(5844, Object(WP_Post), 9)

#6 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)

#7 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/plugin.php(517): WP_Hook->do_action(Array)

#8 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(213): do_action('wpml_tm_save_po...', 5844, Object(WP_Post), false)

#9 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-frontend-post-actions.class.php(61): WPML_Post_Translation->after_save_post('19003', Array, 'nl', NULL)

#10 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(326): WPML_Frontend_Post_Actions->save_post_actions(5844, Object(WP_Post))

#11 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)

#12 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/plugin.php(517): WP_Hook->do_action(Array)

#13 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/post.php(5060): do_action('save_post', 5844, Object(WP_Post), true)

#14 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/post.php(5162): wp_insert_post(Array, false, true)

#15 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php(247): wp_update_post(Array)

#16 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(196): WC_Product_Variation_Data_Store_CPT->update(Object(WC_Product_Variation))

#17 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(1469): WC_Data_Store->update(Object(WC_Product_Variation))

#18 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/woocommerce/product-variation.php(44): WC_Product->save()

#19 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/woocommerce/product.php(134): set_product_variation(5843, Array, 5844)

#20 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/xml.php(32): set_wc_product(Array, 5843)

#21 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/inriver-sync/functions/sync.php(38): xml_product_sync('/data/sites/web...')

#22 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/themes/ics/templates/tpl-product-sync.php(13): product_sync()

#23 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/themes/ics/base.php(80): include('/data/sites/web...')

#24 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-includes/template-loader.php(106): include('/data/sites/web...')

#25 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-blog-header.php(19): require_once('/data/sites/web...')

#26 /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/index.php(17): require('/data/sites/web...')

#27 {main}

thrown in /data/sites/web/website-in-progressbe/subsites/aquaplan2024.website-in-progress.be/wp-content/plugins/sitepress-multilingual-cms/classes/translation-jobs/class-wpml-element-translation-package.php on line 319

This is the best implementation we could find with the limited documentation for a custom integration. If there is a better way to implement something like this, we would love to hear about it.

February 3, 2025 at 2:15 pm #16663233

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Thank you for additional info.

To troubleshoot this problem, I'll install the Duplicator plugin and generate packages for further debugging purposes. I'll ensure to exclude all media files to maintain a minimal package size. You can find more information about the process here: [link](https://wpml.org/faq/provide-supporters-copy-site/). Please confirm if this approach is acceptable to you.

Our 2nd tier will have to debug this locally to see why it fails.

February 3, 2025 at 2:28 pm #16663339

geertP

This is ok, thanks