@@ -20,465 +20,465 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
22 | 22 | { |
23 | - /** |
|
24 | - * @var RegFormFactory |
|
25 | - */ |
|
26 | - protected $reg_form_factory; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $reg_form_factory_version = RegFormFactory::VERSION_2; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * class constructor |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param EE_Checkout $checkout |
|
39 | - */ |
|
40 | - public function __construct(EE_Checkout $checkout) |
|
41 | - { |
|
42 | - $this->_slug = 'attendee_information'; |
|
43 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
44 | - $this->checkout = $checkout; |
|
45 | - $this->_reset_success_message(); |
|
46 | - $this->set_instructions( |
|
47 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
48 | - ); |
|
49 | - $this->reg_form_factory = new RegFormFactory($this->reg_form_factory_version); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - public function translate_js_strings() |
|
54 | - { |
|
55 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
56 | - ' is a required question.', |
|
57 | - 'event_espresso' |
|
58 | - ); |
|
59 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
60 | - ' is a required question. Please enter a value for at least one of the options.', |
|
61 | - 'event_espresso' |
|
62 | - ); |
|
63 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
64 | - 'Please answer all required questions correctly before proceeding.', |
|
65 | - 'event_espresso' |
|
66 | - ); |
|
67 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
68 | - esc_html_x( |
|
69 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
70 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - '<br/>' |
|
74 | - ); |
|
75 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
76 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
77 | - 'event_espresso' |
|
78 | - ); |
|
79 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
80 | - 'You must enter a valid email address.', |
|
81 | - 'event_espresso' |
|
82 | - ); |
|
83 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
84 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
85 | - 'event_espresso' |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - public function enqueue_styles_and_scripts() |
|
91 | - { |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return boolean |
|
97 | - */ |
|
98 | - public function initialize_reg_step(): bool |
|
99 | - { |
|
100 | - return true; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return FormSectionProperInterface |
|
106 | - * @throws EE_Error |
|
107 | - * @throws ReflectionException |
|
108 | - */ |
|
109 | - public function generate_reg_form(): FormSectionProperInterface |
|
110 | - { |
|
111 | - return $this->reg_form_factory->getRegForm([$this]); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * looking for hooks? |
|
117 | - * this method has been replaced by: |
|
118 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
119 | - * |
|
120 | - * @deprecated $VID:$ |
|
121 | - */ |
|
122 | - private function _registrations_reg_form() |
|
123 | - { |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * looking for hooks? |
|
129 | - * this method has been replaced by: |
|
130 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
131 | - * |
|
132 | - * @deprecated $VID:$ |
|
133 | - */ |
|
134 | - private function _additional_attendee_reg_info_input() |
|
135 | - { |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * looking for hooks? |
|
141 | - * this method has been replaced by: |
|
142 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
143 | - * |
|
144 | - * @deprecated $VID:$ |
|
145 | - */ |
|
146 | - private function _question_group_reg_form() |
|
147 | - { |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * looking for hooks? |
|
153 | - * this method has been replaced by: |
|
154 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
155 | - * |
|
156 | - * @deprecated $VID:$ |
|
157 | - */ |
|
158 | - private function _question_group_header() |
|
159 | - { |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * looking for hooks? |
|
165 | - * this method has been replaced by: |
|
166 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
167 | - * |
|
168 | - * @deprecated $VID:$ |
|
169 | - */ |
|
170 | - private function _copy_attendee_info_form() |
|
171 | - { |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * looking for hooks? |
|
177 | - * this method has been replaced by: |
|
178 | - * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
179 | - * |
|
180 | - * @deprecated $VID:$ |
|
181 | - */ |
|
182 | - private function _auto_copy_attendee_info() |
|
183 | - { |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * looking for hooks? |
|
189 | - * this method has been replaced by: |
|
190 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
191 | - * |
|
192 | - * @deprecated $VID:$ |
|
193 | - */ |
|
194 | - private function _copy_attendee_info_inputs() |
|
195 | - { |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * looking for hooks? |
|
201 | - * this method has been replaced by: |
|
202 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
203 | - * |
|
204 | - * @deprecated $VID:$ |
|
205 | - */ |
|
206 | - private function _additional_primary_registrant_inputs() |
|
207 | - { |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * looking for hooks? |
|
213 | - * this method has been replaced by: |
|
214 | - * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
215 | - * |
|
216 | - * @param EE_Registration $registration |
|
217 | - * @param EE_Question $question |
|
218 | - * @return EE_Form_Input_Base |
|
219 | - * @throws EE_Error |
|
220 | - * @throws ReflectionException |
|
221 | - * @deprecated $VID:$ |
|
222 | - */ |
|
223 | - public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
224 | - { |
|
225 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
226 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
227 | - return $reg_form_question_factory->create($registration, $question); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * looking for hooks? |
|
233 | - * this method has been replaced by: |
|
234 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
235 | - * |
|
236 | - * @deprecated $VID:$ |
|
237 | - */ |
|
238 | - private function _generate_question_input() |
|
239 | - { |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * looking for hooks? |
|
245 | - * this method has been replaced by: |
|
246 | - * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
247 | - * |
|
248 | - * @param array|null $countries_list |
|
249 | - * @param EE_Question|null $question |
|
250 | - * @param EE_Registration|null $registration |
|
251 | - * @param EE_Answer|null $answer |
|
252 | - * @return array 2d keys are country IDs, values are their names |
|
253 | - * @throws EE_Error |
|
254 | - * @throws ReflectionException |
|
255 | - * @deprecated $VID:$ |
|
256 | - */ |
|
257 | - public function use_cached_countries_for_form_input( |
|
258 | - array $countries_list = null, |
|
259 | - EE_Question $question = null, |
|
260 | - EE_Registration $registration = null, |
|
261 | - EE_Answer $answer = null |
|
262 | - ): array { |
|
263 | - /** @var CountryOptions $country_options */ |
|
264 | - $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
265 | - return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * looking for hooks? |
|
271 | - * this method has been replaced by: |
|
272 | - * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
273 | - * |
|
274 | - * @param array|null $states_list |
|
275 | - * @param EE_Question|null $question |
|
276 | - * @param EE_Registration|null $registration |
|
277 | - * @param EE_Answer|null $answer |
|
278 | - * @return array 2d keys are state IDs, values are their names |
|
279 | - * @throws EE_Error |
|
280 | - * @throws ReflectionException |
|
281 | - * @deprecated $VID:$ |
|
282 | - */ |
|
283 | - public function use_cached_states_for_form_input( |
|
284 | - array $states_list = null, |
|
285 | - EE_Question $question = null, |
|
286 | - EE_Registration $registration = null, |
|
287 | - EE_Answer $answer = null |
|
288 | - ): array { |
|
289 | - /** @var StateOptions $state_options */ |
|
290 | - $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
291 | - return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /********************************************************************************************************/ |
|
296 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
297 | - /********************************************************************************************************/ |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * @return bool |
|
302 | - * @throws EE_Error |
|
303 | - * @throws InvalidArgumentException |
|
304 | - * @throws ReflectionException |
|
305 | - * @throws RuntimeException |
|
306 | - * @throws InvalidDataTypeException |
|
307 | - * @throws InvalidInterfaceException |
|
308 | - */ |
|
309 | - public function process_reg_step(): bool |
|
310 | - { |
|
311 | - // grab validated data from form |
|
312 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
313 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
314 | - if (empty($valid_data)) { |
|
315 | - return $this->inValidDataError(); |
|
316 | - } |
|
317 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
318 | - return $this->inValidTransactionError(); |
|
319 | - } |
|
320 | - // get cached registrations |
|
321 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
322 | - // verify we got the goods |
|
323 | - if (empty($registrations)) { |
|
324 | - return $this->noRegistrationsError(); |
|
325 | - } |
|
326 | - $reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout); |
|
327 | - // extract attendee info from form data and save to model objects |
|
328 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
329 | - // return immediately if the previous step exited early due to errors |
|
330 | - return false; |
|
331 | - } |
|
332 | - // if first pass thru SPCO, |
|
333 | - // then let's check processed registrations against the total number of tickets in the cart |
|
334 | - $registrations_processed = $reg_form_handler->attendeeCount(); |
|
335 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
336 | - return $this->registrationProcessingError($registrations_processed); |
|
337 | - } |
|
338 | - // mark this reg step as completed |
|
339 | - $this->set_completed(); |
|
340 | - $this->_set_success_message( |
|
341 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
342 | - ); |
|
343 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
344 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
345 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
346 | - return true; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @return bool |
|
352 | - * @since $VID:$ |
|
353 | - */ |
|
354 | - private function inValidDataError(): bool |
|
355 | - { |
|
356 | - EE_Error::add_error( |
|
357 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
358 | - __FILE__, |
|
359 | - __FUNCTION__, |
|
360 | - __LINE__ |
|
361 | - ); |
|
362 | - return false; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * @return bool |
|
368 | - * @since $VID:$ |
|
369 | - */ |
|
370 | - private function inValidTransactionError(): bool |
|
371 | - { |
|
372 | - EE_Error::add_error( |
|
373 | - esc_html__( |
|
374 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
375 | - 'event_espresso' |
|
376 | - ), |
|
377 | - __FILE__, |
|
378 | - __FUNCTION__, |
|
379 | - __LINE__ |
|
380 | - ); |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * @return bool |
|
387 | - * @since $VID:$ |
|
388 | - */ |
|
389 | - private function noRegistrationsError(): bool |
|
390 | - { |
|
391 | - // combine the old translated string with a new one, in order to not break translations |
|
392 | - $error_message = esc_html__( |
|
393 | - 'Your form data could not be applied to any valid registrations.', |
|
394 | - 'event_espresso' |
|
395 | - ); |
|
396 | - $error_message .= sprintf( |
|
397 | - esc_html_x( |
|
398 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
399 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
400 | - 'event_espresso' |
|
401 | - ), |
|
402 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
403 | - '</a>', |
|
404 | - '<br />' |
|
405 | - ); |
|
406 | - EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
407 | - return false; |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * @param int $registrations_processed |
|
413 | - * @return bool |
|
414 | - * @since $VID:$ |
|
415 | - */ |
|
416 | - private function registrationProcessingError(int $registrations_processed): bool |
|
417 | - { |
|
418 | - // generate a correctly translated string for all possible singular/plural combinations |
|
419 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
420 | - $error_msg = sprintf( |
|
421 | - esc_html_x( |
|
422 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
423 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
424 | - 'event_espresso' |
|
425 | - ), |
|
426 | - $this->checkout->total_ticket_count, |
|
427 | - $registrations_processed |
|
428 | - ); |
|
429 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
430 | - $error_msg = sprintf( |
|
431 | - esc_html_x( |
|
432 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
433 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
434 | - 'event_espresso' |
|
435 | - ), |
|
436 | - $this->checkout->total_ticket_count, |
|
437 | - $registrations_processed |
|
438 | - ); |
|
439 | - } else { |
|
440 | - $error_msg = sprintf( |
|
441 | - esc_html__( |
|
442 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
443 | - 'event_espresso' |
|
444 | - ), |
|
445 | - $this->checkout->total_ticket_count, |
|
446 | - $registrations_processed |
|
447 | - ); |
|
448 | - } |
|
449 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
450 | - return false; |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - /** |
|
455 | - * update_reg_step |
|
456 | - * this is the final step after a user revisits the site to edit their attendee information |
|
457 | - * this gets called AFTER the process_reg_step() method above |
|
458 | - * |
|
459 | - * @return bool |
|
460 | - * @throws EE_Error |
|
461 | - * @throws InvalidArgumentException |
|
462 | - * @throws ReflectionException |
|
463 | - * @throws RuntimeException |
|
464 | - * @throws InvalidDataTypeException |
|
465 | - * @throws InvalidInterfaceException |
|
466 | - */ |
|
467 | - public function update_reg_step(): bool |
|
468 | - { |
|
469 | - // save everything |
|
470 | - if ($this->process_reg_step()) { |
|
471 | - $this->checkout->redirect = true; |
|
472 | - $this->checkout->redirect_url = add_query_arg( |
|
473 | - [ |
|
474 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
475 | - 'revisit' => true, |
|
476 | - ], |
|
477 | - $this->checkout->thank_you_page_url |
|
478 | - ); |
|
479 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
480 | - return true; |
|
481 | - } |
|
482 | - return false; |
|
483 | - } |
|
23 | + /** |
|
24 | + * @var RegFormFactory |
|
25 | + */ |
|
26 | + protected $reg_form_factory; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $reg_form_factory_version = RegFormFactory::VERSION_2; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * class constructor |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param EE_Checkout $checkout |
|
39 | + */ |
|
40 | + public function __construct(EE_Checkout $checkout) |
|
41 | + { |
|
42 | + $this->_slug = 'attendee_information'; |
|
43 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
44 | + $this->checkout = $checkout; |
|
45 | + $this->_reset_success_message(); |
|
46 | + $this->set_instructions( |
|
47 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
48 | + ); |
|
49 | + $this->reg_form_factory = new RegFormFactory($this->reg_form_factory_version); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + public function translate_js_strings() |
|
54 | + { |
|
55 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
56 | + ' is a required question.', |
|
57 | + 'event_espresso' |
|
58 | + ); |
|
59 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
60 | + ' is a required question. Please enter a value for at least one of the options.', |
|
61 | + 'event_espresso' |
|
62 | + ); |
|
63 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
64 | + 'Please answer all required questions correctly before proceeding.', |
|
65 | + 'event_espresso' |
|
66 | + ); |
|
67 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
68 | + esc_html_x( |
|
69 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
70 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + '<br/>' |
|
74 | + ); |
|
75 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
76 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
77 | + 'event_espresso' |
|
78 | + ); |
|
79 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
80 | + 'You must enter a valid email address.', |
|
81 | + 'event_espresso' |
|
82 | + ); |
|
83 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
84 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
85 | + 'event_espresso' |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + public function enqueue_styles_and_scripts() |
|
91 | + { |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return boolean |
|
97 | + */ |
|
98 | + public function initialize_reg_step(): bool |
|
99 | + { |
|
100 | + return true; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return FormSectionProperInterface |
|
106 | + * @throws EE_Error |
|
107 | + * @throws ReflectionException |
|
108 | + */ |
|
109 | + public function generate_reg_form(): FormSectionProperInterface |
|
110 | + { |
|
111 | + return $this->reg_form_factory->getRegForm([$this]); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * looking for hooks? |
|
117 | + * this method has been replaced by: |
|
118 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
119 | + * |
|
120 | + * @deprecated $VID:$ |
|
121 | + */ |
|
122 | + private function _registrations_reg_form() |
|
123 | + { |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * looking for hooks? |
|
129 | + * this method has been replaced by: |
|
130 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
131 | + * |
|
132 | + * @deprecated $VID:$ |
|
133 | + */ |
|
134 | + private function _additional_attendee_reg_info_input() |
|
135 | + { |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * looking for hooks? |
|
141 | + * this method has been replaced by: |
|
142 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
143 | + * |
|
144 | + * @deprecated $VID:$ |
|
145 | + */ |
|
146 | + private function _question_group_reg_form() |
|
147 | + { |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * looking for hooks? |
|
153 | + * this method has been replaced by: |
|
154 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
155 | + * |
|
156 | + * @deprecated $VID:$ |
|
157 | + */ |
|
158 | + private function _question_group_header() |
|
159 | + { |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * looking for hooks? |
|
165 | + * this method has been replaced by: |
|
166 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
167 | + * |
|
168 | + * @deprecated $VID:$ |
|
169 | + */ |
|
170 | + private function _copy_attendee_info_form() |
|
171 | + { |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * looking for hooks? |
|
177 | + * this method has been replaced by: |
|
178 | + * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
179 | + * |
|
180 | + * @deprecated $VID:$ |
|
181 | + */ |
|
182 | + private function _auto_copy_attendee_info() |
|
183 | + { |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * looking for hooks? |
|
189 | + * this method has been replaced by: |
|
190 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
191 | + * |
|
192 | + * @deprecated $VID:$ |
|
193 | + */ |
|
194 | + private function _copy_attendee_info_inputs() |
|
195 | + { |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * looking for hooks? |
|
201 | + * this method has been replaced by: |
|
202 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
203 | + * |
|
204 | + * @deprecated $VID:$ |
|
205 | + */ |
|
206 | + private function _additional_primary_registrant_inputs() |
|
207 | + { |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * looking for hooks? |
|
213 | + * this method has been replaced by: |
|
214 | + * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
215 | + * |
|
216 | + * @param EE_Registration $registration |
|
217 | + * @param EE_Question $question |
|
218 | + * @return EE_Form_Input_Base |
|
219 | + * @throws EE_Error |
|
220 | + * @throws ReflectionException |
|
221 | + * @deprecated $VID:$ |
|
222 | + */ |
|
223 | + public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
224 | + { |
|
225 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
226 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
227 | + return $reg_form_question_factory->create($registration, $question); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * looking for hooks? |
|
233 | + * this method has been replaced by: |
|
234 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
235 | + * |
|
236 | + * @deprecated $VID:$ |
|
237 | + */ |
|
238 | + private function _generate_question_input() |
|
239 | + { |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * looking for hooks? |
|
245 | + * this method has been replaced by: |
|
246 | + * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
247 | + * |
|
248 | + * @param array|null $countries_list |
|
249 | + * @param EE_Question|null $question |
|
250 | + * @param EE_Registration|null $registration |
|
251 | + * @param EE_Answer|null $answer |
|
252 | + * @return array 2d keys are country IDs, values are their names |
|
253 | + * @throws EE_Error |
|
254 | + * @throws ReflectionException |
|
255 | + * @deprecated $VID:$ |
|
256 | + */ |
|
257 | + public function use_cached_countries_for_form_input( |
|
258 | + array $countries_list = null, |
|
259 | + EE_Question $question = null, |
|
260 | + EE_Registration $registration = null, |
|
261 | + EE_Answer $answer = null |
|
262 | + ): array { |
|
263 | + /** @var CountryOptions $country_options */ |
|
264 | + $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
265 | + return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * looking for hooks? |
|
271 | + * this method has been replaced by: |
|
272 | + * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
273 | + * |
|
274 | + * @param array|null $states_list |
|
275 | + * @param EE_Question|null $question |
|
276 | + * @param EE_Registration|null $registration |
|
277 | + * @param EE_Answer|null $answer |
|
278 | + * @return array 2d keys are state IDs, values are their names |
|
279 | + * @throws EE_Error |
|
280 | + * @throws ReflectionException |
|
281 | + * @deprecated $VID:$ |
|
282 | + */ |
|
283 | + public function use_cached_states_for_form_input( |
|
284 | + array $states_list = null, |
|
285 | + EE_Question $question = null, |
|
286 | + EE_Registration $registration = null, |
|
287 | + EE_Answer $answer = null |
|
288 | + ): array { |
|
289 | + /** @var StateOptions $state_options */ |
|
290 | + $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
291 | + return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /********************************************************************************************************/ |
|
296 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
297 | + /********************************************************************************************************/ |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * @return bool |
|
302 | + * @throws EE_Error |
|
303 | + * @throws InvalidArgumentException |
|
304 | + * @throws ReflectionException |
|
305 | + * @throws RuntimeException |
|
306 | + * @throws InvalidDataTypeException |
|
307 | + * @throws InvalidInterfaceException |
|
308 | + */ |
|
309 | + public function process_reg_step(): bool |
|
310 | + { |
|
311 | + // grab validated data from form |
|
312 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
313 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
314 | + if (empty($valid_data)) { |
|
315 | + return $this->inValidDataError(); |
|
316 | + } |
|
317 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
318 | + return $this->inValidTransactionError(); |
|
319 | + } |
|
320 | + // get cached registrations |
|
321 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
322 | + // verify we got the goods |
|
323 | + if (empty($registrations)) { |
|
324 | + return $this->noRegistrationsError(); |
|
325 | + } |
|
326 | + $reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout); |
|
327 | + // extract attendee info from form data and save to model objects |
|
328 | + if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
329 | + // return immediately if the previous step exited early due to errors |
|
330 | + return false; |
|
331 | + } |
|
332 | + // if first pass thru SPCO, |
|
333 | + // then let's check processed registrations against the total number of tickets in the cart |
|
334 | + $registrations_processed = $reg_form_handler->attendeeCount(); |
|
335 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
336 | + return $this->registrationProcessingError($registrations_processed); |
|
337 | + } |
|
338 | + // mark this reg step as completed |
|
339 | + $this->set_completed(); |
|
340 | + $this->_set_success_message( |
|
341 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
342 | + ); |
|
343 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
344 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
345 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
346 | + return true; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @return bool |
|
352 | + * @since $VID:$ |
|
353 | + */ |
|
354 | + private function inValidDataError(): bool |
|
355 | + { |
|
356 | + EE_Error::add_error( |
|
357 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
358 | + __FILE__, |
|
359 | + __FUNCTION__, |
|
360 | + __LINE__ |
|
361 | + ); |
|
362 | + return false; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * @return bool |
|
368 | + * @since $VID:$ |
|
369 | + */ |
|
370 | + private function inValidTransactionError(): bool |
|
371 | + { |
|
372 | + EE_Error::add_error( |
|
373 | + esc_html__( |
|
374 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
375 | + 'event_espresso' |
|
376 | + ), |
|
377 | + __FILE__, |
|
378 | + __FUNCTION__, |
|
379 | + __LINE__ |
|
380 | + ); |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * @return bool |
|
387 | + * @since $VID:$ |
|
388 | + */ |
|
389 | + private function noRegistrationsError(): bool |
|
390 | + { |
|
391 | + // combine the old translated string with a new one, in order to not break translations |
|
392 | + $error_message = esc_html__( |
|
393 | + 'Your form data could not be applied to any valid registrations.', |
|
394 | + 'event_espresso' |
|
395 | + ); |
|
396 | + $error_message .= sprintf( |
|
397 | + esc_html_x( |
|
398 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
399 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
400 | + 'event_espresso' |
|
401 | + ), |
|
402 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
403 | + '</a>', |
|
404 | + '<br />' |
|
405 | + ); |
|
406 | + EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
407 | + return false; |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * @param int $registrations_processed |
|
413 | + * @return bool |
|
414 | + * @since $VID:$ |
|
415 | + */ |
|
416 | + private function registrationProcessingError(int $registrations_processed): bool |
|
417 | + { |
|
418 | + // generate a correctly translated string for all possible singular/plural combinations |
|
419 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
420 | + $error_msg = sprintf( |
|
421 | + esc_html_x( |
|
422 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
423 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
424 | + 'event_espresso' |
|
425 | + ), |
|
426 | + $this->checkout->total_ticket_count, |
|
427 | + $registrations_processed |
|
428 | + ); |
|
429 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
430 | + $error_msg = sprintf( |
|
431 | + esc_html_x( |
|
432 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
433 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
434 | + 'event_espresso' |
|
435 | + ), |
|
436 | + $this->checkout->total_ticket_count, |
|
437 | + $registrations_processed |
|
438 | + ); |
|
439 | + } else { |
|
440 | + $error_msg = sprintf( |
|
441 | + esc_html__( |
|
442 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
443 | + 'event_espresso' |
|
444 | + ), |
|
445 | + $this->checkout->total_ticket_count, |
|
446 | + $registrations_processed |
|
447 | + ); |
|
448 | + } |
|
449 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
450 | + return false; |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + /** |
|
455 | + * update_reg_step |
|
456 | + * this is the final step after a user revisits the site to edit their attendee information |
|
457 | + * this gets called AFTER the process_reg_step() method above |
|
458 | + * |
|
459 | + * @return bool |
|
460 | + * @throws EE_Error |
|
461 | + * @throws InvalidArgumentException |
|
462 | + * @throws ReflectionException |
|
463 | + * @throws RuntimeException |
|
464 | + * @throws InvalidDataTypeException |
|
465 | + * @throws InvalidInterfaceException |
|
466 | + */ |
|
467 | + public function update_reg_step(): bool |
|
468 | + { |
|
469 | + // save everything |
|
470 | + if ($this->process_reg_step()) { |
|
471 | + $this->checkout->redirect = true; |
|
472 | + $this->checkout->redirect_url = add_query_arg( |
|
473 | + [ |
|
474 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
475 | + 'revisit' => true, |
|
476 | + ], |
|
477 | + $this->checkout->thank_you_page_url |
|
478 | + ); |
|
479 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
480 | + return true; |
|
481 | + } |
|
482 | + return false; |
|
483 | + } |
|
484 | 484 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | public function translate_js_strings() |
54 | 54 | { |
55 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
55 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
56 | 56 | ' is a required question.', |
57 | 57 | 'event_espresso' |
58 | 58 | ); |
59 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
59 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
60 | 60 | ' is a required question. Please enter a value for at least one of the options.', |
61 | 61 | 'event_espresso' |
62 | 62 | ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'Please answer all required questions correctly before proceeding.', |
65 | 65 | 'event_espresso' |
66 | 66 | ); |
67 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
67 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
68 | 68 | esc_html_x( |
69 | 69 | 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
70 | 70 | 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | ), |
73 | 73 | '<br/>' |
74 | 74 | ); |
75 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
75 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
76 | 76 | 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
77 | 77 | 'event_espresso' |
78 | 78 | ); |
79 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
79 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
80 | 80 | 'You must enter a valid email address.', |
81 | 81 | 'event_espresso' |
82 | 82 | ); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | if (empty($valid_data)) { |
315 | 315 | return $this->inValidDataError(); |
316 | 316 | } |
317 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
317 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
318 | 318 | return $this->inValidTransactionError(); |
319 | 319 | } |
320 | 320 | // get cached registrations |
@@ -325,14 +325,14 @@ discard block |
||
325 | 325 | } |
326 | 326 | $reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout); |
327 | 327 | // extract attendee info from form data and save to model objects |
328 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
328 | + if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
329 | 329 | // return immediately if the previous step exited early due to errors |
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | // if first pass thru SPCO, |
333 | 333 | // then let's check processed registrations against the total number of tickets in the cart |
334 | 334 | $registrations_processed = $reg_form_handler->attendeeCount(); |
335 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
335 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
336 | 336 | return $this->registrationProcessingError($registrations_processed); |
337 | 337 | } |
338 | 338 | // mark this reg step as completed |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
400 | 400 | 'event_espresso' |
401 | 401 | ), |
402 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
402 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
403 | 403 | '</a>', |
404 | 404 | '<br />' |
405 | 405 | ); |