-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Email subject does not respect user's preferred language in abandoned cart emails #92
Comments
That's very likely correct, as we're just using these values from the plugin settings. I think we can sort that out. |
Thank you! In the meantime, while waiting for an improvement on this, is there a workaround available today to ensure that the subject of the sent email is in the user's preferred language? |
I don't think there's a quick fix for this that's a DIY solution, sorry! |
Wouldn't it be possible to modify the subject on the fly using Example: Event::on(
Carts::class,
Carts::EVENT_BEFORE_MAIL_SEND,
function (BeforeMailSend $event) {
$message = $event->message;
$message->subject = 'Custom translated text from user preferred language';
}
); |
Ah, you know I did forget about that event. You'd be right. I was thinking you could only use the native Craft Thanks for raising that. Haven't tested it specifically, but I believe that should work for now? |
Describe the bug
The email subject line for abandoned cart reminders does not respect the user's preferred language when it is set using a custom field. While I am able to dynamically set the email's content language using the
Carts::EVENT_BEFORE_MAIL_SEND
event, the subject line always defaults to the primary site language.Context:
In my project, users have a custom field
preferredLanguage
, which specifies their preferred communication language. Using the following event listener, I dynamically set the email content to match this preference:While this correctly updates the language for the email content, the subject lines configured in the plugin, such as:
always fall back to the site's default language.
Expected:
The email subject should respect the user's preferred language.
Actual:
The email subject defaults to the site's primary language, regardless of the user's preference.
Additional Notes:
I suspect this behavior is related to how the subject is defined in the
sendMail
function of the plugin. It does not appear to take into account the dynamically setCraft::$app->language
or the$message->language
value.Steps to reproduce
verbb/abandoned-cart
plugin.preferredLanguage
to the User model and set values for different users (e.g., "fr", "en").translations/{language}/site.php
.Carts::EVENT_BEFORE_MAIL_SEND
event to set the email content's language dynamically based on the user'spreferredLanguage
field.Craft CMS version
5.5.10
Plugin version
4.0.4
Multi-site?
Yes
Additional context
No response
The text was updated successfully, but these errors were encountered: