Skip Navigation

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

Problem:
You are trying to configure WooCommerce PDF Invoices to generate invoices in different languages using WPML, but you can't save the settings for each language. The PDF always generates information in English, and the button cannot be translated because the page settings are not saved.
Solution:
Firstly, it's important to note that the WooCommerce PDF Invoices plugin by Andrew Benbow is not officially compatible with WPML. We recommend using a compatible plugin like WooCommerce PDF Invoices and Packing Slips Professional.
However, as a workaround, you can try the following steps:
1. Open

.../wp-content/plugins/woocommerce-pdf-invoice/classes/class-pdf-send-pdf-class.php

2. Look for line 183 and replace:

// Get the WooCommerce order_id<br />$order_id = $order->get_id();

with:

// Get the WooCommerce order_id<br />$order_id = $order->get_id();<br /><br />// WPML workaround for compsupp-7811<br />$order_lang = $order->get_meta('wpml_language', true);<br />$settings['pdf_termsid'] = apply_filters('wpml_object_id', $settings['pdf_termsid'], 'page', TRUE, $order_lang);

This code should help translate the page_ID based on the order language.

If this solution does not resolve your issue or seems outdated, please check the related known issues and ensure you have the latest versions of themes and plugins installed. If necessary, do not hesitate to open a new support ticket at WPML support forum for further assistance.

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 0 replies, has 1 voice.

Last updated by Dražen 1 week, 1 day ago.

Assisted by: Dražen.

Author Posts
January 10, 2025 at 9:33 am

bogdan-alexandruB-2

Background of the issue:
I am trying to configure WooCommerce PDF Invoices on my site hidden link to generate invoices in different languages using WPML. I am following the documentation at https://woocommerce.com/document/woocommerce-pdf-invoice-setup-and-customization/.

Symptoms:
I can't save the settings for each language so that the PDF generates information in different languages. The English page is always used in the PDF, and the button cannot be translated because the page settings are not saved, only one language is saved.

Questions:
Why can't I save the settings for each language in WooCommerce PDF Invoices?
How can I ensure that the PDF generates information in different languages using WPML?
Why is the English page always used in the PDF despite different language settings?
How can I translate the button if the page settings are not saved?

January 10, 2025 at 10:23 am
January 15, 2025 at 9:49 am #16596432

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for the patience and sorry for the long wait.

I have checked and was able to reproduce this issue on a clean test site, it seems to be a compatibility bug with WPML and WooCommerce PDF Invoices by Andrew Benbow plugin.

Please note this plugin is not officially compatible with WPML nor was tested by us, we will try to help but in the end, it might need author collaboration to continue further and them joining our GoGLobal compatibility program. https://wpml.org/documentation/support/go-global-program/

I would advise using compatible plugins like: https://wpml.org/plugin/woocommerce-pdf-invoices-and-packing-slips-professional/

I will escalate this to the compatibility team and update you when I have some feedback.

Regards,
Drazen

January 21, 2025 at 7:26 am #16616472

Dražen
Supporter

Languages: English (English )

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

Hello,

please try next:

Workaround
Open .../wp-content/plugins/woocommerce-pdf-invoice/classes/class-pdf-send-pdf-class.php

Look for line 183

Replace:

// Get the WooCommerce order_id
$order_id   	= $order->get_id();

With:

// Get the WooCommerce order_id
$order_id   	= $order->get_id();

// WPML workaround for compsupp-7811
$order_lang = $order->get_meta( 'wpml_language', true );
$settings['pdf_termsid'] = apply_filters( 'wpml_object_id', $settings['pdf_termsid'], 'page', TRUE, $order_lang );

That should translate the page_ID in the order language.

Regards,
Drazen