Page 1 of 5

Separate mails for shop owner and customer - no bcc

Posted: 28 Feb 2020, 11:03
by boettner
Hi,

is it easily possible to split email notification of new orders (payment received) and to send emails with different content to customer and the shop owner? Using BCC the owner and the customer would receive the same mail.

I know that I have to split the email jobs and configure different template paths there but how can I set a fixed "TO:" mail address that receives the owner mails? Is it possible without writing decorator or extending the existing Aimeos\Controller\Jobs\Order\Email\Payment?

Best
Robert.

Re: Separate mails for shop owner and customer - no bcc

Posted: 28 Feb 2020, 13:48
by boettner
One followup question:
When doing it by extending/decorating how would one possibly handle mail sent/not sent status best if emails get sent by two jobs in parallel?

Re: Separate mails for shop owner and customer - no bcc

Posted: 28 Feb 2020, 13:58
by aimeos
You should write an "Email" decorator for the service providers that sends an e-mail to the configured address:
https://github.com/aimeos/aimeos-core/t ... /Decorator

Then, these e-mails are sent when the job controllers for delivery and/or payment status updates (aka confirmation e-mails) are executed. We would love to get a contribution for this feature from you :-)

Re: Separate mails for shop owner and customer - no bcc

Posted: 28 Feb 2020, 14:17
by boettner
Ah, that´s a new track that should make my second question unnecessary. Thanks! Building upon the existing providers should be no problem. What I don´t understand yet is how is this new provider going to be called?

Merging back should be no problem. Do I have to consider anything special since we are still on 18.10?

Re: Separate mails for shop owner and customer - no bcc

Posted: 28 Feb 2020, 14:35
by aimeos
It's a decorator and it's stacked upon the configured provider in the service panel of the admin interface. You should decorate the processBatch() method and send an e-mail if it's called (done when the order/service/delivery job is run by the cronjob).

2018.10 doesn't use return type hints compared to dev-master.

Please remind yourself, that LTS support for 2018.10 has run out and if you want to continue using that version securely, you need ELTS support from the Aimeos company:

https://aimeos.com/support#c427

Re: Separate mails for shop owner and customer - no bcc

Posted: 20 Mar 2020, 15:44
by boettner
I could continue my work on the Decorator today. Setting it up like suggested, stacking the new Email Decorator upon the existing ones like for example on the payment "PrePay,Email", the Decorator gets executed in the address step during checkout. It is configured nowhere else. I would like to set it up that it´s executed after the payment has been authorized which occurs automatically in this setup since we only offer paying by invoice, meaning at the very end of the checkout process. Like it´s done with the regular email notifications.

And another question in advance on this topic: how can use the existing email templates for my custom notification?

A nice and weekend to everyone. Stay healthy!

Robert.

Re: Separate mails for shop owner and customer - no bcc

Posted: 22 Mar 2020, 10:53
by aimeos
Stack your decorator on top of the delivery service provider, not the payment service provider.

For using templates, you can have a look at the XML deliver service provider as reference:
https://github.com/aimeos/aimeos-core/b ... ry/Xml.php
You can simplify configuration because you probably don't need configurable templates.

Re: Separate mails for shop owner and customer - no bcc

Posted: 23 Mar 2020, 10:30
by boettner
Thanks for the suggestions.

What do I have to ensure when stacking it on top of the delivery providers regarding isAvailable()? True returns all delivery options as valid, false none. Both won´t work.

That´s the current stack: Manual,Weight,Country,Email

Re: Separate mails for shop owner and customer - no bcc

Posted: 24 Mar 2020, 11:46
by aimeos
Decorators are stacked from left to right, so the right-most is on top.
If you don't overwrite the isAvailable() method, the result from the next decorator is passed back:
https://github.com/aimeos/aimeos-core/b ... e.php#L140

Re: Separate mails for shop owner and customer - no bcc

Posted: 15 Apr 2020, 12:36
by boettner
Hi and thanks again.

Ok, I thought isAvailable() was mandatory.

But I still don´t see how the Decorator mechanism will achieve the desired behavior: sending the separate mail upon basket completion, after payment execution. Delivery service decorators will be executed prior to completion. Or where/how do I have to implement my methods for actually sending the mail?

Sorry for asking that much.