Commit 80c26629 authored by Robin van Sloten's avatar Robin van Sloten Committed by Jonathan Sacksick
Browse files

Issue #3121168 by Neograph734, longwave, lisastreeter: Include the store name...

Issue #3121168 by Neograph734, longwave, lisastreeter: Include the store name in the email From header.
parent a043aa81
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class OrderReceiptMail implements OrderReceiptMailInterface {

    $params = [
      'id' => 'order_receipt',
      'from' => $order->getStore()->getEmail(),
      'from' => $order->getStore()->getEmailFromHeader(),
      'bcc' => $bcc,
      'order' => $order,
    ];
+2 −2
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ class OrderReceiptMailTest extends OrderKernelTestBase {
    $email = end($emails);
    $this->assertEquals('text/html; charset=UTF-8;', $email['headers']['Content-Type']);
    $this->assertEquals('8Bit', $email['headers']['Content-Transfer-Encoding']);
    $this->assertEquals($this->order->getStore()->getEmail(), $email['from']);
    $this->assertEquals($this->order->getStore()->getEmailFromHeader(), $email['from']);
    $this->assertEquals('customer@example.com', $email['to']);
    $this->assertFalse(isset($email['headers']['Bcc']));
    $this->assertEquals('Order #2017/01 confirmed', $email['subject']);
@@ -130,7 +130,7 @@ class OrderReceiptMailTest extends OrderKernelTestBase {
    $email = end($emails);
    $this->assertEquals('text/html; charset=UTF-8;', $email['headers']['Content-Type']);
    $this->assertEquals('8Bit', $email['headers']['Content-Transfer-Encoding']);
    $this->assertEquals($this->order->getStore()->getEmail(), $email['from']);
    $this->assertEquals($this->order->getStore()->getEmailFromHeader(), $email['from']);
    $this->assertEquals('custom@example.com', $email['to']);
    $this->assertEquals('store@example.com', $email['headers']['Bcc']);
    $this->assertEquals('Order #2017/01 confirmed', $email['subject']);
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ function commerce_store_mail_alter(&$message) {
    $current_store = \Drupal::service('commerce_store.current_store');
    $current_store = $current_store->getStore();
    if ($current_store) {
      $message['from'] = $current_store->getEmail();
      $message['from'] = $current_store->getEmailFromHeader();
    }
  }
}
+7 −0
Original line number Diff line number Diff line
@@ -108,6 +108,13 @@ class Store extends ContentEntityBase implements StoreInterface {
    return $this->get('mail')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getEmailFromHeader() {
    return sprintf('%s <%s>', $this->getName(), $this->getEmail());
  }

  /**
   * {@inheritdoc}
   */
+11 −1
Original line number Diff line number Diff line
@@ -35,10 +35,20 @@ interface StoreInterface extends ContentEntityInterface, EntityOwnerInterface, E
   * Gets the store email.
   *
   * @return string
   *   The store email
   *   The store email.
   */
  public function getEmail();

  /**
   * Gets the store email formatted as email 'From' header.
   *
   * Example: 'My Store <mystore@example.com>'
   *
   * @return string
   *   The store name, with email wrapped in angle brackets.
   */
  public function getEmailFromHeader();

  /**
   * Sets the store email.
   *
Loading