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?

1 Answer 1


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()

    craft()->on('commerce_emails.beforeSendEmail', function($event) {
        $params = $event->params;

        $craftEmail = $params['craftEmail'];
        $commerceEmail = $params['commerceEmail'];
        $order = $params['order'];
        $orderHistory = $params['orderHistory'];

  • 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: craftcommerce.com/docs/events-reference). Thanks again Brad.
    – ijust
    Commented Jun 7, 2017 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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