1. 12 december 2019
  2. Tips

WHMCS doesn't send any notification when the status of a ticket changes but let's see how we can tweak this process. The provided action hook fulfill this purpose by automatically sending an email notification to customer via API and by adding a reply to the ticket still via API.

Guide customers through the resolving process letting them track the progress of their support tickets. Read comments to adapt it to your needs.
<?

/**
 * Send Email & Add Reply on Ticket status change
 *
 * @package     WHMCS
 * @copyright   Katamaze
 * @link        https://katamaze.com
 * @author      Davide Mantenuto <[email protected]>
 */

use WHMCS\Database\Capsule;

add_hook('TicketStatusChange', 1, function($vars)
{
    $adminUsername = 'admin'; // The reply will be added by this Admin user. Set false to open the ticket using your own customer
    $userID = Capsule::table('tbltickets')->where('id', $vars['ticketid'])->first(['userid'])->userid;

    // Email notification
    $EmailData = array(
        'id' => $userID,
        'customtype' => 'general',
        'customsubject' => 'Thank you for contacting us',
        'custommessage' => 'Your ticket status has been changed to ' .$vars['status']
    );

    localAPI('SendEmail', $EmailData);

    // Ticket reply
    $TicketData = array(
        'ticketid' => $vars['ticketid'],
        'message' => 'Your ticket status has been changed to ' .$vars['status'],
        'clientid' => $userID,
        'adminusername' => $adminUsername,
    );

    localAPI('AddTicketReply', $TicketData);
});

First seen on whmcs.community - Posted by me

Written by

Davide - Founder, Developer