qTranslate-Team / woocommerce-qtranslate-x

Enables multilingual framework for plugin "WooCommerce - excelling eCommerce".
GNU General Public License v3.0
11 stars 19 forks source link

Customer completed order email is sent in the wrong language #3

Closed johnclause closed 9 years ago

johnclause commented 9 years ago

Submitted in two places by https://wordpress.org/support/profile/og-s: https://wordpress.org/support/topic/woocommerce-emails-3 https://wordpress.org/support/topic/wrong-email-language

The description copied here:

I'm using the latest version of Github qTranslate-X, WooCommerce & qTranslate-X

The customer processing order email is sent in the correct language. But than, all e-mails sent from the woocommerce admin are sent in the wrong language. The customer completed order email is sent in the wrong language. It seems that the default language is used.

johnclause commented 9 years ago

Is this e-mail sent in the response to admin action? Indeed, then admin language will be used. Interesting, nobody noticed this before. A workaround would be to switch admin panel to the language needed before pressing button to complete order.

Before we go further, could you confirm that this works?

Michel (@mweimerskirch), did you hear about such problem before?

OGSWEB commented 9 years ago

The default language defined in qtranslate is used (not the admin language)

johnclause commented 9 years ago

Anyway, I think this would not be very easy to solve (unless Michel already had this problem and has a solution), since the original language used on order is not saved anywhere with order, as far as I can imagine. We will have to figure out a way where to save it and then to re-use it on further admin emails.

OGSWEB commented 9 years ago

Do you think it can be resolved? Can I implement the solution from Michel ?

johnclause commented 9 years ago

I am sure it can be done, just will take some time. We have to see what Michel says.

mweimerskirch commented 9 years ago

My plugin didn't solve this either. Actually, I've never even thought about it. I'll see if I can find out whether it's possible or not. I think the only way to make it work would be to store the language at the time the order is made, because WooCommerce has an option to order without creating a user account. This way, the correct language would be used wheter or not the customer has a user account or not.

MarioS3 commented 9 years ago

I have a problem with order emails as well:

automatic email for processing order is sent ok and in correct language (the one that was chosen while making order). But all emails after that look like this:

SUBJECT: [:hr]Vaša Web narudžba od 22/03/2015 je dovršena[:en]Your MK LED Auto/Moto rasvjeta order from 22/03/2015 is complete[:]

Also if I add note to order or if it is marked as completed (basically every email after automatic processing email), it will be send in language that is used in admin panel. I tried several times and it's always like that.

Interesting is that if I deactivate qtranslate & woocommerce plugin, emails are fine, subject is ok and based on language that is used in admin panel.

Can you repair those 2 things?

mweimerskirch commented 9 years ago

@MarioS3 your second problem (" it will be send in language that is used in admin panel") should be solved by #4. Please check if it works for you.

mweimerskirch commented 9 years ago

@MarioS3 I added a fix for your first problem to #4 as well. Please test it and let us know if it works for you as well.

johnclause commented 9 years ago

@OGSWEB, @MarioS3: just in case you are not sure, to test it, download the latest integrating plugin from GitHub https://github.com/qTranslate-Team/woocommerce-qtranslate-x, use "Download ZIP" button, or press here for the sake of convenience.

If all goes well for you, we will publish it as next release, version 1.1.

OGSWEB commented 9 years ago

Parse error: syntax error, unexpected T_FUNCTION in ...woocommerce-qtranslate-x/qwc-admin.php on line 558

mweimerskirch commented 9 years ago

I changed the code so it is compatible with PHP 5.3 again. @OGSWEB You should upgrade to 5.4. PHP 5.3 is no longer supported by the PHP developers.

johnclause commented 9 years ago

I did not mean to close it yet, I do not know why it did, but anyway we can write to closed issue and may re-open if it gets big again.

@OGSWEB, @MarioS3: to test it again, deactivate previously tested plugin, delete its files, then do as before: download the latest integrating plugin from GitHub https://github.com/qTranslate-Team/woocommerce-qtranslate-x, use "Download ZIP" button, or press here for the sake of convenience. You will see the same version 1.1 on newly downloaded plugin, but it is updated.

mweimerskirch commented 9 years ago

@johnclause: It closed, because I wrote "Fixes #3" in the pull request.

MarioS3 commented 9 years ago

I deleted last posts, this is summarized one:

This is list of all problems with plugin version 1.1 activated:

When deactivated following problems appear:

[:hr]Osram Cool Blue Hyper 12V - do 50% bjelije (5000K)[:en]Osram Cool Blue Hyper 12V - up to 50% whiter light (5000K)[:]

johnclause commented 9 years ago

