I use the EVENT_BEFORE_SEND_MAIL event (in Craft Commerce) to check if an order meets certain conditions. If true, the attachment that Commerce adds to the email should be removed. Is there a way to do this?

This is my code so far:

  function(MailEvent $event) {
    $order = $event->order;
    $message = $event->craftEmail;
    $email = $event->commerceEmail;

    // Is this the shop, and the confirmation email?
    if ($order->orderSite->handle == 'shop' && $email->id == 1) {
      // This is where the attachment should be removed

Your Answer

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

Browse other questions tagged or ask your own question.