How to make WooCommerce PDF Invoice plugin to work with WPML

WooCommerce PDF Invoice plugin is a good solution if you need to send an invoice to your customers in PDF format, along with the completed or processing order email.

But if you have multi-language web shop then you will face a problem when a customer makes an order using a language which is not like the one you use in the WordPress administration.

Yes, you might think that everything will work without the problems because you have translated the WC PDF Invoice plugin into all languages which are used in you web shop, and the WPML is all ready for customers to choose their language on front-end. But the problem will occur when you will mark the order as completed in you WP administration. Your customer will receive the PDF invoice written in the language which is used in the WP administration.

But the problem will occur when you will mark the order as completed in you WP administration. Your customer will receive the PDF invoice written in the language which is used in the WP administration.

There is a simple trick which can help you to overcome this issue. Because WooCommerce is such a great plugin and has so many useful filters and hooks, we can filter the URL which used for “order complete” button and append query to it.

The query which we will append to the URL is a key lang, with a value en for example. The value represents the language which customer has used while he created the order. This value is saved along with the order by the WPML plugin, as a post meta. To retrieve this value all you need to do is use get_post_meta(); funciton.

A full example of the code can be found here:

Please have in mind that this code will alter URL for “complete order” button only.

About the Author

Freelance WordPress developer who offers full stack web development services. Occasionally writes about business and WordPress development. When not in front of the computer can be found on a bicycle or enjoying good beer.

Leave a Reply 0 comments

Leave a Reply:







SUBSCRIBE TO NEWSLETTER

Subscribe here in order to occasionally receive updates about new posts

x