Answers.Body: <p>You don't show what code you're trying to use to access the parameters, but something like this should work from your main plugin class:</p>
  
  <pre><code>public function init()
  {
      parent::init();
  
      craft()-&gt;on('commerce_emails.beforeSendEmail', function($event) {
          $params = $event-&gt;params;
  
          $craftEmail = $params['craftEmail'];
          $commerceEmail = $params['commerceEmail'];
          $order = $params['order'];
          $orderHistory = $params['orderHistory'];
  
          ...
      });
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-07T08:29:01.973Z
Answers.Text: Hi Brad, turns out I was looking at the basic emails event `email.onBeforeSendEmail` and not the one for commerce `commerce_emails.beforeSendEmail` (which by the way is not listed on the events reference page: https://craftcommerce.com/docs/events-reference). Thanks again Brad.
Answers.UserDisplayName: ijust
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-06T17:21:31.923Z
Answers.LastActivityDate: 2017-06-06T17:21:31.923Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to access the <code>order</code> and <code>orderHistory</code> model via <code>onBeforeSendEmail</code> event. I can see that in <code>Commerce_EmailsService.php</code> file on line 311 the event is created with those params and passed to <code>onBeforeSendEmail</code>, but when I try to access them from my plugin, they are not there. I thought they would be available in the <code>variables</code> param, but they are not (or I'm doing something wrong here).</p>
  
  <p>Does anyone know if/how I can access those models from <code>onBeforeSendEmail</code> event?</p>
  
Tags: <plugin-craftcommerce><events>
Title: onBeforeSendEmail event triggered from Commerce_EmailsService
ThreadText: # onBeforeSendEmail event triggered from Commerce_EmailsService
  
  (Asked by: username_0 on 2017-06-06)
  
  I'm trying to access the `order` and `orderHistory` model via `onBeforeSendEmail` event. I can see that in `Commerce_EmailsService.php` file on line 311 the event is created with those params and passed to `onBeforeSendEmail`, but when I try to access them from my plugin, they are not there. I thought they would be available in the `variables` param, but they are not (or I'm doing something wrong here).
  
  Does anyone know if/how I can access those models from `onBeforeSendEmail` event?
  
  **Tags:** plugin-craftcommerce, events
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-06. Score: 2 | Accepted answer
  
  You don't show what code you're trying to use to access the parameters, but something like this should work from your main plugin class:
  
  ```
  public function init()
  {
      parent::init();
  
      craft()->on('commerce_emails.beforeSendEmail', function($event) {
          $params = $event->params;
  
          $craftEmail = $params['craftEmail'];
          $commerceEmail = $params['commerceEmail'];
          $order = $params['order'];
          $orderHistory = $params['orderHistory'];
  
          ...
      });
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Hi username_1, turns out I was looking at the basic emails event `email.onBeforeSendEmail` and not the one for commerce `commerce_emails.beforeSendEmail` (which by the way is not listed on the events reference page: https://craftcommerce.com/docs/events-reference). Thanks again username_1.  
  
  ---
  
  