public function onBeforeSendMailContent{$group}{$type}( string &$content, mixed $data ) : bool

Fires while fetching the body to include within the notification e-mails.


Description

Plugins can use this filter to manipulate at runtime the body of the e-mail notifications.

The dynamic portion of the hook name, $group, refers to the section of the plugin sending the e-mail.
Here's a list of supported groups:

  • restaurant
  • takeaway

The dynamic portion of the hook name, $type, refers to the type of event that triggered the e-mail sending.
Here's a list of supported types:

  • customer (restaurant & take-away)
  • admin (restaurant & take-away)
  • cancellation (restaurant & take-away)
  • review (take-away only)
  • stock (take-away only)

This means that, for example, the notification e-mail sent to the administrator, for a take-away order, will trigger a filter called onBeforeSendMailContentTakeawayAdmin.


Parameters

&$content

(string)  The current content of the e-mail. Since the argument is passed as reference, it is possible to manipulate it.

$data

(mixed)  The entity to notify. In case of a take-away order, the argument will be a VREOrderTakeaway object.

The hook might specify additional arguments, which can vary according to the current type.

Return Value

Boolean. Use false to prevent the e-mail sending.


Example

The example below appends a footer at the end of the e-mail. The footer is added only to the notification e-mail sent to the customers for take-away orders.

/**
 * Triggers a filter to let the plugins be able to handle the content of the e-mail.
 *
 * @param   string  &$content  The current e-mail content.
 * @param   object  $order     The take-away order details.
 *
 * @return  bool    False to prevent the e-mail sending.
 */
public function onBeforeSendMailContent(&$content, $order)
{
    $content .= '<div style="background: #f6f6f6; color: #666; width: 100%; padding: 10px 0; table-layout: fixed; font-family: sans-serif;">';
    $content .= '<div style="max-width: 600px; margin: auto;">';
    $content .= '<p style="text-align: center; font-size: smaller;">VikWP - © 2020</p>';
    $content .= '</div>';
    $content .= '</div>';

    return true;
}

Changelog

Version Description
1.8 Introduced.
Last Update: 2023-12-29 14:15
Helpful?