Problem/Motivation

I had a requirement, Where we need to use Html text format for the email body.
I am using the beta-1.0 version of commerce email which is compatible with Drupal 8.

So for this, I have created a patch which will convert the text area to text format (ckeditor field) and update config schema to support the value of text format.
Also define the helper function in Commerce Email entity interface.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Dhruv_r_ana created an issue. See original summary.

ayalon’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB

The first patch contains another fix #3314082. I removed it to able to apply both seperate.

Also, the schema was incorrect. I created a cleaned up version. Also supporting the transition of existing text only templates.

rszrama’s picture

Title: Commerce email patch for ckeditor support for Body mail » Add CKEditor support to the email body textarea

Retitling. If we can get WYSIWYG support here, that'd be awesome. I just wonder if we need to ensure the site is configured to send HTML email before supporting anything other than plain text.

rgnyldz’s picture

After this patch I'm getting the below error when an email is sent with commerce_email on a status change for example;

Error: Call to a member function fromArray() on null in Drupal\symfony_mailer\MailManagerReplacement->mail() (line 89 of modules/contrib/symfony_mailer/src/MailManagerReplacement.php).

Drupal\commerce\MailHandler->sendMail() (Line: 88)
Drupal\commerce_email\EmailSender->send() (Line: 180)
Drupal\commerce_email\EventSubscriber\EmailSubscriber->sendEmail() (Line: 139)
Drupal\commerce_email\EventSubscriber\EmailSubscriber->onEvent()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 422)
Drupal\state_machine\Plugin\Field\FieldType\StateItem->dispatchTransitionEvent() (Line: 389)
Drupal\state_machine\Plugin\Field\FieldType\StateItem->postSave()
call_user_func_array() (Line: 233)
Drupal\Core\Field\FieldItemList->delegateMethod() (Line: 198)
Drupal\Core\Field\FieldItemList->postSave()
call_user_func_array() (Line: 938)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod() (Line: 970)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave() (Line: 896)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 56)
Drupal\commerce\CommerceContentEntityStorage->invokeHook() (Line: 81)
Drupal\commerce_order\OrderStorage->invokeHook() (Line: 564)
Drupal\Core\Entity\EntityStorageBase->doPostSave() (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave() (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 159)
Drupal\commerce_order\OrderStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 123)
Drupal\state_machine\Form\StateTransitionConfirmForm->submitForm()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 270)
Drupal\shield\ShieldMiddleware->bypass() (Line: 226)
Drupal\shield\ShieldMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 692)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Using commerce_email v1.1

mayaslatinek’s picture

I've tested the patch from #3 with v8.x-1.1 on Drupal 10.1.2 and can confirm it works well with the Symfony mailer. The formatted text set in the email configs is seen in the email received.

karengrey made their first commit to this issue’s fork.

karengrey’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
Assigned: Unassigned » karengrey

karengrey’s picture

I have updated the patch based on Ryan's suggestion to check if the site is setup for HTML email. I have added a check for symfony_mailer, as this is the suggested module to use for HTML emails (swiftmailer has been unsupported since November 2021)
I have also included all text formats, so the user has a choice.

I saw no other config available to check if a site is setup to use HTML email, as Core MailManager only returns the default `php_mail` interface.

vmarchuk made their first commit to this issue’s fork.

vmarchuk’s picture

@rszrama

I don't really want to stick with modules that support HTML email (symfony_mailer or whatever), but give users the choice to figure this out themselves. Also, we probably need to add a good description for the Body field.

vmarchuk’s picture

Status: Needs review » Fixed

Committed!

dhruvr’s picture

Thank you vmarchuk

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nick_sh’s picture

Can this be the cause of issue with missing BODY field in translations? Only label and subject