PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.15
Booktics – Appointment Booking Calendar for Service Businesses v1.0.15
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / customer / handlers / customer-event-handler.php

customer-event-handler.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.15, at core/customer/handlers/customer-event-handler.php

70 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Customer\Handlers;
4
5 use Booktics\Models\Customer_Model;
6
7 class Customer_Event_Handler {
8
9 /**
10 * Send invitation mail on customer creation
11 *
12 * @param $customer_id
13 *
14 * @return bool
15 */
16 public function on_customer_create( $customer_id ) {
17 $customer = ( new Customer_Model() )->find( $customer_id );
18 $user = get_user_by( 'ID', $customer_id );
19 $reset_key = get_password_reset_key( $user );
20 $reset_url = network_site_url( "wp-login.php?action=rp&key=$reset_key&login=" . rawurlencode( $user->user_login ), 'login' );
21
22 add_filter(
23 'notification_sdk_email_body', array(
24 $this,
25 'wrap_email_body',
26 ), 10, 1
27 );
28 do_action(
29 'global_notification_hook', 'customer_created', array(
30 'customer_first_name' => $customer->first_name,
31 'customer_last_name' => $customer->last_name,
32 'customer_full_name' => $customer->display_name,
33 'customer_phone' => $customer->phone,
34 'customer_user_name' => $customer->user_login,
35 'customer_email' => $customer->user_email,
36 'password_reset_url' => $reset_url,
37 )
38 );
39
40 return true;
41 }
42
43
44 /**
45 * Wrap email body content with template and replace variables
46 *
47 * @param string $message Email body content to be wrapped
48 *
49 * @return string Modified email body content with template applied
50 */
51 public function wrap_email_body( $message ) {
52
53 $template_path = BOOKTICS_DIR . '/templates/email/team-member-create.html';
54
55 if ( ! file_exists( $template_path ) ) {
56 return $message;
57 }
58 $template = file_get_contents( $template_path );
59 $default_image = get_template_directory_uri() . '/assets/images/placeholder.jpg';
60 $variables = array(
61 '{{MESSAGE}}' => wp_kses_post( $message ),
62 '{{COMPANY_NAME}}' => booktics_get_option( 'business_name', 'Booktics' ),
63 '{{COMPANY_LOGO}}' => booktics_get_option( 'business_logo', $default_image ),
64 '{{COMPANY_ADDRESS}}' => booktics_get_option( 'business_address', 'California, USA' ),
65 );
66
67 return str_replace( array_keys( $variables ), array_values( $variables ), $template );
68 }
69 }
70