PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / views / View.CustomerOrderForm.class.php

View.CustomerOrderForm.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at views/View.CustomerOrderForm.class.php

186 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class to display a customer order form on the front end.
5 *
6 * @since 3.0.0
7 */
8 class ewdotpViewCustomerOrderForm extends ewdotpView {
9
10 /**
11 * Render the view and enqueue required stylesheets
12 * @since 3.0.0
13 */
14 public function render() {
15 global $ewd_otp_controller;
16
17 $this->set_customer_order_options();
18
19 // Add any dependent stylesheets or javascript
20 $this->enqueue_assets();
21
22 // Add css classes to the slider
23 $this->classes = $this->get_classes();
24
25 ob_start();
26
27 $this->add_custom_styling();
28
29 $template = $this->find_template( 'customer-order-form' );
30
31 if ( $template ) {
32 include( $template );
33 }
34
35 $output = ob_get_clean();
36
37 return apply_filters( 'ewd_otp_customer_order_form_output', $output, $this );
38 }
39
40 /**
41 * Prints a custom field, using the correct template based on it's type
42 *
43 * @since 3.0.0
44 */
45 public function print_customer_order_field( $custom_field ) {
46 global $ewd_otp_controller;
47
48 $this->custom_field = $custom_field;
49
50 $this->custom_field->field_value = ! empty( $this->order ) ? $ewd_otp_controller->order_manager->get_field_value( $custom_field->id, $this->order->id ) : '';
51 $this->custom_field->field_value = $custom_field->type == 'checkbox' ? explode( ',', $this->custom_field->field_value ) : $this->custom_field->field_value;
52
53 if ( $custom_field->type == 'text' ) { $template = $this->find_template( 'customer-order-field-text' ); }
54 elseif ( $custom_field->type == 'number' ) { $template = $this->find_template( 'customer-order-field-number' ); }
55 elseif ( $custom_field->type == 'textarea' ) { $template = $this->find_template( 'customer-order-field-textarea' ); }
56 elseif ( $custom_field->type == 'select' ) { $template = $this->find_template( 'customer-order-field-select' ); }
57 elseif ( $custom_field->type == 'radio' ) { $template = $this->find_template( 'customer-order-field-radio' ); }
58 elseif ( $custom_field->type == 'checkbox' ) { $template = $this->find_template( 'customer-order-field-checkbox' ); }
59 elseif ( $custom_field->type == 'link' ) { $template = $this->find_template( 'customer-order-field-link' ); }
60 elseif ( $custom_field->type == 'date' ) { $template = $this->find_template( 'customer-order-field-date' ); }
61 elseif ( $custom_field->type == 'datetime' ) { $template = $this->find_template( 'customer-order-field-datetime' ); }
62 else { $template = null; }
63
64 if ( $template ) {
65 include( $template );
66 }
67 }
68
69 /**
70 * Display the captcha field, if selected via settings
71 *
72 * @since 3.1.1
73 */
74 public function maybe_display_captcha_field() {
75 global $ewd_otp_controller;
76
77 if ( ! $ewd_otp_controller->settings->get_setting( 'use-captcha' ) ) { return; }
78
79 $template = $this->find_template( 'customer-order-recaptcha' );
80
81 if ( $template ) {
82 include( $template );
83 }
84 }
85
86 /**
87 * Print the edit appointment area, if enabled
88 *
89 * @since 3.0.0
90 */
91 public function print_customer_order_form_submit() {
92
93 $template = $this->find_template( 'form-submit' );
94
95 if ( $template ) {
96 include( $template );
97 }
98 }
99
100 public function get_sales_reps() {
101 global $ewd_otp_controller;
102
103 $args = array(
104 'sales_reps_per_page' => 1000
105 );
106
107 return $ewd_otp_controller->sales_rep_manager->get_matching_sales_reps( $args );
108 }
109
110 /**
111 * Get the initial submit faq css classes
112 * @since 3.0.0
113 */
114 public function get_classes( $classes = array() ) {
115 global $ewd_otp_controller;
116
117 $classes = array_merge(
118 $classes,
119 array(
120 'ewd-otp-customer-order-form',
121 'ewd-otp-form'
122 )
123 );
124
125 return apply_filters( 'ewd_otp_customer_order_form_classes', $classes, $this );
126 }
127
128 /**
129 * Allow some parameters to be overwritten with URL parameters, to pay for/cancel/update a specific booking
130 * @since 3.0.0
131 */
132 public function set_request_parameters() {
133 global $ewd_otp_controller;
134
135
136 }
137
138 /**
139 * Add in default options when displaying in the admin appointments area
140 *
141 * @since 3.0.0
142 */
143 public function set_customer_order_options() {
144 global $ewd_otp_controller;
145
146 $this->nonce = wp_create_nonce( basename( __FILE__ ) );
147 $this->location = ! empty( $this->location ) ? $this->location : '';
148 $this->customer_order_form_title = ! empty( $this->customer_order_form_title ) ? $this->customer_order_form_title : __( 'Customer Order Form', 'order-tracking' );
149 $this->customer_order_form_instructions = ! empty( $this->customer_order_form_instructions ) ? $this->customer_order_form_instructions : __( 'Enter information about your order using the form below.', 'order-tracking' );
150 $this->customer_name_field_text = ! empty( $this->customer_name_field_text ) ? $this->customer_name_field_text : $this->get_label( 'label-customer-order-name' );
151 $this->customer_email_field_text = ! empty( $this->customer_email_field_text ) ? $this->customer_email_field_text : $this->get_label( 'label-customer-order-email' );
152 $this->customer_notes_field_text = ! empty( $this->customer_notes_field_text ) ? $this->customer_notes_field_text : $this->get_label( 'label-customer-order-notes' );
153 $this->submit_text = ! empty( $this->submit_text ) ? $this->submit_text : $this->get_label( 'label-customer-order-button' );
154 }
155
156 /**
157 * Enqueue the necessary CSS and JS files
158 * @since 3.0.0
159 */
160 public function enqueue_assets() {
161 global $ewd_otp_controller;
162
163 wp_enqueue_style( 'ewd-otp-css' );
164
165 $args = array(
166 'nonce' => wp_create_nonce( 'ewd-otp-js' ),
167 'default_date' => $ewd_otp_controller->settings->get_setting( 'calendar-offset' ),
168 );
169
170 $ewd_otp_controller->add_front_end_php_data( 'ewd-otp-js', 'ewd_otp_php_data', $args );
171
172 wp_enqueue_script( 'ewd-otp-js' );
173
174 if ( empty( $ewd_otp_controller->settings->get_setting( 'use-captcha' ) ) ) { return; }
175
176 wp_enqueue_script( 'ewd-otp-google-recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . get_locale() . '&render=explicit&onload=ewdotpLoadRecaptcha' );
177 wp_enqueue_script( 'ewd-otp-process-recaptcha', EWD_OTP_PLUGIN_URL . '/assets/js/ewd-otp-recaptcha.js', array( 'ewd-otp-google-recaptcha' ) );
178
179 $args = array(
180 'site_key' => $ewd_otp_controller->settings->get_setting( 'captcha-site-key' ),
181 );
182
183 $ewd_otp_controller->add_front_end_php_data( 'ewd-otp-process-recaptcha', 'ewd_otp_recaptcha', $args );
184 }
185 }
186