Calling from code (trigger)

Vestnik1 min readPage 5 of 12

If the event happens in PHP (a payment handler, a plugin, a processor), queue the emails through the service:

$data = [
    'email'    => $order->get('email'),   // recipient for the “Event user” strategy
    'order_id' => $order->get('id'),      // → [[+order_id]] in the template
    'fullname' => $order->get('name'),    // → [[+fullname]]
    'total'    => $order->get('total'),   // → [[+total]]
];

$count = $modx->services->get('Vestnik')->trigger('shop.order.new', $data, 'component');
ParameterDescription
$eventKeyEvent key, required. Must match the “Event key” of an active rule.
$dataTemplate data array; the email key is the address for the “Event user” strategy, attachments — attachments.
$sourcemanual (default) or component; the plugin passes modx. Rules are not filtered by it and it is not logged — it is passed to OnVestnikBeforeQueue and the debug log.

Returns the number of queued emails. Sending happens by cron.