Sorry, guys, for the delay. We will take a look into it, hopefully over this weekend.

OGSWEB commented 9 years ago

Hope you can fix it :-)

johnclause commented 9 years ago

Apparently Michel is currently unavailable. I may take a look into it within next couple of days. Sorry for the delay.

mweimerskirch commented 9 years ago

I tried reproducing the issues over the weekend, but I wasn't able to. Tried again just now. Everything works fine for me. Are you using any other WooCommerce-related plugins? If yes, try deactivating them. Also, please try using one of the default WordPress themes. Other themes might override the WooCommerce templates and they might ignore some of the newer filters.

MarioS3 commented 9 years ago

@mweimerskirch There were no problems of this kind with previous version, they started with 1.1 version. I don't have overridden templates or anything that could possibly affect to the list of problems that I stated above. Also it's happening on "stock" COD payment method, I didn't even try custom ones, so that also shouldn't be a problem. I have U-design theme, I think that can't be problem also. Maybe you can check by yourself if you are willing to?

johnclause commented 9 years ago

one of the default WordPress themes

Which one, for example, would you recommend for testing?

I am trying Storefront now and cannot get it working in a meaningful way. Emails are not sent to customer, 'thank you' page is apparently messed up, it is basically empty and error message is shown

Notice: Undefined variable: order in /wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php on line 196

Order is shown in multiple languages in /wp-admin/post.php?post=XX&action=edit, and some fields are raw multilingual fields. If I press 'Save Order', email then goes in admin language. However, I verified that, your filter 'save_post' worked and there is meta value for order language in the database.

That is the story so far.

MarioS3 commented 9 years ago

Same problems like johnclause, looks like I'm not the only one :)

mweimerskirch commented 9 years ago

Hmm, strange. I'll check again today. Maybe I mistakenly tested one of my branches instead of the "master" branch. I'll let you know.

As to the theme: Any theme that does not include WooCommerce files is fine for testing. If there are WooCommerce files in the theme, they might override the original ones.

mweimerskirch commented 9 years ago

I was finally able to reproduce the issues on another test installation. I'm not sure what went wrong, but the issue was with the action I used to store the user language. I used the generic "save_post" action from WordPress and I've now replaced it with a woocommerce-specific filter (which also makes the implementation lighter). That worked for me on both the installations that I tried it on. @OGSWEB and @MarioS3: I'd appreciate if you could test if this works for you as well.

mweimerskirch commented 9 years ago

Hmm... there is still something wrong

johnclause commented 9 years ago

The wrong part for me is apparently custom attributes. They still misbehave for me sometimes and maybe there is more, I have recently tried 'simple' product and it did not work for me either under Storefront theme, which does not override templates, as far as I can see.

Filter 'qwc_filter_postmeta' fixed some of too early translations, but not apparently all. Woocommerce apparently rely on untranslated strings in a few places, and if we translate it too early with 'qtranxf_filter_postmeta', it gets confused. I make this derivation based on the fact that if I turn off -X, all works fine, except that all multilingual strings shown untranslated, but all emails, etc, work just fine. When I turn on -X on the same installation, customer e-mail stops coming, only admin one comes, and thank you page shows error message. There are no other errors in log and anywhere else. Apparently it silently breaks in some place and the rest does not go right during order processing. I did not dig it deeper yet.

mweimerskirch commented 9 years ago

I'm still working on it. Please wait before pulling next time until somebody else has tested it. "Hacking" Woocommerce is quite tricky ;-)

johnclause commented 9 years ago

I saw that one in the code yesterday, and if you did not do it I would make the same change later ;) Having the same thought as you did, makes me feel pretty confident about this change.

Besides, normal users may not know how to test a branch. You would need to give instructions for them how to test it in your comment then.

MarioS3 commented 9 years ago

@mweimerskirch Is new update ready for download and test or are you still working something on it?

mweimerskirch commented 9 years ago

At the moment I'm not working on it. I only did a quick test, but it should work better than the earlier versions. I'll do some more tests later today.

MarioS3 commented 9 years ago

I tested you new release and here is summary:

But there are still some problems (So far that I noticed):

These are now really small problems, not crucial ones :)

mweimerskirch commented 9 years ago

The "your order is complete" mail should be sent in the correct language though. (the one that is sent when you click the "complete" button: image

Other issues:

mweimerskirch commented 9 years ago

I committed another patch that fixes the translation tags displayed in the "note added to your order" mail. It does not yet use the user's language (working on that) but at least it does not show translation tags in the subject anymore.

MarioS3 commented 9 years ago

@mweimerskirch yes all others are these from "resend order emails" :)

mweimerskirch commented 9 years ago

