-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjetserver_OrderNotesToTicket.php
More file actions
69 lines (56 loc) · 2.22 KB
/
Copy pathjetserver_OrderNotesToTicket.php
File metadata and controls
69 lines (56 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
*
* Order Notes To Ticket
* Created By Idan Ben-Ezra
*
* Copyrights @ Jetserver Web Hosting
* www.jetserver.net
*
* Hook version 1.0.1
*
**/
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use Illuminate\Database\Capsule\Manager as Capsule;
/*********************
Order Notes To Ticket Settings
*********************/
function jetserverOrderNotesToTicket_settings()
{
global $_LANG, $CONFIG;
$output['apiuser'] = ''; // one of the admins username
$output['ticket_subject'] = 'Notes for the order number %1$s'; // the ticket subject with the order number * use the $_LANG var to use system language file
$output['ticket_pre_message'] = '*** This is an automated message generated by our clients system ***'; // the ticket start of the message * use the $_LANG var to use system language file
$output['ticket_priority'] = 'Low'; // the ticket priority (Low, Medium or High) * default priority is Low
$output['ticket_department'] = ''; // the department id you want to open the ticket to.
$output['stop_email_to_client'] = false; // mark false if you want to send email notification to the client
return $output;
}
/********************/
function jetserverOrderNotesToTicket_openTicket($vars)
{
global $CONFIG;
if($vars['OrderID'])
{
$settings = jetserverOrderNotesToTicket_settings();
$order_details = Capsule::table('tblorders')
->where('id', '=', $vars['OrderID'])
->get();
if(isset($order_details[0]) && trim($order_details[0]->notes) != '')
{
$api_settings = array(
'clientid' => $order_details[0]->userid,
'noemail' => $settings['stop_email_to_client'],
'deptid' => $settings['ticket_department'],
'subject' => sprintf($settings['ticket_subject'], $vars['OrderNumber']),
'message' => ($settings['ticket_pre_message'] ? $settings['ticket_pre_message'] . "\n\n" : '') . $order_details[0]->notes,
'priority' => in_array($settings['ticket_priority'], array('Low','Medium','High')) ? $settings['ticket_priority'] : 'Low',
);
$result = localApi('openTicket', $api_settings, $settings['apiuser']);
logModuleCall("Order Notes To Ticket", "Open Ticket", $api_settings, $result);
}
}
}
add_hook("AfterShoppingCartCheckout", 0, "jetserverOrderNotesToTicket_openTicket");
?>