2

On a website I will be setting up there will be different ranges/types of products. Basically purchased from different departments within the organisation.

I can filter the products in different ways - either by a category or product type of whatever. But is there any way to change where the confirmation email goes to. E.g. All confirmation emails go to finance@domain.com

But if a item is purchased from Category A/Product Type A the confirmation email also goes to deptA@domain.com

An item purchased from Category B/Product Type B - the confirmation email goes to deptB@domain.com

Is this functionality easily achievable or will some sort of plugin be required?

0

Should be pretty doable with a small plugin.

You'd want to listen to something like the onOrderComplete event, then loop through the line items making note of which product types the line items belong to, adding email address to an array to send to.

Then at the end, you can loop through your email address sending the appropriate emails out to each of the users.

  • There's also the craft\commerce\services\Email::EVENT_BEFORE_SEND_MAIL event, which provides an order and email parameters—you could listen to this and manipulate the Email object's recipients. This way, you wouldn't need to re-invent any template rendering (assuming the same email content is still useful). – August Miller May 6 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.