coreshop / CoreShop

CoreShop - Pimcore enhanced eCommerce
http://www.coreshop.org
Other
275 stars 157 forks source link

Allow notification mails which are not send to the customer #482

Closed Cruiser13 closed 6 years ago

Cruiser13 commented 6 years ago
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no

It should be possible to send notification mails to email adresses other than the customer. If you want to inform the shop owner that a new order has been placed, it'll also always send this mail to the customer who placed the order.

solverat commented 6 years ago

we also ran into a situation like this. We used the default Pimcore Mail Events to do this:

Workaround

<?php

class MailAttachmentListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [ MailEvents::PRE_SEND => 'doSomething' ];
    }

    public function doSomething(MailEvent $event)
    {
        $mail = $event->getMail();
        $order = $mail->getParam('object');

        if (!$order instanceof OrderInterface) {
            return;
        }

        if ($mail->getDocument()->getKey() !== 'order-confirmation') {
            return;
        }

        // do something.

    }
}

I know, it's not the best solution but currently there is no other way.

CoreShop Enhancement

Maybe we should trigger an CoreShopNotificationEvent in all *MailActionProcess with the current notification entity and the Mail Instance just before the $mail->send().

dpfaffenbauer commented 6 years ago

I though about having a checkbox sendToDesignatedRecipient to solve the issue. Having an event would be a different thing.

dpfaffenbauer commented 6 years ago

For BC Reasons better doNotSendToDesignatedRecipient

solverat commented 6 years ago

And how do change the recipient after you checked that thing? Also: There could be 100 cases when a mail needs additional or different data, like attachments, bcc, reply to etc.

dpfaffenbauer commented 6 years ago

yes, as I said that is a different issue. But currently it is not possible to send a order mail to the administrators without having the mail sent to the customer as well.

dpfaffenbauer commented 6 years ago

done

Cruiser13 commented 6 years ago

Thanks!