I have found an issue while printing invoice for orders. When I manually print the invoice it always give the product name in English for the first invoice even the complete template is in respective language (order received from the different language store)
If by manual invoice sending you mean you go to WordPress Dashboard and do the sending from there then please consider whatever action is triggered from the WordPress Dashboard takes the dashboard language and not the front end language.
That is how WordPress works.
You can test by going to WordPress Dashboard > Users > Profile changing the profile language of your user to something else sending the invoice and seeing if it sends with that language.
If yes, then you can change the profile language to the language you want when you send the invoices manually.
Also, it is possible to add users with different languages in the dashboard, so you can log in with a user that you want that user language when sending the invoice.
Thankyou for reply!
I understood your point but my concern is that when I'm printing the invoice only the first invoice is printing the product name in English and other invoices are prinitng in correct languages.
Basically we have multiple lanaguages store and the invoice is printed according to user's default language from which the order is received. so when we print the invoice even if the user's lanaguage is swedish then the invoice is printed in Swedish except the Product name. I tried to debug this issue but couldn't find any break-thru.
I am not sure why this might happen. I wonder how can this be a checked and how I can troubleshoot that.
First of all I need to know what plugin we are talking about.
Is it a normal Woocomerce or a thrid party plugin as an addon?
I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
Also give us the steps to be able to check the issue so maybe we can find a solution.
Meanwhile, if it is a normal Woocomemrce one, please do the test below and get back to us with the result:
- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Woocommerce, WPML and WPML add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.
Basically, we have created a custom plugin for printing the invoices where we are printing multiple invoices in different languages altogether. Here the case is that the invoice needs to be printed in the language in which the user has placed the order.
I have mentioned below the code through which I have printed the invoice. Please check
$order_list = [101, 102, 103, 104, 105];
foreach ($order_list as $orderId) {
$order = new WC_Order( $orderId );
foreach( $order->get_items() as $item_id => $item ) {
$itemName = $item->get_name();
}
}
Here the $order_list contains the order IDs, which are in different languages.
We are using `WC_Order` class to get the order details and when I am getting the product name it will always be in English for the first invoice i.e 101 order. even if the 101 order is in any language, it always return the product name in English and second onward it is giving correct product information. Also if we place 101 on second position in that case it is giving in correct language.