And another one. This one is for the "note added to your order" emails.

I'm not sure yet what to do about the "resend order emails" action. If that is the only thing missing, I'd suggest to create a new issue just for this.

johnclause commented 9 years ago

I committed a few more filters to help with translations from order editor page and things like e-mail footer and 'from name' on re-sent email, which you probably did not yet tried to localize.

At this point, in my testing, everything is fine except e-mails re-sent from order editor page with a press of button "Save Order". E-mail now goes partly in the language of order, and partly in admin language. This problem may be very difficult to solve, because the order editor page and action of sending email are both processed within the same request. By the time of email sending, some strings are already translated into admin language and use of filters 'woocommerce_before_resend_order_emails' and 'woocommerce_after_resend_order_emails' only helps on a part of email. I do not know how to solve this. I am curious, how WPML does it? Does anyone have an experience with it?

With the exception mentioned, are we done here? There is a workaround in the worst case, switch admin to the language of order before sending e-mail. It works, it is inconvenient, but better than nothing.

johnclause commented 9 years ago

Michel, it just occured to me that we may ask Woocommerce to change the way they send e-mails from editor pages. It would not be difficult for them to use ajax calls instead in which we could sent language to be different. I have already asked them for a couple of changes, and they did cooperate. But we would need to prepare a complete solution with a single clean PR to simplify their work. They will be naturally concerned not to break anyone, so we really need to test it all in all the ways before coming to them. Do you think it may work?

MarioS3 commented 9 years ago

There is just one more problem with completed email (after clicking button for completed order):

This are Instructions for COD payment gateway, they were shown in both languages like this:

[:hr]Molimo Vas da proizvode platite gotovinom prilikom preuzimanja paketa. Detalje o narudžbi možete pratiti preko Korisničkih stranica.[:en]Please pay your Order with cash when it is delivered to your address. Details about order can be seen on My Account page.[:]

johnclause commented 9 years ago

It did not reproduce for me, but I noticed that email footer is wrong. Is footer correct for you? @MarioS3: Try new order from scratch again. If instructions are still wrong, that must be on your theme template overrides. To test the theory, remove template overrides and see if it helps. If it does, then you can fix it under a child theme. Woocommerce has instruction on how to override templates. I also assume you use the latest version of everything?

MarioS3 commented 9 years ago

@mweimerskirch I don't have template overrides. I tried again, from new order - automatic email instructions are fine and they look like this:

but when these instructions are displayed in completed order email (or repeated emails from "Order actions", than they are like this:

It's not that big problem - take your time :)

Was there maybe new update after this one? https://github.com/qTranslate-Team/woocommerce-qtranslate-x/issues/3#issuecomment-88622067

johnclause commented 9 years ago

I am sorry, footer is correct, I had it typed in wrong way. So all good for me. @OGSWEB, are you testing it too? Can we release 1.1?

johnclause commented 9 years ago

@MarioS3, yes, I followed your instructions and tested both ways for completed email. It works fine for me, and for COD as well.

I don't have template overrides

I meant, your theme may have it overridden, almost surely. But you can change the overrides through child theme. Please, read Woocommerce instructions. Are you using the latest Woocommerce and WP?

MarioS3 commented 9 years ago

There is one more little thing to look out - this is button when you enter to product attributes :)

image

@johnclause maybe it's because of U-Design, I wouldn't know. Yes, latest Woocommerce and WP.

johnclause commented 9 years ago

@mweimerskirch, do you think we are ready to release 1.1? Do you think we should describe the little issue left with sending admin email from order editor page in an "Known Issue" section? Do you wish to do it, or do you wish me to do it?

mweimerskirch commented 9 years ago

Yes, I think we can release. I'll prepare something for the known issues.

johnclause commented 9 years ago

@MarioS3:

maybe it's because of U-Design, I wouldn't know

I am saying that you can know. Remove overrides temporary to test. Woocommerce instructions on child theme creation explain how it works.

johnclause commented 9 years ago

@mweimerskirch: thanks for the readme, I expanded it a little bit, https://github.com/qTranslate-Team/woocommerce-qtranslate-x#known-issues, and also included the issue with buttons display as @MarioS3 reported. For the latter, I will need to adjust qTranslate-X, may be on 3.3 release, which is coming soon. Anything else I missed?

I would wait for a final feedback from @OGSWEB and @MarioS3, since they are probably the only ones at trouble now with the older version.

johnclause commented 9 years ago

@MarioS3: did you figure it out? What is the status?

johnclause commented 9 years ago

@OGSWEB: Are you still interested?

OGSWEB commented 9 years ago

Yes of course :-) ! Thank you very much !! I was very busy but I will make tests next week