PluginProbe
Bookit — Booking & Appointment Calendar / 1.2
Bookit — Booking & Appointment Calendar v1.2
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 2.1.5 All 61 releases
bookit / helpers / email.php

email.php in Bookit — Booking & Appointment Calendar 1.2, at helpers/email.php

83 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function stm_bookit_mail_content_type()
4 {
5 return 'text/html';
6 }
7
8 add_action('bookit_appointment_created', 'stm_bookit_appointment_created', 100, 2);
9
10 function stm_bookit_appointment_created($post_id, $data)
11 {
12
13
14 $settings = get_option('bookit_settings');
15 $date_format = get_option('date_format');
16 $time_format = get_option('time_format');
17
18 $service = get_the_title($data['service']['value']); // get service
19 $start_time = stm_booki_date_i18n($time_format, $data['start_day']['value']); // get start day
20 $end_time = stm_booki_date_i18n($time_format, $data['end_day']['value']); // get end day
21 $total = stm_bookit_price_view(get_post_meta($post_id, 'bookit_total', true));
22
23 $token = get_post_meta($post_id, 'bookit_app_token', true);
24 $to = $data['email']['value'];
25 $headers[] = 'Content-Type: text/html; charset=UTF-8';
26
27 $subject = __('Your Appointment created.', 'bookit');
28
29 $body = '';
30
31
32
33 if($data['repeating']['value'] == 'on'){
34 //IF REPEATING
35
36 $arr_week_days = explode(',', $data['repeating_days']['value']); //get repeating week days to array
37 $txt_week = '';
38 //get week days with method
39 foreach($arr_week_days as $item){
40 $txt_week .= stm_booki_date_i18n('l', $item) .' ';
41 }
42
43 $r_start_day = stm_booki_date_i18n($date_format, $data['start_day']['value']); // get repeating start day
44 $r_end_day = stm_booki_date_i18n($date_format, $data['repeating_end_date']['value']); // get repeating end day
45
46 $body .= esc_html__( 'Name', 'bookit' ). ': ' . $data['name']['value']. PHP_EOL .esc_html__( 'Email', 'bookit' ). ": " . $data['email']['value'].PHP_EOL.esc_html__( 'Service', 'bookit' ) .": $service". PHP_EOL .esc_html__( 'Start time', 'bookit' ).": $start_time". PHP_EOL .esc_html__( 'End time', 'bookit' ).": $end_time". PHP_EOL . esc_html__( 'Repeating Start day', 'bookit' ) .": $r_start_day". PHP_EOL . esc_html__( 'Repeating days', 'bookit' ) .": $txt_week". PHP_EOL . esc_html__( 'Repeating end day', 'bookit' ) .": $r_end_day". PHP_EOL . esc_html__( 'Total', 'bookit' ) .": $total".PHP_EOL; // with repeating message's done
47
48 }else {
49 //ELSE NOT REPEATING
50 $appointment_day = stm_booki_date_i18n('d F', $data['end_day']['value']); // get appointment day
51 $body .= esc_html__( 'Name', 'bookit' ). ': ' . $data['name']['value']. PHP_EOL .esc_html__( 'Email', 'bookit' ). ": " . $data['email']['value'].PHP_EOL.esc_html__( 'Service', 'bookit' ) .": $service". PHP_EOL .esc_html__( 'Start time', 'bookit' ).": $start_time". PHP_EOL .esc_html__( 'End time', 'bookit' ).": $end_time". PHP_EOL .esc_html__( 'Appointment day', 'bookit' ).": $appointment_day". PHP_EOL . esc_html__( 'Total', 'bookit' ) .": $total". PHP_EOL;//without repeating message's done
52 }
53
54 if($settings['booking_type'] === 'registered_booking') {
55
56 $slug = get_the_title($settings['user_dashboard']);
57
58 $url = get_home_url() . "/$slug/?id={$token}";
59
60 $body .= sprintf(__('You can view appointment status and complete order <a href="%s">here</a>.', 'bookit'), $url);
61
62 }elseif($settings['booking_type'] == 'guest_booking') {
63
64 $url = apply_filters( 'stm_bookit_payment_filter', '', $total, $post_id, $service );
65
66 if ( !empty($url) ) {
67 $body .= sprintf(__('You can click <a href="%s">here</a> and pay with Paypal.', 'bookit'), $url);
68 }
69
70 }
71
72 add_filter('wp_mail_content_type', 'stm_bookit_mail_content_type');
73
74 $sent = wp_mail($to, $subject, $body, $headers);
75
76 remove_filter('wp_mail_content_type', 'stm_bookit_mail_content_type');
77
78 $fh = fopen('log.txt', 'w');
79 $results = $sent . ' ' . $to . $subject . $body ;
80
81 fwrite($fh, $results);
82 fclose($fh);
83 }