PluginProbe
Bookit — Booking & Appointment Calendar / 2.6.0.5
Bookit — Booking & Appointment Calendar v2.6.0.5
2.6.0.5 2.6.0.4 2.6.0.3 2.6.0.2 2.6.0.1 2.6.0 trunk 1.2 1.2.2 1.2.3 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 All 62 releases
bookit / includes / helpers / MailTemplateHelper.php

MailTemplateHelper.php in Bookit — Booking & Appointment Calendar 2.6.0.5, at includes/helpers/MailTemplateHelper.php

146 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Bookit\Helpers;
4
5 /**
6 * Bookit Mail Template Helper
7 */
8
9
10 class MailTemplateHelper {
11
12 /**
13 * Default templates data for base settings
14 * @var array[]
15 */
16 protected static $_default_templates = [
17 'appointment_created_customer' => [
18 'enabled' => true,
19 'subject' => 'Your Appointment Request #[appointment_id] successfully sent!',
20 'body' => 'Hi, [customer_name].' . PHP_EOL . 'Your Appointment Request successfully sent!' . PHP_EOL
21 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
22 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
23 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
24 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
25 ],
26 'appointment_created_admin' => [
27 'enabled' => true,
28 'to' => '[admin],[staff]',
29 'subject' => 'New Appointment Request by [customer_name] - #[appointment_id]!',
30 'body' => 'Name: [customer_name]' . PHP_EOL . 'Email: [customer_email]' . PHP_EOL . 'Phone: [customer_phone]' . PHP_EOL
31 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
32 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
33 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
34 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
35 ],
36 'appointment_updated_customer' => [
37 'enabled' => true,
38 'subject' => 'Your Appointment #[appointment_id] has been modified!',
39 'body' => 'Hi, [customer_name].' . PHP_EOL . 'Your Appointment Request successfully modified!' . PHP_EOL
40 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
41 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
42 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
43 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
44 ],
45 'appointment_updated_admin' => [
46 'enabled' => true,
47 'to' => '[admin],[staff]',
48 'subject' => 'Appointment #[appointment_id] modified!',
49 'body' => 'Name: [customer_name]' . PHP_EOL . 'Email: [customer_email]' . PHP_EOL . 'Phone: [customer_phone]' . PHP_EOL
50 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
51 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
52 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
53 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
54 ],
55 'payment_complete_customer' => [
56 'enabled' => true,
57 'subject' => 'Your Payment for Appointment #[appointment_id] received!',
58 'body' => 'Hi, [customer_name].' . PHP_EOL . 'Your Payment from [payment_method] was received!' . PHP_EOL
59 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
60 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
61 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
62 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
63 ],
64 'payment_complete_admin' => [
65 'enabled' => true,
66 'to' => '[admin]',
67 'subject' => 'You received Payment from [customer_name] for Appointment #[appointment_id]!',
68 'body' => 'You received Payment from [payment_method]!' . PHP_EOL
69 . 'Name: [customer_name]' . PHP_EOL . 'Email: [customer_email]' . PHP_EOL . 'Phone: [customer_phone]' . PHP_EOL
70 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
71 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
72 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
73 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
74 ],
75 'appointment_status_changed' => [
76 'enabled' => true,
77 'subject' => 'Your Appointment Request #[appointment_id] [status]!',
78 'body' => 'Hi, [customer_name].' . PHP_EOL . 'Your Appointment #[appointment_id] [status]!' . PHP_EOL
79 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
80 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
81 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
82 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
83 ],
84 'appointment_status_changed_admin' => [
85 'enabled' => true,
86 'to' => '[admin],[staff]',
87 'subject' => 'Your Appointment Request #[appointment_id] [status]!',
88 'body' => 'Name: [customer_name]' . PHP_EOL . 'Email: [customer_email]' . PHP_EOL . 'Phone: [customer_phone]' . PHP_EOL
89 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
90 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
91 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
92 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
93 ],
94 'appointment_deleted_customer' => [
95 'enabled' => true,
96 'subject' => 'Your Appointment #[appointment_id] has been deleted!',
97 'body' => 'Hi, [customer_name].' . PHP_EOL . 'Your Appointment Request was deleted!' . PHP_EOL
98 . 'Reason: [reason]' . PHP_EOL
99 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
100 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
101 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
102 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
103 ],
104 'appointment_deleted_staff' => [
105 'enabled' => true,
106 'subject' => 'Appointment #[appointment_id] deleted!',
107 'body' => 'Name: [customer_name]' . PHP_EOL . 'Email: [customer_email]' . PHP_EOL . 'Phone: [customer_phone]' . PHP_EOL
108 . 'Reason: [reason]' . PHP_EOL
109 . 'Service: [service_title]' . PHP_EOL . 'Staff: [staff_name]' . PHP_EOL . 'Staff phone: [staff_phone]' . PHP_EOL
110 . 'Start time: [start_time]' . PHP_EOL . 'Appointment day: [appointment_day]' . PHP_EOL
111 . 'Payment Method: [payment_method]' . PHP_EOL . 'Payment Status: [payment_status]' . PHP_EOL
112 . 'Total: [total]' . PHP_EOL . 'Status: [status]',
113 ],
114 ];
115
116 /*
117 * Get template by name (key)
118 */
119 public static function getTemplatesByName( string $name){
120
121 if ( ! $name || ! is_array( self::$_default_templates[$name] ) ) {
122 return [];
123 }
124
125 return self::$_default_templates[$name];
126 }
127
128 /*
129 * Get base template list
130 */
131 public static function getTemplates() {
132 return self::$_default_templates;
133 }
134
135
136 /** add email templates to wpml single strings */
137 public static function registerTemplateDataToWPMLStrings() {
138 if ( has_action('wpml_register_single_string') ) {
139 $emailTemplates = get_option_by_path( 'bookit_settings.emails', (object) [] );
140 foreach ( $emailTemplates as $templateTitle => $template ) {
141 do_action('wpml_register_single_string', 'bookit', $templateTitle . '_subject', $template['subject']);
142 do_action('wpml_register_single_string', 'bookit', $templateTitle . '_body', $template['body']);
143 }
144 }
145 }
146 }