Completed
Branch FET/rule-specific-exclusions-l... (334422)
by
unknown
17:10 queued 32s
created
modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php 2 patches
Indentation   +627 added lines, -627 removed lines patch added patch discarded remove patch
@@ -12,631 +12,631 @@
 block discarded – undo
12 12
 abstract class EE_SPCO_Reg_Step
13 13
 {
14 14
 
15
-    /**
16
-     *    $_completed - TRUE if this step has fully completed it's duties
17
-     *
18
-     * @access protected
19
-     * @type bool $_completed
20
-     */
21
-    protected $_completed = false;
22
-
23
-    /**
24
-     *    $_is_current_step - TRUE if this is the current step
25
-     *
26
-     * @access protected
27
-     * @type bool $_is_current_step
28
-     */
29
-    protected $_is_current_step = false;
30
-
31
-    /**
32
-     *    $_order - when the reg step should be run relative to other steps
33
-     *
34
-     * @access protected
35
-     * @type int $_template
36
-     */
37
-    protected $_order = 0;
38
-
39
-    /**
40
-     *    $_slug - URL param for this step
41
-     *
42
-     * @access protected
43
-     * @type string $_slug
44
-     */
45
-    protected $_slug;
46
-
47
-    /**
48
-     *    $_name - Step Name - translatable string
49
-     *
50
-     * @access protected
51
-     * @type string $_slug
52
-     */
53
-    protected $_name;
54
-
55
-    /**
56
-     *    $_submit_button_text - translatable string that appears on this step's submit button
57
-     *
58
-     * @access protected
59
-     * @type string $_slug
60
-     */
61
-    protected $_submit_button_text;
62
-
63
-    /**
64
-     *    $_template - template name
65
-     *
66
-     * @access protected
67
-     * @type string $_template
68
-     */
69
-    protected $_template;
70
-
71
-    /**
72
-     *    $_reg_form_name - the form input name and id attribute
73
-     *
74
-     * @access protected
75
-     * @var string $_reg_form_name
76
-     */
77
-    protected $_reg_form_name;
78
-
79
-    /**
80
-     *    $_success_message - text to display upon successful form submission
81
-     *
82
-     * @access private
83
-     * @var string $_success_message
84
-     */
85
-    protected $_success_message;
86
-
87
-    /**
88
-     *    $_instructions - a brief description of how to complete the reg step.
89
-     *    Usually displayed in conjunction with the previous step's success message.
90
-     *
91
-     * @access private
92
-     * @var string $_instructions
93
-     */
94
-    protected $_instructions;
95
-
96
-    /**
97
-     *    $_valid_data - the normalized and validated data for this step
98
-     *
99
-     * @access public
100
-     * @var array $_valid_data
101
-     */
102
-    protected $_valid_data = array();
103
-
104
-    /**
105
-     *    $reg_form - the registration form for this step
106
-     *
107
-     * @access public
108
-     * @var EE_Form_Section_Proper $reg_form
109
-     */
110
-    public $reg_form;
111
-
112
-    /**
113
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
114
-     *
115
-     * @access public
116
-     * @var EE_Checkout $checkout
117
-     */
118
-    public $checkout;
119
-
120
-
121
-    /**
122
-     * @return void
123
-     */
124
-    abstract public function translate_js_strings();
125
-
126
-
127
-    /**
128
-     * @return void
129
-     */
130
-    abstract public function enqueue_styles_and_scripts();
131
-
132
-
133
-    /**
134
-     * @return boolean
135
-     */
136
-    abstract public function initialize_reg_step();
137
-
138
-
139
-    /**
140
-     * @return string
141
-     */
142
-    abstract public function generate_reg_form();
143
-
144
-
145
-    /**
146
-     * @return boolean
147
-     */
148
-    abstract public function process_reg_step();
149
-
150
-
151
-    /**
152
-     * @return boolean
153
-     */
154
-    abstract public function update_reg_step();
155
-
156
-
157
-    /**
158
-     * @return boolean
159
-     */
160
-    public function completed()
161
-    {
162
-        return $this->_completed;
163
-    }
164
-
165
-
166
-    /**
167
-     * set_completed - toggles $_completed to TRUE
168
-     */
169
-    public function set_completed()
170
-    {
171
-        // DEBUG LOG
172
-        // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
173
-        $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
174
-    }
175
-
176
-
177
-    /**
178
-     * set_completed - toggles $_completed to FALSE
179
-     */
180
-    public function set_not_completed()
181
-    {
182
-        $this->_completed = false;
183
-    }
184
-
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function name()
190
-    {
191
-        return $this->_name;
192
-    }
193
-
194
-
195
-    /**
196
-     * @return string
197
-     */
198
-    public function slug()
199
-    {
200
-        return $this->_slug;
201
-    }
202
-
203
-
204
-    /**
205
-     * submit_button_text
206
-     * the text that appears on the reg step form submit button
207
-     *
208
-     * @return string
209
-     */
210
-    public function submit_button_text()
211
-    {
212
-        return $this->_submit_button_text;
213
-    }
214
-
215
-
216
-    /**
217
-     * set_submit_button_text
218
-     * sets the text that appears on the reg step form submit button
219
-     *
220
-     * @param string $submit_button_text
221
-     */
222
-    public function set_submit_button_text($submit_button_text = '')
223
-    {
224
-        if (! empty($submit_button_text)) {
225
-            $this->_submit_button_text = $submit_button_text;
226
-        } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
227
-            if ($this->checkout->revisit) {
228
-                $this->_submit_button_text = sprintf(
229
-                    __('Update %s', 'event_espresso'),
230
-                    $this->checkout->current_step->name()
231
-                );
232
-            } else {
233
-                $this->_submit_button_text = sprintf(
234
-                    __('Proceed to %s', 'event_espresso'),
235
-                    $this->checkout->next_step->name()
236
-                );
237
-            }
238
-        }
239
-        // filters the submit button text
240
-        $this->_submit_button_text = apply_filters(
241
-            'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
242
-            $this->_submit_button_text,
243
-            $this->checkout
244
-        );
245
-    }
246
-
247
-
248
-    /**
249
-     * @param boolean $is_current_step
250
-     */
251
-    public function set_is_current_step($is_current_step)
252
-    {
253
-        $this->_is_current_step = $is_current_step;
254
-    }
255
-
256
-
257
-    /**
258
-     * @return boolean
259
-     */
260
-    public function is_current_step()
261
-    {
262
-        return $this->_is_current_step;
263
-    }
264
-
265
-
266
-    /**
267
-     * @return boolean
268
-     */
269
-    public function is_final_step()
270
-    {
271
-        return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false;
272
-    }
273
-
274
-
275
-    /**
276
-     * @param int $order
277
-     */
278
-    public function set_order($order)
279
-    {
280
-        $this->_order = $order;
281
-    }
282
-
283
-
284
-    /**
285
-     * @return int
286
-     */
287
-    public function order()
288
-    {
289
-        return $this->_order;
290
-    }
291
-
292
-
293
-    /**
294
-     * @return string
295
-     */
296
-    public function template()
297
-    {
298
-        return $this->_template;
299
-    }
300
-
301
-
302
-    /**
303
-     * @return string
304
-     */
305
-    public function success_message()
306
-    {
307
-        return $this->_success_message;
308
-    }
309
-
310
-
311
-    /**
312
-     * _set_success_message
313
-     *
314
-     * @param string $success_message
315
-     */
316
-    protected function _set_success_message($success_message)
317
-    {
318
-        $this->_success_message = $success_message;
319
-    }
320
-
321
-
322
-    /**
323
-     * _reset_success_message
324
-     *
325
-     * @return void
326
-     */
327
-    protected function _reset_success_message()
328
-    {
329
-        $this->_success_message = '';
330
-    }
331
-
332
-
333
-    /**
334
-     * @return string
335
-     */
336
-    public function _instructions()
337
-    {
338
-        return $this->_instructions;
339
-    }
340
-
341
-
342
-    /**
343
-     * @param string $instructions
344
-     */
345
-    public function set_instructions($instructions)
346
-    {
347
-        $this->_instructions = apply_filters(
348
-            'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
349
-            $instructions,
350
-            $this
351
-        );
352
-    }
353
-
354
-
355
-    /**
356
-     * @param array $valid_data
357
-     */
358
-    public function set_valid_data($valid_data)
359
-    {
360
-        $this->_valid_data = $valid_data;
361
-    }
362
-
363
-
364
-    /**
365
-     * @return array
366
-     */
367
-    public function valid_data()
368
-    {
369
-        if (empty($this->_valid_data)) {
370
-            $this->_valid_data = $this->reg_form->valid_data();
371
-        }
372
-        return $this->_valid_data;
373
-    }
374
-
375
-
376
-    /**
377
-     * @return string
378
-     */
379
-    public function reg_form_name()
380
-    {
381
-        if (empty($this->_reg_form_name)) {
382
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
383
-        }
384
-        return $this->_reg_form_name;
385
-    }
386
-
387
-
388
-    /**
389
-     * @param string $reg_form_name
390
-     */
391
-    protected function set_reg_form_name($reg_form_name)
392
-    {
393
-        $this->_reg_form_name = $reg_form_name;
394
-    }
395
-
396
-
397
-    /**
398
-     * reg_step_url
399
-     *
400
-     * @param string $action
401
-     * @return string
402
-     */
403
-    public function reg_step_url($action = '')
404
-    {
405
-        $query_args = array('step' => $this->slug());
406
-        if (! empty($action)) {
407
-            $query_args['action'] = $action;
408
-        }
409
-        // final step has no display
410
-        if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
411
-            $query_args['action'] = 'process_reg_step';
412
-        }
413
-        if ($this->checkout->revisit) {
414
-            $query_args['revisit'] = true;
415
-        }
416
-        if ($this->checkout->reg_url_link) {
417
-            $query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
418
-        }
419
-        return add_query_arg($query_args, $this->checkout->reg_page_base_url);
420
-    }
421
-
422
-
423
-    /**
424
-     * creates the default hidden inputs section
425
-     *
426
-     * @return EE_Form_Section_Proper
427
-     * @throws \EE_Error
428
-     */
429
-    public function reg_step_hidden_inputs()
430
-    {
431
-        // hidden inputs for admin registrations
432
-        if ($this->checkout->admin_request) {
433
-            return new EE_Form_Section_Proper(
434
-                array(
435
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
436
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
437
-                    'subsections'     => array(
438
-                        'next_step' => new EE_Fixed_Hidden_Input(
439
-                            array(
440
-                                'html_name' => 'next_step',
441
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
442
-                                'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
443
-                                    ? $this->checkout->next_step->slug()
444
-                                    : '',
445
-                            )
446
-                        ),
447
-                    ),
448
-                )
449
-            );
450
-        }
451
-        // hidden inputs for frontend registrations
452
-        return new EE_Form_Section_Proper(
453
-            array(
454
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
455
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
456
-                'subsections'     => array(
457
-                    'action'         => new EE_Fixed_Hidden_Input(
458
-                        array(
459
-                            'html_name' => 'action',
460
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
461
-                            'default'   => apply_filters(
462
-                                'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
463
-                                empty($this->checkout->reg_url_link)
464
-                                    ? 'process_reg_step'
465
-                                    : 'update_reg_step',
466
-                                $this
467
-                            ),
468
-                        )
469
-                    ),
470
-                    'next_step'      => new EE_Fixed_Hidden_Input(
471
-                        array(
472
-                            'html_name' => 'next_step',
473
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
474
-                            'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
475
-                                ? $this->checkout->next_step->slug()
476
-                                : '',
477
-                        )
478
-                    ),
479
-                    'e_reg_url_link' => new EE_Fixed_Hidden_Input(
480
-                        array(
481
-                            'html_name' => 'e_reg_url_link',
482
-                            'html_id'   => 'spco-reg_url_link',
483
-                            'default'   => $this->checkout->reg_url_link,
484
-                        )
485
-                    ),
486
-                    'revisit'        => new EE_Fixed_Hidden_Input(
487
-                        array(
488
-                            'html_name' => 'revisit',
489
-                            'html_id'   => 'spco-revisit',
490
-                            'default'   => $this->checkout->revisit,
491
-                        )
492
-                    ),
493
-                ),
494
-            )
495
-        );
496
-    }
497
-
498
-
499
-    /**
500
-     * generate_reg_form_for_actions
501
-     *
502
-     * @param array $actions
503
-     * @return void
504
-     */
505
-    public function generate_reg_form_for_actions($actions = array())
506
-    {
507
-        $actions = array_merge(
508
-            array(
509
-                'generate_reg_form',
510
-                'display_spco_reg_step',
511
-                'process_reg_step',
512
-                'update_reg_step',
513
-            ),
514
-            $actions
515
-        );
516
-        $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false;
517
-    }
518
-
519
-
520
-    /**
521
-     * @return string
522
-     * @throws \EE_Error
523
-     */
524
-    public function display_reg_form()
525
-    {
526
-        $html = '';
527
-        if ($this->reg_form instanceof EE_Form_Section_Proper) {
528
-            do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
529
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
530
-            if (EE_Registry::instance()->REQ->ajax) {
531
-                $this->reg_form->localize_validation_rules();
532
-                $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
533
-            }
534
-            $html .= $this->reg_form->get_html();
535
-            $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
536
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
537
-        }
538
-        return $html;
539
-    }
540
-
541
-
542
-    /**
543
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
544
-     *
545
-     * @return string
546
-     * @throws \EE_Error
547
-     */
548
-    public function reg_step_submit_button()
549
-    {
550
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
551
-            return '';
552
-        }
553
-        ob_start();
554
-        do_action(
555
-            'AHEE__before_spco_whats_next_buttons',
556
-            $this->slug(),
557
-            $this->checkout->next_step->slug(),
558
-            $this->checkout
559
-        );
560
-        $html = ob_get_clean();
561
-        // generate submit button
562
-        $sbmt_btn = new EE_Submit_Input(
563
-            array(
564
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
565
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
566
-                'html_class'            => 'spco-next-step-btn',
567
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
568
-                'default'               => $this->submit_button_text(),
569
-            )
570
-        );
571
-        $sbmt_btn->set_button_css_attributes(true, 'large');
572
-        $sbmt_btn_html = $sbmt_btn->get_html_for_input();
573
-        $html .= EEH_HTML::div(
574
-            apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this),
575
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
576
-            'spco-whats-next-buttons'
577
-        );
578
-        return $html;
579
-    }
580
-
581
-
582
-    /**
583
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
584
-     *
585
-     * @return string
586
-     */
587
-    public function div_class()
588
-    {
589
-        return $this->is_current_step() ? '' : ' hidden';
590
-    }
591
-
592
-
593
-    /**
594
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
595
-     *
596
-     * @return string
597
-     */
598
-    public function edit_lnk_url()
599
-    {
600
-        return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url);
601
-    }
602
-
603
-
604
-    /**
605
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
606
-     *
607
-     * @return string
608
-     */
609
-    public function edit_link_class()
610
-    {
611
-        return $this->is_current_step() ? ' hidden' : '';
612
-    }
613
-
614
-
615
-    /**
616
-     * update_checkout with changes that have been made to the cart
617
-     *
618
-     * @return void
619
-     * @throws \EE_Error
620
-     */
621
-    public function update_checkout()
622
-    {
623
-        // grab the cart grand total and reset TXN total
624
-        $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
625
-        $this->checkout->stash_transaction_and_checkout();
626
-    }
627
-
628
-
629
-    /**
630
-     *    __sleep
631
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
632
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
633
-     * reg form, because if needed, it will be regenerated anyways
634
-     *
635
-     * @return array
636
-     */
637
-    public function __sleep()
638
-    {
639
-        // remove the reg form and the checkout
640
-        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout'));
641
-    }
15
+	/**
16
+	 *    $_completed - TRUE if this step has fully completed it's duties
17
+	 *
18
+	 * @access protected
19
+	 * @type bool $_completed
20
+	 */
21
+	protected $_completed = false;
22
+
23
+	/**
24
+	 *    $_is_current_step - TRUE if this is the current step
25
+	 *
26
+	 * @access protected
27
+	 * @type bool $_is_current_step
28
+	 */
29
+	protected $_is_current_step = false;
30
+
31
+	/**
32
+	 *    $_order - when the reg step should be run relative to other steps
33
+	 *
34
+	 * @access protected
35
+	 * @type int $_template
36
+	 */
37
+	protected $_order = 0;
38
+
39
+	/**
40
+	 *    $_slug - URL param for this step
41
+	 *
42
+	 * @access protected
43
+	 * @type string $_slug
44
+	 */
45
+	protected $_slug;
46
+
47
+	/**
48
+	 *    $_name - Step Name - translatable string
49
+	 *
50
+	 * @access protected
51
+	 * @type string $_slug
52
+	 */
53
+	protected $_name;
54
+
55
+	/**
56
+	 *    $_submit_button_text - translatable string that appears on this step's submit button
57
+	 *
58
+	 * @access protected
59
+	 * @type string $_slug
60
+	 */
61
+	protected $_submit_button_text;
62
+
63
+	/**
64
+	 *    $_template - template name
65
+	 *
66
+	 * @access protected
67
+	 * @type string $_template
68
+	 */
69
+	protected $_template;
70
+
71
+	/**
72
+	 *    $_reg_form_name - the form input name and id attribute
73
+	 *
74
+	 * @access protected
75
+	 * @var string $_reg_form_name
76
+	 */
77
+	protected $_reg_form_name;
78
+
79
+	/**
80
+	 *    $_success_message - text to display upon successful form submission
81
+	 *
82
+	 * @access private
83
+	 * @var string $_success_message
84
+	 */
85
+	protected $_success_message;
86
+
87
+	/**
88
+	 *    $_instructions - a brief description of how to complete the reg step.
89
+	 *    Usually displayed in conjunction with the previous step's success message.
90
+	 *
91
+	 * @access private
92
+	 * @var string $_instructions
93
+	 */
94
+	protected $_instructions;
95
+
96
+	/**
97
+	 *    $_valid_data - the normalized and validated data for this step
98
+	 *
99
+	 * @access public
100
+	 * @var array $_valid_data
101
+	 */
102
+	protected $_valid_data = array();
103
+
104
+	/**
105
+	 *    $reg_form - the registration form for this step
106
+	 *
107
+	 * @access public
108
+	 * @var EE_Form_Section_Proper $reg_form
109
+	 */
110
+	public $reg_form;
111
+
112
+	/**
113
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
114
+	 *
115
+	 * @access public
116
+	 * @var EE_Checkout $checkout
117
+	 */
118
+	public $checkout;
119
+
120
+
121
+	/**
122
+	 * @return void
123
+	 */
124
+	abstract public function translate_js_strings();
125
+
126
+
127
+	/**
128
+	 * @return void
129
+	 */
130
+	abstract public function enqueue_styles_and_scripts();
131
+
132
+
133
+	/**
134
+	 * @return boolean
135
+	 */
136
+	abstract public function initialize_reg_step();
137
+
138
+
139
+	/**
140
+	 * @return string
141
+	 */
142
+	abstract public function generate_reg_form();
143
+
144
+
145
+	/**
146
+	 * @return boolean
147
+	 */
148
+	abstract public function process_reg_step();
149
+
150
+
151
+	/**
152
+	 * @return boolean
153
+	 */
154
+	abstract public function update_reg_step();
155
+
156
+
157
+	/**
158
+	 * @return boolean
159
+	 */
160
+	public function completed()
161
+	{
162
+		return $this->_completed;
163
+	}
164
+
165
+
166
+	/**
167
+	 * set_completed - toggles $_completed to TRUE
168
+	 */
169
+	public function set_completed()
170
+	{
171
+		// DEBUG LOG
172
+		// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
173
+		$this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
174
+	}
175
+
176
+
177
+	/**
178
+	 * set_completed - toggles $_completed to FALSE
179
+	 */
180
+	public function set_not_completed()
181
+	{
182
+		$this->_completed = false;
183
+	}
184
+
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function name()
190
+	{
191
+		return $this->_name;
192
+	}
193
+
194
+
195
+	/**
196
+	 * @return string
197
+	 */
198
+	public function slug()
199
+	{
200
+		return $this->_slug;
201
+	}
202
+
203
+
204
+	/**
205
+	 * submit_button_text
206
+	 * the text that appears on the reg step form submit button
207
+	 *
208
+	 * @return string
209
+	 */
210
+	public function submit_button_text()
211
+	{
212
+		return $this->_submit_button_text;
213
+	}
214
+
215
+
216
+	/**
217
+	 * set_submit_button_text
218
+	 * sets the text that appears on the reg step form submit button
219
+	 *
220
+	 * @param string $submit_button_text
221
+	 */
222
+	public function set_submit_button_text($submit_button_text = '')
223
+	{
224
+		if (! empty($submit_button_text)) {
225
+			$this->_submit_button_text = $submit_button_text;
226
+		} elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
227
+			if ($this->checkout->revisit) {
228
+				$this->_submit_button_text = sprintf(
229
+					__('Update %s', 'event_espresso'),
230
+					$this->checkout->current_step->name()
231
+				);
232
+			} else {
233
+				$this->_submit_button_text = sprintf(
234
+					__('Proceed to %s', 'event_espresso'),
235
+					$this->checkout->next_step->name()
236
+				);
237
+			}
238
+		}
239
+		// filters the submit button text
240
+		$this->_submit_button_text = apply_filters(
241
+			'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
242
+			$this->_submit_button_text,
243
+			$this->checkout
244
+		);
245
+	}
246
+
247
+
248
+	/**
249
+	 * @param boolean $is_current_step
250
+	 */
251
+	public function set_is_current_step($is_current_step)
252
+	{
253
+		$this->_is_current_step = $is_current_step;
254
+	}
255
+
256
+
257
+	/**
258
+	 * @return boolean
259
+	 */
260
+	public function is_current_step()
261
+	{
262
+		return $this->_is_current_step;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @return boolean
268
+	 */
269
+	public function is_final_step()
270
+	{
271
+		return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param int $order
277
+	 */
278
+	public function set_order($order)
279
+	{
280
+		$this->_order = $order;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return int
286
+	 */
287
+	public function order()
288
+	{
289
+		return $this->_order;
290
+	}
291
+
292
+
293
+	/**
294
+	 * @return string
295
+	 */
296
+	public function template()
297
+	{
298
+		return $this->_template;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return string
304
+	 */
305
+	public function success_message()
306
+	{
307
+		return $this->_success_message;
308
+	}
309
+
310
+
311
+	/**
312
+	 * _set_success_message
313
+	 *
314
+	 * @param string $success_message
315
+	 */
316
+	protected function _set_success_message($success_message)
317
+	{
318
+		$this->_success_message = $success_message;
319
+	}
320
+
321
+
322
+	/**
323
+	 * _reset_success_message
324
+	 *
325
+	 * @return void
326
+	 */
327
+	protected function _reset_success_message()
328
+	{
329
+		$this->_success_message = '';
330
+	}
331
+
332
+
333
+	/**
334
+	 * @return string
335
+	 */
336
+	public function _instructions()
337
+	{
338
+		return $this->_instructions;
339
+	}
340
+
341
+
342
+	/**
343
+	 * @param string $instructions
344
+	 */
345
+	public function set_instructions($instructions)
346
+	{
347
+		$this->_instructions = apply_filters(
348
+			'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
349
+			$instructions,
350
+			$this
351
+		);
352
+	}
353
+
354
+
355
+	/**
356
+	 * @param array $valid_data
357
+	 */
358
+	public function set_valid_data($valid_data)
359
+	{
360
+		$this->_valid_data = $valid_data;
361
+	}
362
+
363
+
364
+	/**
365
+	 * @return array
366
+	 */
367
+	public function valid_data()
368
+	{
369
+		if (empty($this->_valid_data)) {
370
+			$this->_valid_data = $this->reg_form->valid_data();
371
+		}
372
+		return $this->_valid_data;
373
+	}
374
+
375
+
376
+	/**
377
+	 * @return string
378
+	 */
379
+	public function reg_form_name()
380
+	{
381
+		if (empty($this->_reg_form_name)) {
382
+			$this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
383
+		}
384
+		return $this->_reg_form_name;
385
+	}
386
+
387
+
388
+	/**
389
+	 * @param string $reg_form_name
390
+	 */
391
+	protected function set_reg_form_name($reg_form_name)
392
+	{
393
+		$this->_reg_form_name = $reg_form_name;
394
+	}
395
+
396
+
397
+	/**
398
+	 * reg_step_url
399
+	 *
400
+	 * @param string $action
401
+	 * @return string
402
+	 */
403
+	public function reg_step_url($action = '')
404
+	{
405
+		$query_args = array('step' => $this->slug());
406
+		if (! empty($action)) {
407
+			$query_args['action'] = $action;
408
+		}
409
+		// final step has no display
410
+		if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
411
+			$query_args['action'] = 'process_reg_step';
412
+		}
413
+		if ($this->checkout->revisit) {
414
+			$query_args['revisit'] = true;
415
+		}
416
+		if ($this->checkout->reg_url_link) {
417
+			$query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
418
+		}
419
+		return add_query_arg($query_args, $this->checkout->reg_page_base_url);
420
+	}
421
+
422
+
423
+	/**
424
+	 * creates the default hidden inputs section
425
+	 *
426
+	 * @return EE_Form_Section_Proper
427
+	 * @throws \EE_Error
428
+	 */
429
+	public function reg_step_hidden_inputs()
430
+	{
431
+		// hidden inputs for admin registrations
432
+		if ($this->checkout->admin_request) {
433
+			return new EE_Form_Section_Proper(
434
+				array(
435
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
436
+					'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
437
+					'subsections'     => array(
438
+						'next_step' => new EE_Fixed_Hidden_Input(
439
+							array(
440
+								'html_name' => 'next_step',
441
+								'html_id'   => 'spco-' . $this->slug() . '-next-step',
442
+								'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
443
+									? $this->checkout->next_step->slug()
444
+									: '',
445
+							)
446
+						),
447
+					),
448
+				)
449
+			);
450
+		}
451
+		// hidden inputs for frontend registrations
452
+		return new EE_Form_Section_Proper(
453
+			array(
454
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
455
+				'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
456
+				'subsections'     => array(
457
+					'action'         => new EE_Fixed_Hidden_Input(
458
+						array(
459
+							'html_name' => 'action',
460
+							'html_id'   => 'spco-' . $this->slug() . '-action',
461
+							'default'   => apply_filters(
462
+								'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
463
+								empty($this->checkout->reg_url_link)
464
+									? 'process_reg_step'
465
+									: 'update_reg_step',
466
+								$this
467
+							),
468
+						)
469
+					),
470
+					'next_step'      => new EE_Fixed_Hidden_Input(
471
+						array(
472
+							'html_name' => 'next_step',
473
+							'html_id'   => 'spco-' . $this->slug() . '-next-step',
474
+							'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
475
+								? $this->checkout->next_step->slug()
476
+								: '',
477
+						)
478
+					),
479
+					'e_reg_url_link' => new EE_Fixed_Hidden_Input(
480
+						array(
481
+							'html_name' => 'e_reg_url_link',
482
+							'html_id'   => 'spco-reg_url_link',
483
+							'default'   => $this->checkout->reg_url_link,
484
+						)
485
+					),
486
+					'revisit'        => new EE_Fixed_Hidden_Input(
487
+						array(
488
+							'html_name' => 'revisit',
489
+							'html_id'   => 'spco-revisit',
490
+							'default'   => $this->checkout->revisit,
491
+						)
492
+					),
493
+				),
494
+			)
495
+		);
496
+	}
497
+
498
+
499
+	/**
500
+	 * generate_reg_form_for_actions
501
+	 *
502
+	 * @param array $actions
503
+	 * @return void
504
+	 */
505
+	public function generate_reg_form_for_actions($actions = array())
506
+	{
507
+		$actions = array_merge(
508
+			array(
509
+				'generate_reg_form',
510
+				'display_spco_reg_step',
511
+				'process_reg_step',
512
+				'update_reg_step',
513
+			),
514
+			$actions
515
+		);
516
+		$this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false;
517
+	}
518
+
519
+
520
+	/**
521
+	 * @return string
522
+	 * @throws \EE_Error
523
+	 */
524
+	public function display_reg_form()
525
+	{
526
+		$html = '';
527
+		if ($this->reg_form instanceof EE_Form_Section_Proper) {
528
+			do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
529
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
530
+			if (EE_Registry::instance()->REQ->ajax) {
531
+				$this->reg_form->localize_validation_rules();
532
+				$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
533
+			}
534
+			$html .= $this->reg_form->get_html();
535
+			$html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
536
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
537
+		}
538
+		return $html;
539
+	}
540
+
541
+
542
+	/**
543
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
544
+	 *
545
+	 * @return string
546
+	 * @throws \EE_Error
547
+	 */
548
+	public function reg_step_submit_button()
549
+	{
550
+		if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
551
+			return '';
552
+		}
553
+		ob_start();
554
+		do_action(
555
+			'AHEE__before_spco_whats_next_buttons',
556
+			$this->slug(),
557
+			$this->checkout->next_step->slug(),
558
+			$this->checkout
559
+		);
560
+		$html = ob_get_clean();
561
+		// generate submit button
562
+		$sbmt_btn = new EE_Submit_Input(
563
+			array(
564
+				'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
565
+				'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
566
+				'html_class'            => 'spco-next-step-btn',
567
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
568
+				'default'               => $this->submit_button_text(),
569
+			)
570
+		);
571
+		$sbmt_btn->set_button_css_attributes(true, 'large');
572
+		$sbmt_btn_html = $sbmt_btn->get_html_for_input();
573
+		$html .= EEH_HTML::div(
574
+			apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this),
575
+			'spco-' . $this->slug() . '-whats-next-buttons-dv',
576
+			'spco-whats-next-buttons'
577
+		);
578
+		return $html;
579
+	}
580
+
581
+
582
+	/**
583
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
584
+	 *
585
+	 * @return string
586
+	 */
587
+	public function div_class()
588
+	{
589
+		return $this->is_current_step() ? '' : ' hidden';
590
+	}
591
+
592
+
593
+	/**
594
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
595
+	 *
596
+	 * @return string
597
+	 */
598
+	public function edit_lnk_url()
599
+	{
600
+		return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url);
601
+	}
602
+
603
+
604
+	/**
605
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
606
+	 *
607
+	 * @return string
608
+	 */
609
+	public function edit_link_class()
610
+	{
611
+		return $this->is_current_step() ? ' hidden' : '';
612
+	}
613
+
614
+
615
+	/**
616
+	 * update_checkout with changes that have been made to the cart
617
+	 *
618
+	 * @return void
619
+	 * @throws \EE_Error
620
+	 */
621
+	public function update_checkout()
622
+	{
623
+		// grab the cart grand total and reset TXN total
624
+		$this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
625
+		$this->checkout->stash_transaction_and_checkout();
626
+	}
627
+
628
+
629
+	/**
630
+	 *    __sleep
631
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
632
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
633
+	 * reg form, because if needed, it will be regenerated anyways
634
+	 *
635
+	 * @return array
636
+	 */
637
+	public function __sleep()
638
+	{
639
+		// remove the reg form and the checkout
640
+		return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout'));
641
+	}
642 642
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function set_submit_button_text($submit_button_text = '')
223 223
     {
224
-        if (! empty($submit_button_text)) {
224
+        if ( ! empty($submit_button_text)) {
225 225
             $this->_submit_button_text = $submit_button_text;
226 226
         } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
227 227
             if ($this->checkout->revisit) {
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     public function reg_form_name()
380 380
     {
381 381
         if (empty($this->_reg_form_name)) {
382
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
382
+            $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form');
383 383
         }
384 384
         return $this->_reg_form_name;
385 385
     }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     public function reg_step_url($action = '')
404 404
     {
405 405
         $query_args = array('step' => $this->slug());
406
-        if (! empty($action)) {
406
+        if ( ! empty($action)) {
407 407
             $query_args['action'] = $action;
408 408
         }
409 409
         // final step has no display
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
             return new EE_Form_Section_Proper(
434 434
                 array(
435 435
                     'layout_strategy' => new EE_Div_Per_Section_Layout(),
436
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
436
+                    'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
437 437
                     'subsections'     => array(
438 438
                         'next_step' => new EE_Fixed_Hidden_Input(
439 439
                             array(
440 440
                                 'html_name' => 'next_step',
441
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
441
+                                'html_id'   => 'spco-'.$this->slug().'-next-step',
442 442
                                 'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
443 443
                                     ? $this->checkout->next_step->slug()
444 444
                                     : '',
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
         return new EE_Form_Section_Proper(
453 453
             array(
454 454
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
455
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
455
+                'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
456 456
                 'subsections'     => array(
457 457
                     'action'         => new EE_Fixed_Hidden_Input(
458 458
                         array(
459 459
                             'html_name' => 'action',
460
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
460
+                            'html_id'   => 'spco-'.$this->slug().'-action',
461 461
                             'default'   => apply_filters(
462 462
                                 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
463 463
                                 empty($this->checkout->reg_url_link)
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                     'next_step'      => new EE_Fixed_Hidden_Input(
471 471
                         array(
472 472
                             'html_name' => 'next_step',
473
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
473
+                            'html_id'   => 'spco-'.$this->slug().'-next-step',
474 474
                             'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
475 475
                                 ? $this->checkout->next_step->slug()
476 476
                                 : '',
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      */
548 548
     public function reg_step_submit_button()
549 549
     {
550
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
550
+        if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
551 551
             return '';
552 552
         }
553 553
         ob_start();
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
         // generate submit button
562 562
         $sbmt_btn = new EE_Submit_Input(
563 563
             array(
564
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
565
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
564
+                'html_name'             => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
565
+                'html_id'               => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
566 566
                 'html_class'            => 'spco-next-step-btn',
567
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
567
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
568 568
                 'default'               => $this->submit_button_text(),
569 569
             )
570 570
         );
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
         $sbmt_btn_html = $sbmt_btn->get_html_for_input();
573 573
         $html .= EEH_HTML::div(
574 574
             apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this),
575
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
575
+            'spco-'.$this->slug().'-whats-next-buttons-dv',
576 576
             'spco-whats-next-buttons'
577 577
         );
578 578
         return $html;
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 2 patches
Indentation   +2885 added lines, -2885 removed lines patch added patch discarded remove patch
@@ -12,2889 +12,2889 @@
 block discarded – undo
12 12
 class EE_SPCO_Reg_Step_Payment_Options extends EE_SPCO_Reg_Step
13 13
 {
14 14
 
15
-    /**
16
-     * @access protected
17
-     * @var EE_Line_Item_Display $Line_Item_Display
18
-     */
19
-    protected $line_item_display;
20
-
21
-    /**
22
-     * @access protected
23
-     * @var boolean $handle_IPN_in_this_request
24
-     */
25
-    protected $handle_IPN_in_this_request = false;
26
-
27
-
28
-    /**
29
-     *    set_hooks - for hooking into EE Core, other modules, etc
30
-     *
31
-     * @access    public
32
-     * @return    void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        add_filter(
37
-            'FHEE__SPCO__EE_Line_Item_Filter_Collection',
38
-            array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
39
-        );
40
-        add_action(
41
-            'wp_ajax_switch_spco_billing_form',
42
-            array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
43
-        );
44
-        add_action(
45
-            'wp_ajax_nopriv_switch_spco_billing_form',
46
-            array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
47
-        );
48
-        add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
49
-        add_action(
50
-            'wp_ajax_nopriv_save_payer_details',
51
-            array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
52
-        );
53
-        add_action(
54
-            'wp_ajax_get_transaction_details_for_gateways',
55
-            array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
56
-        );
57
-        add_action(
58
-            'wp_ajax_nopriv_get_transaction_details_for_gateways',
59
-            array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
60
-        );
61
-        add_filter(
62
-            'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
63
-            array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
64
-            10,
65
-            1
66
-        );
67
-    }
68
-
69
-
70
-    /**
71
-     *    ajax switch_spco_billing_form
72
-     *
73
-     * @throws \EE_Error
74
-     */
75
-    public static function switch_spco_billing_form()
76
-    {
77
-        EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
78
-    }
79
-
80
-
81
-    /**
82
-     *    ajax save_payer_details
83
-     *
84
-     * @throws \EE_Error
85
-     */
86
-    public static function save_payer_details()
87
-    {
88
-        EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
89
-    }
90
-
91
-
92
-    /**
93
-     *    ajax get_transaction_details
94
-     *
95
-     * @throws \EE_Error
96
-     */
97
-    public static function get_transaction_details()
98
-    {
99
-        EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
100
-    }
101
-
102
-
103
-    /**
104
-     * bypass_recaptcha_for_load_payment_method
105
-     *
106
-     * @access public
107
-     * @return array
108
-     * @throws InvalidArgumentException
109
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
110
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
111
-     */
112
-    public static function bypass_recaptcha_for_load_payment_method()
113
-    {
114
-        return array(
115
-            'EESID'  => EE_Registry::instance()->SSN->id(),
116
-            'step'   => 'payment_options',
117
-            'action' => 'spco_billing_form',
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     *    class constructor
124
-     *
125
-     * @access    public
126
-     * @param    EE_Checkout $checkout
127
-     */
128
-    public function __construct(EE_Checkout $checkout)
129
-    {
130
-        $this->_slug = 'payment_options';
131
-        $this->_name = esc_html__('Payment Options', 'event_espresso');
132
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
133
-        $this->checkout = $checkout;
134
-        $this->_reset_success_message();
135
-        $this->set_instructions(
136
-            esc_html__(
137
-                'Please select a method of payment and provide any necessary billing information before proceeding.',
138
-                'event_espresso'
139
-            )
140
-        );
141
-    }
142
-
143
-
144
-    /**
145
-     * @return null
146
-     */
147
-    public function line_item_display()
148
-    {
149
-        return $this->line_item_display;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param null $line_item_display
155
-     */
156
-    public function set_line_item_display($line_item_display)
157
-    {
158
-        $this->line_item_display = $line_item_display;
159
-    }
160
-
161
-
162
-    /**
163
-     * @return boolean
164
-     */
165
-    public function handle_IPN_in_this_request()
166
-    {
167
-        return $this->handle_IPN_in_this_request;
168
-    }
169
-
170
-
171
-    /**
172
-     * @param boolean $handle_IPN_in_this_request
173
-     */
174
-    public function set_handle_IPN_in_this_request($handle_IPN_in_this_request)
175
-    {
176
-        $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177
-    }
178
-
179
-
180
-    /**
181
-     * translate_js_strings
182
-     *
183
-     * @return void
184
-     */
185
-    public function translate_js_strings()
186
-    {
187
-        EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__(
188
-            'Please select a method of payment in order to continue.',
189
-            'event_espresso'
190
-        );
191
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
192
-            'A valid method of payment could not be determined. Please refresh the page and try again.',
193
-            'event_espresso'
194
-        );
195
-        EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__(
196
-            'Forwarding to Secure Payment Provider.',
197
-            'event_espresso'
198
-        );
199
-    }
200
-
201
-
202
-    /**
203
-     * enqueue_styles_and_scripts
204
-     *
205
-     * @return void
206
-     * @throws EE_Error
207
-     * @throws InvalidArgumentException
208
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
209
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
210
-     */
211
-    public function enqueue_styles_and_scripts()
212
-    {
213
-        $transaction = $this->checkout->transaction;
214
-        // if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
-        if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216
-            return;
217
-        }
218
-        foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
219
-            $transaction,
220
-            EEM_Payment_Method::scope_cart
221
-        ) as $payment_method) {
222
-            $type_obj = $payment_method->type_obj();
223
-            if ($type_obj instanceof EE_PMT_Base) {
224
-                $billing_form = $type_obj->generate_new_billing_form($transaction);
225
-                if ($billing_form instanceof EE_Form_Section_Proper) {
226
-                    $billing_form->enqueue_js();
227
-                }
228
-            }
229
-        }
230
-    }
231
-
232
-
233
-    /**
234
-     * initialize_reg_step
235
-     *
236
-     * @return bool
237
-     * @throws EE_Error
238
-     * @throws InvalidArgumentException
239
-     * @throws ReflectionException
240
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
241
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
242
-     */
243
-    public function initialize_reg_step()
244
-    {
245
-        // TODO: if /when we implement donations, then this will need overriding
246
-        if (// don't need payment options for:
247
-            // registrations made via the admin
248
-            // completed transactions
249
-            // overpaid transactions
250
-            // $ 0.00 transactions(no payment required)
251
-            ! $this->checkout->payment_required()
252
-            // but do NOT remove if current action being called belongs to this reg step
253
-            && ! is_callable(array($this, $this->checkout->action))
254
-            && ! $this->completed()
255
-        ) {
256
-            // and if so, then we no longer need the Payment Options step
257
-            if ($this->is_current_step()) {
258
-                $this->checkout->generate_reg_form = false;
259
-            }
260
-            $this->checkout->remove_reg_step($this->_slug);
261
-            // DEBUG LOG
262
-            // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
263
-            return false;
264
-        }
265
-        // load EEM_Payment_Method
266
-        EE_Registry::instance()->load_model('Payment_Method');
267
-        // get all active payment methods
268
-        $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
269
-            $this->checkout->transaction,
270
-            EEM_Payment_Method::scope_cart
271
-        );
272
-        return true;
273
-    }
274
-
275
-
276
-    /**
277
-     * @return EE_Form_Section_Proper
278
-     * @throws EE_Error
279
-     * @throws InvalidArgumentException
280
-     * @throws ReflectionException
281
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
282
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
283
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
284
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
285
-     */
286
-    public function generate_reg_form()
287
-    {
288
-        // reset in case someone changes their mind
289
-        $this->_reset_selected_method_of_payment();
290
-        // set some defaults
291
-        $this->checkout->selected_method_of_payment = 'payments_closed';
292
-        $registrations_requiring_payment = array();
293
-        $registrations_for_free_events = array();
294
-        $registrations_requiring_pre_approval = array();
295
-        $sold_out_events = array();
296
-        $insufficient_spaces_available = array();
297
-        $no_payment_required = true;
298
-        // loop thru registrations to gather info
299
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
300
-        $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
301
-            $registrations,
302
-            $this->checkout->revisit
303
-        );
304
-        foreach ($registrations as $REG_ID => $registration) {
305
-            /** @var $registration EE_Registration */
306
-            // has this registration lost it's space ?
307
-            if (isset($ejected_registrations[ $REG_ID ])) {
308
-                if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
-                    $sold_out_events[ $registration->event()->ID() ] = $registration->event();
310
-                } else {
311
-                    $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
312
-                }
313
-                continue;
314
-            }
315
-            // event requires admin approval
316
-            if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317
-                // add event to list of events with pre-approval reg status
318
-                $registrations_requiring_pre_approval[ $REG_ID ] = $registration;
319
-                do_action(
320
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321
-                    $registration->event(),
322
-                    $this
323
-                );
324
-                continue;
325
-            }
326
-            if ($this->checkout->revisit
327
-                && $registration->status_ID() !== EEM_Registration::status_id_approved
328
-                && (
329
-                    $registration->event()->is_sold_out()
330
-                    || $registration->event()->is_sold_out(true)
331
-                )
332
-            ) {
333
-                // add event to list of events that are sold out
334
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
335
-                do_action(
336
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337
-                    $registration->event(),
338
-                    $this
339
-                );
340
-                continue;
341
-            }
342
-            // are they allowed to pay now and is there monies owing?
343
-            if ($registration->owes_monies_and_can_pay()) {
344
-                $registrations_requiring_payment[ $REG_ID ] = $registration;
345
-                do_action(
346
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347
-                    $registration->event(),
348
-                    $this
349
-                );
350
-            } elseif (! $this->checkout->revisit
351
-                      && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352
-                      && $registration->ticket()->is_free()
353
-            ) {
354
-                $registrations_for_free_events[ $registration->event()->ID() ] = $registration;
355
-            }
356
-        }
357
-        $subsections = array();
358
-        // now decide which template to load
359
-        if (! empty($sold_out_events)) {
360
-            $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361
-        }
362
-        if (! empty($insufficient_spaces_available)) {
363
-            $subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364
-                $insufficient_spaces_available
365
-            );
366
-        }
367
-        if (! empty($registrations_requiring_pre_approval)) {
368
-            $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369
-                $registrations_requiring_pre_approval
370
-            );
371
-        }
372
-        if (! empty($registrations_for_free_events)) {
373
-            $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374
-        }
375
-        if (! empty($registrations_requiring_payment)) {
376
-            if ($this->checkout->amount_owing > 0) {
377
-                // autoload Line_Item_Display classes
378
-                EEH_Autoloader::register_line_item_filter_autoloaders();
379
-                $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
380
-                    apply_filters(
381
-                        'FHEE__SPCO__EE_Line_Item_Filter_Collection',
382
-                        new EE_Line_Item_Filter_Collection()
383
-                    ),
384
-                    $this->checkout->cart->get_grand_total()
385
-                );
386
-                /** @var EE_Line_Item $filtered_line_item_tree */
387
-                $filtered_line_item_tree = $line_item_filter_processor->process();
388
-                EEH_Autoloader::register_line_item_display_autoloaders();
389
-                $this->set_line_item_display(new EE_Line_Item_Display('spco'));
390
-                $subsections['payment_options'] = $this->_display_payment_options(
391
-                    $this->line_item_display->display_line_item(
392
-                        $filtered_line_item_tree,
393
-                        array('registrations' => $registrations)
394
-                    )
395
-                );
396
-                $this->checkout->amount_owing = $filtered_line_item_tree->total();
397
-                $this->_apply_registration_payments_to_amount_owing($registrations);
398
-            }
399
-            $no_payment_required = false;
400
-        } else {
401
-            $this->_hide_reg_step_submit_button_if_revisit();
402
-        }
403
-        $this->_save_selected_method_of_payment();
404
-
405
-        $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
406
-        $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
407
-
408
-        return new EE_Form_Section_Proper(
409
-            array(
410
-                'name'            => $this->reg_form_name(),
411
-                'html_id'         => $this->reg_form_name(),
412
-                'subsections'     => $subsections,
413
-                'layout_strategy' => new EE_No_Layout(),
414
-            )
415
-        );
416
-    }
417
-
418
-
419
-    /**
420
-     * add line item filters required for this reg step
421
-     * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks():
422
-     *        add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options',
423
-     *        'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the
424
-     *        payment options reg step, can apply these filters via the following: apply_filters(
425
-     *        'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing
426
-     *        filter collection by passing that instead of instantiating a new collection
427
-     *
428
-     * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
429
-     * @return EE_Line_Item_Filter_Collection
430
-     * @throws EE_Error
431
-     * @throws InvalidArgumentException
432
-     * @throws ReflectionException
433
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
434
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
435
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
436
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
437
-     */
438
-    public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439
-    {
440
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
441
-            return $line_item_filter_collection;
442
-        }
443
-        if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444
-            return $line_item_filter_collection;
445
-        }
446
-        if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447
-            return $line_item_filter_collection;
448
-        }
449
-        $line_item_filter_collection->add(
450
-            new EE_Billable_Line_Item_Filter(
451
-                EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
452
-                    EE_Registry::instance()->SSN->checkout()->transaction->registrations(
453
-                        EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
454
-                    )
455
-                )
456
-            )
457
-        );
458
-        $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
459
-        return $line_item_filter_collection;
460
-    }
461
-
462
-
463
-    /**
464
-     * remove_ejected_registrations
465
-     * if a registrant has lost their potential space at an event due to lack of payment,
466
-     * then this method removes them from the list of registrations being paid for during this request
467
-     *
468
-     * @param \EE_Registration[] $registrations
469
-     * @return EE_Registration[]
470
-     * @throws EE_Error
471
-     * @throws InvalidArgumentException
472
-     * @throws ReflectionException
473
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
474
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
475
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
476
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
477
-     */
478
-    public static function remove_ejected_registrations(array $registrations)
479
-    {
480
-        $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
481
-            $registrations,
482
-            EE_Registry::instance()->SSN->checkout()->revisit
483
-        );
484
-        foreach ($registrations as $REG_ID => $registration) {
485
-            // has this registration lost it's space ?
486
-            if (isset($ejected_registrations[ $REG_ID ])) {
487
-                unset($registrations[ $REG_ID ]);
488
-                continue;
489
-            }
490
-        }
491
-        return $registrations;
492
-    }
493
-
494
-
495
-    /**
496
-     * find_registrations_that_lost_their_space
497
-     * If a registrant chooses an offline payment method like Invoice,
498
-     * then no space is reserved for them at the event until they fully pay fo that site
499
-     * (unless the event's default reg status is set to APPROVED)
500
-     * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales,
501
-     * then this method will determine which registrations have lost the ability to complete the reg process.
502
-     *
503
-     * @param \EE_Registration[] $registrations
504
-     * @param bool               $revisit
505
-     * @return array
506
-     * @throws EE_Error
507
-     * @throws InvalidArgumentException
508
-     * @throws ReflectionException
509
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
510
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
511
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
512
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
513
-     */
514
-    public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false)
515
-    {
516
-        // registrations per event
517
-        $event_reg_count = array();
518
-        // spaces left per event
519
-        $event_spaces_remaining = array();
520
-        // tickets left sorted by ID
521
-        $tickets_remaining = array();
522
-        // registrations that have lost their space
523
-        $ejected_registrations = array();
524
-        foreach ($registrations as $REG_ID => $registration) {
525
-            if ($registration->status_ID() === EEM_Registration::status_id_approved
526
-                || apply_filters(
527
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment',
528
-                    false,
529
-                    $registration,
530
-                    $revisit
531
-                )
532
-            ) {
533
-                continue;
534
-            }
535
-            $EVT_ID = $registration->event_ID();
536
-            $ticket = $registration->ticket();
537
-            if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
-                $tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
539
-            }
540
-            if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
-                if (! isset($event_reg_count[ $EVT_ID ])) {
542
-                    $event_reg_count[ $EVT_ID ] = 0;
543
-                }
544
-                $event_reg_count[ $EVT_ID ]++;
545
-                if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
-                    $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
547
-                }
548
-            }
549
-            if ($revisit
550
-                && ($tickets_remaining[ $ticket->ID() ] === 0
551
-                    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
552
-                )
553
-            ) {
554
-                $ejected_registrations[ $REG_ID ] = $registration->event();
555
-                if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556
-                    /** @type EE_Registration_Processor $registration_processor */
557
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
558
-                    // at this point, we should have enough details about the registrant to consider the registration
559
-                    // NOT incomplete
560
-                    $registration_processor->manually_update_registration_status(
561
-                        $registration,
562
-                        EEM_Registration::status_id_wait_list
563
-                    );
564
-                }
565
-            }
566
-        }
567
-        return $ejected_registrations;
568
-    }
569
-
570
-
571
-    /**
572
-     * _hide_reg_step_submit_button
573
-     * removes the html for the reg step submit button
574
-     * by replacing it with an empty string via filter callback
575
-     *
576
-     * @return void
577
-     */
578
-    protected function _adjust_registration_status_if_event_old_sold()
579
-    {
580
-    }
581
-
582
-
583
-    /**
584
-     * _hide_reg_step_submit_button
585
-     * removes the html for the reg step submit button
586
-     * by replacing it with an empty string via filter callback
587
-     *
588
-     * @return void
589
-     */
590
-    protected function _hide_reg_step_submit_button_if_revisit()
591
-    {
592
-        if ($this->checkout->revisit) {
593
-            add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
594
-        }
595
-    }
596
-
597
-
598
-    /**
599
-     * sold_out_events
600
-     * displays notices regarding events that have sold out since hte registrant first signed up
601
-     *
602
-     * @param \EE_Event[] $sold_out_events_array
603
-     * @return \EE_Form_Section_Proper
604
-     * @throws \EE_Error
605
-     */
606
-    private function _sold_out_events($sold_out_events_array = array())
607
-    {
608
-        // set some defaults
609
-        $this->checkout->selected_method_of_payment = 'events_sold_out';
610
-        $sold_out_events = '';
611
-        foreach ($sold_out_events_array as $sold_out_event) {
612
-            $sold_out_events .= EEH_HTML::li(
613
-                EEH_HTML::span(
614
-                    '  ' . $sold_out_event->name(),
615
-                    '',
616
-                    'dashicons dashicons-marker ee-icon-size-16 pink-text'
617
-                )
618
-            );
619
-        }
620
-        return new EE_Form_Section_Proper(
621
-            array(
622
-                'layout_strategy' => new EE_Template_Layout(
623
-                    array(
624
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
625
-                                                  . $this->_slug
626
-                                                  . DS
627
-                                                  . 'sold_out_events.template.php',
628
-                        'template_args'        => apply_filters(
629
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
630
-                            array(
631
-                                'sold_out_events'     => $sold_out_events,
632
-                                'sold_out_events_msg' => apply_filters(
633
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
634
-                                    sprintf(
635
-                                        esc_html__(
636
-                                            'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        '<strong>',
640
-                                        '</strong>',
641
-                                        '<br />'
642
-                                    )
643
-                                ),
644
-                            )
645
-                        ),
646
-                    )
647
-                ),
648
-            )
649
-        );
650
-    }
651
-
652
-
653
-    /**
654
-     * _insufficient_spaces_available
655
-     * displays notices regarding events that do not have enough remaining spaces
656
-     * to satisfy the current number of registrations looking to pay
657
-     *
658
-     * @param \EE_Event[] $insufficient_spaces_events_array
659
-     * @return \EE_Form_Section_Proper
660
-     * @throws \EE_Error
661
-     */
662
-    private function _insufficient_spaces_available($insufficient_spaces_events_array = array())
663
-    {
664
-        // set some defaults
665
-        $this->checkout->selected_method_of_payment = 'invoice';
666
-        $insufficient_space_events = '';
667
-        foreach ($insufficient_spaces_events_array as $event) {
668
-            if ($event instanceof EE_Event) {
669
-                $insufficient_space_events .= EEH_HTML::li(
670
-                    EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
671
-                );
672
-            }
673
-        }
674
-        return new EE_Form_Section_Proper(
675
-            array(
676
-                'subsections'     => array(
677
-                    'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
678
-                    'extra_hidden_inputs'   => $this->_extra_hidden_inputs(),
679
-                ),
680
-                'layout_strategy' => new EE_Template_Layout(
681
-                    array(
682
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
683
-                                                  . $this->_slug
684
-                                                  . DS
685
-                                                  . 'sold_out_events.template.php',
686
-                        'template_args'        => apply_filters(
687
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
688
-                            array(
689
-                                'sold_out_events'     => $insufficient_space_events,
690
-                                'sold_out_events_msg' => apply_filters(
691
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg',
692
-                                    esc_html__(
693
-                                        'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
694
-                                        'event_espresso'
695
-                                    )
696
-                                ),
697
-                            )
698
-                        ),
699
-                    )
700
-                ),
701
-            )
702
-        );
703
-    }
704
-
705
-
706
-    /**
707
-     * registrations_requiring_pre_approval
708
-     *
709
-     * @param array $registrations_requiring_pre_approval
710
-     * @return EE_Form_Section_Proper
711
-     * @throws EE_Error
712
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
713
-     */
714
-    private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array())
715
-    {
716
-        $events_requiring_pre_approval = '';
717
-        foreach ($registrations_requiring_pre_approval as $registration) {
718
-            if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
719
-                $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
720
-                    EEH_HTML::span(
721
-                        '',
722
-                        '',
723
-                        'dashicons dashicons-marker ee-icon-size-16 orange-text'
724
-                    )
725
-                    . EEH_HTML::span($registration->event()->name(), '', 'orange-text')
726
-                );
727
-            }
728
-        }
729
-        return new EE_Form_Section_Proper(
730
-            array(
731
-                'layout_strategy' => new EE_Template_Layout(
732
-                    array(
733
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
734
-                                                  . $this->_slug
735
-                                                  . DS
736
-                                                  . 'events_requiring_pre_approval.template.php', // layout_template
737
-                        'template_args'        => apply_filters(
738
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
739
-                            array(
740
-                                'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
741
-                                'events_requiring_pre_approval_msg' => apply_filters(
742
-                                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
743
-                                    esc_html__(
744
-                                        'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
745
-                                        'event_espresso'
746
-                                    )
747
-                                ),
748
-                            )
749
-                        ),
750
-                    )
751
-                ),
752
-            )
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * _no_payment_required
759
-     *
760
-     * @param \EE_Event[] $registrations_for_free_events
761
-     * @return \EE_Form_Section_Proper
762
-     * @throws \EE_Error
763
-     */
764
-    private function _no_payment_required($registrations_for_free_events = array())
765
-    {
766
-        // set some defaults
767
-        $this->checkout->selected_method_of_payment = 'no_payment_required';
768
-        // generate no_payment_required form
769
-        return new EE_Form_Section_Proper(
770
-            array(
771
-                'layout_strategy' => new EE_Template_Layout(
772
-                    array(
773
-                        'layout_template_file' => SPCO_REG_STEPS_PATH
774
-                                                  . $this->_slug
775
-                                                  . DS
776
-                                                  . 'no_payment_required.template.php', // layout_template
777
-                        'template_args'        => apply_filters(
778
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
779
-                            array(
780
-                                'revisit'                       => $this->checkout->revisit,
781
-                                'registrations'                 => array(),
782
-                                'ticket_count'                  => array(),
783
-                                'registrations_for_free_events' => $registrations_for_free_events,
784
-                                'no_payment_required_msg'       => EEH_HTML::p(
785
-                                    esc_html__('This is a free event, so no billing will occur.', 'event_espresso')
786
-                                ),
787
-                            )
788
-                        ),
789
-                    )
790
-                ),
791
-            )
792
-        );
793
-    }
794
-
795
-
796
-    /**
797
-     * _display_payment_options
798
-     *
799
-     * @param string $transaction_details
800
-     * @return EE_Form_Section_Proper
801
-     * @throws EE_Error
802
-     * @throws InvalidArgumentException
803
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
804
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
805
-     */
806
-    private function _display_payment_options($transaction_details = '')
807
-    {
808
-        // has method_of_payment been set by no-js user?
809
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
810
-        // build payment options form
811
-        return apply_filters(
812
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form',
813
-            new EE_Form_Section_Proper(
814
-                array(
815
-                    'subsections'     => array(
816
-                        'before_payment_options' => apply_filters(
817
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
818
-                            new EE_Form_Section_Proper(
819
-                                array('layout_strategy' => new EE_Div_Per_Section_Layout())
820
-                            )
821
-                        ),
822
-                        'payment_options'        => $this->_setup_payment_options(),
823
-                        'after_payment_options'  => apply_filters(
824
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
825
-                            new EE_Form_Section_Proper(
826
-                                array('layout_strategy' => new EE_Div_Per_Section_Layout())
827
-                            )
828
-                        ),
829
-                    ),
830
-                    'layout_strategy' => new EE_Template_Layout(
831
-                        array(
832
-                            'layout_template_file' => $this->_template,
833
-                            'template_args'        => apply_filters(
834
-                                'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
835
-                                array(
836
-                                    'reg_count'                 => $this->line_item_display->total_items(),
837
-                                    'transaction_details'       => $transaction_details,
838
-                                    'available_payment_methods' => array(),
839
-                                )
840
-                            ),
841
-                        )
842
-                    ),
843
-                )
844
-            )
845
-        );
846
-    }
847
-
848
-
849
-    /**
850
-     * _extra_hidden_inputs
851
-     *
852
-     * @param bool $no_payment_required
853
-     * @return \EE_Form_Section_Proper
854
-     * @throws \EE_Error
855
-     */
856
-    private function _extra_hidden_inputs($no_payment_required = true)
857
-    {
858
-        return new EE_Form_Section_Proper(
859
-            array(
860
-                'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
861
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
862
-                'subsections'     => array(
863
-                    'spco_no_payment_required' => new EE_Hidden_Input(
864
-                        array(
865
-                            'normalization_strategy' => new EE_Boolean_Normalization(),
866
-                            'html_name'              => 'spco_no_payment_required',
867
-                            'html_id'                => 'spco-no-payment-required-payment_options',
868
-                            'default'                => $no_payment_required,
869
-                        )
870
-                    ),
871
-                    'spco_transaction_id'      => new EE_Fixed_Hidden_Input(
872
-                        array(
873
-                            'normalization_strategy' => new EE_Int_Normalization(),
874
-                            'html_name'              => 'spco_transaction_id',
875
-                            'html_id'                => 'spco-transaction-id',
876
-                            'default'                => $this->checkout->transaction->ID(),
877
-                        )
878
-                    ),
879
-                ),
880
-            )
881
-        );
882
-    }
883
-
884
-
885
-    /**
886
-     *    _apply_registration_payments_to_amount_owing
887
-     *
888
-     * @access protected
889
-     * @param array $registrations
890
-     * @throws EE_Error
891
-     */
892
-    protected function _apply_registration_payments_to_amount_owing(array $registrations)
893
-    {
894
-        $payments = array();
895
-        foreach ($registrations as $registration) {
896
-            if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
897
-                $payments += $registration->registration_payments();
898
-            }
899
-        }
900
-        if (! empty($payments)) {
901
-            foreach ($payments as $payment) {
902
-                if ($payment instanceof EE_Registration_Payment) {
903
-                    $this->checkout->amount_owing -= $payment->amount();
904
-                }
905
-            }
906
-        }
907
-    }
908
-
909
-
910
-    /**
911
-     *    _reset_selected_method_of_payment
912
-     *
913
-     * @access    private
914
-     * @param    bool $force_reset
915
-     * @return void
916
-     * @throws InvalidArgumentException
917
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
918
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
919
-     */
920
-    private function _reset_selected_method_of_payment($force_reset = false)
921
-    {
922
-        $reset_payment_method = $force_reset
923
-            ? true
924
-            : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
925
-        if ($reset_payment_method) {
926
-            $this->checkout->selected_method_of_payment = null;
927
-            $this->checkout->payment_method = null;
928
-            $this->checkout->billing_form = null;
929
-            $this->_save_selected_method_of_payment();
930
-        }
931
-    }
932
-
933
-
934
-    /**
935
-     * _save_selected_method_of_payment
936
-     * stores the selected_method_of_payment in the session
937
-     * so that it's available for all subsequent requests including AJAX
938
-     *
939
-     * @access        private
940
-     * @param string $selected_method_of_payment
941
-     * @return void
942
-     * @throws InvalidArgumentException
943
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
944
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
945
-     */
946
-    private function _save_selected_method_of_payment($selected_method_of_payment = '')
947
-    {
948
-        $selected_method_of_payment = ! empty($selected_method_of_payment)
949
-            ? $selected_method_of_payment
950
-            : $this->checkout->selected_method_of_payment;
951
-        EE_Registry::instance()->SSN->set_session_data(
952
-            array('selected_method_of_payment' => $selected_method_of_payment)
953
-        );
954
-    }
955
-
956
-
957
-    /**
958
-     * _setup_payment_options
959
-     *
960
-     * @return EE_Form_Section_Proper
961
-     * @throws EE_Error
962
-     * @throws InvalidArgumentException
963
-     * @throws ReflectionException
964
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
965
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
966
-     */
967
-    public function _setup_payment_options()
968
-    {
969
-        // load payment method classes
970
-        $this->checkout->available_payment_methods = $this->_get_available_payment_methods();
971
-        if (empty($this->checkout->available_payment_methods)) {
972
-            EE_Error::add_error(
973
-                apply_filters(
974
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods',
975
-                    sprintf(
976
-                        esc_html__(
977
-                            'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.',
978
-                            'event_espresso'
979
-                        ),
980
-                        '<br>',
981
-                        EE_Registry::instance()->CFG->organization->get_pretty('email')
982
-                    )
983
-                ),
984
-                __FILE__,
985
-                __FUNCTION__,
986
-                __LINE__
987
-            );
988
-        }
989
-        // switch up header depending on number of available payment methods
990
-        $payment_method_header = count($this->checkout->available_payment_methods) > 1
991
-            ? apply_filters(
992
-                'FHEE__registration_page_payment_options__method_of_payment_hdr',
993
-                esc_html__('Please Select Your Method of Payment', 'event_espresso')
994
-            )
995
-            : apply_filters(
996
-                'FHEE__registration_page_payment_options__method_of_payment_hdr',
997
-                esc_html__('Method of Payment', 'event_espresso')
998
-            );
999
-        $available_payment_methods = array(
1000
-            // display the "Payment Method" header
1001
-            'payment_method_header' => new EE_Form_Section_HTML(
1002
-                EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
1003
-            ),
1004
-        );
1005
-        // the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
1006
-        $available_payment_method_options = array();
1007
-        $default_payment_method_option = array();
1008
-        // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
1009
-        $payment_methods_billing_info = array(
1010
-            new EE_Form_Section_HTML(
1011
-                EEH_HTML::div('<br />', '', '', 'clear:both;')
1012
-            ),
1013
-        );
1014
-        // loop through payment methods
1015
-        foreach ($this->checkout->available_payment_methods as $payment_method) {
1016
-            if ($payment_method instanceof EE_Payment_Method) {
1017
-                $payment_method_button = EEH_HTML::img(
1018
-                    $payment_method->button_url(),
1019
-                    $payment_method->name(),
1020
-                    'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1021
-                    'spco-payment-method-btn-img'
1022
-                );
1023
-                // check if any payment methods are set as default
1024
-                // if payment method is already selected OR nothing is selected and this payment method should be
1025
-                // open_by_default
1026
-                if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
-                    || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028
-                ) {
1029
-                    $this->checkout->selected_method_of_payment = $payment_method->slug();
1030
-                    $this->_save_selected_method_of_payment();
1031
-                    $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1032
-                } else {
1033
-                    $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1034
-                }
1035
-                $payment_methods_billing_info[ $payment_method->slug(
1036
-                ) . '-info' ] = $this->_payment_method_billing_info(
1037
-                    $payment_method
1038
-                );
1039
-            }
1040
-        }
1041
-        // prepend available_payment_method_options with default_payment_method_option so that it appears first in list
1042
-        // of PMs
1043
-        $available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
1044
-        // now generate the actual form  inputs
1045
-        $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs(
1046
-            $available_payment_method_options
1047
-        );
1048
-        $available_payment_methods += $payment_methods_billing_info;
1049
-        // build the available payment methods form
1050
-        return new EE_Form_Section_Proper(
1051
-            array(
1052
-                'html_id'         => 'spco-available-methods-of-payment-dv',
1053
-                'subsections'     => $available_payment_methods,
1054
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1055
-            )
1056
-        );
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * _get_available_payment_methods
1062
-     *
1063
-     * @return EE_Payment_Method[]
1064
-     * @throws EE_Error
1065
-     * @throws InvalidArgumentException
1066
-     * @throws ReflectionException
1067
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1068
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1069
-     */
1070
-    protected function _get_available_payment_methods()
1071
-    {
1072
-        if (! empty($this->checkout->available_payment_methods)) {
1073
-            return $this->checkout->available_payment_methods;
1074
-        }
1075
-        $available_payment_methods = array();
1076
-        // load EEM_Payment_Method
1077
-        EE_Registry::instance()->load_model('Payment_Method');
1078
-        /** @type EEM_Payment_Method $EEM_Payment_Method */
1079
-        $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1080
-        // get all active payment methods
1081
-        $payment_methods = $EEM_Payment_Method->get_all_for_transaction(
1082
-            $this->checkout->transaction,
1083
-            EEM_Payment_Method::scope_cart
1084
-        );
1085
-        foreach ($payment_methods as $payment_method) {
1086
-            if ($payment_method instanceof EE_Payment_Method) {
1087
-                $available_payment_methods[ $payment_method->slug() ] = $payment_method;
1088
-            }
1089
-        }
1090
-        return $available_payment_methods;
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     *    _available_payment_method_inputs
1096
-     *
1097
-     * @access    private
1098
-     * @param    array $available_payment_method_options
1099
-     * @return    \EE_Form_Section_Proper
1100
-     */
1101
-    private function _available_payment_method_inputs($available_payment_method_options = array())
1102
-    {
1103
-        // generate inputs
1104
-        return new EE_Form_Section_Proper(
1105
-            array(
1106
-                'html_id'         => 'ee-available-payment-method-inputs',
1107
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1108
-                'subsections'     => array(
1109
-                    '' => new EE_Radio_Button_Input(
1110
-                        $available_payment_method_options,
1111
-                        array(
1112
-                            'html_name'          => 'selected_method_of_payment',
1113
-                            'html_class'         => 'spco-payment-method',
1114
-                            'default'            => $this->checkout->selected_method_of_payment,
1115
-                            'label_size'         => 11,
1116
-                            'enforce_label_size' => true,
1117
-                        )
1118
-                    ),
1119
-                ),
1120
-            )
1121
-        );
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     *    _payment_method_billing_info
1127
-     *
1128
-     * @access    private
1129
-     * @param    EE_Payment_Method $payment_method
1130
-     * @return EE_Form_Section_Proper
1131
-     * @throws EE_Error
1132
-     * @throws InvalidArgumentException
1133
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
-     */
1136
-    private function _payment_method_billing_info(EE_Payment_Method $payment_method)
1137
-    {
1138
-        $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1139
-            ? true
1140
-            : false;
1141
-        // generate the billing form for payment method
1142
-        $billing_form = $currently_selected
1143
-            ? $this->_get_billing_form_for_payment_method($payment_method)
1144
-            : new EE_Form_Section_HTML();
1145
-        $this->checkout->billing_form = $currently_selected
1146
-            ? $billing_form
1147
-            : $this->checkout->billing_form;
1148
-        // it's all in the details
1149
-        $info_html = EEH_HTML::h3(
1150
-            esc_html__('Important information regarding your payment', 'event_espresso'),
1151
-            '',
1152
-            'spco-payment-method-hdr'
1153
-        );
1154
-        // add some info regarding the step, either from what's saved in the admin,
1155
-        // or a default string depending on whether the PM has a billing form or not
1156
-        if ($payment_method->description()) {
1157
-            $payment_method_info = $payment_method->description();
1158
-        } elseif ($billing_form instanceof EE_Billing_Info_Form) {
1159
-            $payment_method_info = sprintf(
1160
-                esc_html__(
1161
-                    'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
1162
-                    'event_espresso'
1163
-                ),
1164
-                $this->submit_button_text()
1165
-            );
1166
-        } else {
1167
-            $payment_method_info = sprintf(
1168
-                esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1169
-                $this->submit_button_text()
1170
-            );
1171
-        }
1172
-        $info_html .= EEH_HTML::p(
1173
-            apply_filters(
1174
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info',
1175
-                $payment_method_info
1176
-            ),
1177
-            '',
1178
-            'spco-payment-method-desc ee-attention'
1179
-        );
1180
-        return new EE_Form_Section_Proper(
1181
-            array(
1182
-                'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1183
-                'html_class'      => 'spco-payment-method-info-dv',
1184
-                // only display the selected or default PM
1185
-                'html_style'      => $currently_selected ? '' : 'display:none;',
1186
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1187
-                'subsections'     => array(
1188
-                    'info'         => new EE_Form_Section_HTML($info_html),
1189
-                    'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(),
1190
-                ),
1191
-            )
1192
-        );
1193
-    }
1194
-
1195
-
1196
-    /**
1197
-     * get_billing_form_html_for_payment_method
1198
-     *
1199
-     * @access public
1200
-     * @return string
1201
-     * @throws EE_Error
1202
-     * @throws InvalidArgumentException
1203
-     * @throws ReflectionException
1204
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1205
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1206
-     */
1207
-    public function get_billing_form_html_for_payment_method()
1208
-    {
1209
-        // how have they chosen to pay?
1210
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211
-        $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213
-            return false;
1214
-        }
1215
-        if (apply_filters(
1216
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1217
-            false
1218
-        )) {
1219
-            EE_Error::add_success(
1220
-                apply_filters(
1221
-                    'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1222
-                    sprintf(
1223
-                        esc_html__(
1224
-                            'You have selected "%s" as your method of payment. Please note the important payment information below.',
1225
-                            'event_espresso'
1226
-                        ),
1227
-                        $this->checkout->payment_method->name()
1228
-                    )
1229
-                )
1230
-            );
1231
-        }
1232
-        // now generate billing form for selected method of payment
1233
-        $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1234
-        // fill form with attendee info if applicable
1235
-        if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1236
-            && $this->checkout->transaction_has_primary_registrant()
1237
-        ) {
1238
-            $payment_method_billing_form->populate_from_attendee(
1239
-                $this->checkout->transaction->primary_registration()->attendee()
1240
-            );
1241
-        }
1242
-        // and debug content
1243
-        if ($payment_method_billing_form instanceof EE_Billing_Info_Form
1244
-            && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1245
-        ) {
1246
-            $payment_method_billing_form =
1247
-                $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1248
-                    $payment_method_billing_form
1249
-                );
1250
-        }
1251
-        $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1252
-            ? $payment_method_billing_form->get_html()
1253
-            : '';
1254
-        $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1255
-        // localize validation rules for main form
1256
-        $this->checkout->current_step->reg_form->localize_validation_rules();
1257
-        $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1258
-        return true;
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * _get_billing_form_for_payment_method
1264
-     *
1265
-     * @access private
1266
-     * @param EE_Payment_Method $payment_method
1267
-     * @return EE_Billing_Info_Form|EE_Form_Section_HTML
1268
-     * @throws EE_Error
1269
-     * @throws InvalidArgumentException
1270
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1271
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1272
-     */
1273
-    private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method)
1274
-    {
1275
-        $billing_form = $payment_method->type_obj()->billing_form(
1276
-            $this->checkout->transaction,
1277
-            array('amount_owing' => $this->checkout->amount_owing)
1278
-        );
1279
-        if ($billing_form instanceof EE_Billing_Info_Form) {
1280
-            if (apply_filters(
1281
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1282
-                false
1283
-            )
1284
-                && EE_Registry::instance()->REQ->is_set('payment_method')
1285
-            ) {
1286
-                EE_Error::add_success(
1287
-                    apply_filters(
1288
-                        'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1289
-                        sprintf(
1290
-                            esc_html__(
1291
-                                'You have selected "%s" as your method of payment. Please note the important payment information below.',
1292
-                                'event_espresso'
1293
-                            ),
1294
-                            $payment_method->name()
1295
-                        )
1296
-                    )
1297
-                );
1298
-            }
1299
-            return apply_filters(
1300
-                'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
1301
-                $billing_form,
1302
-                $payment_method
1303
-            );
1304
-        }
1305
-        // no actual billing form, so return empty HTML form section
1306
-        return new EE_Form_Section_HTML();
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     * _get_selected_method_of_payment
1312
-     *
1313
-     * @access private
1314
-     * @param boolean $required whether to throw an error if the "selected_method_of_payment"
1315
-     *                          is not found in the incoming request
1316
-     * @param string  $request_param
1317
-     * @return NULL|string
1318
-     * @throws EE_Error
1319
-     * @throws InvalidArgumentException
1320
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1321
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1322
-     */
1323
-    private function _get_selected_method_of_payment(
1324
-        $required = false,
1325
-        $request_param = 'selected_method_of_payment'
1326
-    ) {
1327
-        // is selected_method_of_payment set in the request ?
1328
-        $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1329
-        if ($selected_method_of_payment) {
1330
-            // sanitize it
1331
-            $selected_method_of_payment = is_array($selected_method_of_payment)
1332
-                ? array_shift($selected_method_of_payment)
1333
-                : $selected_method_of_payment;
1334
-            $selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1335
-            // store it in the session so that it's available for all subsequent requests including AJAX
1336
-            $this->_save_selected_method_of_payment($selected_method_of_payment);
1337
-        } else {
1338
-            // or is is set in the session ?
1339
-            $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
1340
-                'selected_method_of_payment'
1341
-            );
1342
-        }
1343
-        // do ya really really gotta have it?
1344
-        if (empty($selected_method_of_payment) && $required) {
1345
-            EE_Error::add_error(
1346
-                sprintf(
1347
-                    esc_html__(
1348
-                        'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.',
1349
-                        'event_espresso'
1350
-                    ),
1351
-                    '<br/>',
1352
-                    '<br/>',
1353
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
1354
-                ),
1355
-                __FILE__,
1356
-                __FUNCTION__,
1357
-                __LINE__
1358
-            );
1359
-            return null;
1360
-        }
1361
-        return $selected_method_of_payment;
1362
-    }
1363
-
1364
-
1365
-
1366
-
1367
-
1368
-
1369
-    /********************************************************************************************************/
1370
-    /***********************************  SWITCH PAYMENT METHOD  ************************************/
1371
-    /********************************************************************************************************/
1372
-    /**
1373
-     * switch_payment_method
1374
-     *
1375
-     * @access public
1376
-     * @return string
1377
-     * @throws EE_Error
1378
-     * @throws InvalidArgumentException
1379
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1380
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1381
-     */
1382
-    public function switch_payment_method()
1383
-    {
1384
-        if (! $this->_verify_payment_method_is_set()) {
1385
-            return false;
1386
-        }
1387
-        if (apply_filters(
1388
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1389
-            false
1390
-        )) {
1391
-            EE_Error::add_success(
1392
-                apply_filters(
1393
-                    'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1394
-                    sprintf(
1395
-                        esc_html__(
1396
-                            'You have selected "%s" as your method of payment. Please note the important payment information below.',
1397
-                            'event_espresso'
1398
-                        ),
1399
-                        $this->checkout->payment_method->name()
1400
-                    )
1401
-                )
1402
-            );
1403
-        }
1404
-        // generate billing form for selected method of payment if it hasn't been done already
1405
-        if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1406
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1407
-                $this->checkout->payment_method
1408
-            );
1409
-        }
1410
-        // fill form with attendee info if applicable
1411
-        if (apply_filters(
1412
-            'FHEE__populate_billing_form_fields_from_attendee',
1413
-            (
1414
-                $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
1415
-                && $this->checkout->transaction_has_primary_registrant()
1416
-            ),
1417
-            $this->checkout->billing_form,
1418
-            $this->checkout->transaction
1419
-        )
1420
-        ) {
1421
-            $this->checkout->billing_form->populate_from_attendee(
1422
-                $this->checkout->transaction->primary_registration()->attendee()
1423
-            );
1424
-        }
1425
-        // and debug content
1426
-        if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1427
-            && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1428
-        ) {
1429
-            $this->checkout->billing_form =
1430
-                $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1431
-                    $this->checkout->billing_form
1432
-                );
1433
-        }
1434
-        // get html and validation rules for form
1435
-        if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1436
-            $this->checkout->json_response->set_return_data(
1437
-                array('payment_method_info' => $this->checkout->billing_form->get_html())
1438
-            );
1439
-            // localize validation rules for main form
1440
-            $this->checkout->billing_form->localize_validation_rules(true);
1441
-            $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1442
-        } else {
1443
-            $this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1444
-        }
1445
-        // prevents advancement to next step
1446
-        $this->checkout->continue_reg = false;
1447
-        return true;
1448
-    }
1449
-
1450
-
1451
-    /**
1452
-     * _verify_payment_method_is_set
1453
-     *
1454
-     * @return bool
1455
-     * @throws EE_Error
1456
-     * @throws InvalidArgumentException
1457
-     * @throws ReflectionException
1458
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1459
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1460
-     */
1461
-    protected function _verify_payment_method_is_set()
1462
-    {
1463
-        // generate billing form for selected method of payment if it hasn't been done already
1464
-        if (empty($this->checkout->selected_method_of_payment)) {
1465
-            // how have they chosen to pay?
1466
-            $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1467
-        } else {
1468
-            // choose your own adventure based on method_of_payment
1469
-            switch ($this->checkout->selected_method_of_payment) {
1470
-                case 'events_sold_out':
1471
-                    EE_Error::add_attention(
1472
-                        apply_filters(
1473
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
1474
-                            esc_html__(
1475
-                                'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1476
-                                'event_espresso'
1477
-                            )
1478
-                        ),
1479
-                        __FILE__,
1480
-                        __FUNCTION__,
1481
-                        __LINE__
1482
-                    );
1483
-                    return false;
1484
-                    break;
1485
-                case 'payments_closed':
1486
-                    EE_Error::add_attention(
1487
-                        apply_filters(
1488
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
1489
-                            esc_html__(
1490
-                                'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.',
1491
-                                'event_espresso'
1492
-                            )
1493
-                        ),
1494
-                        __FILE__,
1495
-                        __FUNCTION__,
1496
-                        __LINE__
1497
-                    );
1498
-                    return false;
1499
-                    break;
1500
-                case 'no_payment_required':
1501
-                    EE_Error::add_attention(
1502
-                        apply_filters(
1503
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
1504
-                            esc_html__(
1505
-                                'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.',
1506
-                                'event_espresso'
1507
-                            )
1508
-                        ),
1509
-                        __FILE__,
1510
-                        __FUNCTION__,
1511
-                        __LINE__
1512
-                    );
1513
-                    return false;
1514
-                    break;
1515
-                default:
1516
-            }
1517
-        }
1518
-        // verify payment method
1519
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520
-            // get payment method for selected method of payment
1521
-            $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522
-        }
1523
-        return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false;
1524
-    }
1525
-
1526
-
1527
-
1528
-    /********************************************************************************************************/
1529
-    /***************************************  SAVE PAYER DETAILS  ****************************************/
1530
-    /********************************************************************************************************/
1531
-    /**
1532
-     * save_payer_details_via_ajax
1533
-     *
1534
-     * @return void
1535
-     * @throws EE_Error
1536
-     * @throws InvalidArgumentException
1537
-     * @throws ReflectionException
1538
-     * @throws RuntimeException
1539
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1540
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1541
-     */
1542
-    public function save_payer_details_via_ajax()
1543
-    {
1544
-        if (! $this->_verify_payment_method_is_set()) {
1545
-            return;
1546
-        }
1547
-        // generate billing form for selected method of payment if it hasn't been done already
1548
-        if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1549
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1550
-                $this->checkout->payment_method
1551
-            );
1552
-        }
1553
-        // generate primary attendee from payer info if applicable
1554
-        if (! $this->checkout->transaction_has_primary_registrant()) {
1555
-            $attendee = $this->_create_attendee_from_request_data();
1556
-            if ($attendee instanceof EE_Attendee) {
1557
-                foreach ($this->checkout->transaction->registrations() as $registration) {
1558
-                    if ($registration->is_primary_registrant()) {
1559
-                        $this->checkout->primary_attendee_obj = $attendee;
1560
-                        $registration->_add_relation_to($attendee, 'Attendee');
1561
-                        $registration->set_attendee_id($attendee->ID());
1562
-                        $registration->update_cache_after_object_save('Attendee', $attendee);
1563
-                    }
1564
-                }
1565
-            }
1566
-        }
1567
-    }
1568
-
1569
-
1570
-    /**
1571
-     * create_attendee_from_request_data
1572
-     * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1573
-     *
1574
-     * @return EE_Attendee
1575
-     * @throws EE_Error
1576
-     * @throws InvalidArgumentException
1577
-     * @throws ReflectionException
1578
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1579
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1580
-     */
1581
-    protected function _create_attendee_from_request_data()
1582
-    {
1583
-        // get State ID
1584
-        $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
-        if (! empty($STA_ID)) {
1586
-            // can we get state object from name ?
1587
-            EE_Registry::instance()->load_model('State');
1588
-            $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1589
-            $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1590
-        }
1591
-        // get Country ISO
1592
-        $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
-        if (! empty($CNT_ISO)) {
1594
-            // can we get country object from name ?
1595
-            EE_Registry::instance()->load_model('Country');
1596
-            $country = EEM_Country::instance()->get_col(
1597
-                array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1598
-                'CNT_ISO'
1599
-            );
1600
-            $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1601
-        }
1602
-        // grab attendee data
1603
-        $attendee_data = array(
1604
-            'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1605
-            'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1606
-            'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1607
-            'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1608
-            'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1609
-            'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1610
-            'STA_ID'       => $STA_ID,
1611
-            'CNT_ISO'      => $CNT_ISO,
1612
-            'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1613
-            'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1614
-        );
1615
-        // validate the email address since it is the most important piece of info
1616
-        if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1617
-            EE_Error::add_error(
1618
-                esc_html__('An invalid email address was submitted.', 'event_espresso'),
1619
-                __FILE__,
1620
-                __FUNCTION__,
1621
-                __LINE__
1622
-            );
1623
-        }
1624
-        // does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625
-        // AND email address
1626
-        if (! empty($attendee_data['ATT_fname'])
1627
-            && ! empty($attendee_data['ATT_lname'])
1628
-            && ! empty($attendee_data['ATT_email'])
1629
-        ) {
1630
-            $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1631
-                array(
1632
-                    'ATT_fname' => $attendee_data['ATT_fname'],
1633
-                    'ATT_lname' => $attendee_data['ATT_lname'],
1634
-                    'ATT_email' => $attendee_data['ATT_email'],
1635
-                )
1636
-            );
1637
-            if ($existing_attendee instanceof EE_Attendee) {
1638
-                return $existing_attendee;
1639
-            }
1640
-        }
1641
-        // no existing attendee? kk let's create a new one
1642
-        // kinda lame, but we need a first and last name to create an attendee, so use the email address if those
1643
-        // don't exist
1644
-        $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1645
-            ? $attendee_data['ATT_fname']
1646
-            : $attendee_data['ATT_email'];
1647
-        $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1648
-            ? $attendee_data['ATT_lname']
1649
-            : $attendee_data['ATT_email'];
1650
-        return EE_Attendee::new_instance($attendee_data);
1651
-    }
1652
-
1653
-
1654
-
1655
-    /********************************************************************************************************/
1656
-    /****************************************  PROCESS REG STEP  *****************************************/
1657
-    /********************************************************************************************************/
1658
-    /**
1659
-     * process_reg_step
1660
-     *
1661
-     * @return bool
1662
-     * @throws EE_Error
1663
-     * @throws InvalidArgumentException
1664
-     * @throws ReflectionException
1665
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1666
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1667
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1668
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
1669
-     */
1670
-    public function process_reg_step()
1671
-    {
1672
-        // how have they chosen to pay?
1673
-        $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1674
-            ? 'no_payment_required'
1675
-            : $this->_get_selected_method_of_payment(true);
1676
-        // choose your own adventure based on method_of_payment
1677
-        switch ($this->checkout->selected_method_of_payment) {
1678
-            case 'events_sold_out':
1679
-                $this->checkout->redirect = true;
1680
-                $this->checkout->redirect_url = $this->checkout->cancel_page_url;
1681
-                $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1682
-                // mark this reg step as completed
1683
-                $this->set_completed();
1684
-                return false;
1685
-                break;
1686
-
1687
-            case 'payments_closed':
1688
-                if (apply_filters(
1689
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1690
-                    false
1691
-                )) {
1692
-                    EE_Error::add_success(
1693
-                        esc_html__('no payment required at this time.', 'event_espresso'),
1694
-                        __FILE__,
1695
-                        __FUNCTION__,
1696
-                        __LINE__
1697
-                    );
1698
-                }
1699
-                // mark this reg step as completed
1700
-                $this->set_completed();
1701
-                return true;
1702
-                break;
1703
-
1704
-            case 'no_payment_required':
1705
-                if (apply_filters(
1706
-                    'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1707
-                    false
1708
-                )) {
1709
-                    EE_Error::add_success(
1710
-                        esc_html__('no payment required.', 'event_espresso'),
1711
-                        __FILE__,
1712
-                        __FUNCTION__,
1713
-                        __LINE__
1714
-                    );
1715
-                }
1716
-                // mark this reg step as completed
1717
-                $this->set_completed();
1718
-                return true;
1719
-                break;
1720
-
1721
-            default:
1722
-                $registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
1723
-                    EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
1724
-                );
1725
-                $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
1726
-                    $registrations,
1727
-                    EE_Registry::instance()->SSN->checkout()->revisit
1728
-                );
1729
-                // calculate difference between the two arrays
1730
-                $registrations = array_diff($registrations, $ejected_registrations);
1731
-                if (empty($registrations)) {
1732
-                    $this->_redirect_because_event_sold_out();
1733
-                    return false;
1734
-                }
1735
-                $payment_successful = $this->_process_payment();
1736
-                if ($payment_successful) {
1737
-                    $this->checkout->continue_reg = true;
1738
-                    $this->_maybe_set_completed($this->checkout->payment_method);
1739
-                } else {
1740
-                    $this->checkout->continue_reg = false;
1741
-                }
1742
-                return $payment_successful;
1743
-        }
1744
-    }
1745
-
1746
-
1747
-    /**
1748
-     * _redirect_because_event_sold_out
1749
-     *
1750
-     * @access protected
1751
-     * @return void
1752
-     */
1753
-    protected function _redirect_because_event_sold_out()
1754
-    {
1755
-        $this->checkout->continue_reg = false;
1756
-        // set redirect URL
1757
-        $this->checkout->redirect_url = add_query_arg(
1758
-            array('e_reg_url_link' => $this->checkout->reg_url_link),
1759
-            $this->checkout->current_step->reg_step_url()
1760
-        );
1761
-        $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1762
-    }
1763
-
1764
-
1765
-    /**
1766
-     * _maybe_set_completed
1767
-     *
1768
-     * @access protected
1769
-     * @param \EE_Payment_Method $payment_method
1770
-     * @return void
1771
-     * @throws \EE_Error
1772
-     */
1773
-    protected function _maybe_set_completed(EE_Payment_Method $payment_method)
1774
-    {
1775
-        switch ($payment_method->type_obj()->payment_occurs()) {
1776
-            case EE_PMT_Base::offsite:
1777
-                break;
1778
-            case EE_PMT_Base::onsite:
1779
-            case EE_PMT_Base::offline:
1780
-                // mark this reg step as completed
1781
-                $this->set_completed();
1782
-                break;
1783
-        }
1784
-    }
1785
-
1786
-
1787
-    /**
1788
-     *    update_reg_step
1789
-     *    this is the final step after a user  revisits the site to retry a payment
1790
-     *
1791
-     * @return bool
1792
-     * @throws EE_Error
1793
-     * @throws InvalidArgumentException
1794
-     * @throws ReflectionException
1795
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1796
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1797
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1798
-     * @throws \EventEspresso\core\exceptions\InvalidStatusException
1799
-     */
1800
-    public function update_reg_step()
1801
-    {
1802
-        $success = true;
1803
-        // if payment required
1804
-        if ($this->checkout->transaction->total() > 0) {
1805
-            do_action(
1806
-                'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1807
-                $this->checkout->transaction
1808
-            );
1809
-            // attempt payment via payment method
1810
-            $success = $this->process_reg_step();
1811
-        }
1812
-        if ($success && ! $this->checkout->redirect) {
1813
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1814
-                $this->checkout->transaction->ID()
1815
-            );
1816
-            // set return URL
1817
-            $this->checkout->redirect_url = add_query_arg(
1818
-                array('e_reg_url_link' => $this->checkout->reg_url_link),
1819
-                $this->checkout->thank_you_page_url
1820
-            );
1821
-        }
1822
-        return $success;
1823
-    }
1824
-
1825
-
1826
-    /**
1827
-     *    _process_payment
1828
-     *
1829
-     * @access private
1830
-     * @return bool
1831
-     * @throws EE_Error
1832
-     * @throws InvalidArgumentException
1833
-     * @throws ReflectionException
1834
-     * @throws RuntimeException
1835
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1836
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1837
-     */
1838
-    private function _process_payment()
1839
-    {
1840
-        // basically confirm that the event hasn't sold out since they hit the page
1841
-        if (! $this->_last_second_ticket_verifications()) {
1842
-            return false;
1843
-        }
1844
-        // ya gotta make a choice man
1845
-        if (empty($this->checkout->selected_method_of_payment)) {
1846
-            $this->checkout->json_response->set_plz_select_method_of_payment(
1847
-                esc_html__('Please select a method of payment before proceeding.', 'event_espresso')
1848
-            );
1849
-            return false;
1850
-        }
1851
-        // get EE_Payment_Method object
1852
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853
-            return false;
1854
-        }
1855
-        // setup billing form
1856
-        if ($this->checkout->payment_method->is_on_site()) {
1857
-            $this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1858
-                $this->checkout->payment_method
1859
-            );
1860
-            // bad billing form ?
1861
-            if (! $this->_billing_form_is_valid()) {
1862
-                return false;
1863
-            }
1864
-        }
1865
-        // ensure primary registrant has been fully processed
1866
-        if (! $this->_setup_primary_registrant_prior_to_payment()) {
1867
-            return false;
1868
-        }
1869
-        // if session is close to expiring (under 10 minutes by default)
1870
-        if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1871
-            // add some time to session expiration so that payment can be completed
1872
-            EE_Registry::instance()->SSN->extend_expiration();
1873
-        }
1874
-        /** @type EE_Transaction_Processor $transaction_processor */
1875
-        // $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1876
-        // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations
1877
-        // for events with a default reg status of Approved
1878
-        // $transaction_processor->toggle_registration_statuses_for_default_approved_events(
1879
-        //      $this->checkout->transaction, $this->checkout->reg_cache_where_params
1880
-        // );
1881
-        // attempt payment
1882
-        $payment = $this->_attempt_payment($this->checkout->payment_method);
1883
-        // process results
1884
-        $payment = $this->_validate_payment($payment);
1885
-        $payment = $this->_post_payment_processing($payment);
1886
-        // verify payment
1887
-        if ($payment instanceof EE_Payment) {
1888
-            // store that for later
1889
-            $this->checkout->payment = $payment;
1890
-            // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1891
-            $this->checkout->transaction->toggle_failed_transaction_status();
1892
-            $payment_status = $payment->status();
1893
-            if ($payment_status === EEM_Payment::status_id_approved
1894
-                || $payment_status === EEM_Payment::status_id_pending
1895
-            ) {
1896
-                return true;
1897
-            } else {
1898
-                return false;
1899
-            }
1900
-        } elseif ($payment === true) {
1901
-            // please note that offline payment methods will NOT make a payment,
1902
-            // but instead just mark themselves as the PMD_ID on the transaction, and return true
1903
-            $this->checkout->payment = $payment;
1904
-            return true;
1905
-        }
1906
-        // where's my money?
1907
-        return false;
1908
-    }
1909
-
1910
-
1911
-    /**
1912
-     * _last_second_ticket_verifications
1913
-     *
1914
-     * @access public
1915
-     * @return bool
1916
-     * @throws EE_Error
1917
-     */
1918
-    protected function _last_second_ticket_verifications()
1919
-    {
1920
-        // don't bother re-validating if not a return visit
1921
-        if (! $this->checkout->revisit) {
1922
-            return true;
1923
-        }
1924
-        $registrations = $this->checkout->transaction->registrations();
1925
-        if (empty($registrations)) {
1926
-            return false;
1927
-        }
1928
-        foreach ($registrations as $registration) {
1929
-            if ($registration instanceof EE_Registration && ! $registration->is_approved()) {
1930
-                $event = $registration->event_obj();
1931
-                if ($event instanceof EE_Event && $event->is_sold_out(true)) {
1932
-                    EE_Error::add_error(
1933
-                        apply_filters(
1934
-                            'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1935
-                            sprintf(
1936
-                                esc_html__(
1937
-                                    'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
1938
-                                    'event_espresso'
1939
-                                ),
1940
-                                $event->name()
1941
-                            )
1942
-                        ),
1943
-                        __FILE__,
1944
-                        __FUNCTION__,
1945
-                        __LINE__
1946
-                    );
1947
-                    return false;
1948
-                }
1949
-            }
1950
-        }
1951
-        return true;
1952
-    }
1953
-
1954
-
1955
-    /**
1956
-     * redirect_form
1957
-     *
1958
-     * @access public
1959
-     * @return bool
1960
-     * @throws EE_Error
1961
-     * @throws InvalidArgumentException
1962
-     * @throws ReflectionException
1963
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1964
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1965
-     */
1966
-    public function redirect_form()
1967
-    {
1968
-        $payment_method_billing_info = $this->_payment_method_billing_info(
1969
-            $this->_get_payment_method_for_selected_method_of_payment()
1970
-        );
1971
-        $html = $payment_method_billing_info->get_html();
1972
-        $html .= $this->checkout->redirect_form;
1973
-        EE_Registry::instance()->REQ->add_output($html);
1974
-        return true;
1975
-    }
1976
-
1977
-
1978
-    /**
1979
-     * _billing_form_is_valid
1980
-     *
1981
-     * @access private
1982
-     * @return bool
1983
-     * @throws \EE_Error
1984
-     */
1985
-    private function _billing_form_is_valid()
1986
-    {
1987
-        if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988
-            return true;
1989
-        }
1990
-        if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1991
-            if ($this->checkout->billing_form->was_submitted()) {
1992
-                $this->checkout->billing_form->receive_form_submission();
1993
-                if ($this->checkout->billing_form->is_valid()) {
1994
-                    return true;
1995
-                }
1996
-                $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1997
-                $error_strings = array();
1998
-                foreach ($validation_errors as $validation_error) {
1999
-                    if ($validation_error instanceof EE_Validation_Error) {
2000
-                        $form_section = $validation_error->get_form_section();
2001
-                        if ($form_section instanceof EE_Form_Input_Base) {
2002
-                            $label = $form_section->html_label_text();
2003
-                        } elseif ($form_section instanceof EE_Form_Section_Base) {
2004
-                            $label = $form_section->name();
2005
-                        } else {
2006
-                            $label = esc_html__('Validation Error', 'event_espresso');
2007
-                        }
2008
-                        $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
2009
-                    }
2010
-                }
2011
-                EE_Error::add_error(
2012
-                    sprintf(
2013
-                        esc_html__(
2014
-                            'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s',
2015
-                            'event_espresso'
2016
-                        ),
2017
-                        '<br/>',
2018
-                        implode('<br/>', $error_strings)
2019
-                    ),
2020
-                    __FILE__,
2021
-                    __FUNCTION__,
2022
-                    __LINE__
2023
-                );
2024
-            } else {
2025
-                EE_Error::add_error(
2026
-                    esc_html__(
2027
-                        'The billing form was not submitted or something prevented it\'s submission.',
2028
-                        'event_espresso'
2029
-                    ),
2030
-                    __FILE__,
2031
-                    __FUNCTION__,
2032
-                    __LINE__
2033
-                );
2034
-            }
2035
-        } else {
2036
-            EE_Error::add_error(
2037
-                esc_html__(
2038
-                    'The submitted billing form is invalid possibly due to a technical reason.',
2039
-                    'event_espresso'
2040
-                ),
2041
-                __FILE__,
2042
-                __FUNCTION__,
2043
-                __LINE__
2044
-            );
2045
-        }
2046
-        return false;
2047
-    }
2048
-
2049
-
2050
-    /**
2051
-     * _setup_primary_registrant_prior_to_payment
2052
-     * ensures that the primary registrant has a valid attendee object created with the critical details populated
2053
-     * (first & last name & email) and that both the transaction object and primary registration object have been saved
2054
-     * plz note that any other registrations will NOT be saved at this point (because they may not have any details
2055
-     * yet)
2056
-     *
2057
-     * @access private
2058
-     * @return bool
2059
-     * @throws EE_Error
2060
-     * @throws InvalidArgumentException
2061
-     * @throws ReflectionException
2062
-     * @throws RuntimeException
2063
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2064
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2065
-     */
2066
-    private function _setup_primary_registrant_prior_to_payment()
2067
-    {
2068
-        // check if transaction has a primary registrant and that it has a related Attendee object
2069
-        // if not, then we need to at least gather some primary registrant data before attempting payment
2070
-        if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
2071
-            && ! $this->checkout->transaction_has_primary_registrant()
2072
-            && ! $this->_capture_primary_registration_data_from_billing_form()
2073
-        ) {
2074
-            return false;
2075
-        }
2076
-        // because saving an object clears it's cache, we need to do the chevy shuffle
2077
-        // grab the primary_registration object
2078
-        $primary_registration = $this->checkout->transaction->primary_registration();
2079
-        // at this point we'll consider a TXN to not have been failed
2080
-        $this->checkout->transaction->toggle_failed_transaction_status();
2081
-        // save the TXN ( which clears cached copy of primary_registration)
2082
-        $this->checkout->transaction->save();
2083
-        // grab TXN ID and save it to the primary_registration
2084
-        $primary_registration->set_transaction_id($this->checkout->transaction->ID());
2085
-        // save what we have so far
2086
-        $primary_registration->save();
2087
-        return true;
2088
-    }
2089
-
2090
-
2091
-    /**
2092
-     * _capture_primary_registration_data_from_billing_form
2093
-     *
2094
-     * @access private
2095
-     * @return bool
2096
-     * @throws EE_Error
2097
-     * @throws InvalidArgumentException
2098
-     * @throws ReflectionException
2099
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2100
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2101
-     */
2102
-    private function _capture_primary_registration_data_from_billing_form()
2103
-    {
2104
-        // convert billing form data into an attendee
2105
-        $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
-        if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107
-            EE_Error::add_error(
2108
-                sprintf(
2109
-                    esc_html__(
2110
-                        'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.',
2111
-                        'event_espresso'
2112
-                    ),
2113
-                    '<br/>',
2114
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2115
-                ),
2116
-                __FILE__,
2117
-                __FUNCTION__,
2118
-                __LINE__
2119
-            );
2120
-            return false;
2121
-        }
2122
-        $primary_registration = $this->checkout->transaction->primary_registration();
2123
-        if (! $primary_registration instanceof EE_Registration) {
2124
-            EE_Error::add_error(
2125
-                sprintf(
2126
-                    esc_html__(
2127
-                        'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2128
-                        'event_espresso'
2129
-                    ),
2130
-                    '<br/>',
2131
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2132
-                ),
2133
-                __FILE__,
2134
-                __FUNCTION__,
2135
-                __LINE__
2136
-            );
2137
-            return false;
2138
-        }
2139
-        if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140
-              instanceof
2141
-              EE_Attendee
2142
-        ) {
2143
-            EE_Error::add_error(
2144
-                sprintf(
2145
-                    esc_html__(
2146
-                        'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.',
2147
-                        'event_espresso'
2148
-                    ),
2149
-                    '<br/>',
2150
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2151
-                ),
2152
-                __FILE__,
2153
-                __FUNCTION__,
2154
-                __LINE__
2155
-            );
2156
-            return false;
2157
-        }
2158
-        /** @type EE_Registration_Processor $registration_processor */
2159
-        $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
2160
-        // at this point, we should have enough details about the registrant to consider the registration NOT incomplete
2161
-        $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
2162
-        return true;
2163
-    }
2164
-
2165
-
2166
-    /**
2167
-     * _get_payment_method_for_selected_method_of_payment
2168
-     * retrieves a valid payment method
2169
-     *
2170
-     * @access public
2171
-     * @return EE_Payment_Method
2172
-     * @throws EE_Error
2173
-     * @throws InvalidArgumentException
2174
-     * @throws ReflectionException
2175
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2176
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2177
-     */
2178
-    private function _get_payment_method_for_selected_method_of_payment()
2179
-    {
2180
-        if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
2181
-            $this->_redirect_because_event_sold_out();
2182
-            return null;
2183
-        }
2184
-        // get EE_Payment_Method object
2185
-        if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
-            $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2187
-        } else {
2188
-            // load EEM_Payment_Method
2189
-            EE_Registry::instance()->load_model('Payment_Method');
2190
-            /** @type EEM_Payment_Method $EEM_Payment_Method */
2191
-            $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
2192
-            $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193
-        }
2194
-        // verify $payment_method
2195
-        if (! $payment_method instanceof EE_Payment_Method) {
2196
-            // not a payment
2197
-            EE_Error::add_error(
2198
-                sprintf(
2199
-                    esc_html__(
2200
-                        'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2201
-                        'event_espresso'
2202
-                    ),
2203
-                    '<br/>',
2204
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2205
-                ),
2206
-                __FILE__,
2207
-                __FUNCTION__,
2208
-                __LINE__
2209
-            );
2210
-            return null;
2211
-        }
2212
-        // and verify it has a valid Payment_Method Type object
2213
-        if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214
-            // not a payment
2215
-            EE_Error::add_error(
2216
-                sprintf(
2217
-                    esc_html__(
2218
-                        'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2219
-                        'event_espresso'
2220
-                    ),
2221
-                    '<br/>',
2222
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2223
-                ),
2224
-                __FILE__,
2225
-                __FUNCTION__,
2226
-                __LINE__
2227
-            );
2228
-            return null;
2229
-        }
2230
-        return $payment_method;
2231
-    }
2232
-
2233
-
2234
-    /**
2235
-     *    _attempt_payment
2236
-     *
2237
-     * @access    private
2238
-     * @type    EE_Payment_Method $payment_method
2239
-     * @return mixed EE_Payment | boolean
2240
-     * @throws EE_Error
2241
-     * @throws InvalidArgumentException
2242
-     * @throws ReflectionException
2243
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2244
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2245
-     */
2246
-    private function _attempt_payment(EE_Payment_Method $payment_method)
2247
-    {
2248
-        $payment = null;
2249
-        $this->checkout->transaction->save();
2250
-        $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
-        if (! $payment_processor instanceof EE_Payment_Processor) {
2252
-            return false;
2253
-        }
2254
-        try {
2255
-            $payment_processor->set_revisit($this->checkout->revisit);
2256
-            // generate payment object
2257
-            $payment = $payment_processor->process_payment(
2258
-                $payment_method,
2259
-                $this->checkout->transaction,
2260
-                $this->checkout->amount_owing,
2261
-                $this->checkout->billing_form,
2262
-                $this->_get_return_url($payment_method),
2263
-                'CART',
2264
-                $this->checkout->admin_request,
2265
-                true,
2266
-                $this->reg_step_url()
2267
-            );
2268
-        } catch (Exception $e) {
2269
-            $this->_handle_payment_processor_exception($e);
2270
-        }
2271
-        return $payment;
2272
-    }
2273
-
2274
-
2275
-    /**
2276
-     * _handle_payment_processor_exception
2277
-     *
2278
-     * @access protected
2279
-     * @param \Exception $e
2280
-     * @return void
2281
-     * @throws EE_Error
2282
-     * @throws InvalidArgumentException
2283
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2284
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2285
-     */
2286
-    protected function _handle_payment_processor_exception(Exception $e)
2287
-    {
2288
-        EE_Error::add_error(
2289
-            sprintf(
2290
-                esc_html__(
2291
-                    'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s',
2292
-                    'event_espresso'
2293
-                ),
2294
-                '<br/>',
2295
-                EE_Registry::instance()->CFG->organization->get_pretty('email'),
2296
-                $e->getMessage(),
2297
-                $e->getFile(),
2298
-                $e->getLine()
2299
-            ),
2300
-            __FILE__,
2301
-            __FUNCTION__,
2302
-            __LINE__
2303
-        );
2304
-    }
2305
-
2306
-
2307
-    /**
2308
-     * _get_return_url
2309
-     *
2310
-     * @access protected
2311
-     * @param \EE_Payment_Method $payment_method
2312
-     * @return string
2313
-     * @throws \EE_Error
2314
-     */
2315
-    protected function _get_return_url(EE_Payment_Method $payment_method)
2316
-    {
2317
-        $return_url = '';
2318
-        switch ($payment_method->type_obj()->payment_occurs()) {
2319
-            case EE_PMT_Base::offsite:
2320
-                $return_url = add_query_arg(
2321
-                    array(
2322
-                        'action'                     => 'process_gateway_response',
2323
-                        'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2324
-                        'spco_txn'                   => $this->checkout->transaction->ID(),
2325
-                    ),
2326
-                    $this->reg_step_url()
2327
-                );
2328
-                break;
2329
-            case EE_PMT_Base::onsite:
2330
-            case EE_PMT_Base::offline:
2331
-                $return_url = $this->checkout->next_step->reg_step_url();
2332
-                break;
2333
-        }
2334
-        return $return_url;
2335
-    }
2336
-
2337
-
2338
-    /**
2339
-     * _validate_payment
2340
-     *
2341
-     * @access private
2342
-     * @param EE_Payment $payment
2343
-     * @return EE_Payment|FALSE
2344
-     * @throws EE_Error
2345
-     * @throws InvalidArgumentException
2346
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2347
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2348
-     */
2349
-    private function _validate_payment($payment = null)
2350
-    {
2351
-        if ($this->checkout->payment_method->is_off_line()) {
2352
-            return true;
2353
-        }
2354
-        // verify payment object
2355
-        if (! $payment instanceof EE_Payment) {
2356
-            // not a payment
2357
-            EE_Error::add_error(
2358
-                sprintf(
2359
-                    esc_html__(
2360
-                        'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.',
2361
-                        'event_espresso'
2362
-                    ),
2363
-                    '<br/>',
2364
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2365
-                ),
2366
-                __FILE__,
2367
-                __FUNCTION__,
2368
-                __LINE__
2369
-            );
2370
-            return false;
2371
-        }
2372
-        return $payment;
2373
-    }
2374
-
2375
-
2376
-    /**
2377
-     * _post_payment_processing
2378
-     *
2379
-     * @access private
2380
-     * @param EE_Payment|bool $payment
2381
-     * @return bool
2382
-     * @throws EE_Error
2383
-     * @throws InvalidArgumentException
2384
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2385
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2386
-     */
2387
-    private function _post_payment_processing($payment = null)
2388
-    {
2389
-        // Off-Line payment?
2390
-        if ($payment === true) {
2391
-            // $this->_setup_redirect_for_next_step();
2392
-            return true;
2393
-            // On-Site payment?
2394
-        } elseif ($this->checkout->payment_method->is_on_site()) {
2395
-            if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396
-                // $this->_setup_redirect_for_next_step();
2397
-                $this->checkout->continue_reg = false;
2398
-            }
2399
-            // Off-Site payment?
2400
-        } elseif ($this->checkout->payment_method->is_off_site()) {
2401
-            // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2402
-            if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2403
-                do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2404
-                $this->checkout->redirect = true;
2405
-                $this->checkout->redirect_form = $payment->redirect_form();
2406
-                $this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2407
-                // set JSON response
2408
-                $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2409
-                // and lastly, let's bump the payment status to pending
2410
-                $payment->set_status(EEM_Payment::status_id_pending);
2411
-                $payment->save();
2412
-            } else {
2413
-                // not a payment
2414
-                $this->checkout->continue_reg = false;
2415
-                EE_Error::add_error(
2416
-                    sprintf(
2417
-                        esc_html__(
2418
-                            'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.',
2419
-                            'event_espresso'
2420
-                        ),
2421
-                        '<br/>',
2422
-                        EE_Registry::instance()->CFG->organization->get_pretty('email')
2423
-                    ),
2424
-                    __FILE__,
2425
-                    __FUNCTION__,
2426
-                    __LINE__
2427
-                );
2428
-            }
2429
-        } else {
2430
-            // ummm ya... not Off-Line, not On-Site, not off-Site ????
2431
-            $this->checkout->continue_reg = false;
2432
-            return false;
2433
-        }
2434
-        return $payment;
2435
-    }
2436
-
2437
-
2438
-    /**
2439
-     *    _process_payment_status
2440
-     *
2441
-     * @access private
2442
-     * @type    EE_Payment $payment
2443
-     * @param string       $payment_occurs
2444
-     * @return bool
2445
-     * @throws EE_Error
2446
-     * @throws InvalidArgumentException
2447
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2448
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2449
-     */
2450
-    private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline)
2451
-    {
2452
-        // off-line payment? carry on
2453
-        if ($payment_occurs === EE_PMT_Base::offline) {
2454
-            return true;
2455
-        }
2456
-        // verify payment validity
2457
-        if ($payment instanceof EE_Payment) {
2458
-            do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2459
-            $msg = $payment->gateway_response();
2460
-            // check results
2461
-            switch ($payment->status()) {
2462
-                // good payment
2463
-                case EEM_Payment::status_id_approved:
2464
-                    EE_Error::add_success(
2465
-                        esc_html__('Your payment was processed successfully.', 'event_espresso'),
2466
-                        __FILE__,
2467
-                        __FUNCTION__,
2468
-                        __LINE__
2469
-                    );
2470
-                    return true;
2471
-                    break;
2472
-                // slow payment
2473
-                case EEM_Payment::status_id_pending:
2474
-                    if (empty($msg)) {
2475
-                        $msg = esc_html__(
2476
-                            'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2477
-                            'event_espresso'
2478
-                        );
2479
-                    }
2480
-                    EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2481
-                    return true;
2482
-                    break;
2483
-                // don't wanna payment
2484
-                case EEM_Payment::status_id_cancelled:
2485
-                    if (empty($msg)) {
2486
-                        $msg = _n(
2487
-                            'Payment cancelled. Please try again.',
2488
-                            'Payment cancelled. Please try again or select another method of payment.',
2489
-                            count($this->checkout->available_payment_methods),
2490
-                            'event_espresso'
2491
-                        );
2492
-                    }
2493
-                    EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2494
-                    return false;
2495
-                    break;
2496
-                // not enough payment
2497
-                case EEM_Payment::status_id_declined:
2498
-                    if (empty($msg)) {
2499
-                        $msg = _n(
2500
-                            'We\'re sorry but your payment was declined. Please try again.',
2501
-                            'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2502
-                            count($this->checkout->available_payment_methods),
2503
-                            'event_espresso'
2504
-                        );
2505
-                    }
2506
-                    EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2507
-                    return false;
2508
-                    break;
2509
-                // bad payment
2510
-                case EEM_Payment::status_id_failed:
2511
-                    if (! empty($msg)) {
2512
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2513
-                        return false;
2514
-                    }
2515
-                    // default to error below
2516
-                    break;
2517
-            }
2518
-        }
2519
-        // off-site payment gateway responses are too unreliable, so let's just assume that
2520
-        // the payment processing is just running slower than the registrant's request
2521
-        if ($payment_occurs === EE_PMT_Base::offsite) {
2522
-            return true;
2523
-        }
2524
-        EE_Error::add_error(
2525
-            sprintf(
2526
-                esc_html__(
2527
-                    'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.',
2528
-                    'event_espresso'
2529
-                ),
2530
-                '<br/>',
2531
-                EE_Registry::instance()->CFG->organization->get_pretty('email')
2532
-            ),
2533
-            __FILE__,
2534
-            __FUNCTION__,
2535
-            __LINE__
2536
-        );
2537
-        return false;
2538
-    }
2539
-
2540
-
2541
-
2542
-
2543
-
2544
-
2545
-    /********************************************************************************************************/
2546
-    /**********************************  PROCESS GATEWAY RESPONSE  **********************************/
2547
-    /********************************************************************************************************/
2548
-    /**
2549
-     * process_gateway_response
2550
-     * this is the return point for Off-Site Payment Methods
2551
-     * It will attempt to "handle the IPN" if it appears that this has not already occurred,
2552
-     * otherwise, it will load up the last payment made for the TXN.
2553
-     * If the payment retrieved looks good, it will then either:
2554
-     *    complete the current step and allow advancement to the next reg step
2555
-     *        or present the payment options again
2556
-     *
2557
-     * @access private
2558
-     * @return EE_Payment|FALSE
2559
-     * @throws EE_Error
2560
-     * @throws InvalidArgumentException
2561
-     * @throws ReflectionException
2562
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2563
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2564
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2565
-     */
2566
-    public function process_gateway_response()
2567
-    {
2568
-        $payment = null;
2569
-        // how have they chosen to pay?
2570
-        $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2571
-        // get EE_Payment_Method object
2572
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2573
-            $this->checkout->continue_reg = false;
2574
-            return false;
2575
-        }
2576
-        if (! $this->checkout->payment_method->is_off_site()) {
2577
-            return false;
2578
-        }
2579
-        $this->_validate_offsite_return();
2580
-        // DEBUG LOG
2581
-        // $this->checkout->log(
2582
-        //     __CLASS__,
2583
-        //     __FUNCTION__,
2584
-        //     __LINE__,
2585
-        //     array(
2586
-        //         'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2587
-        //         'payment_method'             => $this->checkout->payment_method,
2588
-        //     ),
2589
-        //     true
2590
-        // );
2591
-        // verify TXN
2592
-        if ($this->checkout->transaction instanceof EE_Transaction) {
2593
-            $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2594
-            if (! $gateway instanceof EE_Offsite_Gateway) {
2595
-                $this->checkout->continue_reg = false;
2596
-                return false;
2597
-            }
2598
-            $payment = $this->_process_off_site_payment($gateway);
2599
-            $payment = $this->_process_cancelled_payments($payment);
2600
-            $payment = $this->_validate_payment($payment);
2601
-            // if payment was not declined by the payment gateway or cancelled by the registrant
2602
-            if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2603
-                // $this->_setup_redirect_for_next_step();
2604
-                // store that for later
2605
-                $this->checkout->payment = $payment;
2606
-                // mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2607
-                // because we will complete this step during the IPN processing then
2608
-                if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2609
-                    $this->set_completed();
2610
-                }
2611
-                return true;
2612
-            }
2613
-        }
2614
-        // DEBUG LOG
2615
-        // $this->checkout->log(
2616
-        //     __CLASS__,
2617
-        //     __FUNCTION__,
2618
-        //     __LINE__,
2619
-        //     array('payment' => $payment)
2620
-        // );
2621
-        $this->checkout->continue_reg = false;
2622
-        return false;
2623
-    }
2624
-
2625
-
2626
-    /**
2627
-     * _validate_return
2628
-     *
2629
-     * @access private
2630
-     * @return void
2631
-     * @throws EE_Error
2632
-     * @throws InvalidArgumentException
2633
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2634
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2635
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2636
-     */
2637
-    private function _validate_offsite_return()
2638
-    {
2639
-        $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2640
-        if ($TXN_ID !== $this->checkout->transaction->ID()) {
2641
-            // Houston... we might have a problem
2642
-            $invalid_TXN = false;
2643
-            // first gather some info
2644
-            $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2645
-            $primary_registrant = $valid_TXN instanceof EE_Transaction
2646
-                ? $valid_TXN->primary_registration()
2647
-                : null;
2648
-            // let's start by retrieving the cart for this TXN
2649
-            $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2650
-            if ($cart instanceof EE_Cart) {
2651
-                // verify that the current cart has tickets
2652
-                $tickets = $cart->get_tickets();
2653
-                if (empty($tickets)) {
2654
-                    $invalid_TXN = true;
2655
-                }
2656
-            } else {
2657
-                $invalid_TXN = true;
2658
-            }
2659
-            $valid_TXN_SID = $primary_registrant instanceof EE_Registration
2660
-                ? $primary_registrant->session_ID()
2661
-                : null;
2662
-            // validate current Session ID and compare against valid TXN session ID
2663
-            if ($invalid_TXN // if this is already true, then skip other checks
2664
-                || EE_Session::instance()->id() === null
2665
-                || (
2666
-                    // WARNING !!!
2667
-                    // this could be PayPal sending back duplicate requests (ya they do that)
2668
-                    // or it **could** mean someone is simply registering AGAIN after having just done so
2669
-                    // so now we need to determine if this current TXN looks valid or not
2670
-                    // and whether this reg step has even been started ?
2671
-                    EE_Session::instance()->id() === $valid_TXN_SID
2672
-                    // really? you're half way through this reg step, but you never started it ?
2673
-                    && $this->checkout->transaction->reg_step_completed($this->slug()) === false
2674
-                )
2675
-            ) {
2676
-                $invalid_TXN = true;
2677
-            }
2678
-            if ($invalid_TXN) {
2679
-                // is the valid TXN completed ?
2680
-                if ($valid_TXN instanceof EE_Transaction) {
2681
-                    // has this step even been started ?
2682
-                    $reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2683
-                    if ($reg_step_completed !== false && $reg_step_completed !== true) {
2684
-                        // so it **looks** like this is a double request from PayPal
2685
-                        // so let's try to pick up where we left off
2686
-                        $this->checkout->transaction = $valid_TXN;
2687
-                        $this->checkout->refresh_all_entities(true);
2688
-                        return;
2689
-                    }
2690
-                }
2691
-                // you appear to be lost?
2692
-                $this->_redirect_wayward_request($primary_registrant);
2693
-            }
2694
-        }
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * _redirect_wayward_request
2700
-     *
2701
-     * @access private
2702
-     * @param \EE_Registration|null $primary_registrant
2703
-     * @return bool
2704
-     * @throws EE_Error
2705
-     * @throws InvalidArgumentException
2706
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2707
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2708
-     */
2709
-    private function _redirect_wayward_request(EE_Registration $primary_registrant)
2710
-    {
2711
-        if (! $primary_registrant instanceof EE_Registration) {
2712
-            // try redirecting based on the current TXN
2713
-            $primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2714
-                ? $this->checkout->transaction->primary_registration()
2715
-                : null;
2716
-        }
2717
-        if (! $primary_registrant instanceof EE_Registration) {
2718
-            EE_Error::add_error(
2719
-                sprintf(
2720
-                    esc_html__(
2721
-                        'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.',
2722
-                        'event_espresso'
2723
-                    ),
2724
-                    '<br/>',
2725
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
2726
-                ),
2727
-                __FILE__,
2728
-                __FUNCTION__,
2729
-                __LINE__
2730
-            );
2731
-            return false;
2732
-        }
2733
-        // make sure transaction is not locked
2734
-        $this->checkout->transaction->unlock();
2735
-        wp_safe_redirect(
2736
-            add_query_arg(
2737
-                array(
2738
-                    'e_reg_url_link' => $primary_registrant->reg_url_link(),
2739
-                ),
2740
-                $this->checkout->thank_you_page_url
2741
-            )
2742
-        );
2743
-        exit();
2744
-    }
2745
-
2746
-
2747
-    /**
2748
-     * _process_off_site_payment
2749
-     *
2750
-     * @access private
2751
-     * @param \EE_Offsite_Gateway $gateway
2752
-     * @return EE_Payment
2753
-     * @throws EE_Error
2754
-     * @throws InvalidArgumentException
2755
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2756
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2757
-     */
2758
-    private function _process_off_site_payment(EE_Offsite_Gateway $gateway)
2759
-    {
2760
-        try {
2761
-            $request_data = \EE_Registry::instance()->REQ->params();
2762
-            // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2763
-            $this->set_handle_IPN_in_this_request(
2764
-                $gateway->handle_IPN_in_this_request($request_data, false)
2765
-            );
2766
-            if ($this->handle_IPN_in_this_request()) {
2767
-                // get payment details and process results
2768
-                /** @type EE_Payment_Processor $payment_processor */
2769
-                $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2770
-                $payment = $payment_processor->process_ipn(
2771
-                    $request_data,
2772
-                    $this->checkout->transaction,
2773
-                    $this->checkout->payment_method,
2774
-                    true,
2775
-                    false
2776
-                );
2777
-                // $payment_source = 'process_ipn';
2778
-            } else {
2779
-                $payment = $this->checkout->transaction->last_payment();
2780
-                // $payment_source = 'last_payment';
2781
-            }
2782
-        } catch (Exception $e) {
2783
-            // let's just eat the exception and try to move on using any previously set payment info
2784
-            $payment = $this->checkout->transaction->last_payment();
2785
-            // $payment_source = 'last_payment after Exception';
2786
-            // but if we STILL don't have a payment object
2787
-            if (! $payment instanceof EE_Payment) {
2788
-                // then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2789
-                $this->_handle_payment_processor_exception($e);
2790
-            }
2791
-        }
2792
-        // DEBUG LOG
2793
-        // $this->checkout->log(
2794
-        //     __CLASS__,
2795
-        //     __FUNCTION__,
2796
-        //     __LINE__,
2797
-        //     array(
2798
-        //         'process_ipn_payment' => $payment,
2799
-        //         'payment_source'      => $payment_source,
2800
-        //     )
2801
-        // );
2802
-        return $payment;
2803
-    }
2804
-
2805
-
2806
-    /**
2807
-     * _process_cancelled_payments
2808
-     * just makes sure that the payment status gets updated correctly
2809
-     * so tha tan error isn't generated during payment validation
2810
-     *
2811
-     * @access private
2812
-     * @param EE_Payment $payment
2813
-     * @return EE_Payment | FALSE
2814
-     * @throws \EE_Error
2815
-     */
2816
-    private function _process_cancelled_payments($payment = null)
2817
-    {
2818
-        if ($payment instanceof EE_Payment
2819
-            && isset($_REQUEST['ee_cancel_payment'])
2820
-            && $payment->status() === EEM_Payment::status_id_failed
2821
-        ) {
2822
-            $payment->set_status(EEM_Payment::status_id_cancelled);
2823
-        }
2824
-        return $payment;
2825
-    }
2826
-
2827
-
2828
-    /**
2829
-     *    get_transaction_details_for_gateways
2830
-     *
2831
-     * @access    public
2832
-     * @return int
2833
-     * @throws EE_Error
2834
-     * @throws InvalidArgumentException
2835
-     * @throws ReflectionException
2836
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2837
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2838
-     */
2839
-    public function get_transaction_details_for_gateways()
2840
-    {
2841
-        $txn_details = array();
2842
-        // ya gotta make a choice man
2843
-        if (empty($this->checkout->selected_method_of_payment)) {
2844
-            $txn_details = array(
2845
-                'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'),
2846
-            );
2847
-        }
2848
-        // get EE_Payment_Method object
2849
-        if (empty($txn_details)
2850
-            &&
2851
-            ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2852
-        ) {
2853
-            $txn_details = array(
2854
-                'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2855
-                'error'                      => esc_html__(
2856
-                    'A valid Payment Method could not be determined.',
2857
-                    'event_espresso'
2858
-                ),
2859
-            );
2860
-        }
2861
-        if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2862
-            $return_url = $this->_get_return_url($this->checkout->payment_method);
2863
-            $txn_details = array(
2864
-                'TXN_ID'         => $this->checkout->transaction->ID(),
2865
-                'TXN_timestamp'  => $this->checkout->transaction->datetime(),
2866
-                'TXN_total'      => $this->checkout->transaction->total(),
2867
-                'TXN_paid'       => $this->checkout->transaction->paid(),
2868
-                'TXN_reg_steps'  => $this->checkout->transaction->reg_steps(),
2869
-                'STS_ID'         => $this->checkout->transaction->status_ID(),
2870
-                'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2871
-                'payment_amount' => $this->checkout->amount_owing,
2872
-                'return_url'     => $return_url,
2873
-                'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2874
-                'notify_url'     => EE_Config::instance()->core->txn_page_url(
2875
-                    array(
2876
-                        'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
2877
-                        'ee_payment_method' => $this->checkout->payment_method->slug(),
2878
-                    )
2879
-                ),
2880
-            );
2881
-        }
2882
-        echo wp_json_encode($txn_details);
2883
-        exit();
2884
-    }
2885
-
2886
-
2887
-    /**
2888
-     *    __sleep
2889
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
2890
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
2891
-     * reg form, because if needed, it will be regenerated anyways
2892
-     *
2893
-     * @return array
2894
-     */
2895
-    public function __sleep()
2896
-    {
2897
-        // remove the reg form and the checkout
2898
-        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2899
-    }
15
+	/**
16
+	 * @access protected
17
+	 * @var EE_Line_Item_Display $Line_Item_Display
18
+	 */
19
+	protected $line_item_display;
20
+
21
+	/**
22
+	 * @access protected
23
+	 * @var boolean $handle_IPN_in_this_request
24
+	 */
25
+	protected $handle_IPN_in_this_request = false;
26
+
27
+
28
+	/**
29
+	 *    set_hooks - for hooking into EE Core, other modules, etc
30
+	 *
31
+	 * @access    public
32
+	 * @return    void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		add_filter(
37
+			'FHEE__SPCO__EE_Line_Item_Filter_Collection',
38
+			array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
39
+		);
40
+		add_action(
41
+			'wp_ajax_switch_spco_billing_form',
42
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
43
+		);
44
+		add_action(
45
+			'wp_ajax_nopriv_switch_spco_billing_form',
46
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
47
+		);
48
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
49
+		add_action(
50
+			'wp_ajax_nopriv_save_payer_details',
51
+			array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
52
+		);
53
+		add_action(
54
+			'wp_ajax_get_transaction_details_for_gateways',
55
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
56
+		);
57
+		add_action(
58
+			'wp_ajax_nopriv_get_transaction_details_for_gateways',
59
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
60
+		);
61
+		add_filter(
62
+			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
63
+			array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
64
+			10,
65
+			1
66
+		);
67
+	}
68
+
69
+
70
+	/**
71
+	 *    ajax switch_spco_billing_form
72
+	 *
73
+	 * @throws \EE_Error
74
+	 */
75
+	public static function switch_spco_billing_form()
76
+	{
77
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
78
+	}
79
+
80
+
81
+	/**
82
+	 *    ajax save_payer_details
83
+	 *
84
+	 * @throws \EE_Error
85
+	 */
86
+	public static function save_payer_details()
87
+	{
88
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
89
+	}
90
+
91
+
92
+	/**
93
+	 *    ajax get_transaction_details
94
+	 *
95
+	 * @throws \EE_Error
96
+	 */
97
+	public static function get_transaction_details()
98
+	{
99
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
100
+	}
101
+
102
+
103
+	/**
104
+	 * bypass_recaptcha_for_load_payment_method
105
+	 *
106
+	 * @access public
107
+	 * @return array
108
+	 * @throws InvalidArgumentException
109
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
110
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
111
+	 */
112
+	public static function bypass_recaptcha_for_load_payment_method()
113
+	{
114
+		return array(
115
+			'EESID'  => EE_Registry::instance()->SSN->id(),
116
+			'step'   => 'payment_options',
117
+			'action' => 'spco_billing_form',
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 *    class constructor
124
+	 *
125
+	 * @access    public
126
+	 * @param    EE_Checkout $checkout
127
+	 */
128
+	public function __construct(EE_Checkout $checkout)
129
+	{
130
+		$this->_slug = 'payment_options';
131
+		$this->_name = esc_html__('Payment Options', 'event_espresso');
132
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
133
+		$this->checkout = $checkout;
134
+		$this->_reset_success_message();
135
+		$this->set_instructions(
136
+			esc_html__(
137
+				'Please select a method of payment and provide any necessary billing information before proceeding.',
138
+				'event_espresso'
139
+			)
140
+		);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @return null
146
+	 */
147
+	public function line_item_display()
148
+	{
149
+		return $this->line_item_display;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param null $line_item_display
155
+	 */
156
+	public function set_line_item_display($line_item_display)
157
+	{
158
+		$this->line_item_display = $line_item_display;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @return boolean
164
+	 */
165
+	public function handle_IPN_in_this_request()
166
+	{
167
+		return $this->handle_IPN_in_this_request;
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param boolean $handle_IPN_in_this_request
173
+	 */
174
+	public function set_handle_IPN_in_this_request($handle_IPN_in_this_request)
175
+	{
176
+		$this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177
+	}
178
+
179
+
180
+	/**
181
+	 * translate_js_strings
182
+	 *
183
+	 * @return void
184
+	 */
185
+	public function translate_js_strings()
186
+	{
187
+		EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__(
188
+			'Please select a method of payment in order to continue.',
189
+			'event_espresso'
190
+		);
191
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
192
+			'A valid method of payment could not be determined. Please refresh the page and try again.',
193
+			'event_espresso'
194
+		);
195
+		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__(
196
+			'Forwarding to Secure Payment Provider.',
197
+			'event_espresso'
198
+		);
199
+	}
200
+
201
+
202
+	/**
203
+	 * enqueue_styles_and_scripts
204
+	 *
205
+	 * @return void
206
+	 * @throws EE_Error
207
+	 * @throws InvalidArgumentException
208
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
209
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
210
+	 */
211
+	public function enqueue_styles_and_scripts()
212
+	{
213
+		$transaction = $this->checkout->transaction;
214
+		// if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
+		if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216
+			return;
217
+		}
218
+		foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
219
+			$transaction,
220
+			EEM_Payment_Method::scope_cart
221
+		) as $payment_method) {
222
+			$type_obj = $payment_method->type_obj();
223
+			if ($type_obj instanceof EE_PMT_Base) {
224
+				$billing_form = $type_obj->generate_new_billing_form($transaction);
225
+				if ($billing_form instanceof EE_Form_Section_Proper) {
226
+					$billing_form->enqueue_js();
227
+				}
228
+			}
229
+		}
230
+	}
231
+
232
+
233
+	/**
234
+	 * initialize_reg_step
235
+	 *
236
+	 * @return bool
237
+	 * @throws EE_Error
238
+	 * @throws InvalidArgumentException
239
+	 * @throws ReflectionException
240
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
241
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
242
+	 */
243
+	public function initialize_reg_step()
244
+	{
245
+		// TODO: if /when we implement donations, then this will need overriding
246
+		if (// don't need payment options for:
247
+			// registrations made via the admin
248
+			// completed transactions
249
+			// overpaid transactions
250
+			// $ 0.00 transactions(no payment required)
251
+			! $this->checkout->payment_required()
252
+			// but do NOT remove if current action being called belongs to this reg step
253
+			&& ! is_callable(array($this, $this->checkout->action))
254
+			&& ! $this->completed()
255
+		) {
256
+			// and if so, then we no longer need the Payment Options step
257
+			if ($this->is_current_step()) {
258
+				$this->checkout->generate_reg_form = false;
259
+			}
260
+			$this->checkout->remove_reg_step($this->_slug);
261
+			// DEBUG LOG
262
+			// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
263
+			return false;
264
+		}
265
+		// load EEM_Payment_Method
266
+		EE_Registry::instance()->load_model('Payment_Method');
267
+		// get all active payment methods
268
+		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
269
+			$this->checkout->transaction,
270
+			EEM_Payment_Method::scope_cart
271
+		);
272
+		return true;
273
+	}
274
+
275
+
276
+	/**
277
+	 * @return EE_Form_Section_Proper
278
+	 * @throws EE_Error
279
+	 * @throws InvalidArgumentException
280
+	 * @throws ReflectionException
281
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
282
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
283
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
284
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
285
+	 */
286
+	public function generate_reg_form()
287
+	{
288
+		// reset in case someone changes their mind
289
+		$this->_reset_selected_method_of_payment();
290
+		// set some defaults
291
+		$this->checkout->selected_method_of_payment = 'payments_closed';
292
+		$registrations_requiring_payment = array();
293
+		$registrations_for_free_events = array();
294
+		$registrations_requiring_pre_approval = array();
295
+		$sold_out_events = array();
296
+		$insufficient_spaces_available = array();
297
+		$no_payment_required = true;
298
+		// loop thru registrations to gather info
299
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
300
+		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
301
+			$registrations,
302
+			$this->checkout->revisit
303
+		);
304
+		foreach ($registrations as $REG_ID => $registration) {
305
+			/** @var $registration EE_Registration */
306
+			// has this registration lost it's space ?
307
+			if (isset($ejected_registrations[ $REG_ID ])) {
308
+				if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
+					$sold_out_events[ $registration->event()->ID() ] = $registration->event();
310
+				} else {
311
+					$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
312
+				}
313
+				continue;
314
+			}
315
+			// event requires admin approval
316
+			if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317
+				// add event to list of events with pre-approval reg status
318
+				$registrations_requiring_pre_approval[ $REG_ID ] = $registration;
319
+				do_action(
320
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321
+					$registration->event(),
322
+					$this
323
+				);
324
+				continue;
325
+			}
326
+			if ($this->checkout->revisit
327
+				&& $registration->status_ID() !== EEM_Registration::status_id_approved
328
+				&& (
329
+					$registration->event()->is_sold_out()
330
+					|| $registration->event()->is_sold_out(true)
331
+				)
332
+			) {
333
+				// add event to list of events that are sold out
334
+				$sold_out_events[ $registration->event()->ID() ] = $registration->event();
335
+				do_action(
336
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337
+					$registration->event(),
338
+					$this
339
+				);
340
+				continue;
341
+			}
342
+			// are they allowed to pay now and is there monies owing?
343
+			if ($registration->owes_monies_and_can_pay()) {
344
+				$registrations_requiring_payment[ $REG_ID ] = $registration;
345
+				do_action(
346
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347
+					$registration->event(),
348
+					$this
349
+				);
350
+			} elseif (! $this->checkout->revisit
351
+					  && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352
+					  && $registration->ticket()->is_free()
353
+			) {
354
+				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
355
+			}
356
+		}
357
+		$subsections = array();
358
+		// now decide which template to load
359
+		if (! empty($sold_out_events)) {
360
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361
+		}
362
+		if (! empty($insufficient_spaces_available)) {
363
+			$subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364
+				$insufficient_spaces_available
365
+			);
366
+		}
367
+		if (! empty($registrations_requiring_pre_approval)) {
368
+			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369
+				$registrations_requiring_pre_approval
370
+			);
371
+		}
372
+		if (! empty($registrations_for_free_events)) {
373
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374
+		}
375
+		if (! empty($registrations_requiring_payment)) {
376
+			if ($this->checkout->amount_owing > 0) {
377
+				// autoload Line_Item_Display classes
378
+				EEH_Autoloader::register_line_item_filter_autoloaders();
379
+				$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
380
+					apply_filters(
381
+						'FHEE__SPCO__EE_Line_Item_Filter_Collection',
382
+						new EE_Line_Item_Filter_Collection()
383
+					),
384
+					$this->checkout->cart->get_grand_total()
385
+				);
386
+				/** @var EE_Line_Item $filtered_line_item_tree */
387
+				$filtered_line_item_tree = $line_item_filter_processor->process();
388
+				EEH_Autoloader::register_line_item_display_autoloaders();
389
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
390
+				$subsections['payment_options'] = $this->_display_payment_options(
391
+					$this->line_item_display->display_line_item(
392
+						$filtered_line_item_tree,
393
+						array('registrations' => $registrations)
394
+					)
395
+				);
396
+				$this->checkout->amount_owing = $filtered_line_item_tree->total();
397
+				$this->_apply_registration_payments_to_amount_owing($registrations);
398
+			}
399
+			$no_payment_required = false;
400
+		} else {
401
+			$this->_hide_reg_step_submit_button_if_revisit();
402
+		}
403
+		$this->_save_selected_method_of_payment();
404
+
405
+		$subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
406
+		$subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
407
+
408
+		return new EE_Form_Section_Proper(
409
+			array(
410
+				'name'            => $this->reg_form_name(),
411
+				'html_id'         => $this->reg_form_name(),
412
+				'subsections'     => $subsections,
413
+				'layout_strategy' => new EE_No_Layout(),
414
+			)
415
+		);
416
+	}
417
+
418
+
419
+	/**
420
+	 * add line item filters required for this reg step
421
+	 * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks():
422
+	 *        add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options',
423
+	 *        'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the
424
+	 *        payment options reg step, can apply these filters via the following: apply_filters(
425
+	 *        'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing
426
+	 *        filter collection by passing that instead of instantiating a new collection
427
+	 *
428
+	 * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
429
+	 * @return EE_Line_Item_Filter_Collection
430
+	 * @throws EE_Error
431
+	 * @throws InvalidArgumentException
432
+	 * @throws ReflectionException
433
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
434
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
435
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
436
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
437
+	 */
438
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439
+	{
440
+		if (! EE_Registry::instance()->SSN instanceof EE_Session) {
441
+			return $line_item_filter_collection;
442
+		}
443
+		if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444
+			return $line_item_filter_collection;
445
+		}
446
+		if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447
+			return $line_item_filter_collection;
448
+		}
449
+		$line_item_filter_collection->add(
450
+			new EE_Billable_Line_Item_Filter(
451
+				EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
452
+					EE_Registry::instance()->SSN->checkout()->transaction->registrations(
453
+						EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
454
+					)
455
+				)
456
+			)
457
+		);
458
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
459
+		return $line_item_filter_collection;
460
+	}
461
+
462
+
463
+	/**
464
+	 * remove_ejected_registrations
465
+	 * if a registrant has lost their potential space at an event due to lack of payment,
466
+	 * then this method removes them from the list of registrations being paid for during this request
467
+	 *
468
+	 * @param \EE_Registration[] $registrations
469
+	 * @return EE_Registration[]
470
+	 * @throws EE_Error
471
+	 * @throws InvalidArgumentException
472
+	 * @throws ReflectionException
473
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
474
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
475
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
476
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
477
+	 */
478
+	public static function remove_ejected_registrations(array $registrations)
479
+	{
480
+		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
481
+			$registrations,
482
+			EE_Registry::instance()->SSN->checkout()->revisit
483
+		);
484
+		foreach ($registrations as $REG_ID => $registration) {
485
+			// has this registration lost it's space ?
486
+			if (isset($ejected_registrations[ $REG_ID ])) {
487
+				unset($registrations[ $REG_ID ]);
488
+				continue;
489
+			}
490
+		}
491
+		return $registrations;
492
+	}
493
+
494
+
495
+	/**
496
+	 * find_registrations_that_lost_their_space
497
+	 * If a registrant chooses an offline payment method like Invoice,
498
+	 * then no space is reserved for them at the event until they fully pay fo that site
499
+	 * (unless the event's default reg status is set to APPROVED)
500
+	 * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales,
501
+	 * then this method will determine which registrations have lost the ability to complete the reg process.
502
+	 *
503
+	 * @param \EE_Registration[] $registrations
504
+	 * @param bool               $revisit
505
+	 * @return array
506
+	 * @throws EE_Error
507
+	 * @throws InvalidArgumentException
508
+	 * @throws ReflectionException
509
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
510
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
511
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
512
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
513
+	 */
514
+	public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false)
515
+	{
516
+		// registrations per event
517
+		$event_reg_count = array();
518
+		// spaces left per event
519
+		$event_spaces_remaining = array();
520
+		// tickets left sorted by ID
521
+		$tickets_remaining = array();
522
+		// registrations that have lost their space
523
+		$ejected_registrations = array();
524
+		foreach ($registrations as $REG_ID => $registration) {
525
+			if ($registration->status_ID() === EEM_Registration::status_id_approved
526
+				|| apply_filters(
527
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment',
528
+					false,
529
+					$registration,
530
+					$revisit
531
+				)
532
+			) {
533
+				continue;
534
+			}
535
+			$EVT_ID = $registration->event_ID();
536
+			$ticket = $registration->ticket();
537
+			if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
+				$tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
539
+			}
540
+			if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
+				if (! isset($event_reg_count[ $EVT_ID ])) {
542
+					$event_reg_count[ $EVT_ID ] = 0;
543
+				}
544
+				$event_reg_count[ $EVT_ID ]++;
545
+				if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
+					$event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
547
+				}
548
+			}
549
+			if ($revisit
550
+				&& ($tickets_remaining[ $ticket->ID() ] === 0
551
+					|| $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
552
+				)
553
+			) {
554
+				$ejected_registrations[ $REG_ID ] = $registration->event();
555
+				if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556
+					/** @type EE_Registration_Processor $registration_processor */
557
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
558
+					// at this point, we should have enough details about the registrant to consider the registration
559
+					// NOT incomplete
560
+					$registration_processor->manually_update_registration_status(
561
+						$registration,
562
+						EEM_Registration::status_id_wait_list
563
+					);
564
+				}
565
+			}
566
+		}
567
+		return $ejected_registrations;
568
+	}
569
+
570
+
571
+	/**
572
+	 * _hide_reg_step_submit_button
573
+	 * removes the html for the reg step submit button
574
+	 * by replacing it with an empty string via filter callback
575
+	 *
576
+	 * @return void
577
+	 */
578
+	protected function _adjust_registration_status_if_event_old_sold()
579
+	{
580
+	}
581
+
582
+
583
+	/**
584
+	 * _hide_reg_step_submit_button
585
+	 * removes the html for the reg step submit button
586
+	 * by replacing it with an empty string via filter callback
587
+	 *
588
+	 * @return void
589
+	 */
590
+	protected function _hide_reg_step_submit_button_if_revisit()
591
+	{
592
+		if ($this->checkout->revisit) {
593
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
594
+		}
595
+	}
596
+
597
+
598
+	/**
599
+	 * sold_out_events
600
+	 * displays notices regarding events that have sold out since hte registrant first signed up
601
+	 *
602
+	 * @param \EE_Event[] $sold_out_events_array
603
+	 * @return \EE_Form_Section_Proper
604
+	 * @throws \EE_Error
605
+	 */
606
+	private function _sold_out_events($sold_out_events_array = array())
607
+	{
608
+		// set some defaults
609
+		$this->checkout->selected_method_of_payment = 'events_sold_out';
610
+		$sold_out_events = '';
611
+		foreach ($sold_out_events_array as $sold_out_event) {
612
+			$sold_out_events .= EEH_HTML::li(
613
+				EEH_HTML::span(
614
+					'  ' . $sold_out_event->name(),
615
+					'',
616
+					'dashicons dashicons-marker ee-icon-size-16 pink-text'
617
+				)
618
+			);
619
+		}
620
+		return new EE_Form_Section_Proper(
621
+			array(
622
+				'layout_strategy' => new EE_Template_Layout(
623
+					array(
624
+						'layout_template_file' => SPCO_REG_STEPS_PATH
625
+												  . $this->_slug
626
+												  . DS
627
+												  . 'sold_out_events.template.php',
628
+						'template_args'        => apply_filters(
629
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
630
+							array(
631
+								'sold_out_events'     => $sold_out_events,
632
+								'sold_out_events_msg' => apply_filters(
633
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
634
+									sprintf(
635
+										esc_html__(
636
+											'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s',
637
+											'event_espresso'
638
+										),
639
+										'<strong>',
640
+										'</strong>',
641
+										'<br />'
642
+									)
643
+								),
644
+							)
645
+						),
646
+					)
647
+				),
648
+			)
649
+		);
650
+	}
651
+
652
+
653
+	/**
654
+	 * _insufficient_spaces_available
655
+	 * displays notices regarding events that do not have enough remaining spaces
656
+	 * to satisfy the current number of registrations looking to pay
657
+	 *
658
+	 * @param \EE_Event[] $insufficient_spaces_events_array
659
+	 * @return \EE_Form_Section_Proper
660
+	 * @throws \EE_Error
661
+	 */
662
+	private function _insufficient_spaces_available($insufficient_spaces_events_array = array())
663
+	{
664
+		// set some defaults
665
+		$this->checkout->selected_method_of_payment = 'invoice';
666
+		$insufficient_space_events = '';
667
+		foreach ($insufficient_spaces_events_array as $event) {
668
+			if ($event instanceof EE_Event) {
669
+				$insufficient_space_events .= EEH_HTML::li(
670
+					EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
671
+				);
672
+			}
673
+		}
674
+		return new EE_Form_Section_Proper(
675
+			array(
676
+				'subsections'     => array(
677
+					'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
678
+					'extra_hidden_inputs'   => $this->_extra_hidden_inputs(),
679
+				),
680
+				'layout_strategy' => new EE_Template_Layout(
681
+					array(
682
+						'layout_template_file' => SPCO_REG_STEPS_PATH
683
+												  . $this->_slug
684
+												  . DS
685
+												  . 'sold_out_events.template.php',
686
+						'template_args'        => apply_filters(
687
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
688
+							array(
689
+								'sold_out_events'     => $insufficient_space_events,
690
+								'sold_out_events_msg' => apply_filters(
691
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg',
692
+									esc_html__(
693
+										'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
694
+										'event_espresso'
695
+									)
696
+								),
697
+							)
698
+						),
699
+					)
700
+				),
701
+			)
702
+		);
703
+	}
704
+
705
+
706
+	/**
707
+	 * registrations_requiring_pre_approval
708
+	 *
709
+	 * @param array $registrations_requiring_pre_approval
710
+	 * @return EE_Form_Section_Proper
711
+	 * @throws EE_Error
712
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
713
+	 */
714
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array())
715
+	{
716
+		$events_requiring_pre_approval = '';
717
+		foreach ($registrations_requiring_pre_approval as $registration) {
718
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
719
+				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
720
+					EEH_HTML::span(
721
+						'',
722
+						'',
723
+						'dashicons dashicons-marker ee-icon-size-16 orange-text'
724
+					)
725
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
726
+				);
727
+			}
728
+		}
729
+		return new EE_Form_Section_Proper(
730
+			array(
731
+				'layout_strategy' => new EE_Template_Layout(
732
+					array(
733
+						'layout_template_file' => SPCO_REG_STEPS_PATH
734
+												  . $this->_slug
735
+												  . DS
736
+												  . 'events_requiring_pre_approval.template.php', // layout_template
737
+						'template_args'        => apply_filters(
738
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
739
+							array(
740
+								'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
741
+								'events_requiring_pre_approval_msg' => apply_filters(
742
+									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
743
+									esc_html__(
744
+										'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
745
+										'event_espresso'
746
+									)
747
+								),
748
+							)
749
+						),
750
+					)
751
+				),
752
+			)
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * _no_payment_required
759
+	 *
760
+	 * @param \EE_Event[] $registrations_for_free_events
761
+	 * @return \EE_Form_Section_Proper
762
+	 * @throws \EE_Error
763
+	 */
764
+	private function _no_payment_required($registrations_for_free_events = array())
765
+	{
766
+		// set some defaults
767
+		$this->checkout->selected_method_of_payment = 'no_payment_required';
768
+		// generate no_payment_required form
769
+		return new EE_Form_Section_Proper(
770
+			array(
771
+				'layout_strategy' => new EE_Template_Layout(
772
+					array(
773
+						'layout_template_file' => SPCO_REG_STEPS_PATH
774
+												  . $this->_slug
775
+												  . DS
776
+												  . 'no_payment_required.template.php', // layout_template
777
+						'template_args'        => apply_filters(
778
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
779
+							array(
780
+								'revisit'                       => $this->checkout->revisit,
781
+								'registrations'                 => array(),
782
+								'ticket_count'                  => array(),
783
+								'registrations_for_free_events' => $registrations_for_free_events,
784
+								'no_payment_required_msg'       => EEH_HTML::p(
785
+									esc_html__('This is a free event, so no billing will occur.', 'event_espresso')
786
+								),
787
+							)
788
+						),
789
+					)
790
+				),
791
+			)
792
+		);
793
+	}
794
+
795
+
796
+	/**
797
+	 * _display_payment_options
798
+	 *
799
+	 * @param string $transaction_details
800
+	 * @return EE_Form_Section_Proper
801
+	 * @throws EE_Error
802
+	 * @throws InvalidArgumentException
803
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
804
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
805
+	 */
806
+	private function _display_payment_options($transaction_details = '')
807
+	{
808
+		// has method_of_payment been set by no-js user?
809
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
810
+		// build payment options form
811
+		return apply_filters(
812
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form',
813
+			new EE_Form_Section_Proper(
814
+				array(
815
+					'subsections'     => array(
816
+						'before_payment_options' => apply_filters(
817
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
818
+							new EE_Form_Section_Proper(
819
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
820
+							)
821
+						),
822
+						'payment_options'        => $this->_setup_payment_options(),
823
+						'after_payment_options'  => apply_filters(
824
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
825
+							new EE_Form_Section_Proper(
826
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
827
+							)
828
+						),
829
+					),
830
+					'layout_strategy' => new EE_Template_Layout(
831
+						array(
832
+							'layout_template_file' => $this->_template,
833
+							'template_args'        => apply_filters(
834
+								'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
835
+								array(
836
+									'reg_count'                 => $this->line_item_display->total_items(),
837
+									'transaction_details'       => $transaction_details,
838
+									'available_payment_methods' => array(),
839
+								)
840
+							),
841
+						)
842
+					),
843
+				)
844
+			)
845
+		);
846
+	}
847
+
848
+
849
+	/**
850
+	 * _extra_hidden_inputs
851
+	 *
852
+	 * @param bool $no_payment_required
853
+	 * @return \EE_Form_Section_Proper
854
+	 * @throws \EE_Error
855
+	 */
856
+	private function _extra_hidden_inputs($no_payment_required = true)
857
+	{
858
+		return new EE_Form_Section_Proper(
859
+			array(
860
+				'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
861
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
862
+				'subsections'     => array(
863
+					'spco_no_payment_required' => new EE_Hidden_Input(
864
+						array(
865
+							'normalization_strategy' => new EE_Boolean_Normalization(),
866
+							'html_name'              => 'spco_no_payment_required',
867
+							'html_id'                => 'spco-no-payment-required-payment_options',
868
+							'default'                => $no_payment_required,
869
+						)
870
+					),
871
+					'spco_transaction_id'      => new EE_Fixed_Hidden_Input(
872
+						array(
873
+							'normalization_strategy' => new EE_Int_Normalization(),
874
+							'html_name'              => 'spco_transaction_id',
875
+							'html_id'                => 'spco-transaction-id',
876
+							'default'                => $this->checkout->transaction->ID(),
877
+						)
878
+					),
879
+				),
880
+			)
881
+		);
882
+	}
883
+
884
+
885
+	/**
886
+	 *    _apply_registration_payments_to_amount_owing
887
+	 *
888
+	 * @access protected
889
+	 * @param array $registrations
890
+	 * @throws EE_Error
891
+	 */
892
+	protected function _apply_registration_payments_to_amount_owing(array $registrations)
893
+	{
894
+		$payments = array();
895
+		foreach ($registrations as $registration) {
896
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
897
+				$payments += $registration->registration_payments();
898
+			}
899
+		}
900
+		if (! empty($payments)) {
901
+			foreach ($payments as $payment) {
902
+				if ($payment instanceof EE_Registration_Payment) {
903
+					$this->checkout->amount_owing -= $payment->amount();
904
+				}
905
+			}
906
+		}
907
+	}
908
+
909
+
910
+	/**
911
+	 *    _reset_selected_method_of_payment
912
+	 *
913
+	 * @access    private
914
+	 * @param    bool $force_reset
915
+	 * @return void
916
+	 * @throws InvalidArgumentException
917
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
918
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
919
+	 */
920
+	private function _reset_selected_method_of_payment($force_reset = false)
921
+	{
922
+		$reset_payment_method = $force_reset
923
+			? true
924
+			: sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
925
+		if ($reset_payment_method) {
926
+			$this->checkout->selected_method_of_payment = null;
927
+			$this->checkout->payment_method = null;
928
+			$this->checkout->billing_form = null;
929
+			$this->_save_selected_method_of_payment();
930
+		}
931
+	}
932
+
933
+
934
+	/**
935
+	 * _save_selected_method_of_payment
936
+	 * stores the selected_method_of_payment in the session
937
+	 * so that it's available for all subsequent requests including AJAX
938
+	 *
939
+	 * @access        private
940
+	 * @param string $selected_method_of_payment
941
+	 * @return void
942
+	 * @throws InvalidArgumentException
943
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
944
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
945
+	 */
946
+	private function _save_selected_method_of_payment($selected_method_of_payment = '')
947
+	{
948
+		$selected_method_of_payment = ! empty($selected_method_of_payment)
949
+			? $selected_method_of_payment
950
+			: $this->checkout->selected_method_of_payment;
951
+		EE_Registry::instance()->SSN->set_session_data(
952
+			array('selected_method_of_payment' => $selected_method_of_payment)
953
+		);
954
+	}
955
+
956
+
957
+	/**
958
+	 * _setup_payment_options
959
+	 *
960
+	 * @return EE_Form_Section_Proper
961
+	 * @throws EE_Error
962
+	 * @throws InvalidArgumentException
963
+	 * @throws ReflectionException
964
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
965
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
966
+	 */
967
+	public function _setup_payment_options()
968
+	{
969
+		// load payment method classes
970
+		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
971
+		if (empty($this->checkout->available_payment_methods)) {
972
+			EE_Error::add_error(
973
+				apply_filters(
974
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods',
975
+					sprintf(
976
+						esc_html__(
977
+							'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.',
978
+							'event_espresso'
979
+						),
980
+						'<br>',
981
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
982
+					)
983
+				),
984
+				__FILE__,
985
+				__FUNCTION__,
986
+				__LINE__
987
+			);
988
+		}
989
+		// switch up header depending on number of available payment methods
990
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
991
+			? apply_filters(
992
+				'FHEE__registration_page_payment_options__method_of_payment_hdr',
993
+				esc_html__('Please Select Your Method of Payment', 'event_espresso')
994
+			)
995
+			: apply_filters(
996
+				'FHEE__registration_page_payment_options__method_of_payment_hdr',
997
+				esc_html__('Method of Payment', 'event_espresso')
998
+			);
999
+		$available_payment_methods = array(
1000
+			// display the "Payment Method" header
1001
+			'payment_method_header' => new EE_Form_Section_HTML(
1002
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
1003
+			),
1004
+		);
1005
+		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
1006
+		$available_payment_method_options = array();
1007
+		$default_payment_method_option = array();
1008
+		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
1009
+		$payment_methods_billing_info = array(
1010
+			new EE_Form_Section_HTML(
1011
+				EEH_HTML::div('<br />', '', '', 'clear:both;')
1012
+			),
1013
+		);
1014
+		// loop through payment methods
1015
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
1016
+			if ($payment_method instanceof EE_Payment_Method) {
1017
+				$payment_method_button = EEH_HTML::img(
1018
+					$payment_method->button_url(),
1019
+					$payment_method->name(),
1020
+					'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1021
+					'spco-payment-method-btn-img'
1022
+				);
1023
+				// check if any payment methods are set as default
1024
+				// if payment method is already selected OR nothing is selected and this payment method should be
1025
+				// open_by_default
1026
+				if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
+					|| (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028
+				) {
1029
+					$this->checkout->selected_method_of_payment = $payment_method->slug();
1030
+					$this->_save_selected_method_of_payment();
1031
+					$default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1032
+				} else {
1033
+					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1034
+				}
1035
+				$payment_methods_billing_info[ $payment_method->slug(
1036
+				) . '-info' ] = $this->_payment_method_billing_info(
1037
+					$payment_method
1038
+				);
1039
+			}
1040
+		}
1041
+		// prepend available_payment_method_options with default_payment_method_option so that it appears first in list
1042
+		// of PMs
1043
+		$available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
1044
+		// now generate the actual form  inputs
1045
+		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs(
1046
+			$available_payment_method_options
1047
+		);
1048
+		$available_payment_methods += $payment_methods_billing_info;
1049
+		// build the available payment methods form
1050
+		return new EE_Form_Section_Proper(
1051
+			array(
1052
+				'html_id'         => 'spco-available-methods-of-payment-dv',
1053
+				'subsections'     => $available_payment_methods,
1054
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1055
+			)
1056
+		);
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * _get_available_payment_methods
1062
+	 *
1063
+	 * @return EE_Payment_Method[]
1064
+	 * @throws EE_Error
1065
+	 * @throws InvalidArgumentException
1066
+	 * @throws ReflectionException
1067
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1068
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1069
+	 */
1070
+	protected function _get_available_payment_methods()
1071
+	{
1072
+		if (! empty($this->checkout->available_payment_methods)) {
1073
+			return $this->checkout->available_payment_methods;
1074
+		}
1075
+		$available_payment_methods = array();
1076
+		// load EEM_Payment_Method
1077
+		EE_Registry::instance()->load_model('Payment_Method');
1078
+		/** @type EEM_Payment_Method $EEM_Payment_Method */
1079
+		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1080
+		// get all active payment methods
1081
+		$payment_methods = $EEM_Payment_Method->get_all_for_transaction(
1082
+			$this->checkout->transaction,
1083
+			EEM_Payment_Method::scope_cart
1084
+		);
1085
+		foreach ($payment_methods as $payment_method) {
1086
+			if ($payment_method instanceof EE_Payment_Method) {
1087
+				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
1088
+			}
1089
+		}
1090
+		return $available_payment_methods;
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 *    _available_payment_method_inputs
1096
+	 *
1097
+	 * @access    private
1098
+	 * @param    array $available_payment_method_options
1099
+	 * @return    \EE_Form_Section_Proper
1100
+	 */
1101
+	private function _available_payment_method_inputs($available_payment_method_options = array())
1102
+	{
1103
+		// generate inputs
1104
+		return new EE_Form_Section_Proper(
1105
+			array(
1106
+				'html_id'         => 'ee-available-payment-method-inputs',
1107
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1108
+				'subsections'     => array(
1109
+					'' => new EE_Radio_Button_Input(
1110
+						$available_payment_method_options,
1111
+						array(
1112
+							'html_name'          => 'selected_method_of_payment',
1113
+							'html_class'         => 'spco-payment-method',
1114
+							'default'            => $this->checkout->selected_method_of_payment,
1115
+							'label_size'         => 11,
1116
+							'enforce_label_size' => true,
1117
+						)
1118
+					),
1119
+				),
1120
+			)
1121
+		);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 *    _payment_method_billing_info
1127
+	 *
1128
+	 * @access    private
1129
+	 * @param    EE_Payment_Method $payment_method
1130
+	 * @return EE_Form_Section_Proper
1131
+	 * @throws EE_Error
1132
+	 * @throws InvalidArgumentException
1133
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
+	 */
1136
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method)
1137
+	{
1138
+		$currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1139
+			? true
1140
+			: false;
1141
+		// generate the billing form for payment method
1142
+		$billing_form = $currently_selected
1143
+			? $this->_get_billing_form_for_payment_method($payment_method)
1144
+			: new EE_Form_Section_HTML();
1145
+		$this->checkout->billing_form = $currently_selected
1146
+			? $billing_form
1147
+			: $this->checkout->billing_form;
1148
+		// it's all in the details
1149
+		$info_html = EEH_HTML::h3(
1150
+			esc_html__('Important information regarding your payment', 'event_espresso'),
1151
+			'',
1152
+			'spco-payment-method-hdr'
1153
+		);
1154
+		// add some info regarding the step, either from what's saved in the admin,
1155
+		// or a default string depending on whether the PM has a billing form or not
1156
+		if ($payment_method->description()) {
1157
+			$payment_method_info = $payment_method->description();
1158
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
1159
+			$payment_method_info = sprintf(
1160
+				esc_html__(
1161
+					'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
1162
+					'event_espresso'
1163
+				),
1164
+				$this->submit_button_text()
1165
+			);
1166
+		} else {
1167
+			$payment_method_info = sprintf(
1168
+				esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1169
+				$this->submit_button_text()
1170
+			);
1171
+		}
1172
+		$info_html .= EEH_HTML::p(
1173
+			apply_filters(
1174
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info',
1175
+				$payment_method_info
1176
+			),
1177
+			'',
1178
+			'spco-payment-method-desc ee-attention'
1179
+		);
1180
+		return new EE_Form_Section_Proper(
1181
+			array(
1182
+				'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1183
+				'html_class'      => 'spco-payment-method-info-dv',
1184
+				// only display the selected or default PM
1185
+				'html_style'      => $currently_selected ? '' : 'display:none;',
1186
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1187
+				'subsections'     => array(
1188
+					'info'         => new EE_Form_Section_HTML($info_html),
1189
+					'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(),
1190
+				),
1191
+			)
1192
+		);
1193
+	}
1194
+
1195
+
1196
+	/**
1197
+	 * get_billing_form_html_for_payment_method
1198
+	 *
1199
+	 * @access public
1200
+	 * @return string
1201
+	 * @throws EE_Error
1202
+	 * @throws InvalidArgumentException
1203
+	 * @throws ReflectionException
1204
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1205
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1206
+	 */
1207
+	public function get_billing_form_html_for_payment_method()
1208
+	{
1209
+		// how have they chosen to pay?
1210
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211
+		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
+		if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213
+			return false;
1214
+		}
1215
+		if (apply_filters(
1216
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1217
+			false
1218
+		)) {
1219
+			EE_Error::add_success(
1220
+				apply_filters(
1221
+					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1222
+					sprintf(
1223
+						esc_html__(
1224
+							'You have selected "%s" as your method of payment. Please note the important payment information below.',
1225
+							'event_espresso'
1226
+						),
1227
+						$this->checkout->payment_method->name()
1228
+					)
1229
+				)
1230
+			);
1231
+		}
1232
+		// now generate billing form for selected method of payment
1233
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1234
+		// fill form with attendee info if applicable
1235
+		if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1236
+			&& $this->checkout->transaction_has_primary_registrant()
1237
+		) {
1238
+			$payment_method_billing_form->populate_from_attendee(
1239
+				$this->checkout->transaction->primary_registration()->attendee()
1240
+			);
1241
+		}
1242
+		// and debug content
1243
+		if ($payment_method_billing_form instanceof EE_Billing_Info_Form
1244
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1245
+		) {
1246
+			$payment_method_billing_form =
1247
+				$this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1248
+					$payment_method_billing_form
1249
+				);
1250
+		}
1251
+		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1252
+			? $payment_method_billing_form->get_html()
1253
+			: '';
1254
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1255
+		// localize validation rules for main form
1256
+		$this->checkout->current_step->reg_form->localize_validation_rules();
1257
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1258
+		return true;
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * _get_billing_form_for_payment_method
1264
+	 *
1265
+	 * @access private
1266
+	 * @param EE_Payment_Method $payment_method
1267
+	 * @return EE_Billing_Info_Form|EE_Form_Section_HTML
1268
+	 * @throws EE_Error
1269
+	 * @throws InvalidArgumentException
1270
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1271
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1272
+	 */
1273
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method)
1274
+	{
1275
+		$billing_form = $payment_method->type_obj()->billing_form(
1276
+			$this->checkout->transaction,
1277
+			array('amount_owing' => $this->checkout->amount_owing)
1278
+		);
1279
+		if ($billing_form instanceof EE_Billing_Info_Form) {
1280
+			if (apply_filters(
1281
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1282
+				false
1283
+			)
1284
+				&& EE_Registry::instance()->REQ->is_set('payment_method')
1285
+			) {
1286
+				EE_Error::add_success(
1287
+					apply_filters(
1288
+						'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1289
+						sprintf(
1290
+							esc_html__(
1291
+								'You have selected "%s" as your method of payment. Please note the important payment information below.',
1292
+								'event_espresso'
1293
+							),
1294
+							$payment_method->name()
1295
+						)
1296
+					)
1297
+				);
1298
+			}
1299
+			return apply_filters(
1300
+				'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
1301
+				$billing_form,
1302
+				$payment_method
1303
+			);
1304
+		}
1305
+		// no actual billing form, so return empty HTML form section
1306
+		return new EE_Form_Section_HTML();
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 * _get_selected_method_of_payment
1312
+	 *
1313
+	 * @access private
1314
+	 * @param boolean $required whether to throw an error if the "selected_method_of_payment"
1315
+	 *                          is not found in the incoming request
1316
+	 * @param string  $request_param
1317
+	 * @return NULL|string
1318
+	 * @throws EE_Error
1319
+	 * @throws InvalidArgumentException
1320
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1321
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1322
+	 */
1323
+	private function _get_selected_method_of_payment(
1324
+		$required = false,
1325
+		$request_param = 'selected_method_of_payment'
1326
+	) {
1327
+		// is selected_method_of_payment set in the request ?
1328
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1329
+		if ($selected_method_of_payment) {
1330
+			// sanitize it
1331
+			$selected_method_of_payment = is_array($selected_method_of_payment)
1332
+				? array_shift($selected_method_of_payment)
1333
+				: $selected_method_of_payment;
1334
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1335
+			// store it in the session so that it's available for all subsequent requests including AJAX
1336
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
1337
+		} else {
1338
+			// or is is set in the session ?
1339
+			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
1340
+				'selected_method_of_payment'
1341
+			);
1342
+		}
1343
+		// do ya really really gotta have it?
1344
+		if (empty($selected_method_of_payment) && $required) {
1345
+			EE_Error::add_error(
1346
+				sprintf(
1347
+					esc_html__(
1348
+						'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.',
1349
+						'event_espresso'
1350
+					),
1351
+					'<br/>',
1352
+					'<br/>',
1353
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1354
+				),
1355
+				__FILE__,
1356
+				__FUNCTION__,
1357
+				__LINE__
1358
+			);
1359
+			return null;
1360
+		}
1361
+		return $selected_method_of_payment;
1362
+	}
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+	/********************************************************************************************************/
1370
+	/***********************************  SWITCH PAYMENT METHOD  ************************************/
1371
+	/********************************************************************************************************/
1372
+	/**
1373
+	 * switch_payment_method
1374
+	 *
1375
+	 * @access public
1376
+	 * @return string
1377
+	 * @throws EE_Error
1378
+	 * @throws InvalidArgumentException
1379
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1380
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1381
+	 */
1382
+	public function switch_payment_method()
1383
+	{
1384
+		if (! $this->_verify_payment_method_is_set()) {
1385
+			return false;
1386
+		}
1387
+		if (apply_filters(
1388
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1389
+			false
1390
+		)) {
1391
+			EE_Error::add_success(
1392
+				apply_filters(
1393
+					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
1394
+					sprintf(
1395
+						esc_html__(
1396
+							'You have selected "%s" as your method of payment. Please note the important payment information below.',
1397
+							'event_espresso'
1398
+						),
1399
+						$this->checkout->payment_method->name()
1400
+					)
1401
+				)
1402
+			);
1403
+		}
1404
+		// generate billing form for selected method of payment if it hasn't been done already
1405
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1406
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1407
+				$this->checkout->payment_method
1408
+			);
1409
+		}
1410
+		// fill form with attendee info if applicable
1411
+		if (apply_filters(
1412
+			'FHEE__populate_billing_form_fields_from_attendee',
1413
+			(
1414
+				$this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
1415
+				&& $this->checkout->transaction_has_primary_registrant()
1416
+			),
1417
+			$this->checkout->billing_form,
1418
+			$this->checkout->transaction
1419
+		)
1420
+		) {
1421
+			$this->checkout->billing_form->populate_from_attendee(
1422
+				$this->checkout->transaction->primary_registration()->attendee()
1423
+			);
1424
+		}
1425
+		// and debug content
1426
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1427
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1428
+		) {
1429
+			$this->checkout->billing_form =
1430
+				$this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1431
+					$this->checkout->billing_form
1432
+				);
1433
+		}
1434
+		// get html and validation rules for form
1435
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1436
+			$this->checkout->json_response->set_return_data(
1437
+				array('payment_method_info' => $this->checkout->billing_form->get_html())
1438
+			);
1439
+			// localize validation rules for main form
1440
+			$this->checkout->billing_form->localize_validation_rules(true);
1441
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1442
+		} else {
1443
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1444
+		}
1445
+		// prevents advancement to next step
1446
+		$this->checkout->continue_reg = false;
1447
+		return true;
1448
+	}
1449
+
1450
+
1451
+	/**
1452
+	 * _verify_payment_method_is_set
1453
+	 *
1454
+	 * @return bool
1455
+	 * @throws EE_Error
1456
+	 * @throws InvalidArgumentException
1457
+	 * @throws ReflectionException
1458
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1459
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1460
+	 */
1461
+	protected function _verify_payment_method_is_set()
1462
+	{
1463
+		// generate billing form for selected method of payment if it hasn't been done already
1464
+		if (empty($this->checkout->selected_method_of_payment)) {
1465
+			// how have they chosen to pay?
1466
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1467
+		} else {
1468
+			// choose your own adventure based on method_of_payment
1469
+			switch ($this->checkout->selected_method_of_payment) {
1470
+				case 'events_sold_out':
1471
+					EE_Error::add_attention(
1472
+						apply_filters(
1473
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
1474
+							esc_html__(
1475
+								'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1476
+								'event_espresso'
1477
+							)
1478
+						),
1479
+						__FILE__,
1480
+						__FUNCTION__,
1481
+						__LINE__
1482
+					);
1483
+					return false;
1484
+					break;
1485
+				case 'payments_closed':
1486
+					EE_Error::add_attention(
1487
+						apply_filters(
1488
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
1489
+							esc_html__(
1490
+								'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.',
1491
+								'event_espresso'
1492
+							)
1493
+						),
1494
+						__FILE__,
1495
+						__FUNCTION__,
1496
+						__LINE__
1497
+					);
1498
+					return false;
1499
+					break;
1500
+				case 'no_payment_required':
1501
+					EE_Error::add_attention(
1502
+						apply_filters(
1503
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
1504
+							esc_html__(
1505
+								'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.',
1506
+								'event_espresso'
1507
+							)
1508
+						),
1509
+						__FILE__,
1510
+						__FUNCTION__,
1511
+						__LINE__
1512
+					);
1513
+					return false;
1514
+					break;
1515
+				default:
1516
+			}
1517
+		}
1518
+		// verify payment method
1519
+		if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520
+			// get payment method for selected method of payment
1521
+			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522
+		}
1523
+		return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false;
1524
+	}
1525
+
1526
+
1527
+
1528
+	/********************************************************************************************************/
1529
+	/***************************************  SAVE PAYER DETAILS  ****************************************/
1530
+	/********************************************************************************************************/
1531
+	/**
1532
+	 * save_payer_details_via_ajax
1533
+	 *
1534
+	 * @return void
1535
+	 * @throws EE_Error
1536
+	 * @throws InvalidArgumentException
1537
+	 * @throws ReflectionException
1538
+	 * @throws RuntimeException
1539
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1540
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1541
+	 */
1542
+	public function save_payer_details_via_ajax()
1543
+	{
1544
+		if (! $this->_verify_payment_method_is_set()) {
1545
+			return;
1546
+		}
1547
+		// generate billing form for selected method of payment if it hasn't been done already
1548
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1549
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1550
+				$this->checkout->payment_method
1551
+			);
1552
+		}
1553
+		// generate primary attendee from payer info if applicable
1554
+		if (! $this->checkout->transaction_has_primary_registrant()) {
1555
+			$attendee = $this->_create_attendee_from_request_data();
1556
+			if ($attendee instanceof EE_Attendee) {
1557
+				foreach ($this->checkout->transaction->registrations() as $registration) {
1558
+					if ($registration->is_primary_registrant()) {
1559
+						$this->checkout->primary_attendee_obj = $attendee;
1560
+						$registration->_add_relation_to($attendee, 'Attendee');
1561
+						$registration->set_attendee_id($attendee->ID());
1562
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1563
+					}
1564
+				}
1565
+			}
1566
+		}
1567
+	}
1568
+
1569
+
1570
+	/**
1571
+	 * create_attendee_from_request_data
1572
+	 * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1573
+	 *
1574
+	 * @return EE_Attendee
1575
+	 * @throws EE_Error
1576
+	 * @throws InvalidArgumentException
1577
+	 * @throws ReflectionException
1578
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1579
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1580
+	 */
1581
+	protected function _create_attendee_from_request_data()
1582
+	{
1583
+		// get State ID
1584
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
+		if (! empty($STA_ID)) {
1586
+			// can we get state object from name ?
1587
+			EE_Registry::instance()->load_model('State');
1588
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1589
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1590
+		}
1591
+		// get Country ISO
1592
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
+		if (! empty($CNT_ISO)) {
1594
+			// can we get country object from name ?
1595
+			EE_Registry::instance()->load_model('Country');
1596
+			$country = EEM_Country::instance()->get_col(
1597
+				array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1598
+				'CNT_ISO'
1599
+			);
1600
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1601
+		}
1602
+		// grab attendee data
1603
+		$attendee_data = array(
1604
+			'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1605
+			'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1606
+			'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1607
+			'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1608
+			'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1609
+			'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1610
+			'STA_ID'       => $STA_ID,
1611
+			'CNT_ISO'      => $CNT_ISO,
1612
+			'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1613
+			'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1614
+		);
1615
+		// validate the email address since it is the most important piece of info
1616
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1617
+			EE_Error::add_error(
1618
+				esc_html__('An invalid email address was submitted.', 'event_espresso'),
1619
+				__FILE__,
1620
+				__FUNCTION__,
1621
+				__LINE__
1622
+			);
1623
+		}
1624
+		// does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625
+		// AND email address
1626
+		if (! empty($attendee_data['ATT_fname'])
1627
+			&& ! empty($attendee_data['ATT_lname'])
1628
+			&& ! empty($attendee_data['ATT_email'])
1629
+		) {
1630
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1631
+				array(
1632
+					'ATT_fname' => $attendee_data['ATT_fname'],
1633
+					'ATT_lname' => $attendee_data['ATT_lname'],
1634
+					'ATT_email' => $attendee_data['ATT_email'],
1635
+				)
1636
+			);
1637
+			if ($existing_attendee instanceof EE_Attendee) {
1638
+				return $existing_attendee;
1639
+			}
1640
+		}
1641
+		// no existing attendee? kk let's create a new one
1642
+		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those
1643
+		// don't exist
1644
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1645
+			? $attendee_data['ATT_fname']
1646
+			: $attendee_data['ATT_email'];
1647
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1648
+			? $attendee_data['ATT_lname']
1649
+			: $attendee_data['ATT_email'];
1650
+		return EE_Attendee::new_instance($attendee_data);
1651
+	}
1652
+
1653
+
1654
+
1655
+	/********************************************************************************************************/
1656
+	/****************************************  PROCESS REG STEP  *****************************************/
1657
+	/********************************************************************************************************/
1658
+	/**
1659
+	 * process_reg_step
1660
+	 *
1661
+	 * @return bool
1662
+	 * @throws EE_Error
1663
+	 * @throws InvalidArgumentException
1664
+	 * @throws ReflectionException
1665
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1666
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1667
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1668
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
1669
+	 */
1670
+	public function process_reg_step()
1671
+	{
1672
+		// how have they chosen to pay?
1673
+		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1674
+			? 'no_payment_required'
1675
+			: $this->_get_selected_method_of_payment(true);
1676
+		// choose your own adventure based on method_of_payment
1677
+		switch ($this->checkout->selected_method_of_payment) {
1678
+			case 'events_sold_out':
1679
+				$this->checkout->redirect = true;
1680
+				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1681
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1682
+				// mark this reg step as completed
1683
+				$this->set_completed();
1684
+				return false;
1685
+				break;
1686
+
1687
+			case 'payments_closed':
1688
+				if (apply_filters(
1689
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1690
+					false
1691
+				)) {
1692
+					EE_Error::add_success(
1693
+						esc_html__('no payment required at this time.', 'event_espresso'),
1694
+						__FILE__,
1695
+						__FUNCTION__,
1696
+						__LINE__
1697
+					);
1698
+				}
1699
+				// mark this reg step as completed
1700
+				$this->set_completed();
1701
+				return true;
1702
+				break;
1703
+
1704
+			case 'no_payment_required':
1705
+				if (apply_filters(
1706
+					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1707
+					false
1708
+				)) {
1709
+					EE_Error::add_success(
1710
+						esc_html__('no payment required.', 'event_espresso'),
1711
+						__FILE__,
1712
+						__FUNCTION__,
1713
+						__LINE__
1714
+					);
1715
+				}
1716
+				// mark this reg step as completed
1717
+				$this->set_completed();
1718
+				return true;
1719
+				break;
1720
+
1721
+			default:
1722
+				$registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
1723
+					EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
1724
+				);
1725
+				$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
1726
+					$registrations,
1727
+					EE_Registry::instance()->SSN->checkout()->revisit
1728
+				);
1729
+				// calculate difference between the two arrays
1730
+				$registrations = array_diff($registrations, $ejected_registrations);
1731
+				if (empty($registrations)) {
1732
+					$this->_redirect_because_event_sold_out();
1733
+					return false;
1734
+				}
1735
+				$payment_successful = $this->_process_payment();
1736
+				if ($payment_successful) {
1737
+					$this->checkout->continue_reg = true;
1738
+					$this->_maybe_set_completed($this->checkout->payment_method);
1739
+				} else {
1740
+					$this->checkout->continue_reg = false;
1741
+				}
1742
+				return $payment_successful;
1743
+		}
1744
+	}
1745
+
1746
+
1747
+	/**
1748
+	 * _redirect_because_event_sold_out
1749
+	 *
1750
+	 * @access protected
1751
+	 * @return void
1752
+	 */
1753
+	protected function _redirect_because_event_sold_out()
1754
+	{
1755
+		$this->checkout->continue_reg = false;
1756
+		// set redirect URL
1757
+		$this->checkout->redirect_url = add_query_arg(
1758
+			array('e_reg_url_link' => $this->checkout->reg_url_link),
1759
+			$this->checkout->current_step->reg_step_url()
1760
+		);
1761
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1762
+	}
1763
+
1764
+
1765
+	/**
1766
+	 * _maybe_set_completed
1767
+	 *
1768
+	 * @access protected
1769
+	 * @param \EE_Payment_Method $payment_method
1770
+	 * @return void
1771
+	 * @throws \EE_Error
1772
+	 */
1773
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method)
1774
+	{
1775
+		switch ($payment_method->type_obj()->payment_occurs()) {
1776
+			case EE_PMT_Base::offsite:
1777
+				break;
1778
+			case EE_PMT_Base::onsite:
1779
+			case EE_PMT_Base::offline:
1780
+				// mark this reg step as completed
1781
+				$this->set_completed();
1782
+				break;
1783
+		}
1784
+	}
1785
+
1786
+
1787
+	/**
1788
+	 *    update_reg_step
1789
+	 *    this is the final step after a user  revisits the site to retry a payment
1790
+	 *
1791
+	 * @return bool
1792
+	 * @throws EE_Error
1793
+	 * @throws InvalidArgumentException
1794
+	 * @throws ReflectionException
1795
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1796
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1797
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1798
+	 * @throws \EventEspresso\core\exceptions\InvalidStatusException
1799
+	 */
1800
+	public function update_reg_step()
1801
+	{
1802
+		$success = true;
1803
+		// if payment required
1804
+		if ($this->checkout->transaction->total() > 0) {
1805
+			do_action(
1806
+				'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1807
+				$this->checkout->transaction
1808
+			);
1809
+			// attempt payment via payment method
1810
+			$success = $this->process_reg_step();
1811
+		}
1812
+		if ($success && ! $this->checkout->redirect) {
1813
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1814
+				$this->checkout->transaction->ID()
1815
+			);
1816
+			// set return URL
1817
+			$this->checkout->redirect_url = add_query_arg(
1818
+				array('e_reg_url_link' => $this->checkout->reg_url_link),
1819
+				$this->checkout->thank_you_page_url
1820
+			);
1821
+		}
1822
+		return $success;
1823
+	}
1824
+
1825
+
1826
+	/**
1827
+	 *    _process_payment
1828
+	 *
1829
+	 * @access private
1830
+	 * @return bool
1831
+	 * @throws EE_Error
1832
+	 * @throws InvalidArgumentException
1833
+	 * @throws ReflectionException
1834
+	 * @throws RuntimeException
1835
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1836
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1837
+	 */
1838
+	private function _process_payment()
1839
+	{
1840
+		// basically confirm that the event hasn't sold out since they hit the page
1841
+		if (! $this->_last_second_ticket_verifications()) {
1842
+			return false;
1843
+		}
1844
+		// ya gotta make a choice man
1845
+		if (empty($this->checkout->selected_method_of_payment)) {
1846
+			$this->checkout->json_response->set_plz_select_method_of_payment(
1847
+				esc_html__('Please select a method of payment before proceeding.', 'event_espresso')
1848
+			);
1849
+			return false;
1850
+		}
1851
+		// get EE_Payment_Method object
1852
+		if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853
+			return false;
1854
+		}
1855
+		// setup billing form
1856
+		if ($this->checkout->payment_method->is_on_site()) {
1857
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1858
+				$this->checkout->payment_method
1859
+			);
1860
+			// bad billing form ?
1861
+			if (! $this->_billing_form_is_valid()) {
1862
+				return false;
1863
+			}
1864
+		}
1865
+		// ensure primary registrant has been fully processed
1866
+		if (! $this->_setup_primary_registrant_prior_to_payment()) {
1867
+			return false;
1868
+		}
1869
+		// if session is close to expiring (under 10 minutes by default)
1870
+		if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1871
+			// add some time to session expiration so that payment can be completed
1872
+			EE_Registry::instance()->SSN->extend_expiration();
1873
+		}
1874
+		/** @type EE_Transaction_Processor $transaction_processor */
1875
+		// $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1876
+		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations
1877
+		// for events with a default reg status of Approved
1878
+		// $transaction_processor->toggle_registration_statuses_for_default_approved_events(
1879
+		//      $this->checkout->transaction, $this->checkout->reg_cache_where_params
1880
+		// );
1881
+		// attempt payment
1882
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1883
+		// process results
1884
+		$payment = $this->_validate_payment($payment);
1885
+		$payment = $this->_post_payment_processing($payment);
1886
+		// verify payment
1887
+		if ($payment instanceof EE_Payment) {
1888
+			// store that for later
1889
+			$this->checkout->payment = $payment;
1890
+			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1891
+			$this->checkout->transaction->toggle_failed_transaction_status();
1892
+			$payment_status = $payment->status();
1893
+			if ($payment_status === EEM_Payment::status_id_approved
1894
+				|| $payment_status === EEM_Payment::status_id_pending
1895
+			) {
1896
+				return true;
1897
+			} else {
1898
+				return false;
1899
+			}
1900
+		} elseif ($payment === true) {
1901
+			// please note that offline payment methods will NOT make a payment,
1902
+			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1903
+			$this->checkout->payment = $payment;
1904
+			return true;
1905
+		}
1906
+		// where's my money?
1907
+		return false;
1908
+	}
1909
+
1910
+
1911
+	/**
1912
+	 * _last_second_ticket_verifications
1913
+	 *
1914
+	 * @access public
1915
+	 * @return bool
1916
+	 * @throws EE_Error
1917
+	 */
1918
+	protected function _last_second_ticket_verifications()
1919
+	{
1920
+		// don't bother re-validating if not a return visit
1921
+		if (! $this->checkout->revisit) {
1922
+			return true;
1923
+		}
1924
+		$registrations = $this->checkout->transaction->registrations();
1925
+		if (empty($registrations)) {
1926
+			return false;
1927
+		}
1928
+		foreach ($registrations as $registration) {
1929
+			if ($registration instanceof EE_Registration && ! $registration->is_approved()) {
1930
+				$event = $registration->event_obj();
1931
+				if ($event instanceof EE_Event && $event->is_sold_out(true)) {
1932
+					EE_Error::add_error(
1933
+						apply_filters(
1934
+							'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1935
+							sprintf(
1936
+								esc_html__(
1937
+									'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.',
1938
+									'event_espresso'
1939
+								),
1940
+								$event->name()
1941
+							)
1942
+						),
1943
+						__FILE__,
1944
+						__FUNCTION__,
1945
+						__LINE__
1946
+					);
1947
+					return false;
1948
+				}
1949
+			}
1950
+		}
1951
+		return true;
1952
+	}
1953
+
1954
+
1955
+	/**
1956
+	 * redirect_form
1957
+	 *
1958
+	 * @access public
1959
+	 * @return bool
1960
+	 * @throws EE_Error
1961
+	 * @throws InvalidArgumentException
1962
+	 * @throws ReflectionException
1963
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1964
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1965
+	 */
1966
+	public function redirect_form()
1967
+	{
1968
+		$payment_method_billing_info = $this->_payment_method_billing_info(
1969
+			$this->_get_payment_method_for_selected_method_of_payment()
1970
+		);
1971
+		$html = $payment_method_billing_info->get_html();
1972
+		$html .= $this->checkout->redirect_form;
1973
+		EE_Registry::instance()->REQ->add_output($html);
1974
+		return true;
1975
+	}
1976
+
1977
+
1978
+	/**
1979
+	 * _billing_form_is_valid
1980
+	 *
1981
+	 * @access private
1982
+	 * @return bool
1983
+	 * @throws \EE_Error
1984
+	 */
1985
+	private function _billing_form_is_valid()
1986
+	{
1987
+		if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988
+			return true;
1989
+		}
1990
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1991
+			if ($this->checkout->billing_form->was_submitted()) {
1992
+				$this->checkout->billing_form->receive_form_submission();
1993
+				if ($this->checkout->billing_form->is_valid()) {
1994
+					return true;
1995
+				}
1996
+				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1997
+				$error_strings = array();
1998
+				foreach ($validation_errors as $validation_error) {
1999
+					if ($validation_error instanceof EE_Validation_Error) {
2000
+						$form_section = $validation_error->get_form_section();
2001
+						if ($form_section instanceof EE_Form_Input_Base) {
2002
+							$label = $form_section->html_label_text();
2003
+						} elseif ($form_section instanceof EE_Form_Section_Base) {
2004
+							$label = $form_section->name();
2005
+						} else {
2006
+							$label = esc_html__('Validation Error', 'event_espresso');
2007
+						}
2008
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
2009
+					}
2010
+				}
2011
+				EE_Error::add_error(
2012
+					sprintf(
2013
+						esc_html__(
2014
+							'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s',
2015
+							'event_espresso'
2016
+						),
2017
+						'<br/>',
2018
+						implode('<br/>', $error_strings)
2019
+					),
2020
+					__FILE__,
2021
+					__FUNCTION__,
2022
+					__LINE__
2023
+				);
2024
+			} else {
2025
+				EE_Error::add_error(
2026
+					esc_html__(
2027
+						'The billing form was not submitted or something prevented it\'s submission.',
2028
+						'event_espresso'
2029
+					),
2030
+					__FILE__,
2031
+					__FUNCTION__,
2032
+					__LINE__
2033
+				);
2034
+			}
2035
+		} else {
2036
+			EE_Error::add_error(
2037
+				esc_html__(
2038
+					'The submitted billing form is invalid possibly due to a technical reason.',
2039
+					'event_espresso'
2040
+				),
2041
+				__FILE__,
2042
+				__FUNCTION__,
2043
+				__LINE__
2044
+			);
2045
+		}
2046
+		return false;
2047
+	}
2048
+
2049
+
2050
+	/**
2051
+	 * _setup_primary_registrant_prior_to_payment
2052
+	 * ensures that the primary registrant has a valid attendee object created with the critical details populated
2053
+	 * (first & last name & email) and that both the transaction object and primary registration object have been saved
2054
+	 * plz note that any other registrations will NOT be saved at this point (because they may not have any details
2055
+	 * yet)
2056
+	 *
2057
+	 * @access private
2058
+	 * @return bool
2059
+	 * @throws EE_Error
2060
+	 * @throws InvalidArgumentException
2061
+	 * @throws ReflectionException
2062
+	 * @throws RuntimeException
2063
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2064
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2065
+	 */
2066
+	private function _setup_primary_registrant_prior_to_payment()
2067
+	{
2068
+		// check if transaction has a primary registrant and that it has a related Attendee object
2069
+		// if not, then we need to at least gather some primary registrant data before attempting payment
2070
+		if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form
2071
+			&& ! $this->checkout->transaction_has_primary_registrant()
2072
+			&& ! $this->_capture_primary_registration_data_from_billing_form()
2073
+		) {
2074
+			return false;
2075
+		}
2076
+		// because saving an object clears it's cache, we need to do the chevy shuffle
2077
+		// grab the primary_registration object
2078
+		$primary_registration = $this->checkout->transaction->primary_registration();
2079
+		// at this point we'll consider a TXN to not have been failed
2080
+		$this->checkout->transaction->toggle_failed_transaction_status();
2081
+		// save the TXN ( which clears cached copy of primary_registration)
2082
+		$this->checkout->transaction->save();
2083
+		// grab TXN ID and save it to the primary_registration
2084
+		$primary_registration->set_transaction_id($this->checkout->transaction->ID());
2085
+		// save what we have so far
2086
+		$primary_registration->save();
2087
+		return true;
2088
+	}
2089
+
2090
+
2091
+	/**
2092
+	 * _capture_primary_registration_data_from_billing_form
2093
+	 *
2094
+	 * @access private
2095
+	 * @return bool
2096
+	 * @throws EE_Error
2097
+	 * @throws InvalidArgumentException
2098
+	 * @throws ReflectionException
2099
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2100
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2101
+	 */
2102
+	private function _capture_primary_registration_data_from_billing_form()
2103
+	{
2104
+		// convert billing form data into an attendee
2105
+		$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
+		if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107
+			EE_Error::add_error(
2108
+				sprintf(
2109
+					esc_html__(
2110
+						'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.',
2111
+						'event_espresso'
2112
+					),
2113
+					'<br/>',
2114
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2115
+				),
2116
+				__FILE__,
2117
+				__FUNCTION__,
2118
+				__LINE__
2119
+			);
2120
+			return false;
2121
+		}
2122
+		$primary_registration = $this->checkout->transaction->primary_registration();
2123
+		if (! $primary_registration instanceof EE_Registration) {
2124
+			EE_Error::add_error(
2125
+				sprintf(
2126
+					esc_html__(
2127
+						'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2128
+						'event_espresso'
2129
+					),
2130
+					'<br/>',
2131
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2132
+				),
2133
+				__FILE__,
2134
+				__FUNCTION__,
2135
+				__LINE__
2136
+			);
2137
+			return false;
2138
+		}
2139
+		if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140
+			  instanceof
2141
+			  EE_Attendee
2142
+		) {
2143
+			EE_Error::add_error(
2144
+				sprintf(
2145
+					esc_html__(
2146
+						'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.',
2147
+						'event_espresso'
2148
+					),
2149
+					'<br/>',
2150
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2151
+				),
2152
+				__FILE__,
2153
+				__FUNCTION__,
2154
+				__LINE__
2155
+			);
2156
+			return false;
2157
+		}
2158
+		/** @type EE_Registration_Processor $registration_processor */
2159
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
2160
+		// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
2161
+		$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
2162
+		return true;
2163
+	}
2164
+
2165
+
2166
+	/**
2167
+	 * _get_payment_method_for_selected_method_of_payment
2168
+	 * retrieves a valid payment method
2169
+	 *
2170
+	 * @access public
2171
+	 * @return EE_Payment_Method
2172
+	 * @throws EE_Error
2173
+	 * @throws InvalidArgumentException
2174
+	 * @throws ReflectionException
2175
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2176
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2177
+	 */
2178
+	private function _get_payment_method_for_selected_method_of_payment()
2179
+	{
2180
+		if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
2181
+			$this->_redirect_because_event_sold_out();
2182
+			return null;
2183
+		}
2184
+		// get EE_Payment_Method object
2185
+		if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
+			$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2187
+		} else {
2188
+			// load EEM_Payment_Method
2189
+			EE_Registry::instance()->load_model('Payment_Method');
2190
+			/** @type EEM_Payment_Method $EEM_Payment_Method */
2191
+			$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
2192
+			$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193
+		}
2194
+		// verify $payment_method
2195
+		if (! $payment_method instanceof EE_Payment_Method) {
2196
+			// not a payment
2197
+			EE_Error::add_error(
2198
+				sprintf(
2199
+					esc_html__(
2200
+						'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2201
+						'event_espresso'
2202
+					),
2203
+					'<br/>',
2204
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2205
+				),
2206
+				__FILE__,
2207
+				__FUNCTION__,
2208
+				__LINE__
2209
+			);
2210
+			return null;
2211
+		}
2212
+		// and verify it has a valid Payment_Method Type object
2213
+		if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214
+			// not a payment
2215
+			EE_Error::add_error(
2216
+				sprintf(
2217
+					esc_html__(
2218
+						'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.',
2219
+						'event_espresso'
2220
+					),
2221
+					'<br/>',
2222
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2223
+				),
2224
+				__FILE__,
2225
+				__FUNCTION__,
2226
+				__LINE__
2227
+			);
2228
+			return null;
2229
+		}
2230
+		return $payment_method;
2231
+	}
2232
+
2233
+
2234
+	/**
2235
+	 *    _attempt_payment
2236
+	 *
2237
+	 * @access    private
2238
+	 * @type    EE_Payment_Method $payment_method
2239
+	 * @return mixed EE_Payment | boolean
2240
+	 * @throws EE_Error
2241
+	 * @throws InvalidArgumentException
2242
+	 * @throws ReflectionException
2243
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2244
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2245
+	 */
2246
+	private function _attempt_payment(EE_Payment_Method $payment_method)
2247
+	{
2248
+		$payment = null;
2249
+		$this->checkout->transaction->save();
2250
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
+		if (! $payment_processor instanceof EE_Payment_Processor) {
2252
+			return false;
2253
+		}
2254
+		try {
2255
+			$payment_processor->set_revisit($this->checkout->revisit);
2256
+			// generate payment object
2257
+			$payment = $payment_processor->process_payment(
2258
+				$payment_method,
2259
+				$this->checkout->transaction,
2260
+				$this->checkout->amount_owing,
2261
+				$this->checkout->billing_form,
2262
+				$this->_get_return_url($payment_method),
2263
+				'CART',
2264
+				$this->checkout->admin_request,
2265
+				true,
2266
+				$this->reg_step_url()
2267
+			);
2268
+		} catch (Exception $e) {
2269
+			$this->_handle_payment_processor_exception($e);
2270
+		}
2271
+		return $payment;
2272
+	}
2273
+
2274
+
2275
+	/**
2276
+	 * _handle_payment_processor_exception
2277
+	 *
2278
+	 * @access protected
2279
+	 * @param \Exception $e
2280
+	 * @return void
2281
+	 * @throws EE_Error
2282
+	 * @throws InvalidArgumentException
2283
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2284
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2285
+	 */
2286
+	protected function _handle_payment_processor_exception(Exception $e)
2287
+	{
2288
+		EE_Error::add_error(
2289
+			sprintf(
2290
+				esc_html__(
2291
+					'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s',
2292
+					'event_espresso'
2293
+				),
2294
+				'<br/>',
2295
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
2296
+				$e->getMessage(),
2297
+				$e->getFile(),
2298
+				$e->getLine()
2299
+			),
2300
+			__FILE__,
2301
+			__FUNCTION__,
2302
+			__LINE__
2303
+		);
2304
+	}
2305
+
2306
+
2307
+	/**
2308
+	 * _get_return_url
2309
+	 *
2310
+	 * @access protected
2311
+	 * @param \EE_Payment_Method $payment_method
2312
+	 * @return string
2313
+	 * @throws \EE_Error
2314
+	 */
2315
+	protected function _get_return_url(EE_Payment_Method $payment_method)
2316
+	{
2317
+		$return_url = '';
2318
+		switch ($payment_method->type_obj()->payment_occurs()) {
2319
+			case EE_PMT_Base::offsite:
2320
+				$return_url = add_query_arg(
2321
+					array(
2322
+						'action'                     => 'process_gateway_response',
2323
+						'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2324
+						'spco_txn'                   => $this->checkout->transaction->ID(),
2325
+					),
2326
+					$this->reg_step_url()
2327
+				);
2328
+				break;
2329
+			case EE_PMT_Base::onsite:
2330
+			case EE_PMT_Base::offline:
2331
+				$return_url = $this->checkout->next_step->reg_step_url();
2332
+				break;
2333
+		}
2334
+		return $return_url;
2335
+	}
2336
+
2337
+
2338
+	/**
2339
+	 * _validate_payment
2340
+	 *
2341
+	 * @access private
2342
+	 * @param EE_Payment $payment
2343
+	 * @return EE_Payment|FALSE
2344
+	 * @throws EE_Error
2345
+	 * @throws InvalidArgumentException
2346
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2347
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2348
+	 */
2349
+	private function _validate_payment($payment = null)
2350
+	{
2351
+		if ($this->checkout->payment_method->is_off_line()) {
2352
+			return true;
2353
+		}
2354
+		// verify payment object
2355
+		if (! $payment instanceof EE_Payment) {
2356
+			// not a payment
2357
+			EE_Error::add_error(
2358
+				sprintf(
2359
+					esc_html__(
2360
+						'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.',
2361
+						'event_espresso'
2362
+					),
2363
+					'<br/>',
2364
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2365
+				),
2366
+				__FILE__,
2367
+				__FUNCTION__,
2368
+				__LINE__
2369
+			);
2370
+			return false;
2371
+		}
2372
+		return $payment;
2373
+	}
2374
+
2375
+
2376
+	/**
2377
+	 * _post_payment_processing
2378
+	 *
2379
+	 * @access private
2380
+	 * @param EE_Payment|bool $payment
2381
+	 * @return bool
2382
+	 * @throws EE_Error
2383
+	 * @throws InvalidArgumentException
2384
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2385
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2386
+	 */
2387
+	private function _post_payment_processing($payment = null)
2388
+	{
2389
+		// Off-Line payment?
2390
+		if ($payment === true) {
2391
+			// $this->_setup_redirect_for_next_step();
2392
+			return true;
2393
+			// On-Site payment?
2394
+		} elseif ($this->checkout->payment_method->is_on_site()) {
2395
+			if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396
+				// $this->_setup_redirect_for_next_step();
2397
+				$this->checkout->continue_reg = false;
2398
+			}
2399
+			// Off-Site payment?
2400
+		} elseif ($this->checkout->payment_method->is_off_site()) {
2401
+			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2402
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2403
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2404
+				$this->checkout->redirect = true;
2405
+				$this->checkout->redirect_form = $payment->redirect_form();
2406
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2407
+				// set JSON response
2408
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2409
+				// and lastly, let's bump the payment status to pending
2410
+				$payment->set_status(EEM_Payment::status_id_pending);
2411
+				$payment->save();
2412
+			} else {
2413
+				// not a payment
2414
+				$this->checkout->continue_reg = false;
2415
+				EE_Error::add_error(
2416
+					sprintf(
2417
+						esc_html__(
2418
+							'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.',
2419
+							'event_espresso'
2420
+						),
2421
+						'<br/>',
2422
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
2423
+					),
2424
+					__FILE__,
2425
+					__FUNCTION__,
2426
+					__LINE__
2427
+				);
2428
+			}
2429
+		} else {
2430
+			// ummm ya... not Off-Line, not On-Site, not off-Site ????
2431
+			$this->checkout->continue_reg = false;
2432
+			return false;
2433
+		}
2434
+		return $payment;
2435
+	}
2436
+
2437
+
2438
+	/**
2439
+	 *    _process_payment_status
2440
+	 *
2441
+	 * @access private
2442
+	 * @type    EE_Payment $payment
2443
+	 * @param string       $payment_occurs
2444
+	 * @return bool
2445
+	 * @throws EE_Error
2446
+	 * @throws InvalidArgumentException
2447
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2448
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2449
+	 */
2450
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline)
2451
+	{
2452
+		// off-line payment? carry on
2453
+		if ($payment_occurs === EE_PMT_Base::offline) {
2454
+			return true;
2455
+		}
2456
+		// verify payment validity
2457
+		if ($payment instanceof EE_Payment) {
2458
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2459
+			$msg = $payment->gateway_response();
2460
+			// check results
2461
+			switch ($payment->status()) {
2462
+				// good payment
2463
+				case EEM_Payment::status_id_approved:
2464
+					EE_Error::add_success(
2465
+						esc_html__('Your payment was processed successfully.', 'event_espresso'),
2466
+						__FILE__,
2467
+						__FUNCTION__,
2468
+						__LINE__
2469
+					);
2470
+					return true;
2471
+					break;
2472
+				// slow payment
2473
+				case EEM_Payment::status_id_pending:
2474
+					if (empty($msg)) {
2475
+						$msg = esc_html__(
2476
+							'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2477
+							'event_espresso'
2478
+						);
2479
+					}
2480
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2481
+					return true;
2482
+					break;
2483
+				// don't wanna payment
2484
+				case EEM_Payment::status_id_cancelled:
2485
+					if (empty($msg)) {
2486
+						$msg = _n(
2487
+							'Payment cancelled. Please try again.',
2488
+							'Payment cancelled. Please try again or select another method of payment.',
2489
+							count($this->checkout->available_payment_methods),
2490
+							'event_espresso'
2491
+						);
2492
+					}
2493
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2494
+					return false;
2495
+					break;
2496
+				// not enough payment
2497
+				case EEM_Payment::status_id_declined:
2498
+					if (empty($msg)) {
2499
+						$msg = _n(
2500
+							'We\'re sorry but your payment was declined. Please try again.',
2501
+							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2502
+							count($this->checkout->available_payment_methods),
2503
+							'event_espresso'
2504
+						);
2505
+					}
2506
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2507
+					return false;
2508
+					break;
2509
+				// bad payment
2510
+				case EEM_Payment::status_id_failed:
2511
+					if (! empty($msg)) {
2512
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2513
+						return false;
2514
+					}
2515
+					// default to error below
2516
+					break;
2517
+			}
2518
+		}
2519
+		// off-site payment gateway responses are too unreliable, so let's just assume that
2520
+		// the payment processing is just running slower than the registrant's request
2521
+		if ($payment_occurs === EE_PMT_Base::offsite) {
2522
+			return true;
2523
+		}
2524
+		EE_Error::add_error(
2525
+			sprintf(
2526
+				esc_html__(
2527
+					'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.',
2528
+					'event_espresso'
2529
+				),
2530
+				'<br/>',
2531
+				EE_Registry::instance()->CFG->organization->get_pretty('email')
2532
+			),
2533
+			__FILE__,
2534
+			__FUNCTION__,
2535
+			__LINE__
2536
+		);
2537
+		return false;
2538
+	}
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+	/********************************************************************************************************/
2546
+	/**********************************  PROCESS GATEWAY RESPONSE  **********************************/
2547
+	/********************************************************************************************************/
2548
+	/**
2549
+	 * process_gateway_response
2550
+	 * this is the return point for Off-Site Payment Methods
2551
+	 * It will attempt to "handle the IPN" if it appears that this has not already occurred,
2552
+	 * otherwise, it will load up the last payment made for the TXN.
2553
+	 * If the payment retrieved looks good, it will then either:
2554
+	 *    complete the current step and allow advancement to the next reg step
2555
+	 *        or present the payment options again
2556
+	 *
2557
+	 * @access private
2558
+	 * @return EE_Payment|FALSE
2559
+	 * @throws EE_Error
2560
+	 * @throws InvalidArgumentException
2561
+	 * @throws ReflectionException
2562
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2563
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2564
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2565
+	 */
2566
+	public function process_gateway_response()
2567
+	{
2568
+		$payment = null;
2569
+		// how have they chosen to pay?
2570
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2571
+		// get EE_Payment_Method object
2572
+		if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2573
+			$this->checkout->continue_reg = false;
2574
+			return false;
2575
+		}
2576
+		if (! $this->checkout->payment_method->is_off_site()) {
2577
+			return false;
2578
+		}
2579
+		$this->_validate_offsite_return();
2580
+		// DEBUG LOG
2581
+		// $this->checkout->log(
2582
+		//     __CLASS__,
2583
+		//     __FUNCTION__,
2584
+		//     __LINE__,
2585
+		//     array(
2586
+		//         'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2587
+		//         'payment_method'             => $this->checkout->payment_method,
2588
+		//     ),
2589
+		//     true
2590
+		// );
2591
+		// verify TXN
2592
+		if ($this->checkout->transaction instanceof EE_Transaction) {
2593
+			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2594
+			if (! $gateway instanceof EE_Offsite_Gateway) {
2595
+				$this->checkout->continue_reg = false;
2596
+				return false;
2597
+			}
2598
+			$payment = $this->_process_off_site_payment($gateway);
2599
+			$payment = $this->_process_cancelled_payments($payment);
2600
+			$payment = $this->_validate_payment($payment);
2601
+			// if payment was not declined by the payment gateway or cancelled by the registrant
2602
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2603
+				// $this->_setup_redirect_for_next_step();
2604
+				// store that for later
2605
+				$this->checkout->payment = $payment;
2606
+				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2607
+				// because we will complete this step during the IPN processing then
2608
+				if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2609
+					$this->set_completed();
2610
+				}
2611
+				return true;
2612
+			}
2613
+		}
2614
+		// DEBUG LOG
2615
+		// $this->checkout->log(
2616
+		//     __CLASS__,
2617
+		//     __FUNCTION__,
2618
+		//     __LINE__,
2619
+		//     array('payment' => $payment)
2620
+		// );
2621
+		$this->checkout->continue_reg = false;
2622
+		return false;
2623
+	}
2624
+
2625
+
2626
+	/**
2627
+	 * _validate_return
2628
+	 *
2629
+	 * @access private
2630
+	 * @return void
2631
+	 * @throws EE_Error
2632
+	 * @throws InvalidArgumentException
2633
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2634
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2635
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
2636
+	 */
2637
+	private function _validate_offsite_return()
2638
+	{
2639
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2640
+		if ($TXN_ID !== $this->checkout->transaction->ID()) {
2641
+			// Houston... we might have a problem
2642
+			$invalid_TXN = false;
2643
+			// first gather some info
2644
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2645
+			$primary_registrant = $valid_TXN instanceof EE_Transaction
2646
+				? $valid_TXN->primary_registration()
2647
+				: null;
2648
+			// let's start by retrieving the cart for this TXN
2649
+			$cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2650
+			if ($cart instanceof EE_Cart) {
2651
+				// verify that the current cart has tickets
2652
+				$tickets = $cart->get_tickets();
2653
+				if (empty($tickets)) {
2654
+					$invalid_TXN = true;
2655
+				}
2656
+			} else {
2657
+				$invalid_TXN = true;
2658
+			}
2659
+			$valid_TXN_SID = $primary_registrant instanceof EE_Registration
2660
+				? $primary_registrant->session_ID()
2661
+				: null;
2662
+			// validate current Session ID and compare against valid TXN session ID
2663
+			if ($invalid_TXN // if this is already true, then skip other checks
2664
+				|| EE_Session::instance()->id() === null
2665
+				|| (
2666
+					// WARNING !!!
2667
+					// this could be PayPal sending back duplicate requests (ya they do that)
2668
+					// or it **could** mean someone is simply registering AGAIN after having just done so
2669
+					// so now we need to determine if this current TXN looks valid or not
2670
+					// and whether this reg step has even been started ?
2671
+					EE_Session::instance()->id() === $valid_TXN_SID
2672
+					// really? you're half way through this reg step, but you never started it ?
2673
+					&& $this->checkout->transaction->reg_step_completed($this->slug()) === false
2674
+				)
2675
+			) {
2676
+				$invalid_TXN = true;
2677
+			}
2678
+			if ($invalid_TXN) {
2679
+				// is the valid TXN completed ?
2680
+				if ($valid_TXN instanceof EE_Transaction) {
2681
+					// has this step even been started ?
2682
+					$reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2683
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
2684
+						// so it **looks** like this is a double request from PayPal
2685
+						// so let's try to pick up where we left off
2686
+						$this->checkout->transaction = $valid_TXN;
2687
+						$this->checkout->refresh_all_entities(true);
2688
+						return;
2689
+					}
2690
+				}
2691
+				// you appear to be lost?
2692
+				$this->_redirect_wayward_request($primary_registrant);
2693
+			}
2694
+		}
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * _redirect_wayward_request
2700
+	 *
2701
+	 * @access private
2702
+	 * @param \EE_Registration|null $primary_registrant
2703
+	 * @return bool
2704
+	 * @throws EE_Error
2705
+	 * @throws InvalidArgumentException
2706
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2707
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2708
+	 */
2709
+	private function _redirect_wayward_request(EE_Registration $primary_registrant)
2710
+	{
2711
+		if (! $primary_registrant instanceof EE_Registration) {
2712
+			// try redirecting based on the current TXN
2713
+			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2714
+				? $this->checkout->transaction->primary_registration()
2715
+				: null;
2716
+		}
2717
+		if (! $primary_registrant instanceof EE_Registration) {
2718
+			EE_Error::add_error(
2719
+				sprintf(
2720
+					esc_html__(
2721
+						'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.',
2722
+						'event_espresso'
2723
+					),
2724
+					'<br/>',
2725
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2726
+				),
2727
+				__FILE__,
2728
+				__FUNCTION__,
2729
+				__LINE__
2730
+			);
2731
+			return false;
2732
+		}
2733
+		// make sure transaction is not locked
2734
+		$this->checkout->transaction->unlock();
2735
+		wp_safe_redirect(
2736
+			add_query_arg(
2737
+				array(
2738
+					'e_reg_url_link' => $primary_registrant->reg_url_link(),
2739
+				),
2740
+				$this->checkout->thank_you_page_url
2741
+			)
2742
+		);
2743
+		exit();
2744
+	}
2745
+
2746
+
2747
+	/**
2748
+	 * _process_off_site_payment
2749
+	 *
2750
+	 * @access private
2751
+	 * @param \EE_Offsite_Gateway $gateway
2752
+	 * @return EE_Payment
2753
+	 * @throws EE_Error
2754
+	 * @throws InvalidArgumentException
2755
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2756
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2757
+	 */
2758
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway)
2759
+	{
2760
+		try {
2761
+			$request_data = \EE_Registry::instance()->REQ->params();
2762
+			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2763
+			$this->set_handle_IPN_in_this_request(
2764
+				$gateway->handle_IPN_in_this_request($request_data, false)
2765
+			);
2766
+			if ($this->handle_IPN_in_this_request()) {
2767
+				// get payment details and process results
2768
+				/** @type EE_Payment_Processor $payment_processor */
2769
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2770
+				$payment = $payment_processor->process_ipn(
2771
+					$request_data,
2772
+					$this->checkout->transaction,
2773
+					$this->checkout->payment_method,
2774
+					true,
2775
+					false
2776
+				);
2777
+				// $payment_source = 'process_ipn';
2778
+			} else {
2779
+				$payment = $this->checkout->transaction->last_payment();
2780
+				// $payment_source = 'last_payment';
2781
+			}
2782
+		} catch (Exception $e) {
2783
+			// let's just eat the exception and try to move on using any previously set payment info
2784
+			$payment = $this->checkout->transaction->last_payment();
2785
+			// $payment_source = 'last_payment after Exception';
2786
+			// but if we STILL don't have a payment object
2787
+			if (! $payment instanceof EE_Payment) {
2788
+				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2789
+				$this->_handle_payment_processor_exception($e);
2790
+			}
2791
+		}
2792
+		// DEBUG LOG
2793
+		// $this->checkout->log(
2794
+		//     __CLASS__,
2795
+		//     __FUNCTION__,
2796
+		//     __LINE__,
2797
+		//     array(
2798
+		//         'process_ipn_payment' => $payment,
2799
+		//         'payment_source'      => $payment_source,
2800
+		//     )
2801
+		// );
2802
+		return $payment;
2803
+	}
2804
+
2805
+
2806
+	/**
2807
+	 * _process_cancelled_payments
2808
+	 * just makes sure that the payment status gets updated correctly
2809
+	 * so tha tan error isn't generated during payment validation
2810
+	 *
2811
+	 * @access private
2812
+	 * @param EE_Payment $payment
2813
+	 * @return EE_Payment | FALSE
2814
+	 * @throws \EE_Error
2815
+	 */
2816
+	private function _process_cancelled_payments($payment = null)
2817
+	{
2818
+		if ($payment instanceof EE_Payment
2819
+			&& isset($_REQUEST['ee_cancel_payment'])
2820
+			&& $payment->status() === EEM_Payment::status_id_failed
2821
+		) {
2822
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2823
+		}
2824
+		return $payment;
2825
+	}
2826
+
2827
+
2828
+	/**
2829
+	 *    get_transaction_details_for_gateways
2830
+	 *
2831
+	 * @access    public
2832
+	 * @return int
2833
+	 * @throws EE_Error
2834
+	 * @throws InvalidArgumentException
2835
+	 * @throws ReflectionException
2836
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2837
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2838
+	 */
2839
+	public function get_transaction_details_for_gateways()
2840
+	{
2841
+		$txn_details = array();
2842
+		// ya gotta make a choice man
2843
+		if (empty($this->checkout->selected_method_of_payment)) {
2844
+			$txn_details = array(
2845
+				'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'),
2846
+			);
2847
+		}
2848
+		// get EE_Payment_Method object
2849
+		if (empty($txn_details)
2850
+			&&
2851
+			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2852
+		) {
2853
+			$txn_details = array(
2854
+				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2855
+				'error'                      => esc_html__(
2856
+					'A valid Payment Method could not be determined.',
2857
+					'event_espresso'
2858
+				),
2859
+			);
2860
+		}
2861
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2862
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2863
+			$txn_details = array(
2864
+				'TXN_ID'         => $this->checkout->transaction->ID(),
2865
+				'TXN_timestamp'  => $this->checkout->transaction->datetime(),
2866
+				'TXN_total'      => $this->checkout->transaction->total(),
2867
+				'TXN_paid'       => $this->checkout->transaction->paid(),
2868
+				'TXN_reg_steps'  => $this->checkout->transaction->reg_steps(),
2869
+				'STS_ID'         => $this->checkout->transaction->status_ID(),
2870
+				'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2871
+				'payment_amount' => $this->checkout->amount_owing,
2872
+				'return_url'     => $return_url,
2873
+				'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2874
+				'notify_url'     => EE_Config::instance()->core->txn_page_url(
2875
+					array(
2876
+						'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
2877
+						'ee_payment_method' => $this->checkout->payment_method->slug(),
2878
+					)
2879
+				),
2880
+			);
2881
+		}
2882
+		echo wp_json_encode($txn_details);
2883
+		exit();
2884
+	}
2885
+
2886
+
2887
+	/**
2888
+	 *    __sleep
2889
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
2890
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
2891
+	 * reg form, because if needed, it will be regenerated anyways
2892
+	 *
2893
+	 * @return array
2894
+	 */
2895
+	public function __sleep()
2896
+	{
2897
+		// remove the reg form and the checkout
2898
+		return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2899
+	}
2900 2900
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     {
130 130
         $this->_slug = 'payment_options';
131 131
         $this->_name = esc_html__('Payment Options', 'event_espresso');
132
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
132
+        $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
133 133
         $this->checkout = $checkout;
134 134
         $this->_reset_success_message();
135 135
         $this->set_instructions(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $transaction = $this->checkout->transaction;
214 214
         // if the transaction isn't set or nothing is owed on it, don't enqueue any JS
215
-        if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
215
+        if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
216 216
             return;
217 217
         }
218 218
         foreach (EEM_Payment_Method::instance()->get_all_for_transaction(
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
         foreach ($registrations as $REG_ID => $registration) {
305 305
             /** @var $registration EE_Registration */
306 306
             // has this registration lost it's space ?
307
-            if (isset($ejected_registrations[ $REG_ID ])) {
307
+            if (isset($ejected_registrations[$REG_ID])) {
308 308
                 if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
309
-                    $sold_out_events[ $registration->event()->ID() ] = $registration->event();
309
+                    $sold_out_events[$registration->event()->ID()] = $registration->event();
310 310
                 } else {
311
-                    $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
311
+                    $insufficient_spaces_available[$registration->event()->ID()] = $registration->event();
312 312
                 }
313 313
                 continue;
314 314
             }
315 315
             // event requires admin approval
316 316
             if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
317 317
                 // add event to list of events with pre-approval reg status
318
-                $registrations_requiring_pre_approval[ $REG_ID ] = $registration;
318
+                $registrations_requiring_pre_approval[$REG_ID] = $registration;
319 319
                 do_action(
320 320
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
321 321
                     $registration->event(),
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                 )
332 332
             ) {
333 333
                 // add event to list of events that are sold out
334
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
334
+                $sold_out_events[$registration->event()->ID()] = $registration->event();
335 335
                 do_action(
336 336
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
337 337
                     $registration->event(),
@@ -341,38 +341,38 @@  discard block
 block discarded – undo
341 341
             }
342 342
             // are they allowed to pay now and is there monies owing?
343 343
             if ($registration->owes_monies_and_can_pay()) {
344
-                $registrations_requiring_payment[ $REG_ID ] = $registration;
344
+                $registrations_requiring_payment[$REG_ID] = $registration;
345 345
                 do_action(
346 346
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
347 347
                     $registration->event(),
348 348
                     $this
349 349
                 );
350
-            } elseif (! $this->checkout->revisit
350
+            } elseif ( ! $this->checkout->revisit
351 351
                       && $registration->status_ID() !== EEM_Registration::status_id_not_approved
352 352
                       && $registration->ticket()->is_free()
353 353
             ) {
354
-                $registrations_for_free_events[ $registration->event()->ID() ] = $registration;
354
+                $registrations_for_free_events[$registration->event()->ID()] = $registration;
355 355
             }
356 356
         }
357 357
         $subsections = array();
358 358
         // now decide which template to load
359
-        if (! empty($sold_out_events)) {
359
+        if ( ! empty($sold_out_events)) {
360 360
             $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
361 361
         }
362
-        if (! empty($insufficient_spaces_available)) {
362
+        if ( ! empty($insufficient_spaces_available)) {
363 363
             $subsections['insufficient_space'] = $this->_insufficient_spaces_available(
364 364
                 $insufficient_spaces_available
365 365
             );
366 366
         }
367
-        if (! empty($registrations_requiring_pre_approval)) {
367
+        if ( ! empty($registrations_requiring_pre_approval)) {
368 368
             $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
369 369
                 $registrations_requiring_pre_approval
370 370
             );
371 371
         }
372
-        if (! empty($registrations_for_free_events)) {
372
+        if ( ! empty($registrations_for_free_events)) {
373 373
             $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
374 374
         }
375
-        if (! empty($registrations_requiring_payment)) {
375
+        if ( ! empty($registrations_requiring_payment)) {
376 376
             if ($this->checkout->amount_owing > 0) {
377 377
                 // autoload Line_Item_Display classes
378 378
                 EEH_Autoloader::register_line_item_filter_autoloaders();
@@ -437,13 +437,13 @@  discard block
 block discarded – undo
437 437
      */
438 438
     public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection)
439 439
     {
440
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
440
+        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
441 441
             return $line_item_filter_collection;
442 442
         }
443
-        if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
443
+        if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
444 444
             return $line_item_filter_collection;
445 445
         }
446
-        if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
446
+        if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
447 447
             return $line_item_filter_collection;
448 448
         }
449 449
         $line_item_filter_collection->add(
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
         );
484 484
         foreach ($registrations as $REG_ID => $registration) {
485 485
             // has this registration lost it's space ?
486
-            if (isset($ejected_registrations[ $REG_ID ])) {
487
-                unset($registrations[ $REG_ID ]);
486
+            if (isset($ejected_registrations[$REG_ID])) {
487
+                unset($registrations[$REG_ID]);
488 488
                 continue;
489 489
             }
490 490
         }
@@ -534,24 +534,24 @@  discard block
 block discarded – undo
534 534
             }
535 535
             $EVT_ID = $registration->event_ID();
536 536
             $ticket = $registration->ticket();
537
-            if (! isset($tickets_remaining[ $ticket->ID() ])) {
538
-                $tickets_remaining[ $ticket->ID() ] = $ticket->remaining();
537
+            if ( ! isset($tickets_remaining[$ticket->ID()])) {
538
+                $tickets_remaining[$ticket->ID()] = $ticket->remaining();
539 539
             }
540
-            if ($tickets_remaining[ $ticket->ID() ] > 0) {
541
-                if (! isset($event_reg_count[ $EVT_ID ])) {
542
-                    $event_reg_count[ $EVT_ID ] = 0;
540
+            if ($tickets_remaining[$ticket->ID()] > 0) {
541
+                if ( ! isset($event_reg_count[$EVT_ID])) {
542
+                    $event_reg_count[$EVT_ID] = 0;
543 543
                 }
544
-                $event_reg_count[ $EVT_ID ]++;
545
-                if (! isset($event_spaces_remaining[ $EVT_ID ])) {
546
-                    $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale();
544
+                $event_reg_count[$EVT_ID]++;
545
+                if ( ! isset($event_spaces_remaining[$EVT_ID])) {
546
+                    $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
547 547
                 }
548 548
             }
549 549
             if ($revisit
550
-                && ($tickets_remaining[ $ticket->ID() ] === 0
551
-                    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
550
+                && ($tickets_remaining[$ticket->ID()] === 0
551
+                    || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID]
552 552
                 )
553 553
             ) {
554
-                $ejected_registrations[ $REG_ID ] = $registration->event();
554
+                $ejected_registrations[$REG_ID] = $registration->event();
555 555
                 if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
556 556
                     /** @type EE_Registration_Processor $registration_processor */
557 557
                     $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
         foreach ($sold_out_events_array as $sold_out_event) {
612 612
             $sold_out_events .= EEH_HTML::li(
613 613
                 EEH_HTML::span(
614
-                    '  ' . $sold_out_event->name(),
614
+                    '  '.$sold_out_event->name(),
615 615
                     '',
616 616
                     'dashicons dashicons-marker ee-icon-size-16 pink-text'
617 617
                 )
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
         foreach ($insufficient_spaces_events_array as $event) {
668 668
             if ($event instanceof EE_Event) {
669 669
                 $insufficient_space_events .= EEH_HTML::li(
670
-                    EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
670
+                    EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
671 671
                 );
672 672
             }
673 673
         }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
         $events_requiring_pre_approval = '';
717 717
         foreach ($registrations_requiring_pre_approval as $registration) {
718 718
             if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
719
-                $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
719
+                $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
720 720
                     EEH_HTML::span(
721 721
                         '',
722 722
                         '',
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     {
858 858
         return new EE_Form_Section_Proper(
859 859
             array(
860
-                'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
860
+                'html_id'         => 'ee-'.$this->slug().'-extra-hidden-inputs',
861 861
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
862 862
                 'subsections'     => array(
863 863
                     'spco_no_payment_required' => new EE_Hidden_Input(
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
                 $payments += $registration->registration_payments();
898 898
             }
899 899
         }
900
-        if (! empty($payments)) {
900
+        if ( ! empty($payments)) {
901 901
             foreach ($payments as $payment) {
902 902
                 if ($payment instanceof EE_Registration_Payment) {
903 903
                     $this->checkout->amount_owing -= $payment->amount();
@@ -1017,23 +1017,23 @@  discard block
 block discarded – undo
1017 1017
                 $payment_method_button = EEH_HTML::img(
1018 1018
                     $payment_method->button_url(),
1019 1019
                     $payment_method->name(),
1020
-                    'spco-payment-method-' . $payment_method->slug() . '-btn-img',
1020
+                    'spco-payment-method-'.$payment_method->slug().'-btn-img',
1021 1021
                     'spco-payment-method-btn-img'
1022 1022
                 );
1023 1023
                 // check if any payment methods are set as default
1024 1024
                 // if payment method is already selected OR nothing is selected and this payment method should be
1025 1025
                 // open_by_default
1026 1026
                 if (($this->checkout->selected_method_of_payment === $payment_method->slug())
1027
-                    || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1027
+                    || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
1028 1028
                 ) {
1029 1029
                     $this->checkout->selected_method_of_payment = $payment_method->slug();
1030 1030
                     $this->_save_selected_method_of_payment();
1031
-                    $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
1031
+                    $default_payment_method_option[$payment_method->slug()] = $payment_method_button;
1032 1032
                 } else {
1033
-                    $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
1033
+                    $available_payment_method_options[$payment_method->slug()] = $payment_method_button;
1034 1034
                 }
1035
-                $payment_methods_billing_info[ $payment_method->slug(
1036
-                ) . '-info' ] = $this->_payment_method_billing_info(
1035
+                $payment_methods_billing_info[$payment_method->slug(
1036
+                ).'-info'] = $this->_payment_method_billing_info(
1037 1037
                     $payment_method
1038 1038
                 );
1039 1039
             }
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
      */
1070 1070
     protected function _get_available_payment_methods()
1071 1071
     {
1072
-        if (! empty($this->checkout->available_payment_methods)) {
1072
+        if ( ! empty($this->checkout->available_payment_methods)) {
1073 1073
             return $this->checkout->available_payment_methods;
1074 1074
         }
1075 1075
         $available_payment_methods = array();
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
         );
1085 1085
         foreach ($payment_methods as $payment_method) {
1086 1086
             if ($payment_method instanceof EE_Payment_Method) {
1087
-                $available_payment_methods[ $payment_method->slug() ] = $payment_method;
1087
+                $available_payment_methods[$payment_method->slug()] = $payment_method;
1088 1088
             }
1089 1089
         }
1090 1090
         return $available_payment_methods;
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
         );
1180 1180
         return new EE_Form_Section_Proper(
1181 1181
             array(
1182
-                'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1182
+                'html_id'         => 'spco-payment-method-info-'.$payment_method->slug(),
1183 1183
                 'html_class'      => 'spco-payment-method-info-dv',
1184 1184
                 // only display the selected or default PM
1185 1185
                 'html_style'      => $currently_selected ? '' : 'display:none;',
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
         // how have they chosen to pay?
1210 1210
         $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1211 1211
         $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1212
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1212
+        if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1213 1213
             return false;
1214 1214
         }
1215 1215
         if (apply_filters(
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
      */
1382 1382
     public function switch_payment_method()
1383 1383
     {
1384
-        if (! $this->_verify_payment_method_is_set()) {
1384
+        if ( ! $this->_verify_payment_method_is_set()) {
1385 1385
             return false;
1386 1386
         }
1387 1387
         if (apply_filters(
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
             }
1517 1517
         }
1518 1518
         // verify payment method
1519
-        if (! $this->checkout->payment_method instanceof EE_Payment_Method) {
1519
+        if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1520 1520
             // get payment method for selected method of payment
1521 1521
             $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1522 1522
         }
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
      */
1542 1542
     public function save_payer_details_via_ajax()
1543 1543
     {
1544
-        if (! $this->_verify_payment_method_is_set()) {
1544
+        if ( ! $this->_verify_payment_method_is_set()) {
1545 1545
             return;
1546 1546
         }
1547 1547
         // generate billing form for selected method of payment if it hasn't been done already
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
             );
1552 1552
         }
1553 1553
         // generate primary attendee from payer info if applicable
1554
-        if (! $this->checkout->transaction_has_primary_registrant()) {
1554
+        if ( ! $this->checkout->transaction_has_primary_registrant()) {
1555 1555
             $attendee = $this->_create_attendee_from_request_data();
1556 1556
             if ($attendee instanceof EE_Attendee) {
1557 1557
                 foreach ($this->checkout->transaction->registrations() as $registration) {
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
     {
1583 1583
         // get State ID
1584 1584
         $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1585
-        if (! empty($STA_ID)) {
1585
+        if ( ! empty($STA_ID)) {
1586 1586
             // can we get state object from name ?
1587 1587
             EE_Registry::instance()->load_model('State');
1588 1588
             $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
         }
1591 1591
         // get Country ISO
1592 1592
         $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1593
-        if (! empty($CNT_ISO)) {
1593
+        if ( ! empty($CNT_ISO)) {
1594 1594
             // can we get country object from name ?
1595 1595
             EE_Registry::instance()->load_model('Country');
1596 1596
             $country = EEM_Country::instance()->get_col(
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
         }
1624 1624
         // does this attendee already exist in the db ? we're searching using a combination of first name, last name,
1625 1625
         // AND email address
1626
-        if (! empty($attendee_data['ATT_fname'])
1626
+        if ( ! empty($attendee_data['ATT_fname'])
1627 1627
             && ! empty($attendee_data['ATT_lname'])
1628 1628
             && ! empty($attendee_data['ATT_email'])
1629 1629
         ) {
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
     private function _process_payment()
1839 1839
     {
1840 1840
         // basically confirm that the event hasn't sold out since they hit the page
1841
-        if (! $this->_last_second_ticket_verifications()) {
1841
+        if ( ! $this->_last_second_ticket_verifications()) {
1842 1842
             return false;
1843 1843
         }
1844 1844
         // ya gotta make a choice man
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
             return false;
1850 1850
         }
1851 1851
         // get EE_Payment_Method object
1852
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1852
+        if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1853 1853
             return false;
1854 1854
         }
1855 1855
         // setup billing form
@@ -1858,12 +1858,12 @@  discard block
 block discarded – undo
1858 1858
                 $this->checkout->payment_method
1859 1859
             );
1860 1860
             // bad billing form ?
1861
-            if (! $this->_billing_form_is_valid()) {
1861
+            if ( ! $this->_billing_form_is_valid()) {
1862 1862
                 return false;
1863 1863
             }
1864 1864
         }
1865 1865
         // ensure primary registrant has been fully processed
1866
-        if (! $this->_setup_primary_registrant_prior_to_payment()) {
1866
+        if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1867 1867
             return false;
1868 1868
         }
1869 1869
         // if session is close to expiring (under 10 minutes by default)
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
     protected function _last_second_ticket_verifications()
1919 1919
     {
1920 1920
         // don't bother re-validating if not a return visit
1921
-        if (! $this->checkout->revisit) {
1921
+        if ( ! $this->checkout->revisit) {
1922 1922
             return true;
1923 1923
         }
1924 1924
         $registrations = $this->checkout->transaction->registrations();
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
      */
1985 1985
     private function _billing_form_is_valid()
1986 1986
     {
1987
-        if (! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1987
+        if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1988 1988
             return true;
1989 1989
         }
1990 1990
         if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
     {
2104 2104
         // convert billing form data into an attendee
2105 2105
         $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
2106
-        if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2106
+        if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
2107 2107
             EE_Error::add_error(
2108 2108
                 sprintf(
2109 2109
                     esc_html__(
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
             return false;
2121 2121
         }
2122 2122
         $primary_registration = $this->checkout->transaction->primary_registration();
2123
-        if (! $primary_registration instanceof EE_Registration) {
2123
+        if ( ! $primary_registration instanceof EE_Registration) {
2124 2124
             EE_Error::add_error(
2125 2125
                 sprintf(
2126 2126
                     esc_html__(
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
             );
2137 2137
             return false;
2138 2138
         }
2139
-        if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2139
+        if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
2140 2140
               instanceof
2141 2141
               EE_Attendee
2142 2142
         ) {
@@ -2182,8 +2182,8 @@  discard block
 block discarded – undo
2182 2182
             return null;
2183 2183
         }
2184 2184
         // get EE_Payment_Method object
2185
-        if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) {
2186
-            $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2185
+        if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
2186
+            $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
2187 2187
         } else {
2188 2188
             // load EEM_Payment_Method
2189 2189
             EE_Registry::instance()->load_model('Payment_Method');
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
             $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2193 2193
         }
2194 2194
         // verify $payment_method
2195
-        if (! $payment_method instanceof EE_Payment_Method) {
2195
+        if ( ! $payment_method instanceof EE_Payment_Method) {
2196 2196
             // not a payment
2197 2197
             EE_Error::add_error(
2198 2198
                 sprintf(
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
             return null;
2211 2211
         }
2212 2212
         // and verify it has a valid Payment_Method Type object
2213
-        if (! $payment_method->type_obj() instanceof EE_PMT_Base) {
2213
+        if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
2214 2214
             // not a payment
2215 2215
             EE_Error::add_error(
2216 2216
                 sprintf(
@@ -2248,7 +2248,7 @@  discard block
 block discarded – undo
2248 2248
         $payment = null;
2249 2249
         $this->checkout->transaction->save();
2250 2250
         $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2251
-        if (! $payment_processor instanceof EE_Payment_Processor) {
2251
+        if ( ! $payment_processor instanceof EE_Payment_Processor) {
2252 2252
             return false;
2253 2253
         }
2254 2254
         try {
@@ -2352,7 +2352,7 @@  discard block
 block discarded – undo
2352 2352
             return true;
2353 2353
         }
2354 2354
         // verify payment object
2355
-        if (! $payment instanceof EE_Payment) {
2355
+        if ( ! $payment instanceof EE_Payment) {
2356 2356
             // not a payment
2357 2357
             EE_Error::add_error(
2358 2358
                 sprintf(
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
             return true;
2393 2393
             // On-Site payment?
2394 2394
         } elseif ($this->checkout->payment_method->is_on_site()) {
2395
-            if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2395
+            if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2396 2396
                 // $this->_setup_redirect_for_next_step();
2397 2397
                 $this->checkout->continue_reg = false;
2398 2398
             }
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
                     break;
2509 2509
                 // bad payment
2510 2510
                 case EEM_Payment::status_id_failed:
2511
-                    if (! empty($msg)) {
2511
+                    if ( ! empty($msg)) {
2512 2512
                         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2513 2513
                         return false;
2514 2514
                     }
@@ -2569,11 +2569,11 @@  discard block
 block discarded – undo
2569 2569
         // how have they chosen to pay?
2570 2570
         $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2571 2571
         // get EE_Payment_Method object
2572
-        if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2572
+        if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2573 2573
             $this->checkout->continue_reg = false;
2574 2574
             return false;
2575 2575
         }
2576
-        if (! $this->checkout->payment_method->is_off_site()) {
2576
+        if ( ! $this->checkout->payment_method->is_off_site()) {
2577 2577
             return false;
2578 2578
         }
2579 2579
         $this->_validate_offsite_return();
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
         // verify TXN
2592 2592
         if ($this->checkout->transaction instanceof EE_Transaction) {
2593 2593
             $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2594
-            if (! $gateway instanceof EE_Offsite_Gateway) {
2594
+            if ( ! $gateway instanceof EE_Offsite_Gateway) {
2595 2595
                 $this->checkout->continue_reg = false;
2596 2596
                 return false;
2597 2597
             }
@@ -2708,13 +2708,13 @@  discard block
 block discarded – undo
2708 2708
      */
2709 2709
     private function _redirect_wayward_request(EE_Registration $primary_registrant)
2710 2710
     {
2711
-        if (! $primary_registrant instanceof EE_Registration) {
2711
+        if ( ! $primary_registrant instanceof EE_Registration) {
2712 2712
             // try redirecting based on the current TXN
2713 2713
             $primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2714 2714
                 ? $this->checkout->transaction->primary_registration()
2715 2715
                 : null;
2716 2716
         }
2717
-        if (! $primary_registrant instanceof EE_Registration) {
2717
+        if ( ! $primary_registrant instanceof EE_Registration) {
2718 2718
             EE_Error::add_error(
2719 2719
                 sprintf(
2720 2720
                     esc_html__(
@@ -2784,7 +2784,7 @@  discard block
 block discarded – undo
2784 2784
             $payment = $this->checkout->transaction->last_payment();
2785 2785
             // $payment_source = 'last_payment after Exception';
2786 2786
             // but if we STILL don't have a payment object
2787
-            if (! $payment instanceof EE_Payment) {
2787
+            if ( ! $payment instanceof EE_Payment) {
2788 2788
                 // then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2789 2789
                 $this->_handle_payment_processor_exception($e);
2790 2790
             }
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +1350 added lines, -1350 removed lines patch added patch discarded remove patch
@@ -15,1357 +15,1357 @@
 block discarded – undo
15 15
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
16 16
 {
17 17
 
18
-    /**
19
-     * @type bool $_print_copy_info
20
-     */
21
-    private $_print_copy_info = false;
22
-
23
-    /**
24
-     * @type array $_attendee_data
25
-     */
26
-    private $_attendee_data = array();
27
-
28
-    /**
29
-     * @type array $_required_questions
30
-     */
31
-    private $_required_questions = array();
32
-
33
-    /**
34
-     * @type array $_registration_answers
35
-     */
36
-    private $_registration_answers = array();
37
-
38
-
39
-    /**
40
-     *    class constructor
41
-     *
42
-     * @access    public
43
-     * @param    EE_Checkout $checkout
44
-     */
45
-    public function __construct(EE_Checkout $checkout)
46
-    {
47
-        $this->_slug = 'attendee_information';
48
-        $this->_name = esc_html__('Attendee Information', 'event_espresso');
49
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
50
-        $this->checkout = $checkout;
51
-        $this->_reset_success_message();
52
-        $this->set_instructions(
53
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
54
-        );
55
-    }
56
-
57
-
58
-    public function translate_js_strings()
59
-    {
60
-        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
61
-            ' is a required question.',
62
-            'event_espresso'
63
-        );
64
-        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
65
-            ' is a required question. Please enter a value for at least one of the options.',
66
-            'event_espresso'
67
-        );
68
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
69
-            'Please answer all required questions correctly before proceeding.',
70
-            'event_espresso'
71
-        );
72
-        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
73
-            esc_html__(
74
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
75
-                'event_espresso'
76
-            ),
77
-            '<br/>'
78
-        );
79
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
80
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
81
-            'event_espresso'
82
-        );
83
-        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
84
-            'You must enter a valid email address.',
85
-            'event_espresso'
86
-        );
87
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
88
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
89
-            'event_espresso'
90
-        );
91
-    }
92
-
93
-
94
-    public function enqueue_styles_and_scripts()
95
-    {
96
-    }
97
-
98
-
99
-    /**
100
-     * @return boolean
101
-     */
102
-    public function initialize_reg_step()
103
-    {
104
-        return true;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return EE_Form_Section_Proper
110
-     * @throws EE_Error
111
-     * @throws InvalidArgumentException
112
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
113
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
114
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
115
-     */
116
-    public function generate_reg_form()
117
-    {
118
-        $this->_print_copy_info = false;
119
-        $primary_registrant = null;
120
-        // autoload Line_Item_Display classes
121
-        EEH_Autoloader::register_line_item_display_autoloaders();
122
-        $Line_Item_Display = new EE_Line_Item_Display();
123
-        // calculate taxes
124
-        $Line_Item_Display->display_line_item(
125
-            $this->checkout->cart->get_grand_total(),
126
-            array('set_tax_rate' => true)
127
-        );
128
-        /** @var $subsections EE_Form_Section_Proper[] */
129
-        $subsections = array(
130
-            'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
131
-        );
132
-        $template_args = array(
133
-            'revisit'       => $this->checkout->revisit,
134
-            'registrations' => array(),
135
-            'ticket_count'  => array(),
136
-        );
137
-        // grab the saved registrations from the transaction
138
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
139
-        if ($registrations) {
140
-            foreach ($registrations as $registration) {
141
-                // can this registration be processed during this visit ?
142
-                if ($registration instanceof EE_Registration
143
-                    && $this->checkout->visit_allows_processing_of_this_registration($registration)
144
-                ) {
145
-                    $subsection = $this->_registrations_reg_form($registration);
146
-                    if (! $subsection instanceof EE_Form_Section_Proper) {
147
-                        continue;
148
-                    }
149
-                    $subsections[ $registration->reg_url_link() ] = $subsection;
150
-                    if (! $this->checkout->admin_request) {
151
-                        $template_args['registrations'][ $registration->reg_url_link() ] = $registration;
152
-                        $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
153
-                            $template_args['ticket_count'][ $registration->ticket()->ID() ]
154
-                        )
155
-                            ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
156
-                            : 1;
157
-                        $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
158
-                            $this->checkout->cart->get_grand_total(),
159
-                            'Ticket',
160
-                            array($registration->ticket()->ID())
161
-                        );
162
-                        $ticket_line_item = is_array($ticket_line_item)
163
-                            ? reset($ticket_line_item)
164
-                            : $ticket_line_item;
165
-                        $template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
166
-                            $Line_Item_Display->display_line_item($ticket_line_item);
167
-                    }
168
-                    if ($registration->is_primary_registrant()) {
169
-                        $primary_registrant = $registration->reg_url_link();
170
-                    }
171
-                }
172
-            }
173
-            // print_copy_info ?
174
-            if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
175
-                // TODO: add admin option for toggling copy attendee info,
176
-                // then use that value to change $this->_print_copy_info
177
-                $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
178
-                    ? $this->_copy_attendee_info_form()
179
-                    : $this->_auto_copy_attendee_info();
180
-                // generate hidden input
181
-                if (isset($subsections[ $primary_registrant ])
182
-                    && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
183
-                ) {
184
-                    $subsections[ $primary_registrant ]->add_subsections(
185
-                        $copy_options,
186
-                        'primary_registrant',
187
-                        false
188
-                    );
189
-                }
190
-            }
191
-        }
192
-        return new EE_Form_Section_Proper(
193
-            array(
194
-                'name'            => $this->reg_form_name(),
195
-                'html_id'         => $this->reg_form_name(),
196
-                'subsections'     => $subsections,
197
-                'layout_strategy' => $this->checkout->admin_request
198
-                    ?
199
-                    new EE_Div_Per_Section_Layout()
200
-                    :
201
-                    new EE_Template_Layout(
202
-                        array(
203
-                            'layout_template_file' => $this->_template, // layout_template
204
-                            'template_args'        => $template_args,
205
-                        )
206
-                    ),
207
-            )
208
-        );
209
-    }
210
-
211
-
212
-    /**
213
-     * @param EE_Registration $registration
214
-     * @return EE_Form_Section_Base
215
-     * @throws EE_Error
216
-     * @throws InvalidArgumentException
217
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
218
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
219
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
220
-     */
221
-    private function _registrations_reg_form(EE_Registration $registration)
222
-    {
223
-        static $attendee_nmbr = 1;
224
-        $form_args = array();
225
-        // verify that registration has valid event
226
-        if ($registration->event() instanceof EE_Event) {
227
-            $question_groups = $registration->event()->question_groups(
228
-                apply_filters(
229
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
230
-                    array(
231
-                        array(
232
-                            'Event.EVT_ID'                     => $registration->event()->ID(),
233
-                            'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
234
-                        ),
235
-                        'order_by' => array('QSG_order' => 'ASC'),
236
-                    ),
237
-                    $registration,
238
-                    $this
239
-                )
240
-            );
241
-            if ($question_groups) {
242
-                // array of params to pass to parent constructor
243
-                $form_args = array(
244
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
245
-                    'html_class'      => 'ee-reg-form-attendee-dv',
246
-                    'html_style'      => $this->checkout->admin_request
247
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
248
-                        : '',
249
-                    'subsections'     => array(),
250
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
251
-                        array(
252
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
253
-                            'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
254
-                        )
255
-                    ),
256
-                );
257
-                foreach ($question_groups as $question_group) {
258
-                    if ($question_group instanceof EE_Question_Group) {
259
-                        $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
260
-                            $registration,
261
-                            $question_group
262
-                        );
263
-                    }
264
-                }
265
-                // add hidden input
266
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
267
-                    $registration
268
-                );
269
-                // if we have question groups for additional attendees, then display the copy options
270
-                $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
271
-                if ($registration->is_primary_registrant()) {
272
-                    // generate hidden input
273
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
274
-                        $registration
275
-                    );
276
-                }
277
-            }
278
-        }
279
-        $attendee_nmbr++;
280
-        return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : null;
281
-    }
282
-
283
-
284
-    /**
285
-     * _additional_attendee_reg_info_input
286
-     *
287
-     * @access public
288
-     * @param EE_Registration $registration
289
-     * @param bool            $additional_attendee_reg_info
290
-     * @return    EE_Form_Input_Base
291
-     * @throws \EE_Error
292
-     */
293
-    private function _additional_attendee_reg_info_input(
294
-        EE_Registration $registration,
295
-        $additional_attendee_reg_info = true
296
-    ) {
297
-        // generate hidden input
298
-        return new EE_Hidden_Input(
299
-            array(
300
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
301
-                'default' => $additional_attendee_reg_info,
302
-            )
303
-        );
304
-    }
305
-
306
-
307
-    /**
308
-     * @param EE_Registration   $registration
309
-     * @param EE_Question_Group $question_group
310
-     * @return EE_Form_Section_Proper
311
-     * @throws EE_Error
312
-     * @throws InvalidArgumentException
313
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
314
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
315
-     */
316
-    private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
317
-    {
318
-        // array of params to pass to parent constructor
319
-        $form_args = array(
320
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
321
-            'html_class'      => $this->checkout->admin_request
322
-                ? 'form-table ee-reg-form-qstn-grp-dv'
323
-                : 'ee-reg-form-qstn-grp-dv',
324
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
325
-                                 . $registration->ID() . '-lbl',
326
-            'subsections'     => array(
327
-                'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
328
-            ),
329
-            'layout_strategy' => $this->checkout->admin_request
330
-                ? new EE_Admin_Two_Column_Layout()
331
-                : new EE_Div_Per_Section_Layout(),
332
-        );
333
-        // where params
334
-        $query_params = array('QST_deleted' => 0);
335
-        // don't load admin only questions on the frontend
336
-        if (! $this->checkout->admin_request) {
337
-            $query_params['QST_admin_only'] = array('!=', true);
338
-        }
339
-        $questions = $question_group->get_many_related(
340
-            'Question',
341
-            apply_filters(
342
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
343
-                array(
344
-                    $query_params,
345
-                    'order_by' => array(
346
-                        'Question_Group_Question.QGQ_order' => 'ASC',
347
-                    ),
348
-                ),
349
-                $question_group,
350
-                $registration,
351
-                $this
352
-            )
353
-        );
354
-        // filter for additional content before questions
355
-        $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
356
-            apply_filters(
357
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
358
-                '',
359
-                $registration,
360
-                $question_group,
361
-                $this
362
-            )
363
-        );
364
-        // loop thru questions
365
-        foreach ($questions as $question) {
366
-            if ($question instanceof EE_Question) {
367
-                $identifier = $question->is_system_question()
368
-                    ? $question->system_ID()
369
-                    : $question->ID();
370
-                $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
371
-            }
372
-        }
373
-        $form_args['subsections'] = apply_filters(
374
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
375
-            $form_args['subsections'],
376
-            $registration,
377
-            $question_group,
378
-            $this
379
-        );
380
-        // filter for additional content after questions
381
-        $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
382
-            apply_filters(
383
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
384
-                '',
385
-                $registration,
386
-                $question_group,
387
-                $this
388
-            )
389
-        );
390
-        // d($form_args);
391
-        $question_group_reg_form = new EE_Form_Section_Proper($form_args);
392
-        return apply_filters(
393
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
394
-            $question_group_reg_form,
395
-            $registration,
396
-            $question_group,
397
-            $this
398
-        );
399
-    }
400
-
401
-
402
-    /**
403
-     * @access public
404
-     * @param EE_Question_Group $question_group
405
-     * @return    EE_Form_Section_HTML
406
-     */
407
-    private function _question_group_header(EE_Question_Group $question_group)
408
-    {
409
-        $html = '';
410
-        // group_name
411
-        if ($question_group->show_group_name() && $question_group->name() !== '') {
412
-            if ($this->checkout->admin_request) {
413
-                $html .= EEH_HTML::br();
414
-                $html .= EEH_HTML::h3(
415
-                    $question_group->name(),
416
-                    '',
417
-                    'ee-reg-form-qstn-grp-title title',
418
-                    'font-size: 1.3em; padding-left:0;'
419
-                );
420
-            } else {
421
-                $html .= EEH_HTML::h4(
422
-                    $question_group->name(),
423
-                    '',
424
-                    'ee-reg-form-qstn-grp-title section-title'
425
-                );
426
-            }
427
-        }
428
-        // group_desc
429
-        if ($question_group->show_group_desc() && $question_group->desc() !== '') {
430
-            $html .= EEH_HTML::p(
431
-                $question_group->desc(),
432
-                '',
433
-                $this->checkout->admin_request
434
-                    ? 'ee-reg-form-qstn-grp-desc-pg'
435
-                    : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
436
-            );
437
-        }
438
-        return new EE_Form_Section_HTML($html);
439
-    }
440
-
441
-
442
-    /**
443
-     * @access public
444
-     * @return    EE_Form_Section_Proper
445
-     * @throws \EE_Error
446
-     */
447
-    private function _copy_attendee_info_form()
448
-    {
449
-        // array of params to pass to parent constructor
450
-        return new EE_Form_Section_Proper(
451
-            array(
452
-                'subsections'     => $this->_copy_attendee_info_inputs(),
453
-                'layout_strategy' => new EE_Template_Layout(
454
-                    array(
455
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
456
-                                                      . $this->_slug
457
-                                                      . DS
458
-                                                      . 'copy_attendee_info.template.php',
459
-                        'begin_template_file'      => null,
460
-                        'input_template_file'      => null,
461
-                        'subsection_template_file' => null,
462
-                        'end_template_file'        => null,
463
-                    )
464
-                ),
465
-            )
466
-        );
467
-    }
468
-
469
-
470
-    /**
471
-     * _auto_copy_attendee_info
472
-     *
473
-     * @access public
474
-     * @return EE_Form_Section_HTML
475
-     */
476
-    private function _auto_copy_attendee_info()
477
-    {
478
-        return new EE_Form_Section_HTML(
479
-            EEH_Template::locate_template(
480
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
481
-                apply_filters(
482
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
483
-                    array()
484
-                ),
485
-                true,
486
-                true
487
-            )
488
-        );
489
-    }
490
-
491
-
492
-    /**
493
-     * _copy_attendee_info_inputs
494
-     *
495
-     * @access public
496
-     * @return array
497
-     * @throws \EE_Error
498
-     */
499
-    private function _copy_attendee_info_inputs()
500
-    {
501
-        $copy_attendee_info_inputs = array();
502
-        $prev_ticket = null;
503
-        // grab the saved registrations from the transaction
504
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
505
-        foreach ($registrations as $registration) {
506
-            // for all  attendees other than the primary attendee
507
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
508
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
509
-                if ($registration->ticket()->ID() !== $prev_ticket) {
510
-                    $item_name = $registration->ticket()->name();
511
-                    $item_name .= $registration->ticket()->description() !== ''
512
-                        ? ' - ' . $registration->ticket()->description()
513
-                        : '';
514
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
515
-                    ) . ']' ] =
516
-                        new EE_Form_Section_HTML(
517
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
518
-                        );
519
-                    $prev_ticket = $registration->ticket()->ID();
520
-                }
521
-
522
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
523
-                    new EE_Checkbox_Multi_Input(
524
-                        array(
525
-                            $registration->ID() => sprintf(
526
-                                esc_html__('Attendee #%s', 'event_espresso'),
527
-                                $registration->count()
528
-                            ),
529
-                        ),
530
-                        array(
531
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
532
-                            'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
533
-                            'display_html_label_text' => false,
534
-                        )
535
-                    );
536
-            }
537
-        }
538
-        return $copy_attendee_info_inputs;
539
-    }
540
-
541
-
542
-    /**
543
-     * _additional_primary_registrant_inputs
544
-     *
545
-     * @access public
546
-     * @param EE_Registration $registration
547
-     * @return    EE_Form_Input_Base
548
-     * @throws \EE_Error
549
-     */
550
-    private function _additional_primary_registrant_inputs(EE_Registration $registration)
551
-    {
552
-        // generate hidden input
553
-        return new EE_Hidden_Input(
554
-            array(
555
-                'html_id' => 'primary_registrant',
556
-                'default' => $registration->reg_url_link(),
557
-            )
558
-        );
559
-    }
560
-
561
-
562
-    /**
563
-     * @access public
564
-     * @param EE_Registration $registration
565
-     * @param EE_Question     $question
566
-     * @return EE_Form_Input_Base
567
-     * @throws EE_Error
568
-     * @throws InvalidArgumentException
569
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
570
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
571
-     */
572
-    public function reg_form_question(EE_Registration $registration, EE_Question $question)
573
-    {
574
-
575
-        // if this question was for an attendee detail, then check for that answer
576
-        $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
577
-            $registration,
578
-            $question->system_ID()
579
-        );
580
-        $answer = $answer_value === null
581
-            ? EEM_Answer::instance()->get_one(
582
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
583
-            )
584
-            : null;
585
-        // if NOT returning to edit an existing registration
586
-        // OR if this question is for an attendee property
587
-        // OR we still don't have an EE_Answer object
588
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
589
-            // create an EE_Answer object for storing everything in
590
-            $answer = EE_Answer::new_instance(
591
-                array(
592
-                    'QST_ID' => $question->ID(),
593
-                    'REG_ID' => $registration->ID(),
594
-                )
595
-            );
596
-        }
597
-        // verify instance
598
-        if ($answer instanceof EE_Answer) {
599
-            if (! empty($answer_value)) {
600
-                $answer->set('ANS_value', $answer_value);
601
-            }
602
-            $answer->cache('Question', $question);
603
-            // remember system ID had a bug where sometimes it could be null
604
-            $answer_cache_id = $question->is_system_question()
605
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
606
-                : $question->ID() . '-' . $registration->reg_url_link();
607
-            $registration->cache('Answer', $answer, $answer_cache_id);
608
-        }
609
-        return $this->_generate_question_input($registration, $question, $answer);
610
-    }
611
-
612
-
613
-    /**
614
-     * @param EE_Registration $registration
615
-     * @param EE_Question     $question
616
-     * @param                 mixed EE_Answer|NULL      $answer
617
-     * @return EE_Form_Input_Base
618
-     * @throws \EE_Error
619
-     */
620
-    private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
621
-    {
622
-        $identifier = $question->is_system_question()
623
-            ? $question->system_ID()
624
-            : $question->ID();
625
-        $this->_required_questions[ $identifier ] = $question->required() ? true : false;
626
-        add_filter(
627
-            'FHEE__EE_Question__generate_form_input__country_options',
628
-            array($this, 'use_cached_countries_for_form_input'),
629
-            10,
630
-            4
631
-        );
632
-        add_filter(
633
-            'FHEE__EE_Question__generate_form_input__state_options',
634
-            array($this, 'use_cached_states_for_form_input'),
635
-            10,
636
-            4
637
-        );
638
-        $input_constructor_args = array(
639
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
640
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
641
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
642
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
643
-            'html_label_class' => 'ee-reg-qstn',
644
-        );
645
-        $input_constructor_args['html_label_id'] .= '-lbl';
646
-        if ($answer instanceof EE_Answer && $answer->ID()) {
647
-            $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
648
-            $input_constructor_args['html_id'] .= '-' . $answer->ID();
649
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
650
-        }
651
-        $form_input = $question->generate_form_input(
652
-            $registration,
653
-            $answer,
654
-            $input_constructor_args
655
-        );
656
-        remove_filter(
657
-            'FHEE__EE_Question__generate_form_input__country_options',
658
-            array($this, 'use_cached_countries_for_form_input')
659
-        );
660
-        remove_filter(
661
-            'FHEE__EE_Question__generate_form_input__state_options',
662
-            array($this, 'use_cached_states_for_form_input')
663
-        );
664
-        return $form_input;
665
-    }
666
-
667
-
668
-    /**
669
-     * Gets the list of countries for the form input
670
-     *
671
-     * @param array|null       $countries_list
672
-     * @param \EE_Question     $question
673
-     * @param \EE_Registration $registration
674
-     * @param \EE_Answer       $answer
675
-     * @return array 2d keys are country IDs, values are their names
676
-     * @throws EE_Error
677
-     * @throws InvalidArgumentException
678
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
679
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
680
-     */
681
-    public function use_cached_countries_for_form_input(
682
-        $countries_list,
683
-        \EE_Question $question = null,
684
-        \EE_Registration $registration = null,
685
-        \EE_Answer $answer = null
686
-    ) {
687
-        $country_options = array('' => '');
688
-        // get possibly cached list of countries
689
-        $countries = $this->checkout->action === 'process_reg_step'
690
-            ? EEM_Country::instance()->get_all_countries()
691
-            : EEM_Country::instance()->get_all_active_countries();
692
-        if (! empty($countries)) {
693
-            foreach ($countries as $country) {
694
-                if ($country instanceof EE_Country) {
695
-                    $country_options[ $country->ID() ] = $country->name();
696
-                }
697
-            }
698
-        }
699
-        if ($question instanceof EE_Question
700
-            && $registration instanceof EE_Registration) {
701
-            $answer = EEM_Answer::instance()->get_one(
702
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
703
-            );
704
-        } else {
705
-            $answer = EE_Answer::new_instance();
706
-        }
707
-        $country_options = apply_filters(
708
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
709
-            $country_options,
710
-            $this,
711
-            $registration,
712
-            $question,
713
-            $answer
714
-        );
715
-        return $country_options;
716
-    }
717
-
718
-
719
-    /**
720
-     * Gets the list of states for the form input
721
-     *
722
-     * @param array|null       $states_list
723
-     * @param \EE_Question     $question
724
-     * @param \EE_Registration $registration
725
-     * @param \EE_Answer       $answer
726
-     * @return array 2d keys are state IDs, values are their names
727
-     * @throws EE_Error
728
-     * @throws InvalidArgumentException
729
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
730
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
731
-     */
732
-    public function use_cached_states_for_form_input(
733
-        $states_list,
734
-        \EE_Question $question = null,
735
-        \EE_Registration $registration = null,
736
-        \EE_Answer $answer = null
737
-    ) {
738
-        $state_options = array('' => array('' => ''));
739
-        $states = $this->checkout->action === 'process_reg_step'
740
-            ? EEM_State::instance()->get_all_states()
741
-            : EEM_State::instance()->get_all_active_states();
742
-        if (! empty($states)) {
743
-            foreach ($states as $state) {
744
-                if ($state instanceof EE_State) {
745
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
746
-                }
747
-            }
748
-        }
749
-        $state_options = apply_filters(
750
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
751
-            $state_options,
752
-            $this,
753
-            $registration,
754
-            $question,
755
-            $answer
756
-        );
757
-        return $state_options;
758
-    }
759
-
760
-
761
-
762
-
763
-
764
-
765
-    /********************************************************************************************************/
766
-    /****************************************  PROCESS REG STEP  ****************************************/
767
-    /********************************************************************************************************/
768
-    /**
769
-     * @return bool
770
-     * @throws EE_Error
771
-     * @throws InvalidArgumentException
772
-     * @throws ReflectionException
773
-     * @throws RuntimeException
774
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
775
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
776
-     */
777
-    public function process_reg_step()
778
-    {
779
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780
-        // grab validated data from form
781
-        $valid_data = $this->checkout->current_step->valid_data();
782
-        // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
783
-        // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
784
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
785
-        if (empty($valid_data)) {
786
-            EE_Error::add_error(
787
-                esc_html__('No valid question responses were received.', 'event_espresso'),
788
-                __FILE__,
789
-                __FUNCTION__,
790
-                __LINE__
791
-            );
792
-            return false;
793
-        }
794
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
795
-            EE_Error::add_error(
796
-                esc_html__(
797
-                    'A valid transaction could not be initiated for processing your registrations.',
798
-                    'event_espresso'
799
-                ),
800
-                __FILE__,
801
-                __FUNCTION__,
802
-                __LINE__
803
-            );
804
-            return false;
805
-        }
806
-        // get cached registrations
807
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
808
-        // verify we got the goods
809
-        if (empty($registrations)) {
810
-            // combine the old translated string with a new one, in order to not break translations
811
-            $error_message = esc_html__(
812
-                'Your form data could not be applied to any valid registrations.',
813
-                'event_espresso'
814
-            )
815
-                             . sprintf(
816
-                                 esc_html__(
817
-                                     '%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.',
818
-                                     'event_espresso'
819
-                                 ),
820
-                                 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
821
-                                 '</a>',
822
-                                 '<br />'
823
-                             );
824
-            EE_Error::add_error(
825
-                $error_message,
826
-                __FILE__,
827
-                __FUNCTION__,
828
-                __LINE__
829
-            );
830
-            return false;
831
-        }
832
-        // extract attendee info from form data and save to model objects
833
-        $registrations_processed = $this->_process_registrations($registrations, $valid_data);
834
-        // if first pass thru SPCO,
835
-        // then let's check processed registrations against the total number of tickets in the cart
836
-        if ($registrations_processed === false) {
837
-            // but return immediately if the previous step exited early due to errors
838
-            return false;
839
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
840
-            // generate a correctly translated string for all possible singular/plural combinations
841
-            if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
842
-                $error_msg = sprintf(
843
-                    esc_html__(
844
-                        'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
845
-                        'event_espresso'
846
-                    ),
847
-                    $this->checkout->total_ticket_count,
848
-                    $registrations_processed
849
-                );
850
-            } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
851
-                $error_msg = sprintf(
852
-                    esc_html__(
853
-                        'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
854
-                        'event_espresso'
855
-                    ),
856
-                    $this->checkout->total_ticket_count,
857
-                    $registrations_processed
858
-                );
859
-            } else {
860
-                $error_msg = sprintf(
861
-                    esc_html__(
862
-                        'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
863
-                        'event_espresso'
864
-                    ),
865
-                    $this->checkout->total_ticket_count,
866
-                    $registrations_processed
867
-                );
868
-            }
869
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
870
-            return false;
871
-        }
872
-        // mark this reg step as completed
873
-        $this->set_completed();
874
-        $this->_set_success_message(
875
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
876
-        );
877
-        // do action in case a plugin wants to do something with the data submitted in step 1.
878
-        // passes EE_Single_Page_Checkout, and it's posted data
879
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
880
-        return true;
881
-    }
882
-
883
-
884
-    /**
885
-     *    _process_registrations
886
-     *
887
-     * @param EE_Registration[] $registrations
888
-     * @param array             $valid_data
889
-     * @return bool|int
890
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
891
-     * @throws EE_Error
892
-     * @throws InvalidArgumentException
893
-     * @throws ReflectionException
894
-     * @throws RuntimeException
895
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
896
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
897
-     */
898
-    private function _process_registrations($registrations = array(), $valid_data = array())
899
-    {
900
-        // load resources and set some defaults
901
-        EE_Registry::instance()->load_model('Attendee');
902
-        // holder for primary registrant attendee object
903
-        $this->checkout->primary_attendee_obj = null;
904
-        // array for tracking reg form data for the primary registrant
905
-        $primary_registrant = array(
906
-            'line_item_id' => null,
907
-        );
908
-        $copy_primary = false;
909
-        // reg form sections that do not contain inputs
910
-        $non_input_form_sections = array(
911
-            'primary_registrant',
912
-            'additional_attendee_reg_info',
913
-            'spco_copy_attendee_chk',
914
-        );
915
-        // attendee counter
916
-        $att_nmbr = 0;
917
-        // grab the saved registrations from the transaction
918
-        foreach ($registrations as $registration) {
919
-            // verify EE_Registration object
920
-            if (! $registration instanceof EE_Registration) {
921
-                EE_Error::add_error(
922
-                    esc_html__(
923
-                        'An invalid Registration object was discovered when attempting to process your registration information.',
924
-                        'event_espresso'
925
-                    ),
926
-                    __FILE__,
927
-                    __FUNCTION__,
928
-                    __LINE__
929
-                );
930
-                return false;
931
-            }
932
-            /** @var string $reg_url_link */
933
-            $reg_url_link = $registration->reg_url_link();
934
-            // reg_url_link exists ?
935
-            if (! empty($reg_url_link)) {
936
-                // should this registration be processed during this visit ?
937
-                if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
938
-                    // if NOT revisiting, then let's save the registration now,
939
-                    // so that we have a REG_ID to use when generating other objects
940
-                    if (! $this->checkout->revisit) {
941
-                        $registration->save();
942
-                    }
943
-                    /**
944
-                     * This allows plugins to trigger a fail on processing of a
945
-                     * registration for any conditions they may have for it to pass.
946
-                     *
947
-                     * @var bool   if true is returned by the plugin then the
948
-                     *            registration processing is halted.
949
-                     */
950
-                    if (apply_filters(
951
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
952
-                        false,
953
-                        $att_nmbr,
954
-                        $registration,
955
-                        $registrations,
956
-                        $valid_data,
957
-                        $this
958
-                    )) {
959
-                        return false;
960
-                    }
961
-
962
-                    // Houston, we have a registration!
963
-                    $att_nmbr++;
964
-                    $this->_attendee_data[ $reg_url_link ] = array();
965
-                    // grab any existing related answer objects
966
-                    $this->_registration_answers = $registration->answers();
967
-                    // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
968
-                    if (isset($valid_data[ $reg_url_link ])) {
969
-                        // do we need to copy basic info from primary attendee ?
970
-                        $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
971
-                                        && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0
972
-                            ? true
973
-                            : false;
974
-                        // filter form input data for this registration
975
-                        $valid_data[ $reg_url_link ] = (array) apply_filters(
976
-                            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
977
-                            $valid_data[ $reg_url_link ]
978
-                        );
979
-                        if (isset($valid_data['primary_attendee'])) {
980
-                            $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
981
-                                ? $valid_data['primary_attendee']
982
-                                : false;
983
-                            unset($valid_data['primary_attendee']);
984
-                        }
985
-                        // now loop through our array of valid post data && process attendee reg forms
986
-                        foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
987
-                            if (! in_array($form_section, $non_input_form_sections)) {
988
-                                foreach ($form_inputs as $form_input => $input_value) {
989
-                                    // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
990
-                                    // check for critical inputs
991
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
992
-                                        $form_input,
993
-                                        $input_value
994
-                                    )
995
-                                    ) {
996
-                                        return false;
997
-                                    }
998
-                                    // store a bit of data about the primary attendee
999
-                                    if ($att_nmbr === 1
1000
-                                        && ! empty($input_value)
1001
-                                        && $reg_url_link === $primary_registrant['line_item_id']
1002
-                                    ) {
1003
-                                        $primary_registrant[ $form_input ] = $input_value;
1004
-                                    } elseif ($copy_primary
1005
-                                              && $input_value === null
1006
-                                              && isset($primary_registrant[ $form_input ])
1007
-                                    ) {
1008
-                                        $input_value = $primary_registrant[ $form_input ];
1009
-                                    }
1010
-                                    // now attempt to save the input data
1011
-                                    if (! $this->_save_registration_form_input(
1012
-                                        $registration,
1013
-                                        $form_input,
1014
-                                        $input_value
1015
-                                    )
1016
-                                    ) {
1017
-                                        EE_Error::add_error(
1018
-                                            sprintf(
1019
-                                                esc_html__(
1020
-                                                    'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1021
-                                                    'event_espresso'
1022
-                                                ),
1023
-                                                $form_input,
1024
-                                                $input_value
1025
-                                            ),
1026
-                                            __FILE__,
1027
-                                            __FUNCTION__,
1028
-                                            __LINE__
1029
-                                        );
1030
-                                        return false;
1031
-                                    }
1032
-                                }
1033
-                            }
1034
-                        }  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1035
-                    }
1036
-                    // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1037
-                    // this registration does not require additional attendee information ?
1038
-                    if ($copy_primary
1039
-                        && $att_nmbr > 1
1040
-                        && $this->checkout->primary_attendee_obj instanceof EE_Attendee
1041
-                    ) {
1042
-                        // just copy the primary registrant
1043
-                        $attendee = $this->checkout->primary_attendee_obj;
1044
-                    } else {
1045
-                        // ensure critical details are set for additional attendees
1046
-                        $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1047
-                            ? $this->_copy_critical_attendee_details_from_primary_registrant(
1048
-                                $this->_attendee_data[ $reg_url_link ]
1049
-                            )
1050
-                            : $this->_attendee_data[ $reg_url_link ];
1051
-                        // execute create attendee command (which may return an existing attendee)
1052
-                        $attendee = EE_Registry::instance()->BUS->execute(
1053
-                            new CreateAttendeeCommand(
1054
-                                $this->_attendee_data[ $reg_url_link ],
1055
-                                $registration
1056
-                            )
1057
-                        );
1058
-                        // who's #1 ?
1059
-                        if ($att_nmbr === 1) {
1060
-                            $this->checkout->primary_attendee_obj = $attendee;
1061
-                        }
1062
-                    }
1063
-                    // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1064
-                    // add relation to registration, set attendee ID, and cache attendee
1065
-                    $this->_associate_attendee_with_registration($registration, $attendee);
1066
-                    // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1067
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1068
-                        EE_Error::add_error(
1069
-                            sprintf(
1070
-                                esc_html__(
1071
-                                    'Registration %s has an invalid or missing Attendee object.',
1072
-                                    'event_espresso'
1073
-                                ),
1074
-                                $reg_url_link
1075
-                            ),
1076
-                            __FILE__,
1077
-                            __FUNCTION__,
1078
-                            __LINE__
1079
-                        );
1080
-                        return false;
1081
-                    }
1082
-                    /** @type EE_Registration_Processor $registration_processor */
1083
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1084
-                    // at this point, we should have enough details about the registrant to consider the registration
1085
-                    // NOT incomplete
1086
-                    $registration_processor->toggle_incomplete_registration_status_to_default(
1087
-                        $registration,
1088
-                        false,
1089
-                        new Context(
1090
-                            'spco_reg_step_attendee_information_process_registrations',
1091
-                            esc_html__(
1092
-                                'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1093
-                                'event_espresso'
1094
-                            )
1095
-                        )
1096
-                    );
1097
-                    // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1098
-                    // abandoned
1099
-                    $this->checkout->transaction->toggle_failed_transaction_status();
1100
-                    // if we've gotten this far, then let's save what we have
1101
-                    $registration->save();
1102
-                    // add relation between TXN and registration
1103
-                    $this->_associate_registration_with_transaction($registration);
1104
-                }
1105
-            } else {
1106
-                EE_Error::add_error(
1107
-                    esc_html__(
1108
-                        'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1109
-                        'event_espresso'
1110
-                    ),
1111
-                    __FILE__,
1112
-                    __FUNCTION__,
1113
-                    __LINE__
1114
-                );
1115
-                // remove malformed data
1116
-                unset($valid_data[ $reg_url_link ]);
1117
-                return false;
1118
-            }
1119
-        } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1120
-        return $att_nmbr;
1121
-    }
1122
-
1123
-
1124
-    /**
1125
-     *    _save_registration_form_input
1126
-     *
1127
-     * @param EE_Registration $registration
1128
-     * @param string          $form_input
1129
-     * @param string          $input_value
1130
-     * @return bool
1131
-     * @throws EE_Error
1132
-     * @throws InvalidArgumentException
1133
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
-     */
1136
-    private function _save_registration_form_input(
1137
-        EE_Registration $registration,
1138
-        $form_input = '',
1139
-        $input_value = ''
1140
-    ) {
1141
-        // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1142
-        // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1143
-        // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1144
-        // allow for plugins to hook in and do their own processing of the form input.
1145
-        // For plugins to bypass normal processing here, they just need to return a boolean value.
1146
-        if (apply_filters(
1147
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1148
-            false,
1149
-            $registration,
1150
-            $form_input,
1151
-            $input_value,
1152
-            $this
1153
-        )) {
1154
-            return true;
1155
-        }
1156
-        /*
18
+	/**
19
+	 * @type bool $_print_copy_info
20
+	 */
21
+	private $_print_copy_info = false;
22
+
23
+	/**
24
+	 * @type array $_attendee_data
25
+	 */
26
+	private $_attendee_data = array();
27
+
28
+	/**
29
+	 * @type array $_required_questions
30
+	 */
31
+	private $_required_questions = array();
32
+
33
+	/**
34
+	 * @type array $_registration_answers
35
+	 */
36
+	private $_registration_answers = array();
37
+
38
+
39
+	/**
40
+	 *    class constructor
41
+	 *
42
+	 * @access    public
43
+	 * @param    EE_Checkout $checkout
44
+	 */
45
+	public function __construct(EE_Checkout $checkout)
46
+	{
47
+		$this->_slug = 'attendee_information';
48
+		$this->_name = esc_html__('Attendee Information', 'event_espresso');
49
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
50
+		$this->checkout = $checkout;
51
+		$this->_reset_success_message();
52
+		$this->set_instructions(
53
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
54
+		);
55
+	}
56
+
57
+
58
+	public function translate_js_strings()
59
+	{
60
+		EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
61
+			' is a required question.',
62
+			'event_espresso'
63
+		);
64
+		EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
65
+			' is a required question. Please enter a value for at least one of the options.',
66
+			'event_espresso'
67
+		);
68
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
69
+			'Please answer all required questions correctly before proceeding.',
70
+			'event_espresso'
71
+		);
72
+		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
73
+			esc_html__(
74
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
75
+				'event_espresso'
76
+			),
77
+			'<br/>'
78
+		);
79
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
80
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
81
+			'event_espresso'
82
+		);
83
+		EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
84
+			'You must enter a valid email address.',
85
+			'event_espresso'
86
+		);
87
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
88
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
89
+			'event_espresso'
90
+		);
91
+	}
92
+
93
+
94
+	public function enqueue_styles_and_scripts()
95
+	{
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return boolean
101
+	 */
102
+	public function initialize_reg_step()
103
+	{
104
+		return true;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return EE_Form_Section_Proper
110
+	 * @throws EE_Error
111
+	 * @throws InvalidArgumentException
112
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
113
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
114
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
115
+	 */
116
+	public function generate_reg_form()
117
+	{
118
+		$this->_print_copy_info = false;
119
+		$primary_registrant = null;
120
+		// autoload Line_Item_Display classes
121
+		EEH_Autoloader::register_line_item_display_autoloaders();
122
+		$Line_Item_Display = new EE_Line_Item_Display();
123
+		// calculate taxes
124
+		$Line_Item_Display->display_line_item(
125
+			$this->checkout->cart->get_grand_total(),
126
+			array('set_tax_rate' => true)
127
+		);
128
+		/** @var $subsections EE_Form_Section_Proper[] */
129
+		$subsections = array(
130
+			'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
131
+		);
132
+		$template_args = array(
133
+			'revisit'       => $this->checkout->revisit,
134
+			'registrations' => array(),
135
+			'ticket_count'  => array(),
136
+		);
137
+		// grab the saved registrations from the transaction
138
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
139
+		if ($registrations) {
140
+			foreach ($registrations as $registration) {
141
+				// can this registration be processed during this visit ?
142
+				if ($registration instanceof EE_Registration
143
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
144
+				) {
145
+					$subsection = $this->_registrations_reg_form($registration);
146
+					if (! $subsection instanceof EE_Form_Section_Proper) {
147
+						continue;
148
+					}
149
+					$subsections[ $registration->reg_url_link() ] = $subsection;
150
+					if (! $this->checkout->admin_request) {
151
+						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
152
+						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
153
+							$template_args['ticket_count'][ $registration->ticket()->ID() ]
154
+						)
155
+							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
156
+							: 1;
157
+						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
158
+							$this->checkout->cart->get_grand_total(),
159
+							'Ticket',
160
+							array($registration->ticket()->ID())
161
+						);
162
+						$ticket_line_item = is_array($ticket_line_item)
163
+							? reset($ticket_line_item)
164
+							: $ticket_line_item;
165
+						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
166
+							$Line_Item_Display->display_line_item($ticket_line_item);
167
+					}
168
+					if ($registration->is_primary_registrant()) {
169
+						$primary_registrant = $registration->reg_url_link();
170
+					}
171
+				}
172
+			}
173
+			// print_copy_info ?
174
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
175
+				// TODO: add admin option for toggling copy attendee info,
176
+				// then use that value to change $this->_print_copy_info
177
+				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
178
+					? $this->_copy_attendee_info_form()
179
+					: $this->_auto_copy_attendee_info();
180
+				// generate hidden input
181
+				if (isset($subsections[ $primary_registrant ])
182
+					&& $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
183
+				) {
184
+					$subsections[ $primary_registrant ]->add_subsections(
185
+						$copy_options,
186
+						'primary_registrant',
187
+						false
188
+					);
189
+				}
190
+			}
191
+		}
192
+		return new EE_Form_Section_Proper(
193
+			array(
194
+				'name'            => $this->reg_form_name(),
195
+				'html_id'         => $this->reg_form_name(),
196
+				'subsections'     => $subsections,
197
+				'layout_strategy' => $this->checkout->admin_request
198
+					?
199
+					new EE_Div_Per_Section_Layout()
200
+					:
201
+					new EE_Template_Layout(
202
+						array(
203
+							'layout_template_file' => $this->_template, // layout_template
204
+							'template_args'        => $template_args,
205
+						)
206
+					),
207
+			)
208
+		);
209
+	}
210
+
211
+
212
+	/**
213
+	 * @param EE_Registration $registration
214
+	 * @return EE_Form_Section_Base
215
+	 * @throws EE_Error
216
+	 * @throws InvalidArgumentException
217
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
218
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
219
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
220
+	 */
221
+	private function _registrations_reg_form(EE_Registration $registration)
222
+	{
223
+		static $attendee_nmbr = 1;
224
+		$form_args = array();
225
+		// verify that registration has valid event
226
+		if ($registration->event() instanceof EE_Event) {
227
+			$question_groups = $registration->event()->question_groups(
228
+				apply_filters(
229
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
230
+					array(
231
+						array(
232
+							'Event.EVT_ID'                     => $registration->event()->ID(),
233
+							'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
234
+						),
235
+						'order_by' => array('QSG_order' => 'ASC'),
236
+					),
237
+					$registration,
238
+					$this
239
+				)
240
+			);
241
+			if ($question_groups) {
242
+				// array of params to pass to parent constructor
243
+				$form_args = array(
244
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
245
+					'html_class'      => 'ee-reg-form-attendee-dv',
246
+					'html_style'      => $this->checkout->admin_request
247
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
248
+						: '',
249
+					'subsections'     => array(),
250
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
251
+						array(
252
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
253
+							'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
254
+						)
255
+					),
256
+				);
257
+				foreach ($question_groups as $question_group) {
258
+					if ($question_group instanceof EE_Question_Group) {
259
+						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
260
+							$registration,
261
+							$question_group
262
+						);
263
+					}
264
+				}
265
+				// add hidden input
266
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
267
+					$registration
268
+				);
269
+				// if we have question groups for additional attendees, then display the copy options
270
+				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
271
+				if ($registration->is_primary_registrant()) {
272
+					// generate hidden input
273
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
274
+						$registration
275
+					);
276
+				}
277
+			}
278
+		}
279
+		$attendee_nmbr++;
280
+		return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : null;
281
+	}
282
+
283
+
284
+	/**
285
+	 * _additional_attendee_reg_info_input
286
+	 *
287
+	 * @access public
288
+	 * @param EE_Registration $registration
289
+	 * @param bool            $additional_attendee_reg_info
290
+	 * @return    EE_Form_Input_Base
291
+	 * @throws \EE_Error
292
+	 */
293
+	private function _additional_attendee_reg_info_input(
294
+		EE_Registration $registration,
295
+		$additional_attendee_reg_info = true
296
+	) {
297
+		// generate hidden input
298
+		return new EE_Hidden_Input(
299
+			array(
300
+				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
301
+				'default' => $additional_attendee_reg_info,
302
+			)
303
+		);
304
+	}
305
+
306
+
307
+	/**
308
+	 * @param EE_Registration   $registration
309
+	 * @param EE_Question_Group $question_group
310
+	 * @return EE_Form_Section_Proper
311
+	 * @throws EE_Error
312
+	 * @throws InvalidArgumentException
313
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
314
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
315
+	 */
316
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
317
+	{
318
+		// array of params to pass to parent constructor
319
+		$form_args = array(
320
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
321
+			'html_class'      => $this->checkout->admin_request
322
+				? 'form-table ee-reg-form-qstn-grp-dv'
323
+				: 'ee-reg-form-qstn-grp-dv',
324
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
325
+								 . $registration->ID() . '-lbl',
326
+			'subsections'     => array(
327
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
328
+			),
329
+			'layout_strategy' => $this->checkout->admin_request
330
+				? new EE_Admin_Two_Column_Layout()
331
+				: new EE_Div_Per_Section_Layout(),
332
+		);
333
+		// where params
334
+		$query_params = array('QST_deleted' => 0);
335
+		// don't load admin only questions on the frontend
336
+		if (! $this->checkout->admin_request) {
337
+			$query_params['QST_admin_only'] = array('!=', true);
338
+		}
339
+		$questions = $question_group->get_many_related(
340
+			'Question',
341
+			apply_filters(
342
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
343
+				array(
344
+					$query_params,
345
+					'order_by' => array(
346
+						'Question_Group_Question.QGQ_order' => 'ASC',
347
+					),
348
+				),
349
+				$question_group,
350
+				$registration,
351
+				$this
352
+			)
353
+		);
354
+		// filter for additional content before questions
355
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
356
+			apply_filters(
357
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
358
+				'',
359
+				$registration,
360
+				$question_group,
361
+				$this
362
+			)
363
+		);
364
+		// loop thru questions
365
+		foreach ($questions as $question) {
366
+			if ($question instanceof EE_Question) {
367
+				$identifier = $question->is_system_question()
368
+					? $question->system_ID()
369
+					: $question->ID();
370
+				$form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
371
+			}
372
+		}
373
+		$form_args['subsections'] = apply_filters(
374
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
375
+			$form_args['subsections'],
376
+			$registration,
377
+			$question_group,
378
+			$this
379
+		);
380
+		// filter for additional content after questions
381
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
382
+			apply_filters(
383
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
384
+				'',
385
+				$registration,
386
+				$question_group,
387
+				$this
388
+			)
389
+		);
390
+		// d($form_args);
391
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
392
+		return apply_filters(
393
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
394
+			$question_group_reg_form,
395
+			$registration,
396
+			$question_group,
397
+			$this
398
+		);
399
+	}
400
+
401
+
402
+	/**
403
+	 * @access public
404
+	 * @param EE_Question_Group $question_group
405
+	 * @return    EE_Form_Section_HTML
406
+	 */
407
+	private function _question_group_header(EE_Question_Group $question_group)
408
+	{
409
+		$html = '';
410
+		// group_name
411
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
412
+			if ($this->checkout->admin_request) {
413
+				$html .= EEH_HTML::br();
414
+				$html .= EEH_HTML::h3(
415
+					$question_group->name(),
416
+					'',
417
+					'ee-reg-form-qstn-grp-title title',
418
+					'font-size: 1.3em; padding-left:0;'
419
+				);
420
+			} else {
421
+				$html .= EEH_HTML::h4(
422
+					$question_group->name(),
423
+					'',
424
+					'ee-reg-form-qstn-grp-title section-title'
425
+				);
426
+			}
427
+		}
428
+		// group_desc
429
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
430
+			$html .= EEH_HTML::p(
431
+				$question_group->desc(),
432
+				'',
433
+				$this->checkout->admin_request
434
+					? 'ee-reg-form-qstn-grp-desc-pg'
435
+					: 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
436
+			);
437
+		}
438
+		return new EE_Form_Section_HTML($html);
439
+	}
440
+
441
+
442
+	/**
443
+	 * @access public
444
+	 * @return    EE_Form_Section_Proper
445
+	 * @throws \EE_Error
446
+	 */
447
+	private function _copy_attendee_info_form()
448
+	{
449
+		// array of params to pass to parent constructor
450
+		return new EE_Form_Section_Proper(
451
+			array(
452
+				'subsections'     => $this->_copy_attendee_info_inputs(),
453
+				'layout_strategy' => new EE_Template_Layout(
454
+					array(
455
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
456
+													  . $this->_slug
457
+													  . DS
458
+													  . 'copy_attendee_info.template.php',
459
+						'begin_template_file'      => null,
460
+						'input_template_file'      => null,
461
+						'subsection_template_file' => null,
462
+						'end_template_file'        => null,
463
+					)
464
+				),
465
+			)
466
+		);
467
+	}
468
+
469
+
470
+	/**
471
+	 * _auto_copy_attendee_info
472
+	 *
473
+	 * @access public
474
+	 * @return EE_Form_Section_HTML
475
+	 */
476
+	private function _auto_copy_attendee_info()
477
+	{
478
+		return new EE_Form_Section_HTML(
479
+			EEH_Template::locate_template(
480
+				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
481
+				apply_filters(
482
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
483
+					array()
484
+				),
485
+				true,
486
+				true
487
+			)
488
+		);
489
+	}
490
+
491
+
492
+	/**
493
+	 * _copy_attendee_info_inputs
494
+	 *
495
+	 * @access public
496
+	 * @return array
497
+	 * @throws \EE_Error
498
+	 */
499
+	private function _copy_attendee_info_inputs()
500
+	{
501
+		$copy_attendee_info_inputs = array();
502
+		$prev_ticket = null;
503
+		// grab the saved registrations from the transaction
504
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
505
+		foreach ($registrations as $registration) {
506
+			// for all  attendees other than the primary attendee
507
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
508
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
509
+				if ($registration->ticket()->ID() !== $prev_ticket) {
510
+					$item_name = $registration->ticket()->name();
511
+					$item_name .= $registration->ticket()->description() !== ''
512
+						? ' - ' . $registration->ticket()->description()
513
+						: '';
514
+					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
515
+					) . ']' ] =
516
+						new EE_Form_Section_HTML(
517
+							'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
518
+						);
519
+					$prev_ticket = $registration->ticket()->ID();
520
+				}
521
+
522
+				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
523
+					new EE_Checkbox_Multi_Input(
524
+						array(
525
+							$registration->ID() => sprintf(
526
+								esc_html__('Attendee #%s', 'event_espresso'),
527
+								$registration->count()
528
+							),
529
+						),
530
+						array(
531
+							'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
532
+							'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
533
+							'display_html_label_text' => false,
534
+						)
535
+					);
536
+			}
537
+		}
538
+		return $copy_attendee_info_inputs;
539
+	}
540
+
541
+
542
+	/**
543
+	 * _additional_primary_registrant_inputs
544
+	 *
545
+	 * @access public
546
+	 * @param EE_Registration $registration
547
+	 * @return    EE_Form_Input_Base
548
+	 * @throws \EE_Error
549
+	 */
550
+	private function _additional_primary_registrant_inputs(EE_Registration $registration)
551
+	{
552
+		// generate hidden input
553
+		return new EE_Hidden_Input(
554
+			array(
555
+				'html_id' => 'primary_registrant',
556
+				'default' => $registration->reg_url_link(),
557
+			)
558
+		);
559
+	}
560
+
561
+
562
+	/**
563
+	 * @access public
564
+	 * @param EE_Registration $registration
565
+	 * @param EE_Question     $question
566
+	 * @return EE_Form_Input_Base
567
+	 * @throws EE_Error
568
+	 * @throws InvalidArgumentException
569
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
570
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
571
+	 */
572
+	public function reg_form_question(EE_Registration $registration, EE_Question $question)
573
+	{
574
+
575
+		// if this question was for an attendee detail, then check for that answer
576
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
577
+			$registration,
578
+			$question->system_ID()
579
+		);
580
+		$answer = $answer_value === null
581
+			? EEM_Answer::instance()->get_one(
582
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
583
+			)
584
+			: null;
585
+		// if NOT returning to edit an existing registration
586
+		// OR if this question is for an attendee property
587
+		// OR we still don't have an EE_Answer object
588
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
589
+			// create an EE_Answer object for storing everything in
590
+			$answer = EE_Answer::new_instance(
591
+				array(
592
+					'QST_ID' => $question->ID(),
593
+					'REG_ID' => $registration->ID(),
594
+				)
595
+			);
596
+		}
597
+		// verify instance
598
+		if ($answer instanceof EE_Answer) {
599
+			if (! empty($answer_value)) {
600
+				$answer->set('ANS_value', $answer_value);
601
+			}
602
+			$answer->cache('Question', $question);
603
+			// remember system ID had a bug where sometimes it could be null
604
+			$answer_cache_id = $question->is_system_question()
605
+				? $question->system_ID() . '-' . $registration->reg_url_link()
606
+				: $question->ID() . '-' . $registration->reg_url_link();
607
+			$registration->cache('Answer', $answer, $answer_cache_id);
608
+		}
609
+		return $this->_generate_question_input($registration, $question, $answer);
610
+	}
611
+
612
+
613
+	/**
614
+	 * @param EE_Registration $registration
615
+	 * @param EE_Question     $question
616
+	 * @param                 mixed EE_Answer|NULL      $answer
617
+	 * @return EE_Form_Input_Base
618
+	 * @throws \EE_Error
619
+	 */
620
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
621
+	{
622
+		$identifier = $question->is_system_question()
623
+			? $question->system_ID()
624
+			: $question->ID();
625
+		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
626
+		add_filter(
627
+			'FHEE__EE_Question__generate_form_input__country_options',
628
+			array($this, 'use_cached_countries_for_form_input'),
629
+			10,
630
+			4
631
+		);
632
+		add_filter(
633
+			'FHEE__EE_Question__generate_form_input__state_options',
634
+			array($this, 'use_cached_states_for_form_input'),
635
+			10,
636
+			4
637
+		);
638
+		$input_constructor_args = array(
639
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
640
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
641
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
642
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
643
+			'html_label_class' => 'ee-reg-qstn',
644
+		);
645
+		$input_constructor_args['html_label_id'] .= '-lbl';
646
+		if ($answer instanceof EE_Answer && $answer->ID()) {
647
+			$input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
648
+			$input_constructor_args['html_id'] .= '-' . $answer->ID();
649
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
650
+		}
651
+		$form_input = $question->generate_form_input(
652
+			$registration,
653
+			$answer,
654
+			$input_constructor_args
655
+		);
656
+		remove_filter(
657
+			'FHEE__EE_Question__generate_form_input__country_options',
658
+			array($this, 'use_cached_countries_for_form_input')
659
+		);
660
+		remove_filter(
661
+			'FHEE__EE_Question__generate_form_input__state_options',
662
+			array($this, 'use_cached_states_for_form_input')
663
+		);
664
+		return $form_input;
665
+	}
666
+
667
+
668
+	/**
669
+	 * Gets the list of countries for the form input
670
+	 *
671
+	 * @param array|null       $countries_list
672
+	 * @param \EE_Question     $question
673
+	 * @param \EE_Registration $registration
674
+	 * @param \EE_Answer       $answer
675
+	 * @return array 2d keys are country IDs, values are their names
676
+	 * @throws EE_Error
677
+	 * @throws InvalidArgumentException
678
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
679
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
680
+	 */
681
+	public function use_cached_countries_for_form_input(
682
+		$countries_list,
683
+		\EE_Question $question = null,
684
+		\EE_Registration $registration = null,
685
+		\EE_Answer $answer = null
686
+	) {
687
+		$country_options = array('' => '');
688
+		// get possibly cached list of countries
689
+		$countries = $this->checkout->action === 'process_reg_step'
690
+			? EEM_Country::instance()->get_all_countries()
691
+			: EEM_Country::instance()->get_all_active_countries();
692
+		if (! empty($countries)) {
693
+			foreach ($countries as $country) {
694
+				if ($country instanceof EE_Country) {
695
+					$country_options[ $country->ID() ] = $country->name();
696
+				}
697
+			}
698
+		}
699
+		if ($question instanceof EE_Question
700
+			&& $registration instanceof EE_Registration) {
701
+			$answer = EEM_Answer::instance()->get_one(
702
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
703
+			);
704
+		} else {
705
+			$answer = EE_Answer::new_instance();
706
+		}
707
+		$country_options = apply_filters(
708
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
709
+			$country_options,
710
+			$this,
711
+			$registration,
712
+			$question,
713
+			$answer
714
+		);
715
+		return $country_options;
716
+	}
717
+
718
+
719
+	/**
720
+	 * Gets the list of states for the form input
721
+	 *
722
+	 * @param array|null       $states_list
723
+	 * @param \EE_Question     $question
724
+	 * @param \EE_Registration $registration
725
+	 * @param \EE_Answer       $answer
726
+	 * @return array 2d keys are state IDs, values are their names
727
+	 * @throws EE_Error
728
+	 * @throws InvalidArgumentException
729
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
730
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
731
+	 */
732
+	public function use_cached_states_for_form_input(
733
+		$states_list,
734
+		\EE_Question $question = null,
735
+		\EE_Registration $registration = null,
736
+		\EE_Answer $answer = null
737
+	) {
738
+		$state_options = array('' => array('' => ''));
739
+		$states = $this->checkout->action === 'process_reg_step'
740
+			? EEM_State::instance()->get_all_states()
741
+			: EEM_State::instance()->get_all_active_states();
742
+		if (! empty($states)) {
743
+			foreach ($states as $state) {
744
+				if ($state instanceof EE_State) {
745
+					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
746
+				}
747
+			}
748
+		}
749
+		$state_options = apply_filters(
750
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
751
+			$state_options,
752
+			$this,
753
+			$registration,
754
+			$question,
755
+			$answer
756
+		);
757
+		return $state_options;
758
+	}
759
+
760
+
761
+
762
+
763
+
764
+
765
+	/********************************************************************************************************/
766
+	/****************************************  PROCESS REG STEP  ****************************************/
767
+	/********************************************************************************************************/
768
+	/**
769
+	 * @return bool
770
+	 * @throws EE_Error
771
+	 * @throws InvalidArgumentException
772
+	 * @throws ReflectionException
773
+	 * @throws RuntimeException
774
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
775
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
776
+	 */
777
+	public function process_reg_step()
778
+	{
779
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780
+		// grab validated data from form
781
+		$valid_data = $this->checkout->current_step->valid_data();
782
+		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
783
+		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
784
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
785
+		if (empty($valid_data)) {
786
+			EE_Error::add_error(
787
+				esc_html__('No valid question responses were received.', 'event_espresso'),
788
+				__FILE__,
789
+				__FUNCTION__,
790
+				__LINE__
791
+			);
792
+			return false;
793
+		}
794
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
795
+			EE_Error::add_error(
796
+				esc_html__(
797
+					'A valid transaction could not be initiated for processing your registrations.',
798
+					'event_espresso'
799
+				),
800
+				__FILE__,
801
+				__FUNCTION__,
802
+				__LINE__
803
+			);
804
+			return false;
805
+		}
806
+		// get cached registrations
807
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
808
+		// verify we got the goods
809
+		if (empty($registrations)) {
810
+			// combine the old translated string with a new one, in order to not break translations
811
+			$error_message = esc_html__(
812
+				'Your form data could not be applied to any valid registrations.',
813
+				'event_espresso'
814
+			)
815
+							 . sprintf(
816
+								 esc_html__(
817
+									 '%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.',
818
+									 'event_espresso'
819
+								 ),
820
+								 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
821
+								 '</a>',
822
+								 '<br />'
823
+							 );
824
+			EE_Error::add_error(
825
+				$error_message,
826
+				__FILE__,
827
+				__FUNCTION__,
828
+				__LINE__
829
+			);
830
+			return false;
831
+		}
832
+		// extract attendee info from form data and save to model objects
833
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
834
+		// if first pass thru SPCO,
835
+		// then let's check processed registrations against the total number of tickets in the cart
836
+		if ($registrations_processed === false) {
837
+			// but return immediately if the previous step exited early due to errors
838
+			return false;
839
+		} elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
840
+			// generate a correctly translated string for all possible singular/plural combinations
841
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
842
+				$error_msg = sprintf(
843
+					esc_html__(
844
+						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
845
+						'event_espresso'
846
+					),
847
+					$this->checkout->total_ticket_count,
848
+					$registrations_processed
849
+				);
850
+			} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
851
+				$error_msg = sprintf(
852
+					esc_html__(
853
+						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
854
+						'event_espresso'
855
+					),
856
+					$this->checkout->total_ticket_count,
857
+					$registrations_processed
858
+				);
859
+			} else {
860
+				$error_msg = sprintf(
861
+					esc_html__(
862
+						'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
863
+						'event_espresso'
864
+					),
865
+					$this->checkout->total_ticket_count,
866
+					$registrations_processed
867
+				);
868
+			}
869
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
870
+			return false;
871
+		}
872
+		// mark this reg step as completed
873
+		$this->set_completed();
874
+		$this->_set_success_message(
875
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
876
+		);
877
+		// do action in case a plugin wants to do something with the data submitted in step 1.
878
+		// passes EE_Single_Page_Checkout, and it's posted data
879
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
880
+		return true;
881
+	}
882
+
883
+
884
+	/**
885
+	 *    _process_registrations
886
+	 *
887
+	 * @param EE_Registration[] $registrations
888
+	 * @param array             $valid_data
889
+	 * @return bool|int
890
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
891
+	 * @throws EE_Error
892
+	 * @throws InvalidArgumentException
893
+	 * @throws ReflectionException
894
+	 * @throws RuntimeException
895
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
896
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
897
+	 */
898
+	private function _process_registrations($registrations = array(), $valid_data = array())
899
+	{
900
+		// load resources and set some defaults
901
+		EE_Registry::instance()->load_model('Attendee');
902
+		// holder for primary registrant attendee object
903
+		$this->checkout->primary_attendee_obj = null;
904
+		// array for tracking reg form data for the primary registrant
905
+		$primary_registrant = array(
906
+			'line_item_id' => null,
907
+		);
908
+		$copy_primary = false;
909
+		// reg form sections that do not contain inputs
910
+		$non_input_form_sections = array(
911
+			'primary_registrant',
912
+			'additional_attendee_reg_info',
913
+			'spco_copy_attendee_chk',
914
+		);
915
+		// attendee counter
916
+		$att_nmbr = 0;
917
+		// grab the saved registrations from the transaction
918
+		foreach ($registrations as $registration) {
919
+			// verify EE_Registration object
920
+			if (! $registration instanceof EE_Registration) {
921
+				EE_Error::add_error(
922
+					esc_html__(
923
+						'An invalid Registration object was discovered when attempting to process your registration information.',
924
+						'event_espresso'
925
+					),
926
+					__FILE__,
927
+					__FUNCTION__,
928
+					__LINE__
929
+				);
930
+				return false;
931
+			}
932
+			/** @var string $reg_url_link */
933
+			$reg_url_link = $registration->reg_url_link();
934
+			// reg_url_link exists ?
935
+			if (! empty($reg_url_link)) {
936
+				// should this registration be processed during this visit ?
937
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
938
+					// if NOT revisiting, then let's save the registration now,
939
+					// so that we have a REG_ID to use when generating other objects
940
+					if (! $this->checkout->revisit) {
941
+						$registration->save();
942
+					}
943
+					/**
944
+					 * This allows plugins to trigger a fail on processing of a
945
+					 * registration for any conditions they may have for it to pass.
946
+					 *
947
+					 * @var bool   if true is returned by the plugin then the
948
+					 *            registration processing is halted.
949
+					 */
950
+					if (apply_filters(
951
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
952
+						false,
953
+						$att_nmbr,
954
+						$registration,
955
+						$registrations,
956
+						$valid_data,
957
+						$this
958
+					)) {
959
+						return false;
960
+					}
961
+
962
+					// Houston, we have a registration!
963
+					$att_nmbr++;
964
+					$this->_attendee_data[ $reg_url_link ] = array();
965
+					// grab any existing related answer objects
966
+					$this->_registration_answers = $registration->answers();
967
+					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
968
+					if (isset($valid_data[ $reg_url_link ])) {
969
+						// do we need to copy basic info from primary attendee ?
970
+						$copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
971
+										&& absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0
972
+							? true
973
+							: false;
974
+						// filter form input data for this registration
975
+						$valid_data[ $reg_url_link ] = (array) apply_filters(
976
+							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
977
+							$valid_data[ $reg_url_link ]
978
+						);
979
+						if (isset($valid_data['primary_attendee'])) {
980
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
981
+								? $valid_data['primary_attendee']
982
+								: false;
983
+							unset($valid_data['primary_attendee']);
984
+						}
985
+						// now loop through our array of valid post data && process attendee reg forms
986
+						foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
987
+							if (! in_array($form_section, $non_input_form_sections)) {
988
+								foreach ($form_inputs as $form_input => $input_value) {
989
+									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
990
+									// check for critical inputs
991
+									if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
992
+										$form_input,
993
+										$input_value
994
+									)
995
+									) {
996
+										return false;
997
+									}
998
+									// store a bit of data about the primary attendee
999
+									if ($att_nmbr === 1
1000
+										&& ! empty($input_value)
1001
+										&& $reg_url_link === $primary_registrant['line_item_id']
1002
+									) {
1003
+										$primary_registrant[ $form_input ] = $input_value;
1004
+									} elseif ($copy_primary
1005
+											  && $input_value === null
1006
+											  && isset($primary_registrant[ $form_input ])
1007
+									) {
1008
+										$input_value = $primary_registrant[ $form_input ];
1009
+									}
1010
+									// now attempt to save the input data
1011
+									if (! $this->_save_registration_form_input(
1012
+										$registration,
1013
+										$form_input,
1014
+										$input_value
1015
+									)
1016
+									) {
1017
+										EE_Error::add_error(
1018
+											sprintf(
1019
+												esc_html__(
1020
+													'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1021
+													'event_espresso'
1022
+												),
1023
+												$form_input,
1024
+												$input_value
1025
+											),
1026
+											__FILE__,
1027
+											__FUNCTION__,
1028
+											__LINE__
1029
+										);
1030
+										return false;
1031
+									}
1032
+								}
1033
+							}
1034
+						}  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1035
+					}
1036
+					// EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1037
+					// this registration does not require additional attendee information ?
1038
+					if ($copy_primary
1039
+						&& $att_nmbr > 1
1040
+						&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1041
+					) {
1042
+						// just copy the primary registrant
1043
+						$attendee = $this->checkout->primary_attendee_obj;
1044
+					} else {
1045
+						// ensure critical details are set for additional attendees
1046
+						$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1047
+							? $this->_copy_critical_attendee_details_from_primary_registrant(
1048
+								$this->_attendee_data[ $reg_url_link ]
1049
+							)
1050
+							: $this->_attendee_data[ $reg_url_link ];
1051
+						// execute create attendee command (which may return an existing attendee)
1052
+						$attendee = EE_Registry::instance()->BUS->execute(
1053
+							new CreateAttendeeCommand(
1054
+								$this->_attendee_data[ $reg_url_link ],
1055
+								$registration
1056
+							)
1057
+						);
1058
+						// who's #1 ?
1059
+						if ($att_nmbr === 1) {
1060
+							$this->checkout->primary_attendee_obj = $attendee;
1061
+						}
1062
+					}
1063
+					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1064
+					// add relation to registration, set attendee ID, and cache attendee
1065
+					$this->_associate_attendee_with_registration($registration, $attendee);
1066
+					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1067
+					if (! $registration->attendee() instanceof EE_Attendee) {
1068
+						EE_Error::add_error(
1069
+							sprintf(
1070
+								esc_html__(
1071
+									'Registration %s has an invalid or missing Attendee object.',
1072
+									'event_espresso'
1073
+								),
1074
+								$reg_url_link
1075
+							),
1076
+							__FILE__,
1077
+							__FUNCTION__,
1078
+							__LINE__
1079
+						);
1080
+						return false;
1081
+					}
1082
+					/** @type EE_Registration_Processor $registration_processor */
1083
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1084
+					// at this point, we should have enough details about the registrant to consider the registration
1085
+					// NOT incomplete
1086
+					$registration_processor->toggle_incomplete_registration_status_to_default(
1087
+						$registration,
1088
+						false,
1089
+						new Context(
1090
+							'spco_reg_step_attendee_information_process_registrations',
1091
+							esc_html__(
1092
+								'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1093
+								'event_espresso'
1094
+							)
1095
+						)
1096
+					);
1097
+					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1098
+					// abandoned
1099
+					$this->checkout->transaction->toggle_failed_transaction_status();
1100
+					// if we've gotten this far, then let's save what we have
1101
+					$registration->save();
1102
+					// add relation between TXN and registration
1103
+					$this->_associate_registration_with_transaction($registration);
1104
+				}
1105
+			} else {
1106
+				EE_Error::add_error(
1107
+					esc_html__(
1108
+						'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1109
+						'event_espresso'
1110
+					),
1111
+					__FILE__,
1112
+					__FUNCTION__,
1113
+					__LINE__
1114
+				);
1115
+				// remove malformed data
1116
+				unset($valid_data[ $reg_url_link ]);
1117
+				return false;
1118
+			}
1119
+		} // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1120
+		return $att_nmbr;
1121
+	}
1122
+
1123
+
1124
+	/**
1125
+	 *    _save_registration_form_input
1126
+	 *
1127
+	 * @param EE_Registration $registration
1128
+	 * @param string          $form_input
1129
+	 * @param string          $input_value
1130
+	 * @return bool
1131
+	 * @throws EE_Error
1132
+	 * @throws InvalidArgumentException
1133
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1134
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1135
+	 */
1136
+	private function _save_registration_form_input(
1137
+		EE_Registration $registration,
1138
+		$form_input = '',
1139
+		$input_value = ''
1140
+	) {
1141
+		// \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1142
+		// \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1143
+		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1144
+		// allow for plugins to hook in and do their own processing of the form input.
1145
+		// For plugins to bypass normal processing here, they just need to return a boolean value.
1146
+		if (apply_filters(
1147
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1148
+			false,
1149
+			$registration,
1150
+			$form_input,
1151
+			$input_value,
1152
+			$this
1153
+		)) {
1154
+			return true;
1155
+		}
1156
+		/*
1157 1157
          * $answer_cache_id is the key used to find the EE_Answer we want
1158 1158
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1159 1159
          */
1160
-        $answer_cache_id = $this->checkout->reg_url_link
1161
-            ? $form_input . '-' . $registration->reg_url_link()
1162
-            : $form_input;
1163
-        $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1164
-                         && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1165
-            ? true
1166
-            : false;
1167
-        // rename form_inputs if they are EE_Attendee properties
1168
-        switch ((string) $form_input) {
1169
-            case 'state':
1170
-            case 'STA_ID':
1171
-                $attendee_property = true;
1172
-                $form_input = 'STA_ID';
1173
-                break;
1174
-
1175
-            case 'country':
1176
-            case 'CNT_ISO':
1177
-                $attendee_property = true;
1178
-                $form_input = 'CNT_ISO';
1179
-                break;
1180
-
1181
-            default:
1182
-                $ATT_input = 'ATT_' . $form_input;
1183
-                // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1184
-                $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1185
-                $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1186
-        }
1187
-        // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1188
-        // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1189
-        // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1190
-        // if this form input has a corresponding attendee property
1191
-        if ($attendee_property) {
1192
-            $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1193
-            if ($answer_is_obj) {
1194
-                // and delete the corresponding answer since we won't be storing this data in that object
1195
-                $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1196
-                $this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1197
-            }
1198
-            return true;
1199
-        } elseif ($answer_is_obj) {
1200
-            // save this data to the answer object
1201
-            $this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1202
-            $result = $this->_registration_answers[ $answer_cache_id ]->save();
1203
-            return $result !== false ? true : false;
1204
-        } else {
1205
-            foreach ($this->_registration_answers as $answer) {
1206
-                if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1207
-                    $answer->set_value($input_value);
1208
-                    $result = $answer->save();
1209
-                    return $result !== false ? true : false;
1210
-                }
1211
-            }
1212
-        }
1213
-        return false;
1214
-    }
1215
-
1216
-
1217
-    /**
1218
-     *    _verify_critical_attendee_details_are_set
1219
-     *
1220
-     * @param string $form_input
1221
-     * @param string $input_value
1222
-     * @return boolean
1223
-     */
1224
-    private function _verify_critical_attendee_details_are_set_and_validate_email(
1225
-        $form_input = '',
1226
-        $input_value = ''
1227
-    ) {
1228
-        if (empty($input_value)) {
1229
-            // if the form input isn't marked as being required, then just return
1230
-            if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1231
-                return true;
1232
-            }
1233
-            switch ($form_input) {
1234
-                case 'fname':
1235
-                    EE_Error::add_error(
1236
-                        esc_html__('First Name is a required value.', 'event_espresso'),
1237
-                        __FILE__,
1238
-                        __FUNCTION__,
1239
-                        __LINE__
1240
-                    );
1241
-                    return false;
1242
-                    break;
1243
-                case 'lname':
1244
-                    EE_Error::add_error(
1245
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
1246
-                        __FILE__,
1247
-                        __FUNCTION__,
1248
-                        __LINE__
1249
-                    );
1250
-                    return false;
1251
-                    break;
1252
-                case 'email':
1253
-                    EE_Error::add_error(
1254
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
1255
-                        __FILE__,
1256
-                        __FUNCTION__,
1257
-                        __LINE__
1258
-                    );
1259
-                    return false;
1260
-                    break;
1261
-            }
1262
-        }
1263
-        return true;
1264
-    }
1265
-
1266
-
1267
-    /**
1268
-     *    _associate_attendee_with_registration
1269
-     *
1270
-     * @param EE_Registration $registration
1271
-     * @param EE_Attendee     $attendee
1272
-     * @return void
1273
-     * @throws EE_Error
1274
-     * @throws RuntimeException
1275
-     */
1276
-    private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1277
-    {
1278
-        // add relation to attendee
1279
-        $registration->_add_relation_to($attendee, 'Attendee');
1280
-        $registration->set_attendee_id($attendee->ID());
1281
-        $registration->update_cache_after_object_save('Attendee', $attendee);
1282
-    }
1283
-
1284
-
1285
-    /**
1286
-     *    _associate_registration_with_transaction
1287
-     *
1288
-     * @param EE_Registration $registration
1289
-     * @return void
1290
-     * @throws \EE_Error
1291
-     */
1292
-    private function _associate_registration_with_transaction(EE_Registration $registration)
1293
-    {
1294
-        // add relation to registration
1295
-        $this->checkout->transaction->_add_relation_to($registration, 'Registration');
1296
-        $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     *    _copy_critical_attendee_details_from_primary_registrant
1302
-     *    ensures that all attendees at least have data for first name, last name, and email address
1303
-     *
1304
-     * @param array $attendee_data
1305
-     * @return array
1306
-     * @throws \EE_Error
1307
-     */
1308
-    private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1309
-    {
1310
-        // bare minimum critical details include first name, last name, email address
1311
-        $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1312
-        // add address info to critical details?
1313
-        if (apply_filters(
1314
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1315
-            false
1316
-        )) {
1317
-            $address_details = array(
1318
-                'ATT_address',
1319
-                'ATT_address2',
1320
-                'ATT_city',
1321
-                'STA_ID',
1322
-                'CNT_ISO',
1323
-                'ATT_zip',
1324
-                'ATT_phone',
1325
-            );
1326
-            $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1327
-        }
1328
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
1329
-            if (! isset($attendee_data[ $critical_attendee_detail ])
1330
-                || empty($attendee_data[ $critical_attendee_detail ])
1331
-            ) {
1332
-                $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1333
-                    $critical_attendee_detail
1334
-                );
1335
-            }
1336
-        }
1337
-        return $attendee_data;
1338
-    }
1339
-
1340
-
1341
-    /**
1342
-     *    update_reg_step
1343
-     *    this is the final step after a user  revisits the site to edit their attendee information
1344
-     *    this gets called AFTER the process_reg_step() method above
1345
-     *
1346
-     * @return bool
1347
-     * @throws EE_Error
1348
-     * @throws InvalidArgumentException
1349
-     * @throws ReflectionException
1350
-     * @throws RuntimeException
1351
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1352
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1353
-     */
1354
-    public function update_reg_step()
1355
-    {
1356
-        // save everything
1357
-        if ($this->process_reg_step()) {
1358
-            $this->checkout->redirect = true;
1359
-            $this->checkout->redirect_url = add_query_arg(
1360
-                array(
1361
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
1362
-                    'revisit'        => true,
1363
-                ),
1364
-                $this->checkout->thank_you_page_url
1365
-            );
1366
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1367
-            return true;
1368
-        }
1369
-        return false;
1370
-    }
1160
+		$answer_cache_id = $this->checkout->reg_url_link
1161
+			? $form_input . '-' . $registration->reg_url_link()
1162
+			: $form_input;
1163
+		$answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1164
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1165
+			? true
1166
+			: false;
1167
+		// rename form_inputs if they are EE_Attendee properties
1168
+		switch ((string) $form_input) {
1169
+			case 'state':
1170
+			case 'STA_ID':
1171
+				$attendee_property = true;
1172
+				$form_input = 'STA_ID';
1173
+				break;
1174
+
1175
+			case 'country':
1176
+			case 'CNT_ISO':
1177
+				$attendee_property = true;
1178
+				$form_input = 'CNT_ISO';
1179
+				break;
1180
+
1181
+			default:
1182
+				$ATT_input = 'ATT_' . $form_input;
1183
+				// EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1184
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1185
+				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1186
+		}
1187
+		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1188
+		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1189
+		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1190
+		// if this form input has a corresponding attendee property
1191
+		if ($attendee_property) {
1192
+			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1193
+			if ($answer_is_obj) {
1194
+				// and delete the corresponding answer since we won't be storing this data in that object
1195
+				$registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1196
+				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1197
+			}
1198
+			return true;
1199
+		} elseif ($answer_is_obj) {
1200
+			// save this data to the answer object
1201
+			$this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1202
+			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1203
+			return $result !== false ? true : false;
1204
+		} else {
1205
+			foreach ($this->_registration_answers as $answer) {
1206
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1207
+					$answer->set_value($input_value);
1208
+					$result = $answer->save();
1209
+					return $result !== false ? true : false;
1210
+				}
1211
+			}
1212
+		}
1213
+		return false;
1214
+	}
1215
+
1216
+
1217
+	/**
1218
+	 *    _verify_critical_attendee_details_are_set
1219
+	 *
1220
+	 * @param string $form_input
1221
+	 * @param string $input_value
1222
+	 * @return boolean
1223
+	 */
1224
+	private function _verify_critical_attendee_details_are_set_and_validate_email(
1225
+		$form_input = '',
1226
+		$input_value = ''
1227
+	) {
1228
+		if (empty($input_value)) {
1229
+			// if the form input isn't marked as being required, then just return
1230
+			if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1231
+				return true;
1232
+			}
1233
+			switch ($form_input) {
1234
+				case 'fname':
1235
+					EE_Error::add_error(
1236
+						esc_html__('First Name is a required value.', 'event_espresso'),
1237
+						__FILE__,
1238
+						__FUNCTION__,
1239
+						__LINE__
1240
+					);
1241
+					return false;
1242
+					break;
1243
+				case 'lname':
1244
+					EE_Error::add_error(
1245
+						esc_html__('Last Name is a required value.', 'event_espresso'),
1246
+						__FILE__,
1247
+						__FUNCTION__,
1248
+						__LINE__
1249
+					);
1250
+					return false;
1251
+					break;
1252
+				case 'email':
1253
+					EE_Error::add_error(
1254
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
1255
+						__FILE__,
1256
+						__FUNCTION__,
1257
+						__LINE__
1258
+					);
1259
+					return false;
1260
+					break;
1261
+			}
1262
+		}
1263
+		return true;
1264
+	}
1265
+
1266
+
1267
+	/**
1268
+	 *    _associate_attendee_with_registration
1269
+	 *
1270
+	 * @param EE_Registration $registration
1271
+	 * @param EE_Attendee     $attendee
1272
+	 * @return void
1273
+	 * @throws EE_Error
1274
+	 * @throws RuntimeException
1275
+	 */
1276
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1277
+	{
1278
+		// add relation to attendee
1279
+		$registration->_add_relation_to($attendee, 'Attendee');
1280
+		$registration->set_attendee_id($attendee->ID());
1281
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1282
+	}
1283
+
1284
+
1285
+	/**
1286
+	 *    _associate_registration_with_transaction
1287
+	 *
1288
+	 * @param EE_Registration $registration
1289
+	 * @return void
1290
+	 * @throws \EE_Error
1291
+	 */
1292
+	private function _associate_registration_with_transaction(EE_Registration $registration)
1293
+	{
1294
+		// add relation to registration
1295
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1296
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 *    _copy_critical_attendee_details_from_primary_registrant
1302
+	 *    ensures that all attendees at least have data for first name, last name, and email address
1303
+	 *
1304
+	 * @param array $attendee_data
1305
+	 * @return array
1306
+	 * @throws \EE_Error
1307
+	 */
1308
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1309
+	{
1310
+		// bare minimum critical details include first name, last name, email address
1311
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1312
+		// add address info to critical details?
1313
+		if (apply_filters(
1314
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1315
+			false
1316
+		)) {
1317
+			$address_details = array(
1318
+				'ATT_address',
1319
+				'ATT_address2',
1320
+				'ATT_city',
1321
+				'STA_ID',
1322
+				'CNT_ISO',
1323
+				'ATT_zip',
1324
+				'ATT_phone',
1325
+			);
1326
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1327
+		}
1328
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1329
+			if (! isset($attendee_data[ $critical_attendee_detail ])
1330
+				|| empty($attendee_data[ $critical_attendee_detail ])
1331
+			) {
1332
+				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1333
+					$critical_attendee_detail
1334
+				);
1335
+			}
1336
+		}
1337
+		return $attendee_data;
1338
+	}
1339
+
1340
+
1341
+	/**
1342
+	 *    update_reg_step
1343
+	 *    this is the final step after a user  revisits the site to edit their attendee information
1344
+	 *    this gets called AFTER the process_reg_step() method above
1345
+	 *
1346
+	 * @return bool
1347
+	 * @throws EE_Error
1348
+	 * @throws InvalidArgumentException
1349
+	 * @throws ReflectionException
1350
+	 * @throws RuntimeException
1351
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1352
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1353
+	 */
1354
+	public function update_reg_step()
1355
+	{
1356
+		// save everything
1357
+		if ($this->process_reg_step()) {
1358
+			$this->checkout->redirect = true;
1359
+			$this->checkout->redirect_url = add_query_arg(
1360
+				array(
1361
+					'e_reg_url_link' => $this->checkout->reg_url_link,
1362
+					'revisit'        => true,
1363
+				),
1364
+				$this->checkout->thank_you_page_url
1365
+			);
1366
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1367
+			return true;
1368
+		}
1369
+		return false;
1370
+	}
1371 1371
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $this->_slug = 'attendee_information';
48 48
         $this->_name = esc_html__('Attendee Information', 'event_espresso');
49
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
49
+        $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
50 50
         $this->checkout = $checkout;
51 51
         $this->_reset_success_message();
52 52
         $this->set_instructions(
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
                     && $this->checkout->visit_allows_processing_of_this_registration($registration)
144 144
                 ) {
145 145
                     $subsection = $this->_registrations_reg_form($registration);
146
-                    if (! $subsection instanceof EE_Form_Section_Proper) {
146
+                    if ( ! $subsection instanceof EE_Form_Section_Proper) {
147 147
                         continue;
148 148
                     }
149
-                    $subsections[ $registration->reg_url_link() ] = $subsection;
150
-                    if (! $this->checkout->admin_request) {
151
-                        $template_args['registrations'][ $registration->reg_url_link() ] = $registration;
152
-                        $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
153
-                            $template_args['ticket_count'][ $registration->ticket()->ID() ]
149
+                    $subsections[$registration->reg_url_link()] = $subsection;
150
+                    if ( ! $this->checkout->admin_request) {
151
+                        $template_args['registrations'][$registration->reg_url_link()] = $registration;
152
+                        $template_args['ticket_count'][$registration->ticket()->ID()] = isset(
153
+                            $template_args['ticket_count'][$registration->ticket()->ID()]
154 154
                         )
155
-                            ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
155
+                            ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
156 156
                             : 1;
157 157
                         $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
158 158
                             $this->checkout->cart->get_grand_total(),
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                         $ticket_line_item = is_array($ticket_line_item)
163 163
                             ? reset($ticket_line_item)
164 164
                             : $ticket_line_item;
165
-                        $template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
165
+                        $template_args['ticket_line_item'][$registration->ticket()->ID()] =
166 166
                             $Line_Item_Display->display_line_item($ticket_line_item);
167 167
                     }
168 168
                     if ($registration->is_primary_registrant()) {
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
                     ? $this->_copy_attendee_info_form()
179 179
                     : $this->_auto_copy_attendee_info();
180 180
                 // generate hidden input
181
-                if (isset($subsections[ $primary_registrant ])
182
-                    && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
181
+                if (isset($subsections[$primary_registrant])
182
+                    && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
183 183
                 ) {
184
-                    $subsections[ $primary_registrant ]->add_subsections(
184
+                    $subsections[$primary_registrant]->add_subsections(
185 185
                         $copy_options,
186 186
                         'primary_registrant',
187 187
                         false
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             if ($question_groups) {
242 242
                 // array of params to pass to parent constructor
243 243
                 $form_args = array(
244
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
244
+                    'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
245 245
                     'html_class'      => 'ee-reg-form-attendee-dv',
246 246
                     'html_style'      => $this->checkout->admin_request
247 247
                         ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 );
257 257
                 foreach ($question_groups as $question_group) {
258 258
                     if ($question_group instanceof EE_Question_Group) {
259
-                        $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
259
+                        $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
260 260
                             $registration,
261 261
                             $question_group
262 262
                         );
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         // generate hidden input
298 298
         return new EE_Hidden_Input(
299 299
             array(
300
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
300
+                'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
301 301
                 'default' => $additional_attendee_reg_info,
302 302
             )
303 303
         );
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
     {
318 318
         // array of params to pass to parent constructor
319 319
         $form_args = array(
320
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
320
+            'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'.$registration->ID(),
321 321
             'html_class'      => $this->checkout->admin_request
322 322
                 ? 'form-table ee-reg-form-qstn-grp-dv'
323 323
                 : 'ee-reg-form-qstn-grp-dv',
324
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
325
-                                 . $registration->ID() . '-lbl',
324
+            'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'
325
+                                 . $registration->ID().'-lbl',
326 326
             'subsections'     => array(
327 327
                 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
328 328
             ),
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         // where params
334 334
         $query_params = array('QST_deleted' => 0);
335 335
         // don't load admin only questions on the frontend
336
-        if (! $this->checkout->admin_request) {
336
+        if ( ! $this->checkout->admin_request) {
337 337
             $query_params['QST_admin_only'] = array('!=', true);
338 338
         }
339 339
         $questions = $question_group->get_many_related(
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
                 $identifier = $question->is_system_question()
368 368
                     ? $question->system_ID()
369 369
                     : $question->ID();
370
-                $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
370
+                $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
371 371
             }
372 372
         }
373 373
         $form_args['subsections'] = apply_filters(
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     {
478 478
         return new EE_Form_Section_HTML(
479 479
             EEH_Template::locate_template(
480
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
480
+                SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
481 481
                 apply_filters(
482 482
                     'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
483 483
                     array()
@@ -509,17 +509,17 @@  discard block
 block discarded – undo
509 509
                 if ($registration->ticket()->ID() !== $prev_ticket) {
510 510
                     $item_name = $registration->ticket()->name();
511 511
                     $item_name .= $registration->ticket()->description() !== ''
512
-                        ? ' - ' . $registration->ticket()->description()
512
+                        ? ' - '.$registration->ticket()->description()
513 513
                         : '';
514
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
515
-                    ) . ']' ] =
514
+                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID(
515
+                    ).']'] =
516 516
                         new EE_Form_Section_HTML(
517
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
517
+                            '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
518 518
                         );
519 519
                     $prev_ticket = $registration->ticket()->ID();
520 520
                 }
521 521
 
522
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
522
+                $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] =
523 523
                     new EE_Checkbox_Multi_Input(
524 524
                         array(
525 525
                             $registration->ID() => sprintf(
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                             ),
529 529
                         ),
530 530
                         array(
531
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
531
+                            'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
532 532
                             'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
533 533
                             'display_html_label_text' => false,
534 534
                         )
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
         }
597 597
         // verify instance
598 598
         if ($answer instanceof EE_Answer) {
599
-            if (! empty($answer_value)) {
599
+            if ( ! empty($answer_value)) {
600 600
                 $answer->set('ANS_value', $answer_value);
601 601
             }
602 602
             $answer->cache('Question', $question);
603 603
             // remember system ID had a bug where sometimes it could be null
604 604
             $answer_cache_id = $question->is_system_question()
605
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
606
-                : $question->ID() . '-' . $registration->reg_url_link();
605
+                ? $question->system_ID().'-'.$registration->reg_url_link()
606
+                : $question->ID().'-'.$registration->reg_url_link();
607 607
             $registration->cache('Answer', $answer, $answer_cache_id);
608 608
         }
609 609
         return $this->_generate_question_input($registration, $question, $answer);
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
         $identifier = $question->is_system_question()
623 623
             ? $question->system_ID()
624 624
             : $question->ID();
625
-        $this->_required_questions[ $identifier ] = $question->required() ? true : false;
625
+        $this->_required_questions[$identifier] = $question->required() ? true : false;
626 626
         add_filter(
627 627
             'FHEE__EE_Question__generate_form_input__country_options',
628 628
             array($this, 'use_cached_countries_for_form_input'),
@@ -636,17 +636,17 @@  discard block
 block discarded – undo
636 636
             4
637 637
         );
638 638
         $input_constructor_args = array(
639
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
640
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
641
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
642
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
639
+            'html_name'        => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
640
+            'html_id'          => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
641
+            'html_class'       => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
642
+            'html_label_id'    => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
643 643
             'html_label_class' => 'ee-reg-qstn',
644 644
         );
645 645
         $input_constructor_args['html_label_id'] .= '-lbl';
646 646
         if ($answer instanceof EE_Answer && $answer->ID()) {
647
-            $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
648
-            $input_constructor_args['html_id'] .= '-' . $answer->ID();
649
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
647
+            $input_constructor_args['html_name'] .= '['.$answer->ID().']';
648
+            $input_constructor_args['html_id'] .= '-'.$answer->ID();
649
+            $input_constructor_args['html_label_id'] .= '-'.$answer->ID();
650 650
         }
651 651
         $form_input = $question->generate_form_input(
652 652
             $registration,
@@ -689,10 +689,10 @@  discard block
 block discarded – undo
689 689
         $countries = $this->checkout->action === 'process_reg_step'
690 690
             ? EEM_Country::instance()->get_all_countries()
691 691
             : EEM_Country::instance()->get_all_active_countries();
692
-        if (! empty($countries)) {
692
+        if ( ! empty($countries)) {
693 693
             foreach ($countries as $country) {
694 694
                 if ($country instanceof EE_Country) {
695
-                    $country_options[ $country->ID() ] = $country->name();
695
+                    $country_options[$country->ID()] = $country->name();
696 696
                 }
697 697
             }
698 698
         }
@@ -739,10 +739,10 @@  discard block
 block discarded – undo
739 739
         $states = $this->checkout->action === 'process_reg_step'
740 740
             ? EEM_State::instance()->get_all_states()
741 741
             : EEM_State::instance()->get_all_active_states();
742
-        if (! empty($states)) {
742
+        if ( ! empty($states)) {
743 743
             foreach ($states as $state) {
744 744
                 if ($state instanceof EE_State) {
745
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
745
+                    $state_options[$state->country()->name()][$state->ID()] = $state->name();
746 746
                 }
747 747
             }
748 748
         }
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
             );
792 792
             return false;
793 793
         }
794
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
794
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
795 795
             EE_Error::add_error(
796 796
                 esc_html__(
797 797
                     'A valid transaction could not be initiated for processing your registrations.',
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                                      '%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.',
818 818
                                      'event_espresso'
819 819
                                  ),
820
-                                 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
820
+                                 '<a href="'.get_post_type_archive_link('espresso_events').'" >',
821 821
                                  '</a>',
822 822
                                  '<br />'
823 823
                              );
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
         if ($registrations_processed === false) {
837 837
             // but return immediately if the previous step exited early due to errors
838 838
             return false;
839
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
839
+        } elseif ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
840 840
             // generate a correctly translated string for all possible singular/plural combinations
841 841
             if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
842 842
                 $error_msg = sprintf(
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
         // grab the saved registrations from the transaction
918 918
         foreach ($registrations as $registration) {
919 919
             // verify EE_Registration object
920
-            if (! $registration instanceof EE_Registration) {
920
+            if ( ! $registration instanceof EE_Registration) {
921 921
                 EE_Error::add_error(
922 922
                     esc_html__(
923 923
                         'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -932,12 +932,12 @@  discard block
 block discarded – undo
932 932
             /** @var string $reg_url_link */
933 933
             $reg_url_link = $registration->reg_url_link();
934 934
             // reg_url_link exists ?
935
-            if (! empty($reg_url_link)) {
935
+            if ( ! empty($reg_url_link)) {
936 936
                 // should this registration be processed during this visit ?
937 937
                 if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
938 938
                     // if NOT revisiting, then let's save the registration now,
939 939
                     // so that we have a REG_ID to use when generating other objects
940
-                    if (! $this->checkout->revisit) {
940
+                    if ( ! $this->checkout->revisit) {
941 941
                         $registration->save();
942 942
                     }
943 943
                     /**
@@ -961,20 +961,20 @@  discard block
 block discarded – undo
961 961
 
962 962
                     // Houston, we have a registration!
963 963
                     $att_nmbr++;
964
-                    $this->_attendee_data[ $reg_url_link ] = array();
964
+                    $this->_attendee_data[$reg_url_link] = array();
965 965
                     // grab any existing related answer objects
966 966
                     $this->_registration_answers = $registration->answers();
967 967
                     // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
968
-                    if (isset($valid_data[ $reg_url_link ])) {
968
+                    if (isset($valid_data[$reg_url_link])) {
969 969
                         // do we need to copy basic info from primary attendee ?
970
-                        $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
971
-                                        && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0
970
+                        $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
971
+                                        && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
972 972
                             ? true
973 973
                             : false;
974 974
                         // filter form input data for this registration
975
-                        $valid_data[ $reg_url_link ] = (array) apply_filters(
975
+                        $valid_data[$reg_url_link] = (array) apply_filters(
976 976
                             'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
977
-                            $valid_data[ $reg_url_link ]
977
+                            $valid_data[$reg_url_link]
978 978
                         );
979 979
                         if (isset($valid_data['primary_attendee'])) {
980 980
                             $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
@@ -983,12 +983,12 @@  discard block
 block discarded – undo
983 983
                             unset($valid_data['primary_attendee']);
984 984
                         }
985 985
                         // now loop through our array of valid post data && process attendee reg forms
986
-                        foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
987
-                            if (! in_array($form_section, $non_input_form_sections)) {
986
+                        foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
987
+                            if ( ! in_array($form_section, $non_input_form_sections)) {
988 988
                                 foreach ($form_inputs as $form_input => $input_value) {
989 989
                                     // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
990 990
                                     // check for critical inputs
991
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
991
+                                    if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email(
992 992
                                         $form_input,
993 993
                                         $input_value
994 994
                                     )
@@ -1000,15 +1000,15 @@  discard block
 block discarded – undo
1000 1000
                                         && ! empty($input_value)
1001 1001
                                         && $reg_url_link === $primary_registrant['line_item_id']
1002 1002
                                     ) {
1003
-                                        $primary_registrant[ $form_input ] = $input_value;
1003
+                                        $primary_registrant[$form_input] = $input_value;
1004 1004
                                     } elseif ($copy_primary
1005 1005
                                               && $input_value === null
1006
-                                              && isset($primary_registrant[ $form_input ])
1006
+                                              && isset($primary_registrant[$form_input])
1007 1007
                                     ) {
1008
-                                        $input_value = $primary_registrant[ $form_input ];
1008
+                                        $input_value = $primary_registrant[$form_input];
1009 1009
                                     }
1010 1010
                                     // now attempt to save the input data
1011
-                                    if (! $this->_save_registration_form_input(
1011
+                                    if ( ! $this->_save_registration_form_input(
1012 1012
                                         $registration,
1013 1013
                                         $form_input,
1014 1014
                                         $input_value
@@ -1043,15 +1043,15 @@  discard block
 block discarded – undo
1043 1043
                         $attendee = $this->checkout->primary_attendee_obj;
1044 1044
                     } else {
1045 1045
                         // ensure critical details are set for additional attendees
1046
-                        $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1046
+                        $this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1047 1047
                             ? $this->_copy_critical_attendee_details_from_primary_registrant(
1048
-                                $this->_attendee_data[ $reg_url_link ]
1048
+                                $this->_attendee_data[$reg_url_link]
1049 1049
                             )
1050
-                            : $this->_attendee_data[ $reg_url_link ];
1050
+                            : $this->_attendee_data[$reg_url_link];
1051 1051
                         // execute create attendee command (which may return an existing attendee)
1052 1052
                         $attendee = EE_Registry::instance()->BUS->execute(
1053 1053
                             new CreateAttendeeCommand(
1054
-                                $this->_attendee_data[ $reg_url_link ],
1054
+                                $this->_attendee_data[$reg_url_link],
1055 1055
                                 $registration
1056 1056
                             )
1057 1057
                         );
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
                     // add relation to registration, set attendee ID, and cache attendee
1065 1065
                     $this->_associate_attendee_with_registration($registration, $attendee);
1066 1066
                     // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1067
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1067
+                    if ( ! $registration->attendee() instanceof EE_Attendee) {
1068 1068
                         EE_Error::add_error(
1069 1069
                             sprintf(
1070 1070
                                 esc_html__(
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
                     __LINE__
1114 1114
                 );
1115 1115
                 // remove malformed data
1116
-                unset($valid_data[ $reg_url_link ]);
1116
+                unset($valid_data[$reg_url_link]);
1117 1117
                 return false;
1118 1118
             }
1119 1119
         } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1159 1159
          */
1160 1160
         $answer_cache_id = $this->checkout->reg_url_link
1161
-            ? $form_input . '-' . $registration->reg_url_link()
1161
+            ? $form_input.'-'.$registration->reg_url_link()
1162 1162
             : $form_input;
1163
-        $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1164
-                         && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1163
+        $answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1164
+                         && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1165 1165
             ? true
1166 1166
             : false;
1167 1167
         // rename form_inputs if they are EE_Attendee properties
@@ -1179,27 +1179,27 @@  discard block
 block discarded – undo
1179 1179
                 break;
1180 1180
 
1181 1181
             default:
1182
-                $ATT_input = 'ATT_' . $form_input;
1182
+                $ATT_input = 'ATT_'.$form_input;
1183 1183
                 // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1184 1184
                 $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1185
-                $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1185
+                $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1186 1186
         }
1187 1187
         // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1188 1188
         // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1189 1189
         // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1190 1190
         // if this form input has a corresponding attendee property
1191 1191
         if ($attendee_property) {
1192
-            $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1192
+            $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1193 1193
             if ($answer_is_obj) {
1194 1194
                 // and delete the corresponding answer since we won't be storing this data in that object
1195
-                $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1196
-                $this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1195
+                $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1196
+                $this->_registration_answers[$answer_cache_id]->delete_permanently();
1197 1197
             }
1198 1198
             return true;
1199 1199
         } elseif ($answer_is_obj) {
1200 1200
             // save this data to the answer object
1201
-            $this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1202
-            $result = $this->_registration_answers[ $answer_cache_id ]->save();
1201
+            $this->_registration_answers[$answer_cache_id]->set_value($input_value);
1202
+            $result = $this->_registration_answers[$answer_cache_id]->save();
1203 1203
             return $result !== false ? true : false;
1204 1204
         } else {
1205 1205
             foreach ($this->_registration_answers as $answer) {
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
     ) {
1228 1228
         if (empty($input_value)) {
1229 1229
             // if the form input isn't marked as being required, then just return
1230
-            if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1230
+            if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1231 1231
                 return true;
1232 1232
             }
1233 1233
             switch ($form_input) {
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
             $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1327 1327
         }
1328 1328
         foreach ($critical_attendee_details as $critical_attendee_detail) {
1329
-            if (! isset($attendee_data[ $critical_attendee_detail ])
1330
-                || empty($attendee_data[ $critical_attendee_detail ])
1329
+            if ( ! isset($attendee_data[$critical_attendee_detail])
1330
+                || empty($attendee_data[$critical_attendee_detail])
1331 1331
             ) {
1332
-                $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1332
+                $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1333 1333
                     $critical_attendee_detail
1334 1334
                 );
1335 1335
             }
Please login to merge, or discard this patch.
finalize_registration/EE_SPCO_Reg_Step_Finalize_Registration.class.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -12,236 +12,236 @@
 block discarded – undo
12 12
 class EE_SPCO_Reg_Step_Finalize_Registration extends EE_SPCO_Reg_Step
13 13
 {
14 14
 
15
-    /**
16
-     *    class constructor
17
-     *
18
-     * @access    public
19
-     * @param    EE_Checkout $checkout
20
-     */
21
-    public function __construct(EE_Checkout $checkout)
22
-    {
23
-        $this->_slug = 'finalize_registration';
24
-        $this->_name = __('Finalize Registration', 'event_espresso');
25
-        $this->_submit_button_text = $this->_name;
26
-        $this->_template = '';
27
-        $this->checkout = $checkout;
28
-    }
29
-
30
-
31
-    public function translate_js_strings()
32
-    {
33
-    }
34
-
35
-
36
-    public function enqueue_styles_and_scripts()
37
-    {
38
-    }
39
-
40
-
41
-    /**
42
-     * @return boolean
43
-     */
44
-    public function initialize_reg_step()
45
-    {
46
-        // there's actually no reg form to process if this is the final step
47
-        if ($this->is_current_step()) {
48
-            $this->checkout->step = $_REQUEST['step'] = $this->slug();
49
-            $this->checkout->action = $_REQUEST['action'] = 'process_reg_step';
50
-            $this->checkout->generate_reg_form = false;
51
-        }
52
-        return true;
53
-    }
54
-
55
-
56
-    /**
57
-     * @return string
58
-     * @throws \EE_Error
59
-     */
60
-    public function generate_reg_form()
61
-    {
62
-        // create empty form so that things don't break
63
-        $this->reg_form = new EE_Form_Section_Proper();
64
-        return '';
65
-    }
66
-
67
-
68
-    /**
69
-     * @return boolean
70
-     * @throws \RuntimeException
71
-     * @throws \EE_Error
72
-     */
73
-    public function process_reg_step()
74
-    {
75
-        // ensure all data gets refreshed from the db
76
-        $this->checkout->refresh_all_entities(true);
77
-        // ensures that all details and statuses for transaction, registration, and payments are updated
78
-        $txn_update_params = $this->_finalize_transaction();
79
-        // maybe send messages
80
-        $this->_set_notification_triggers();
81
-        // send messages
82
-        /** @type EE_Registration_Processor $registration_processor */
83
-        $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
84
-        $registration_processor->trigger_registration_update_notifications(
85
-            $this->checkout->transaction->primary_registration(),
86
-            $txn_update_params
87
-        );
88
-        // set a hook point
89
-        do_action(
90
-            'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
91
-            $this->checkout,
92
-            $txn_update_params
93
-        );
94
-        // check if transaction has a primary registrant and that it has a related Attendee object
95
-        if (! $this->_validate_primary_registrant()) {
96
-            return false;
97
-        }
98
-        // you don't have to go home but you can't stay here !
99
-        $this->checkout->redirect = true;
100
-        $this->checkout->continue_reg = true;
101
-        $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
102
-        if (! (
103
-            $this->checkout->payment_method instanceof EE_Payment_Method
104
-            && $this->checkout->payment_method->is_off_site()
105
-        )) {
106
-            // mark this reg step as completed
107
-            $this->set_completed();
108
-        }
109
-        $this->checkout->set_exit_spco();
110
-        return true;
111
-    }
112
-
113
-
114
-    /**
115
-     * _finalize_transaction
116
-     * ensures that all details and statuses for transaction, registration, and payments are updated
117
-     *
118
-     * @return array
119
-     * @throws \RuntimeException
120
-     * @throws \EE_Error
121
-     */
122
-    protected function _finalize_transaction()
123
-    {
124
-        /** @type EE_Transaction_Processor $transaction_processor */
125
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
126
-        // set revisit flag in txn processor
127
-        $transaction_processor->set_revisit($this->checkout->revisit);
128
-        // at this point we'll consider a TXN to not have been abandoned
129
-        $this->checkout->transaction->toggle_abandoned_transaction_status();
130
-        if ($this->checkout->cart instanceof EE_Cart) {
131
-            // save TXN data to the cart
132
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
133
-                $this->checkout->transaction->ID()
134
-            );
135
-        }
136
-        // maybe update status, but don't save transaction just yet
137
-        $this->checkout->transaction->update_status_based_on_total_paid(false);
138
-        // this will result in the base session properties getting saved to the TXN_Session_data field
139
-        $this->checkout->transaction->set_txn_session_data(
140
-            EE_Registry::instance()->SSN->get_session_data(null, true)
141
-        );
142
-        // update the TXN if payment conditions have changed, but do NOT trigger notifications,
143
-        // because we will do that in process_reg_step() after setting some more triggers
144
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
145
-            $this->checkout->transaction,
146
-            $this->checkout->payment,
147
-            $this->checkout->reg_cache_where_params,
148
-            false
149
-        );
150
-    }
151
-
152
-
153
-    /**
154
-     * If request is not a revisit, and an Off-Site gateway using IPNs has NOT been selected...
155
-     * OR
156
-     * if it IS a revisit and the TXN and/or one or more REG statuses have changed...
157
-     * then trigger notifications
158
-     *
159
-     * @return void
160
-     * @throws \EE_Error
161
-     */
162
-    protected function _set_notification_triggers()
163
-    {
164
-
165
-        if ($this->checkout->payment_method instanceof EE_Payment_Method) {
166
-            // let's start with the assumption that we need to trigger notifications
167
-            // then toggle this to false for conditions where we know we don't need to
168
-            $deliver_notifications = true;
169
-            if (// if SPCO revisit
170
-                filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN)
171
-                // and TXN or REG statuses have NOT changed due to a payment
172
-                && ! (
173
-                    $this->checkout->transaction->txn_status_updated()
174
-                    || $this->checkout->any_reg_status_updated()
175
-                )
176
-            ) {
177
-                $deliver_notifications = false;
178
-            }
179
-            if ($this->checkout->payment_method->is_off_site()) {
180
-                /** @var EE_Gateway $gateway */
181
-                $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
182
-                // and the gateway uses a separate request to process the IPN
183
-                if ($gateway instanceof EE_Offsite_Gateway
184
-                    && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)
185
-                ) {
186
-                    // IPN request will handle triggering notifications
187
-                    $deliver_notifications = false;
188
-                    // no really... don't send any notices in this request
189
-                    remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications');
190
-                    add_filter(
191
-                        'FHEE__EED_Messages___maybe_registration__deliver_notifications',
192
-                        '__return_false',
193
-                        15
194
-                    );
195
-                }
196
-            }
197
-            if ($deliver_notifications) {
198
-                // send out notifications
199
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
200
-            }
201
-        }
202
-    }
203
-
204
-
205
-    /**
206
-     * check if transaction has a primary registrant and that it has a related Attendee object
207
-     *
208
-     * @return boolean
209
-     * @throws \EE_Error
210
-     */
211
-    protected function _validate_primary_registrant()
212
-    {
213
-        if (! $this->checkout->transaction_has_primary_registrant()) {
214
-            EE_Error::add_error(
215
-                __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'),
216
-                __FILE__,
217
-                __FUNCTION__,
218
-                __LINE__
219
-            );
220
-            $this->checkout->redirect = false;
221
-            $this->checkout->continue_reg = false;
222
-            return false;
223
-        }
224
-        // setup URL for redirect
225
-        $this->checkout->redirect_url = add_query_arg(
226
-            array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()),
227
-            $this->checkout->thank_you_page_url
228
-        );
229
-        return true;
230
-    }
231
-
232
-
233
-    /**
234
-     * @return void
235
-     */
236
-    public function update_reg_step()
237
-    {
238
-        EE_Error::doing_it_wrong(
239
-            __CLASS__ . '::' . __FILE__,
240
-            __(
241
-                'Can not call update_reg_step() on the Finalize Registration reg step.',
242
-                'event_espresso'
243
-            ),
244
-            '4.6.0'
245
-        );
246
-    }
15
+	/**
16
+	 *    class constructor
17
+	 *
18
+	 * @access    public
19
+	 * @param    EE_Checkout $checkout
20
+	 */
21
+	public function __construct(EE_Checkout $checkout)
22
+	{
23
+		$this->_slug = 'finalize_registration';
24
+		$this->_name = __('Finalize Registration', 'event_espresso');
25
+		$this->_submit_button_text = $this->_name;
26
+		$this->_template = '';
27
+		$this->checkout = $checkout;
28
+	}
29
+
30
+
31
+	public function translate_js_strings()
32
+	{
33
+	}
34
+
35
+
36
+	public function enqueue_styles_and_scripts()
37
+	{
38
+	}
39
+
40
+
41
+	/**
42
+	 * @return boolean
43
+	 */
44
+	public function initialize_reg_step()
45
+	{
46
+		// there's actually no reg form to process if this is the final step
47
+		if ($this->is_current_step()) {
48
+			$this->checkout->step = $_REQUEST['step'] = $this->slug();
49
+			$this->checkout->action = $_REQUEST['action'] = 'process_reg_step';
50
+			$this->checkout->generate_reg_form = false;
51
+		}
52
+		return true;
53
+	}
54
+
55
+
56
+	/**
57
+	 * @return string
58
+	 * @throws \EE_Error
59
+	 */
60
+	public function generate_reg_form()
61
+	{
62
+		// create empty form so that things don't break
63
+		$this->reg_form = new EE_Form_Section_Proper();
64
+		return '';
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return boolean
70
+	 * @throws \RuntimeException
71
+	 * @throws \EE_Error
72
+	 */
73
+	public function process_reg_step()
74
+	{
75
+		// ensure all data gets refreshed from the db
76
+		$this->checkout->refresh_all_entities(true);
77
+		// ensures that all details and statuses for transaction, registration, and payments are updated
78
+		$txn_update_params = $this->_finalize_transaction();
79
+		// maybe send messages
80
+		$this->_set_notification_triggers();
81
+		// send messages
82
+		/** @type EE_Registration_Processor $registration_processor */
83
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
84
+		$registration_processor->trigger_registration_update_notifications(
85
+			$this->checkout->transaction->primary_registration(),
86
+			$txn_update_params
87
+		);
88
+		// set a hook point
89
+		do_action(
90
+			'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
91
+			$this->checkout,
92
+			$txn_update_params
93
+		);
94
+		// check if transaction has a primary registrant and that it has a related Attendee object
95
+		if (! $this->_validate_primary_registrant()) {
96
+			return false;
97
+		}
98
+		// you don't have to go home but you can't stay here !
99
+		$this->checkout->redirect = true;
100
+		$this->checkout->continue_reg = true;
101
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
102
+		if (! (
103
+			$this->checkout->payment_method instanceof EE_Payment_Method
104
+			&& $this->checkout->payment_method->is_off_site()
105
+		)) {
106
+			// mark this reg step as completed
107
+			$this->set_completed();
108
+		}
109
+		$this->checkout->set_exit_spco();
110
+		return true;
111
+	}
112
+
113
+
114
+	/**
115
+	 * _finalize_transaction
116
+	 * ensures that all details and statuses for transaction, registration, and payments are updated
117
+	 *
118
+	 * @return array
119
+	 * @throws \RuntimeException
120
+	 * @throws \EE_Error
121
+	 */
122
+	protected function _finalize_transaction()
123
+	{
124
+		/** @type EE_Transaction_Processor $transaction_processor */
125
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
126
+		// set revisit flag in txn processor
127
+		$transaction_processor->set_revisit($this->checkout->revisit);
128
+		// at this point we'll consider a TXN to not have been abandoned
129
+		$this->checkout->transaction->toggle_abandoned_transaction_status();
130
+		if ($this->checkout->cart instanceof EE_Cart) {
131
+			// save TXN data to the cart
132
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
133
+				$this->checkout->transaction->ID()
134
+			);
135
+		}
136
+		// maybe update status, but don't save transaction just yet
137
+		$this->checkout->transaction->update_status_based_on_total_paid(false);
138
+		// this will result in the base session properties getting saved to the TXN_Session_data field
139
+		$this->checkout->transaction->set_txn_session_data(
140
+			EE_Registry::instance()->SSN->get_session_data(null, true)
141
+		);
142
+		// update the TXN if payment conditions have changed, but do NOT trigger notifications,
143
+		// because we will do that in process_reg_step() after setting some more triggers
144
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
145
+			$this->checkout->transaction,
146
+			$this->checkout->payment,
147
+			$this->checkout->reg_cache_where_params,
148
+			false
149
+		);
150
+	}
151
+
152
+
153
+	/**
154
+	 * If request is not a revisit, and an Off-Site gateway using IPNs has NOT been selected...
155
+	 * OR
156
+	 * if it IS a revisit and the TXN and/or one or more REG statuses have changed...
157
+	 * then trigger notifications
158
+	 *
159
+	 * @return void
160
+	 * @throws \EE_Error
161
+	 */
162
+	protected function _set_notification_triggers()
163
+	{
164
+
165
+		if ($this->checkout->payment_method instanceof EE_Payment_Method) {
166
+			// let's start with the assumption that we need to trigger notifications
167
+			// then toggle this to false for conditions where we know we don't need to
168
+			$deliver_notifications = true;
169
+			if (// if SPCO revisit
170
+				filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN)
171
+				// and TXN or REG statuses have NOT changed due to a payment
172
+				&& ! (
173
+					$this->checkout->transaction->txn_status_updated()
174
+					|| $this->checkout->any_reg_status_updated()
175
+				)
176
+			) {
177
+				$deliver_notifications = false;
178
+			}
179
+			if ($this->checkout->payment_method->is_off_site()) {
180
+				/** @var EE_Gateway $gateway */
181
+				$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
182
+				// and the gateway uses a separate request to process the IPN
183
+				if ($gateway instanceof EE_Offsite_Gateway
184
+					&& $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)
185
+				) {
186
+					// IPN request will handle triggering notifications
187
+					$deliver_notifications = false;
188
+					// no really... don't send any notices in this request
189
+					remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications');
190
+					add_filter(
191
+						'FHEE__EED_Messages___maybe_registration__deliver_notifications',
192
+						'__return_false',
193
+						15
194
+					);
195
+				}
196
+			}
197
+			if ($deliver_notifications) {
198
+				// send out notifications
199
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
200
+			}
201
+		}
202
+	}
203
+
204
+
205
+	/**
206
+	 * check if transaction has a primary registrant and that it has a related Attendee object
207
+	 *
208
+	 * @return boolean
209
+	 * @throws \EE_Error
210
+	 */
211
+	protected function _validate_primary_registrant()
212
+	{
213
+		if (! $this->checkout->transaction_has_primary_registrant()) {
214
+			EE_Error::add_error(
215
+				__('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'),
216
+				__FILE__,
217
+				__FUNCTION__,
218
+				__LINE__
219
+			);
220
+			$this->checkout->redirect = false;
221
+			$this->checkout->continue_reg = false;
222
+			return false;
223
+		}
224
+		// setup URL for redirect
225
+		$this->checkout->redirect_url = add_query_arg(
226
+			array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()),
227
+			$this->checkout->thank_you_page_url
228
+		);
229
+		return true;
230
+	}
231
+
232
+
233
+	/**
234
+	 * @return void
235
+	 */
236
+	public function update_reg_step()
237
+	{
238
+		EE_Error::doing_it_wrong(
239
+			__CLASS__ . '::' . __FILE__,
240
+			__(
241
+				'Can not call update_reg_step() on the Finalize Registration reg step.',
242
+				'event_espresso'
243
+			),
244
+			'4.6.0'
245
+		);
246
+	}
247 247
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
             $txn_update_params
93 93
         );
94 94
         // check if transaction has a primary registrant and that it has a related Attendee object
95
-        if (! $this->_validate_primary_registrant()) {
95
+        if ( ! $this->_validate_primary_registrant()) {
96 96
             return false;
97 97
         }
98 98
         // you don't have to go home but you can't stay here !
99 99
         $this->checkout->redirect = true;
100 100
         $this->checkout->continue_reg = true;
101 101
         $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
102
-        if (! (
102
+        if ( ! (
103 103
             $this->checkout->payment_method instanceof EE_Payment_Method
104 104
             && $this->checkout->payment_method->is_off_site()
105 105
         )) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     protected function _validate_primary_registrant()
212 212
     {
213
-        if (! $this->checkout->transaction_has_primary_registrant()) {
213
+        if ( ! $this->checkout->transaction_has_primary_registrant()) {
214 214
             EE_Error::add_error(
215 215
                 __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'),
216 216
                 __FILE__,
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     public function update_reg_step()
237 237
     {
238 238
         EE_Error::doing_it_wrong(
239
-            __CLASS__ . '::' . __FILE__,
239
+            __CLASS__.'::'.__FILE__,
240 240
             __(
241 241
                 'Can not call update_reg_step() on the Finalize Registration reg step.',
242 242
                 'event_espresso'
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 2 patches
Indentation   +365 added lines, -365 removed lines patch added patch discarded remove patch
@@ -9,398 +9,398 @@
 block discarded – undo
9 9
 class Invoice
10 10
 {
11 11
 
12
-    /**
13
-     *
14
-     * @var EE_Registration
15
-     */
16
-    private $registration;
17
-    /**
18
-     *
19
-     * @var EE_Transaction
20
-     */
21
-    private $transaction;
22
-    /**
23
-     *
24
-     * @var EE_Payment_Method
25
-     */
26
-    private $invoice_payment_method;
27
-    private $EE;
12
+	/**
13
+	 *
14
+	 * @var EE_Registration
15
+	 */
16
+	private $registration;
17
+	/**
18
+	 *
19
+	 * @var EE_Transaction
20
+	 */
21
+	private $transaction;
22
+	/**
23
+	 *
24
+	 * @var EE_Payment_Method
25
+	 */
26
+	private $invoice_payment_method;
27
+	private $EE;
28 28
 
29 29
 
30
-    /**
31
-     * Invoice constructor.
32
-     *
33
-     * @deprecated 4.9.13
34
-     * @param int $url_link
35
-     */
36
-    public function __construct($url_link = 0)
37
-    {
38
-        EE_Error::doing_it_wrong(
39
-            __CLASS__,
40
-            esc_html__(
41
-                'This class has been deprecated and replaced by the new Messages library.',
42
-                'event_espresso'
43
-            ),
44
-            '4.9.12',
45
-            '5.0.0'
46
-        );
47
-        if ($this->registration = EE_Registry::instance()->load_model(
48
-            'Registration'
49
-        )->get_registration_for_reg_url_link($url_link)) {
50
-            $this->transaction = $this->registration->transaction();
51
-            // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
-            $payment_settings = EE_Config::instance()->gateway->payment_settings;
53
-            $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
-        } else {
55
-            EE_Error::add_error(
56
-                __(
57
-                    'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
-                    'event_espresso'
59
-                ),
60
-                __FILE__,
61
-                __FUNCTION__,
62
-                __LINE__
63
-            );
64
-        }
65
-    }
30
+	/**
31
+	 * Invoice constructor.
32
+	 *
33
+	 * @deprecated 4.9.13
34
+	 * @param int $url_link
35
+	 */
36
+	public function __construct($url_link = 0)
37
+	{
38
+		EE_Error::doing_it_wrong(
39
+			__CLASS__,
40
+			esc_html__(
41
+				'This class has been deprecated and replaced by the new Messages library.',
42
+				'event_espresso'
43
+			),
44
+			'4.9.12',
45
+			'5.0.0'
46
+		);
47
+		if ($this->registration = EE_Registry::instance()->load_model(
48
+			'Registration'
49
+		)->get_registration_for_reg_url_link($url_link)) {
50
+			$this->transaction = $this->registration->transaction();
51
+			// get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
+			$payment_settings = EE_Config::instance()->gateway->payment_settings;
53
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
+		} else {
55
+			EE_Error::add_error(
56
+				__(
57
+					'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
+					'event_espresso'
59
+				),
60
+				__FILE__,
61
+				__FUNCTION__,
62
+				__LINE__
63
+			);
64
+		}
65
+	}
66 66
 
67
-    public function send_invoice($download = false)
68
-    {
69
-        $template_args = array();
70
-        $EE = EE_Registry::instance();
67
+	public function send_invoice($download = false)
68
+	{
69
+		$template_args = array();
70
+		$EE = EE_Registry::instance();
71 71
 
72
-        // allow the request to override the default theme defined in the invoice settings
73
-        $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
-            $_REQUEST['theme']
75
-        ) : null;
76
-        $themes = array(
77
-            1 => "simple.css",
78
-            2 => "bauhaus.css",
79
-            3 => "ejs.css",
80
-            4 => "horizon.css",
81
-            5 => "lola.css",
82
-            6 => "tranquility.css",
83
-            7 => "union.css",
84
-        );
85
-        // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
88
-        } else {
89
-            $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
-                'legacy_invoice_css',
91
-                true,
92
-                'simple.css'
93
-            );
94
-        }
72
+		// allow the request to override the default theme defined in the invoice settings
73
+		$theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
+			$_REQUEST['theme']
75
+		) : null;
76
+		$themes = array(
77
+			1 => "simple.css",
78
+			2 => "bauhaus.css",
79
+			3 => "ejs.css",
80
+			4 => "horizon.css",
81
+			5 => "lola.css",
82
+			6 => "tranquility.css",
83
+			7 => "union.css",
84
+		);
85
+		// Get the CSS file
86
+		if (isset($themes[ $theme_requested ])) {
87
+			$template_args['invoice_css'] = $themes[ $theme_requested ];
88
+		} else {
89
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
+				'legacy_invoice_css',
91
+				true,
92
+				'simple.css'
93
+			);
94
+		}
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
-        } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
-        }
101
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
96
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
+		} else {
99
+			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
+		}
101
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103
-        $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
-        $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
-            'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
-        $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
-        $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
-            $EE->CFG->organization->STA_ID
110
-        );
111
-        $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
-            $EE->CFG->organization->CNT_ISO
113
-        );
114
-        $template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
-        $template_args['email'] = $EE->CFG->organization->get_pretty('email');
103
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
+		$template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
+			'address_1'
106
+		) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
+		$template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
+		$template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
+			$EE->CFG->organization->STA_ID
110
+		);
111
+		$template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
+			$EE->CFG->organization->CNT_ISO
113
+		);
114
+		$template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
+		$template_args['email'] = $EE->CFG->organization->get_pretty('email');
116 116
 
117
-        $template_args['registration_code'] = $this->registration->reg_code();
118
-        $template_args['registration_date'] = $this->registration->date();
119
-        $template_args['name'] = $primary_attendee->full_name();
120
-        $template_args['attendee_address'] = $primary_attendee->address();
121
-        $template_args['attendee_address2'] = $primary_attendee->address2();
122
-        $template_args['attendee_city'] = $primary_attendee->city();
123
-        $attendee_state = $primary_attendee->state_obj();
124
-        if ($attendee_state) {
125
-            $attendee_state_name = $attendee_state->name();
126
-        } else {
127
-            $attendee_state_name = '';
128
-        }
129
-        $template_args['attendee_state'] = $attendee_state_name;
130
-        $template_args['attendee_zip'] = $primary_attendee->zip();
117
+		$template_args['registration_code'] = $this->registration->reg_code();
118
+		$template_args['registration_date'] = $this->registration->date();
119
+		$template_args['name'] = $primary_attendee->full_name();
120
+		$template_args['attendee_address'] = $primary_attendee->address();
121
+		$template_args['attendee_address2'] = $primary_attendee->address2();
122
+		$template_args['attendee_city'] = $primary_attendee->city();
123
+		$attendee_state = $primary_attendee->state_obj();
124
+		if ($attendee_state) {
125
+			$attendee_state_name = $attendee_state->name();
126
+		} else {
127
+			$attendee_state_name = '';
128
+		}
129
+		$template_args['attendee_state'] = $attendee_state_name;
130
+		$template_args['attendee_zip'] = $primary_attendee->zip();
131 131
 
132
-        $template_args['ship_name'] = $template_args['name'];
133
-        $template_args['ship_address'] = $template_args['attendee_address'];
134
-        $template_args['ship_city'] = $template_args['attendee_city'];
135
-        $template_args['ship_state'] = $template_args['attendee_state'];
136
-        $template_args['ship_zip'] = $template_args['attendee_zip'];
132
+		$template_args['ship_name'] = $template_args['name'];
133
+		$template_args['ship_address'] = $template_args['attendee_address'];
134
+		$template_args['ship_city'] = $template_args['attendee_city'];
135
+		$template_args['ship_state'] = $template_args['attendee_state'];
136
+		$template_args['ship_zip'] = $template_args['attendee_zip'];
137 137
 
138
-        $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
-        $template_args['transaction'] = $this->transaction;
140
-        $template_args['amount_pd'] = $this->transaction->paid();
141
-        $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
-        $template_args['payments'] = $this->transaction->approved_payments();
143
-        $template_args['net_total'] = '';
144
-        $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
-        $template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
-        $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
-            $this->transaction->total_line_item()
148
-        );
149
-        if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
-            // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
-            $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
153
-                foreach ($tax_items as $tax) {
154
-                    $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
-                }
156
-            }
138
+		$template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
+		$template_args['transaction'] = $this->transaction;
140
+		$template_args['amount_pd'] = $this->transaction->paid();
141
+		$template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
+		$template_args['payments'] = $this->transaction->approved_payments();
143
+		$template_args['net_total'] = '';
144
+		$template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
+		$template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
+		$template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
+			$this->transaction->total_line_item()
148
+		);
149
+		if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
+			// $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
+			$tax_items = $this->transaction->tax_items();
152
+			if (! empty($tax_items)) {
153
+				foreach ($tax_items as $tax) {
154
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
+				}
156
+			}
157 157
 
158
-            $difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
-            if ($difference < 0) {
160
-                $text = __('Discount', 'event_espresso');
161
-            } else {
162
-                $text = __('Extra', 'event_espresso');
163
-            }
164
-            $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
-        }
158
+			$difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
+			if ($difference < 0) {
160
+				$text = __('Discount', 'event_espresso');
161
+			} else {
162
+				$text = __('Extra', 'event_espresso');
163
+			}
164
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
+		}
166 166
 
167
-        $template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
-        $template_args['template_payment_instructions'] = wpautop(
169
-            stripslashes_deep(
170
-                html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
-            )
172
-        );
173
-        $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
-        if (isset($_GET['receipt'])) {
175
-            // receipt-specific stuff
176
-            $events_for_txn = EEM_Event::instance()->get_all(
177
-                array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
-            );
179
-            $ticket_line_items_per_event = array();
180
-            $registrations_per_line_item = array();
181
-            $venues_for_events = array();
182
-            foreach ($events_for_txn as $event_id => $event) {
183
-                $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
-                    array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
-                );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
-                foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
-                    $ticket = $line_item->ticket();
189
-                    $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
-                        array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
-                    );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
-                }
194
-                $venues_for_events = array_merge($venues_for_events, $event->venues());
195
-            }
196
-            $tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
-                array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
-            );
199
-            $questions_to_skip = array(
200
-                EEM_Attendee::system_question_fname,
201
-                EEM_Attendee::system_question_lname,
202
-                EEM_Attendee::system_question_email,
203
-            );
167
+		$template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
+		$template_args['template_payment_instructions'] = wpautop(
169
+			stripslashes_deep(
170
+				html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
+			)
172
+		);
173
+		$template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
+		if (isset($_GET['receipt'])) {
175
+			// receipt-specific stuff
176
+			$events_for_txn = EEM_Event::instance()->get_all(
177
+				array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
+			);
179
+			$ticket_line_items_per_event = array();
180
+			$registrations_per_line_item = array();
181
+			$venues_for_events = array();
182
+			foreach ($events_for_txn as $event_id => $event) {
183
+				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
+					array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
+				);
186
+				$ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
+					$ticket = $line_item->ticket();
189
+					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
+						array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
+					);
192
+					$registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
+				}
194
+				$venues_for_events = array_merge($venues_for_events, $event->venues());
195
+			}
196
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
+				array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
+			);
199
+			$questions_to_skip = array(
200
+				EEM_Attendee::system_question_fname,
201
+				EEM_Attendee::system_question_lname,
202
+				EEM_Attendee::system_question_email,
203
+			);
204 204
 
205 205
 
206
-            $template_args['events_for_txn'] = $events_for_txn;
207
-            $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
-            $template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
-            $template_args['venues_for_events'] = $venues_for_events;
210
-            $template_args['tax_total_line_item'] = $tax_total_line_item;
211
-            $template_args['questions_to_skip'] = $questions_to_skip;
212
-            // d($template_args);
213
-            $template_args['download_link'] = $this->registration->receipt_url('download');
214
-        } else {
215
-            // it's just an invoice we're accessing
216
-            $template_args['download_link'] = $this->registration->invoice_url('download');
217
-        }
206
+			$template_args['events_for_txn'] = $events_for_txn;
207
+			$template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
+			$template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
+			$template_args['venues_for_events'] = $venues_for_events;
210
+			$template_args['tax_total_line_item'] = $tax_total_line_item;
211
+			$template_args['questions_to_skip'] = $questions_to_skip;
212
+			// d($template_args);
213
+			$template_args['download_link'] = $this->registration->receipt_url('download');
214
+		} else {
215
+			// it's just an invoice we're accessing
216
+			$template_args['download_link'] = $this->registration->invoice_url('download');
217
+		}
218 218
 
219
-        // Get the HTML as an object
220
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
-        $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
223
-            $template_args,
224
-            true,
225
-            true
226
-        );
227
-        if (isset($_GET['receipt'])) {
228
-            $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
230
-                $template_args,
231
-                true,
232
-                true
233
-            );
234
-        } else {
235
-            $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
237
-                $template_args,
238
-                true,
239
-                true
240
-            );
241
-        }
219
+		// Get the HTML as an object
220
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
+		$template_header = EEH_Template::locate_template(
222
+			$templates_relative_path . 'invoice_header.template.php',
223
+			$template_args,
224
+			true,
225
+			true
226
+		);
227
+		if (isset($_GET['receipt'])) {
228
+			$template_body = EEH_Template::locate_template(
229
+				$templates_relative_path . 'receipt_body.template.php',
230
+				$template_args,
231
+				true,
232
+				true
233
+			);
234
+		} else {
235
+			$template_body = EEH_Template::locate_template(
236
+				$templates_relative_path . 'invoice_body.template.php',
237
+				$template_args,
238
+				true,
239
+				true
240
+			);
241
+		}
242 242
 
243 243
 
244
-        $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
246
-            $template_args,
247
-            true,
248
-            true
249
-        );
244
+		$template_footer = EEH_Template::locate_template(
245
+			$templates_relative_path . 'invoice_footer.template.php',
246
+			$template_args,
247
+			true,
248
+			true
249
+		);
250 250
 
251
-        $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
251
+		$copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
252 252
 
253
-        $content = $this->espresso_replace_invoice_shortcodes($template_header);
254
-        for ($x = 1; $x <= $copies; $x++) {
255
-            $content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
-        }
257
-        $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
253
+		$content = $this->espresso_replace_invoice_shortcodes($template_header);
254
+		for ($x = 1; $x <= $copies; $x++) {
255
+			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
+		}
257
+		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259
-        // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
261
-            echo $content;
262
-            exit(0);
263
-        }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
265
-            'Invoice #',
266
-            'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
-        $invoice_name = str_replace(' ', '_', $invoice_name);
269
-        // Create the PDF
270
-        if (array_key_exists('html', $_GET)) {
271
-            echo $content;
272
-        } else {
273
-            // only load dompdf if nobody else has yet...
274
-            if (! defined('DOMPDF_DIR')) {
275
-                define('DOMPDF_ENABLE_REMOTE', true);
276
-                define('DOMPDF_ENABLE_JAVASCRIPT', false);
277
-                define('DOMPDF_ENABLE_CSS_FLOAT', true);
278
-                require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
279
-            }
280
-            $dompdf = new DOMPDF();
281
-            $dompdf->load_html($content);
282
-            $dompdf->render();
283
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
284
-        }
285
-        exit(0);
286
-    }
259
+		// Check if debugging or mobile is set
260
+		if (! empty($_REQUEST['html'])) {
261
+			echo $content;
262
+			exit(0);
263
+		}
264
+		$invoice_name = $template_args['organization'] . ' ' . __(
265
+			'Invoice #',
266
+			'event_espresso'
267
+		) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
+		$invoice_name = str_replace(' ', '_', $invoice_name);
269
+		// Create the PDF
270
+		if (array_key_exists('html', $_GET)) {
271
+			echo $content;
272
+		} else {
273
+			// only load dompdf if nobody else has yet...
274
+			if (! defined('DOMPDF_DIR')) {
275
+				define('DOMPDF_ENABLE_REMOTE', true);
276
+				define('DOMPDF_ENABLE_JAVASCRIPT', false);
277
+				define('DOMPDF_ENABLE_CSS_FLOAT', true);
278
+				require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
279
+			}
280
+			$dompdf = new DOMPDF();
281
+			$dompdf->load_html($content);
282
+			$dompdf->render();
283
+			$dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
284
+		}
285
+		exit(0);
286
+	}
287 287
 
288
-    /**
289
-     * Checks if this line item, or any of its children, actually has a description.
290
-     * If none do, then the template can decide to not show any description column
291
-     *
292
-     * @param EE_Line_Item $line_item
293
-     * @return boolean
294
-     */
295
-    public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
296
-    {
297
-        if ($line_item->desc()) {
298
-            return true;
299
-        } else {
300
-            foreach ($line_item->children() as $child_line_item) {
301
-                if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
302
-                    return true;
303
-                }
304
-            }
305
-            // well, if I and my children don't have descriptions, I guess not
306
-            return false;
307
-        }
308
-    }
288
+	/**
289
+	 * Checks if this line item, or any of its children, actually has a description.
290
+	 * If none do, then the template can decide to not show any description column
291
+	 *
292
+	 * @param EE_Line_Item $line_item
293
+	 * @return boolean
294
+	 */
295
+	public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
296
+	{
297
+		if ($line_item->desc()) {
298
+			return true;
299
+		} else {
300
+			foreach ($line_item->children() as $child_line_item) {
301
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
302
+					return true;
303
+				}
304
+			}
305
+			// well, if I and my children don't have descriptions, I guess not
306
+			return false;
307
+		}
308
+	}
309 309
 
310 310
 // Perform the shortcode replacement
311
-    public function espresso_replace_invoice_shortcodes($content)
312
-    {
311
+	public function espresso_replace_invoice_shortcodes($content)
312
+	{
313 313
 
314
-        $EE = EE_Registry::instance();
315
-        // Create the logo
316
-        $invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
317
-            'pdf_logo_image',
318
-            true,
319
-            $EE->CFG->organization->logo_url
320
-        );
321
-        if (! empty($invoice_logo_url)) {
322
-            $image_size = getimagesize($invoice_logo_url);
323
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
324
-        } else {
325
-            $invoice_logo_image = '';
326
-        }
327
-        $SearchValues = array(
328
-            "[organization]",
329
-            "[registration_code]",
330
-            "[transaction_id]",
331
-            "[name]",
332
-            "[base_url]",
333
-            "[download_link]",
334
-            "[invoice_logo_image]",
335
-            "[street]",
336
-            "[city]",
337
-            "[state]",
338
-            "[zip]",
339
-            "[email]",
340
-            "[vat]",
341
-            "[registration_date]",
342
-            "[instructions]",
343
-        );
344
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
345
-        $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
346
-        if ($org_state) {
347
-            $org_state_name = $org_state->name();
348
-        } else {
349
-            $org_state_name = '';
350
-        }
351
-        $ReplaceValues = array(
352
-            $EE->CFG->organization->get_pretty('name'),
353
-            $this->registration->reg_code(),
354
-            $this->transaction->ID(),
355
-            $primary_attendee->full_name(),
356
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
357
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
358
-            $this->registration->invoice_url(),
359
-            // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
360
-            $invoice_logo_image,
361
-            empty($EE->CFG->organization->address_2)
362
-                ? $EE->CFG->organization->get_pretty('address_1')
363
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
364
-                    'address_2'
365
-                ),
366
-            $EE->CFG->organization->get_pretty('city'),
367
-            $org_state_name,
368
-            $EE->CFG->organization->get_pretty('zip'),
369
-            $EE->CFG->organization->get_pretty('email'),
370
-            $EE->CFG->organization->vat,
371
-            $this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
372
-            $this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
373
-        );
314
+		$EE = EE_Registry::instance();
315
+		// Create the logo
316
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
317
+			'pdf_logo_image',
318
+			true,
319
+			$EE->CFG->organization->logo_url
320
+		);
321
+		if (! empty($invoice_logo_url)) {
322
+			$image_size = getimagesize($invoice_logo_url);
323
+			$invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
324
+		} else {
325
+			$invoice_logo_image = '';
326
+		}
327
+		$SearchValues = array(
328
+			"[organization]",
329
+			"[registration_code]",
330
+			"[transaction_id]",
331
+			"[name]",
332
+			"[base_url]",
333
+			"[download_link]",
334
+			"[invoice_logo_image]",
335
+			"[street]",
336
+			"[city]",
337
+			"[state]",
338
+			"[zip]",
339
+			"[email]",
340
+			"[vat]",
341
+			"[registration_date]",
342
+			"[instructions]",
343
+		);
344
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
345
+		$org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
346
+		if ($org_state) {
347
+			$org_state_name = $org_state->name();
348
+		} else {
349
+			$org_state_name = '';
350
+		}
351
+		$ReplaceValues = array(
352
+			$EE->CFG->organization->get_pretty('name'),
353
+			$this->registration->reg_code(),
354
+			$this->transaction->ID(),
355
+			$primary_attendee->full_name(),
356
+			(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
357
+				: EE_GATEWAYS_URL . 'Invoice/lib/templates/',
358
+			$this->registration->invoice_url(),
359
+			// home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
360
+			$invoice_logo_image,
361
+			empty($EE->CFG->organization->address_2)
362
+				? $EE->CFG->organization->get_pretty('address_1')
363
+				: $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
364
+					'address_2'
365
+				),
366
+			$EE->CFG->organization->get_pretty('city'),
367
+			$org_state_name,
368
+			$EE->CFG->organization->get_pretty('zip'),
369
+			$EE->CFG->organization->get_pretty('email'),
370
+			$EE->CFG->organization->vat,
371
+			$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
372
+			$this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
373
+		);
374 374
 
375
-        return str_replace($SearchValues, $ReplaceValues, $content);
376
-    }
375
+		return str_replace($SearchValues, $ReplaceValues, $content);
376
+	}
377 377
 
378
-    public function espressoLoadData($items)
379
-    {
380
-        $lines = $items;
381
-        $data = array();
382
-        foreach ($lines as $line) {
383
-            $data[] = explode(';', chop($line));
384
-        }
378
+	public function espressoLoadData($items)
379
+	{
380
+		$lines = $items;
381
+		$data = array();
382
+		foreach ($lines as $line) {
383
+			$data[] = explode(';', chop($line));
384
+		}
385 385
 
386
-        return $data;
387
-    }
386
+		return $data;
387
+	}
388 388
 
389 389
 
390
-    public function espressoInvoiceTotals($text, $total_cost)
391
-    {
390
+	public function espressoInvoiceTotals($text, $total_cost)
391
+	{
392 392
 
393
-        $html = '';
394
-        if ($total_cost < 0) {
395
-            $total_cost = (-1) * $total_cost;
396
-        }
397
-        $find = array(' ');
398
-        $replace = array('-');
399
-        $row_id = strtolower(str_replace($find, $replace, $text));
400
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
401
-        $html .= '<td class="item_r">' . $text . '</td>';
402
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
403
-        $html .= '</tr>';
404
-        return $html;
405
-    }
393
+		$html = '';
394
+		if ($total_cost < 0) {
395
+			$total_cost = (-1) * $total_cost;
396
+		}
397
+		$find = array(' ');
398
+		$replace = array('-');
399
+		$row_id = strtolower(str_replace($find, $replace, $text));
400
+		$html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
401
+		$html .= '<td class="item_r">' . $text . '</td>';
402
+		$html .= '<td class="item_r">' . $total_cost . '</td>';
403
+		$html .= '</tr>';
404
+		return $html;
405
+	}
406 406
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
             7 => "union.css",
84 84
         );
85 85
         // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
86
+        if (isset($themes[$theme_requested])) {
87
+            $template_args['invoice_css'] = $themes[$theme_requested];
88 88
         } else {
89 89
             $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90 90
                 'legacy_invoice_css',
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
             );
94 94
         }
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
96
+        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
97
+            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
98 98
         } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
99
+            $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
100 100
         }
101 101
         $primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103 103
         $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104 104
         $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105 105
             'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
106
+        ) : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2');
107 107
         $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108 108
         $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109 109
             $EE->CFG->organization->STA_ID
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if ($template_args['amount_pd'] != $template_args['total_cost']) {
150 150
             // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151 151
             $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
152
+            if ( ! empty($tax_items)) {
153 153
                 foreach ($tax_items as $tax) {
154 154
                     $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155 155
                 }
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
                 $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184 184
                     array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185 185
                 );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
186
+                $ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
187 187
                 foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188 188
                     $ticket = $line_item->ticket();
189 189
                     $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190 190
                         array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191 191
                     );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
192
+                    $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
193 193
                 }
194 194
                 $venues_for_events = array_merge($venues_for_events, $event->venues());
195 195
             }
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
         // Get the HTML as an object
220 220
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221 221
         $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
222
+            $templates_relative_path.'invoice_header.template.php',
223 223
             $template_args,
224 224
             true,
225 225
             true
226 226
         );
227 227
         if (isset($_GET['receipt'])) {
228 228
             $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
229
+                $templates_relative_path.'receipt_body.template.php',
230 230
                 $template_args,
231 231
                 true,
232 232
                 true
233 233
             );
234 234
         } else {
235 235
             $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
236
+                $templates_relative_path.'invoice_body.template.php',
237 237
                 $template_args,
238 238
                 true,
239 239
                 true
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 
244 244
         $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
245
+            $templates_relative_path.'invoice_footer.template.php',
246 246
             $template_args,
247 247
             true,
248 248
             true
@@ -257,30 +257,30 @@  discard block
 block discarded – undo
257 257
         $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259 259
         // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
260
+        if ( ! empty($_REQUEST['html'])) {
261 261
             echo $content;
262 262
             exit(0);
263 263
         }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
264
+        $invoice_name = $template_args['organization'].' '.__(
265 265
             'Invoice #',
266 266
             'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
267
+        ).$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name'];
268 268
         $invoice_name = str_replace(' ', '_', $invoice_name);
269 269
         // Create the PDF
270 270
         if (array_key_exists('html', $_GET)) {
271 271
             echo $content;
272 272
         } else {
273 273
             // only load dompdf if nobody else has yet...
274
-            if (! defined('DOMPDF_DIR')) {
274
+            if ( ! defined('DOMPDF_DIR')) {
275 275
                 define('DOMPDF_ENABLE_REMOTE', true);
276 276
                 define('DOMPDF_ENABLE_JAVASCRIPT', false);
277 277
                 define('DOMPDF_ENABLE_CSS_FLOAT', true);
278
-                require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
278
+                require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php');
279 279
             }
280 280
             $dompdf = new DOMPDF();
281 281
             $dompdf->load_html($content);
282 282
             $dompdf->render();
283
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
283
+            $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download));
284 284
         }
285 285
         exit(0);
286 286
     }
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
             true,
319 319
             $EE->CFG->organization->logo_url
320 320
         );
321
-        if (! empty($invoice_logo_url)) {
321
+        if ( ! empty($invoice_logo_url)) {
322 322
             $image_size = getimagesize($invoice_logo_url);
323
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
323
+            $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
324 324
         } else {
325 325
             $invoice_logo_image = '';
326 326
         }
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
             $this->registration->reg_code(),
354 354
             $this->transaction->ID(),
355 355
             $primary_attendee->full_name(),
356
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
357
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
356
+            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
357
+                : EE_GATEWAYS_URL.'Invoice/lib/templates/',
358 358
             $this->registration->invoice_url(),
359 359
             // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
360 360
             $invoice_logo_image,
361 361
             empty($EE->CFG->organization->address_2)
362 362
                 ? $EE->CFG->organization->get_pretty('address_1')
363
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
363
+                : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty(
364 364
                     'address_2'
365 365
                 ),
366 366
             $EE->CFG->organization->get_pretty('city'),
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
         $find = array(' ');
398 398
         $replace = array('-');
399 399
         $row_id = strtolower(str_replace($find, $replace, $text));
400
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
401
-        $html .= '<td class="item_r">' . $text . '</td>';
402
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
400
+        $html .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
401
+        $html .= '<td class="item_r">'.$text.'</td>';
402
+        $html .= '<td class="item_r">'.$total_cost.'</td>';
403 403
         $html .= '</tr>';
404 404
         return $html;
405 405
     }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 2 patches
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -12,374 +12,374 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
14 14
 {
15
-    /**
16
-     * Initial setup of data (called by parent).
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->_view !== 'trash'
21
-            ? $this->_admin_page->get_attendees($this->_per_page)
22
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
23
-        $this->_all_data_count = $this->_view !== 'trash'
24
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
25
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
26
-    }
27
-
28
-
29
-    /**
30
-     * Initial setup of properties.
31
-     */
32
-    protected function _set_properties()
33
-    {
34
-        $this->_wp_list_args = array(
35
-            'singular' => esc_html__('attendee', 'event_espresso'),
36
-            'plural'   => esc_html__('attendees', 'event_espresso'),
37
-            'ajax'     => true,
38
-            'screen'   => $this->_admin_page->get_current_screen()->id,
39
-        );
40
-
41
-        $this->_columns = array(
42
-            'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
-            'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
-            'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
-            'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
-            'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
-            'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
-            'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
-            'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
-            'ATT_city'           => esc_html__('City', 'event_espresso'),
51
-            'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
-            'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
-        );
54
-
55
-        $this->_sortable_columns = array(
56
-            'ATT_ID'             => array('ATT_ID' => false),
57
-            'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
-            'ATT_fname'          => array('ATT_fname' => false),
59
-            'ATT_email'          => array('ATT_email' => false),
60
-            'Registration_Count' => array('Registration_Count' => false),
61
-            'ATT_city'           => array('ATT_city' => false),
62
-            'STA_ID'             => array('STA_ID' => false),
63
-            'CNT_ISO'            => array('CNT_ISO' => false),
64
-        );
65
-
66
-        $this->_hidden_columns = array(
67
-            'ATT_phone',
68
-            'ATT_address',
69
-            'ATT_city',
70
-            'STA_ID',
71
-            'CNT_ISO',
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * Initial setup of filters
78
-     *
79
-     * @return array
80
-     */
81
-    protected function _get_table_filters()
82
-    {
83
-        return array();
84
-    }
85
-
86
-
87
-    /**
88
-     * Initial setup of counts for views
89
-     *
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     */
94
-    protected function _add_view_counts()
95
-    {
96
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
-        if (EE_Registry::instance()->CAP->current_user_can(
98
-            'ee_delete_contacts',
99
-            'espresso_registrations_delete_registration'
100
-        )) {
101
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
102
-        }
103
-    }
104
-
105
-
106
-    /**
107
-     * Get count of attendees.
108
-     *
109
-     * @return int
110
-     * @throws EE_Error
111
-     * @throws InvalidArgumentException
112
-     * @throws InvalidDataTypeException
113
-     * @throws InvalidInterfaceException
114
-     */
115
-    protected function _get_attendees_count()
116
-    {
117
-        return EEM_Attendee::instance()->count();
118
-    }
119
-
120
-
121
-    /**
122
-     * Checkbox column
123
-     *
124
-     * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
125
-     * @return string
126
-     * @throws EE_Error
127
-     */
128
-    public function column_cb($attendee)
129
-    {
130
-        if (! $attendee instanceof EE_Attendee) {
131
-            return '';
132
-        }
133
-        return sprintf(
134
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
-            $attendee->ID()
136
-        );
137
-    }
138
-
139
-
140
-    /**
141
-     * ATT_ID column
142
-     *
143
-     * @param EE_Attendee $attendee
144
-     * @return string
145
-     * @throws EE_Error
146
-     */
147
-    public function column_ATT_ID(EE_Attendee $attendee)
148
-    {
149
-        $content = $attendee->ID();
150
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
-        return $content;
153
-    }
154
-
155
-
156
-    /**
157
-     * ATT_lname column
158
-     *
159
-     * @param EE_Attendee $attendee
160
-     * @return string
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     * @throws EE_Error
165
-     */
166
-    public function column_ATT_lname(EE_Attendee $attendee)
167
-    {
168
-        // edit attendee link
169
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
-            array(
171
-                'action' => 'edit_attendee',
172
-                'post'   => $attendee->ID(),
173
-            ),
174
-            REG_ADMIN_URL
175
-        );
176
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
177
-            'ee_edit_contacts',
178
-            'espresso_registrations_edit_attendee'
179
-        )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
183
-            : $attendee->lname();
184
-        return $name_link;
185
-    }
186
-
187
-
188
-    /**
189
-     * ATT_fname column
190
-     *
191
-     * @param EE_Attendee $attendee
192
-     * @return string
193
-     * @throws InvalidArgumentException
194
-     * @throws InvalidDataTypeException
195
-     * @throws InvalidInterfaceException
196
-     * @throws EE_Error
197
-     */
198
-    public function column_ATT_fname(EE_Attendee $attendee)
199
-    {
200
-        // Build row actions
201
-        $actions = array();
202
-        // edit attendee link
203
-        if (EE_Registry::instance()->CAP->current_user_can(
204
-            'ee_edit_contacts',
205
-            'espresso_registrations_edit_attendee'
206
-        )) {
207
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
-                array(
209
-                    'action' => 'edit_attendee',
210
-                    'post'   => $attendee->ID(),
211
-                ),
212
-                REG_ADMIN_URL
213
-            );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
217
-        }
218
-
219
-        if ($this->_view === 'in_use') {
220
-            // trash attendee link
221
-            if (EE_Registry::instance()->CAP->current_user_can(
222
-                'ee_delete_contacts',
223
-                'espresso_registrations_trash_attendees'
224
-            )) {
225
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
-                    array(
227
-                        'action' => 'trash_attendee',
228
-                        'ATT_ID' => $attendee->ID(),
229
-                    ),
230
-                    REG_ADMIN_URL
231
-                );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
-            }
236
-        } else {
237
-            if (EE_Registry::instance()->CAP->current_user_can(
238
-                'ee_delete_contacts',
239
-                'espresso_registrations_restore_attendees'
240
-            )) {
241
-                // restore attendee link
242
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
-                    array(
244
-                        'action' => 'restore_attendees',
245
-                        'ATT_ID' => $attendee->ID(),
246
-                    ),
247
-                    REG_ADMIN_URL
248
-                );
249
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
252
-            }
253
-        }
254
-
255
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
256
-            array(
257
-                'action' => 'edit_attendee',
258
-                'post'   => $attendee->ID(),
259
-            ),
260
-            REG_ADMIN_URL
261
-        );
262
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
263
-            'ee_edit_contacts',
264
-            'espresso_registrations_edit_attendee'
265
-        )
266
-            ? '<a href="' . $edit_lnk_url . '" title="'
267
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
268
-            : $attendee->fname();
269
-
270
-        // Return the name contents
271
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
272
-    }
273
-
274
-
275
-    /**
276
-     * Email Column
277
-     *
278
-     * @param EE_Attendee $attendee
279
-     * @return string
280
-     * @throws EE_Error
281
-     */
282
-    public function column_ATT_email(EE_Attendee $attendee)
283
-    {
284
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
285
-    }
286
-
287
-
288
-    /**
289
-     * Column displaying count of registrations attached to Attendee.
290
-     *
291
-     * @param EE_Attendee $attendee
292
-     * @return string
293
-     * @throws EE_Error
294
-     */
295
-    public function column_Registration_Count(EE_Attendee $attendee)
296
-    {
297
-        $link = EEH_URL::add_query_args_and_nonce(
298
-            array(
299
-                'action' => 'default',
300
-                'ATT_ID' => $attendee->ID(),
301
-            ),
302
-            REG_ADMIN_URL
303
-        );
304
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
305
-    }
306
-
307
-
308
-    /**
309
-     * ATT_address column
310
-     *
311
-     * @param EE_Attendee $attendee
312
-     * @return mixed
313
-     * @throws EE_Error
314
-     */
315
-    public function column_ATT_address(EE_Attendee $attendee)
316
-    {
317
-        return $attendee->address();
318
-    }
319
-
320
-
321
-    /**
322
-     * ATT_city column
323
-     *
324
-     * @param EE_Attendee $attendee
325
-     * @return mixed
326
-     * @throws EE_Error
327
-     */
328
-    public function column_ATT_city(EE_Attendee $attendee)
329
-    {
330
-        return $attendee->city();
331
-    }
332
-
333
-
334
-    /**
335
-     * State Column
336
-     *
337
-     * @param EE_Attendee $attendee
338
-     * @return string
339
-     * @throws EE_Error
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     */
344
-    public function column_STA_ID(EE_Attendee $attendee)
345
-    {
346
-        $states = EEM_State::instance()->get_all_states();
347
-        $state = isset($states[ $attendee->state_ID() ])
348
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
349
-            : $attendee->state_ID();
350
-        return ! is_numeric($state) ? $state : '';
351
-    }
352
-
353
-
354
-    /**
355
-     * Country Column
356
-     *
357
-     * @param EE_Attendee $attendee
358
-     * @return string
359
-     * @throws EE_Error
360
-     * @throws InvalidArgumentException
361
-     * @throws InvalidDataTypeException
362
-     * @throws InvalidInterfaceException
363
-     */
364
-    public function column_CNT_ISO(EE_Attendee $attendee)
365
-    {
366
-        $countries = EEM_Country::instance()->get_all_countries();
367
-        $country = isset($countries[ $attendee->country_ID() ])
368
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
369
-            : $attendee->country_ID();
370
-        return ! is_numeric($country) ? $country : '';
371
-    }
372
-
373
-
374
-    /**
375
-     * Phone Number column
376
-     *
377
-     * @param EE_Attendee $attendee
378
-     * @return mixed
379
-     * @throws EE_Error
380
-     */
381
-    public function column_ATT_phone(EE_Attendee $attendee)
382
-    {
383
-        return $attendee->phone();
384
-    }
15
+	/**
16
+	 * Initial setup of data (called by parent).
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->_view !== 'trash'
21
+			? $this->_admin_page->get_attendees($this->_per_page)
22
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
23
+		$this->_all_data_count = $this->_view !== 'trash'
24
+			? $this->_admin_page->get_attendees($this->_per_page, true)
25
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
26
+	}
27
+
28
+
29
+	/**
30
+	 * Initial setup of properties.
31
+	 */
32
+	protected function _set_properties()
33
+	{
34
+		$this->_wp_list_args = array(
35
+			'singular' => esc_html__('attendee', 'event_espresso'),
36
+			'plural'   => esc_html__('attendees', 'event_espresso'),
37
+			'ajax'     => true,
38
+			'screen'   => $this->_admin_page->get_current_screen()->id,
39
+		);
40
+
41
+		$this->_columns = array(
42
+			'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
+			'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
+			'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
+			'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
+			'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
+			'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
+			'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
+			'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
+			'ATT_city'           => esc_html__('City', 'event_espresso'),
51
+			'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
+			'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
+		);
54
+
55
+		$this->_sortable_columns = array(
56
+			'ATT_ID'             => array('ATT_ID' => false),
57
+			'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
+			'ATT_fname'          => array('ATT_fname' => false),
59
+			'ATT_email'          => array('ATT_email' => false),
60
+			'Registration_Count' => array('Registration_Count' => false),
61
+			'ATT_city'           => array('ATT_city' => false),
62
+			'STA_ID'             => array('STA_ID' => false),
63
+			'CNT_ISO'            => array('CNT_ISO' => false),
64
+		);
65
+
66
+		$this->_hidden_columns = array(
67
+			'ATT_phone',
68
+			'ATT_address',
69
+			'ATT_city',
70
+			'STA_ID',
71
+			'CNT_ISO',
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * Initial setup of filters
78
+	 *
79
+	 * @return array
80
+	 */
81
+	protected function _get_table_filters()
82
+	{
83
+		return array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * Initial setup of counts for views
89
+	 *
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 */
94
+	protected function _add_view_counts()
95
+	{
96
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
+		if (EE_Registry::instance()->CAP->current_user_can(
98
+			'ee_delete_contacts',
99
+			'espresso_registrations_delete_registration'
100
+		)) {
101
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
102
+		}
103
+	}
104
+
105
+
106
+	/**
107
+	 * Get count of attendees.
108
+	 *
109
+	 * @return int
110
+	 * @throws EE_Error
111
+	 * @throws InvalidArgumentException
112
+	 * @throws InvalidDataTypeException
113
+	 * @throws InvalidInterfaceException
114
+	 */
115
+	protected function _get_attendees_count()
116
+	{
117
+		return EEM_Attendee::instance()->count();
118
+	}
119
+
120
+
121
+	/**
122
+	 * Checkbox column
123
+	 *
124
+	 * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
125
+	 * @return string
126
+	 * @throws EE_Error
127
+	 */
128
+	public function column_cb($attendee)
129
+	{
130
+		if (! $attendee instanceof EE_Attendee) {
131
+			return '';
132
+		}
133
+		return sprintf(
134
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
+			$attendee->ID()
136
+		);
137
+	}
138
+
139
+
140
+	/**
141
+	 * ATT_ID column
142
+	 *
143
+	 * @param EE_Attendee $attendee
144
+	 * @return string
145
+	 * @throws EE_Error
146
+	 */
147
+	public function column_ATT_ID(EE_Attendee $attendee)
148
+	{
149
+		$content = $attendee->ID();
150
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
+		return $content;
153
+	}
154
+
155
+
156
+	/**
157
+	 * ATT_lname column
158
+	 *
159
+	 * @param EE_Attendee $attendee
160
+	 * @return string
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 * @throws EE_Error
165
+	 */
166
+	public function column_ATT_lname(EE_Attendee $attendee)
167
+	{
168
+		// edit attendee link
169
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
+			array(
171
+				'action' => 'edit_attendee',
172
+				'post'   => $attendee->ID(),
173
+			),
174
+			REG_ADMIN_URL
175
+		);
176
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
177
+			'ee_edit_contacts',
178
+			'espresso_registrations_edit_attendee'
179
+		)
180
+			? '<a href="' . $edit_lnk_url . '" title="'
181
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
+			  . $attendee->lname() . '</a>'
183
+			: $attendee->lname();
184
+		return $name_link;
185
+	}
186
+
187
+
188
+	/**
189
+	 * ATT_fname column
190
+	 *
191
+	 * @param EE_Attendee $attendee
192
+	 * @return string
193
+	 * @throws InvalidArgumentException
194
+	 * @throws InvalidDataTypeException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws EE_Error
197
+	 */
198
+	public function column_ATT_fname(EE_Attendee $attendee)
199
+	{
200
+		// Build row actions
201
+		$actions = array();
202
+		// edit attendee link
203
+		if (EE_Registry::instance()->CAP->current_user_can(
204
+			'ee_edit_contacts',
205
+			'espresso_registrations_edit_attendee'
206
+		)) {
207
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
+				array(
209
+					'action' => 'edit_attendee',
210
+					'post'   => $attendee->ID(),
211
+				),
212
+				REG_ADMIN_URL
213
+			);
214
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
217
+		}
218
+
219
+		if ($this->_view === 'in_use') {
220
+			// trash attendee link
221
+			if (EE_Registry::instance()->CAP->current_user_can(
222
+				'ee_delete_contacts',
223
+				'espresso_registrations_trash_attendees'
224
+			)) {
225
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
+					array(
227
+						'action' => 'trash_attendee',
228
+						'ATT_ID' => $attendee->ID(),
229
+					),
230
+					REG_ADMIN_URL
231
+				);
232
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
234
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
+			}
236
+		} else {
237
+			if (EE_Registry::instance()->CAP->current_user_can(
238
+				'ee_delete_contacts',
239
+				'espresso_registrations_restore_attendees'
240
+			)) {
241
+				// restore attendee link
242
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
+					array(
244
+						'action' => 'restore_attendees',
245
+						'ATT_ID' => $attendee->ID(),
246
+					),
247
+					REG_ADMIN_URL
248
+				);
249
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
252
+			}
253
+		}
254
+
255
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
256
+			array(
257
+				'action' => 'edit_attendee',
258
+				'post'   => $attendee->ID(),
259
+			),
260
+			REG_ADMIN_URL
261
+		);
262
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
263
+			'ee_edit_contacts',
264
+			'espresso_registrations_edit_attendee'
265
+		)
266
+			? '<a href="' . $edit_lnk_url . '" title="'
267
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
268
+			: $attendee->fname();
269
+
270
+		// Return the name contents
271
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
272
+	}
273
+
274
+
275
+	/**
276
+	 * Email Column
277
+	 *
278
+	 * @param EE_Attendee $attendee
279
+	 * @return string
280
+	 * @throws EE_Error
281
+	 */
282
+	public function column_ATT_email(EE_Attendee $attendee)
283
+	{
284
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
285
+	}
286
+
287
+
288
+	/**
289
+	 * Column displaying count of registrations attached to Attendee.
290
+	 *
291
+	 * @param EE_Attendee $attendee
292
+	 * @return string
293
+	 * @throws EE_Error
294
+	 */
295
+	public function column_Registration_Count(EE_Attendee $attendee)
296
+	{
297
+		$link = EEH_URL::add_query_args_and_nonce(
298
+			array(
299
+				'action' => 'default',
300
+				'ATT_ID' => $attendee->ID(),
301
+			),
302
+			REG_ADMIN_URL
303
+		);
304
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
305
+	}
306
+
307
+
308
+	/**
309
+	 * ATT_address column
310
+	 *
311
+	 * @param EE_Attendee $attendee
312
+	 * @return mixed
313
+	 * @throws EE_Error
314
+	 */
315
+	public function column_ATT_address(EE_Attendee $attendee)
316
+	{
317
+		return $attendee->address();
318
+	}
319
+
320
+
321
+	/**
322
+	 * ATT_city column
323
+	 *
324
+	 * @param EE_Attendee $attendee
325
+	 * @return mixed
326
+	 * @throws EE_Error
327
+	 */
328
+	public function column_ATT_city(EE_Attendee $attendee)
329
+	{
330
+		return $attendee->city();
331
+	}
332
+
333
+
334
+	/**
335
+	 * State Column
336
+	 *
337
+	 * @param EE_Attendee $attendee
338
+	 * @return string
339
+	 * @throws EE_Error
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 */
344
+	public function column_STA_ID(EE_Attendee $attendee)
345
+	{
346
+		$states = EEM_State::instance()->get_all_states();
347
+		$state = isset($states[ $attendee->state_ID() ])
348
+			? $states[ $attendee->state_ID() ]->get('STA_name')
349
+			: $attendee->state_ID();
350
+		return ! is_numeric($state) ? $state : '';
351
+	}
352
+
353
+
354
+	/**
355
+	 * Country Column
356
+	 *
357
+	 * @param EE_Attendee $attendee
358
+	 * @return string
359
+	 * @throws EE_Error
360
+	 * @throws InvalidArgumentException
361
+	 * @throws InvalidDataTypeException
362
+	 * @throws InvalidInterfaceException
363
+	 */
364
+	public function column_CNT_ISO(EE_Attendee $attendee)
365
+	{
366
+		$countries = EEM_Country::instance()->get_all_countries();
367
+		$country = isset($countries[ $attendee->country_ID() ])
368
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
369
+			: $attendee->country_ID();
370
+		return ! is_numeric($country) ? $country : '';
371
+	}
372
+
373
+
374
+	/**
375
+	 * Phone Number column
376
+	 *
377
+	 * @param EE_Attendee $attendee
378
+	 * @return mixed
379
+	 * @throws EE_Error
380
+	 */
381
+	public function column_ATT_phone(EE_Attendee $attendee)
382
+	{
383
+		return $attendee->phone();
384
+	}
385 385
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function column_cb($attendee)
129 129
     {
130
-        if (! $attendee instanceof EE_Attendee) {
130
+        if ( ! $attendee instanceof EE_Attendee) {
131 131
             return '';
132 132
         }
133 133
         return sprintf(
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $content = $attendee->ID();
150 150
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
151
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
152 152
         return $content;
153 153
     }
154 154
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
             'ee_edit_contacts',
178 178
             'espresso_registrations_edit_attendee'
179 179
         )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
180
+            ? '<a href="'.$edit_lnk_url.'" title="'
181
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
182
+              . $attendee->lname().'</a>'
183 183
             : $attendee->lname();
184 184
         return $name_link;
185 185
     }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
                 ),
212 212
                 REG_ADMIN_URL
213 213
             );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
214
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
215
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
216
+                               . esc_html__('Edit', 'event_espresso').'</a>';
217 217
         }
218 218
 
219 219
         if ($this->_view === 'in_use') {
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                     ),
230 230
                     REG_ADMIN_URL
231 231
                 );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
232
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
233 233
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
234
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
235 235
             }
236 236
         } else {
237 237
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
                     ),
247 247
                     REG_ADMIN_URL
248 248
                 );
249
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
249
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
250
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
251
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
252 252
             }
253 253
         }
254 254
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
             'ee_edit_contacts',
264 264
             'espresso_registrations_edit_attendee'
265 265
         )
266
-            ? '<a href="' . $edit_lnk_url . '" title="'
267
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
266
+            ? '<a href="'.$edit_lnk_url.'" title="'
267
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
268 268
             : $attendee->fname();
269 269
 
270 270
         // Return the name contents
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function column_ATT_email(EE_Attendee $attendee)
283 283
     {
284
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
284
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
285 285
     }
286 286
 
287 287
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             ),
302 302
             REG_ADMIN_URL
303 303
         );
304
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
304
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
305 305
     }
306 306
 
307 307
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
     public function column_STA_ID(EE_Attendee $attendee)
345 345
     {
346 346
         $states = EEM_State::instance()->get_all_states();
347
-        $state = isset($states[ $attendee->state_ID() ])
348
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
347
+        $state = isset($states[$attendee->state_ID()])
348
+            ? $states[$attendee->state_ID()]->get('STA_name')
349 349
             : $attendee->state_ID();
350 350
         return ! is_numeric($state) ? $state : '';
351 351
     }
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
     public function column_CNT_ISO(EE_Attendee $attendee)
365 365
     {
366 366
         $countries = EEM_Country::instance()->get_all_countries();
367
-        $country = isset($countries[ $attendee->country_ID() ])
368
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
367
+        $country = isset($countries[$attendee->country_ID()])
368
+            ? $countries[$attendee->country_ID()]->get('CNT_name')
369 369
             : $attendee->country_ID();
370 370
         return ! is_numeric($country) ? $country : '';
371 371
     }
Please login to merge, or discard this patch.
admin_pages/registrations/help_tours/Event_Checkin_Help_Tour.class.php 2 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -15,289 +15,289 @@
 block discarded – undo
15 15
 class Event_Checkin_Help_Tour extends EE_Help_Tour
16 16
 {
17 17
 
18
-    protected function _set_tour_properties()
19
-    {
20
-        $this->_label = __('Event Check-in Tour', 'event_espresso');
21
-        if (isset($this->_req_data['event_id'])) {
22
-            $this->_slug = 'event-checkin-overview-joyride';
23
-        } else {
24
-            $this->_slug = 'all-event-checkin-overview-joyride';
25
-        }
26
-    }
18
+	protected function _set_tour_properties()
19
+	{
20
+		$this->_label = __('Event Check-in Tour', 'event_espresso');
21
+		if (isset($this->_req_data['event_id'])) {
22
+			$this->_slug = 'event-checkin-overview-joyride';
23
+		} else {
24
+			$this->_slug = 'all-event-checkin-overview-joyride';
25
+		}
26
+	}
27 27
 
28 28
 
29
-    protected function _set_tour_stops()
30
-    {
31
-        $this->_stops = array(
32
-            10  => array(
33
-                'content' => $this->_start(),
34
-            ),
35
-            20  => array(
36
-                'id'      => '_REG_count',
37
-                'content' => $this->_reg_count_stop(),
38
-                'options' => array(
39
-                    'tipLocation'    => 'top',
40
-                    'tipAdjustmentX' => -5,
41
-                    'tipAdjustmentY' => -20,
42
-                ),
43
-            ),
44
-            30  => array(
45
-                'id'      => 'ATT_name',
46
-                'content' => $this->_attendee_name_stop(),
47
-                'options' => array(
48
-                    'tipLocation'    => 'top',
49
-                    'tipAdjustmentX' => -5,
50
-                    'tipAdjustmentY' => -20,
51
-                ),
52
-            ),
53
-            40  => array(
54
-                'id'      => 'ATT_email',
55
-                'content' => $this->_attendee_email_stop(),
56
-                'options' => array(
57
-                    'tipLocation'    => 'top',
58
-                    'tipAdjustmentX' => -5,
59
-                    'tipAdjustmentY' => -20,
60
-                ),
61
-            ),
62
-            50  => array(
63
-                'id'      => '_REG_date',
64
-                'content' => $this->_reg_date_stop(),
65
-                'options' => array(
66
-                    'tipLocation'    => 'top',
67
-                    'tipAdjustmentX' => -5,
68
-                    'tipAdjustmentY' => -20,
69
-                ),
70
-            ),
71
-            60  => array(
72
-                'id'      => '_REG_code',
73
-                'content' => $this->_reg_code_stop(),
74
-                'options' => array(
75
-                    'tipLocation'    => 'top',
76
-                    'tipAdjustmentX' => -5,
77
-                    'tipAdjustmentY' => -20,
78
-                ),
79
-            ),
80
-            80  => array(
81
-                'id'      => '_REG_final_price',
82
-                'content' => $this->_reg_final_price_stop(),
83
-                'options' => array(
84
-                    'tipLocation'    => 'top',
85
-                    'tipAdjustmentX' => -5,
86
-                    'tipAdjustmentY' => -20,
87
-                ),
88
-            ),
89
-            90  => array(
90
-                'id'      => 'TXN_paid',
91
-                'content' => $this->_txn_paid_stop(),
92
-                'options' => array(
93
-                    'tipLocation'    => 'left',
94
-                    'tipAdjustmentX' => 0,
95
-                    'tipAdjustmentY' => -50,
96
-                ),
97
-            ),
98
-            100 => array(
99
-                'id'      => 'TXN_total',
100
-                'content' => $this->_txn_total_stop(),
101
-                'options' => array(
102
-                    'tipLocation'    => 'left',
103
-                    'tipAdjustmentX' => 0,
104
-                    'tipAdjustmentY' => -50,
105
-                ),
106
-            ),
107
-            110 => array(
108
-                'id'      => 'PRC_name',
109
-                'content' => $this->_prc_name_stop(),
110
-                'options' => array(
111
-                    'tipLocation'    => 'left',
112
-                    'tipAdjustmentX' => 0,
113
-                    'tipAdjustmentY' => -50,
114
-                ),
115
-            ),
116
-            115 => array(
117
-                'id'      => 'actions',
118
-                'content' => $this->_actions_stop(),
119
-                'options' => array(
120
-                    'tipLocation'    => 'left',
121
-                    'tipAdjustmentX' => 0,
122
-                    'tipAdjustmentY' => -30,
123
-                ),
124
-            ),
125
-            120 => array(
126
-                'class'   => 'ee-list-table-legend-container',
127
-                'content' => $this->_legend_stop(),
128
-                'options' => array(
129
-                    'tipLocation'    => 'top',
130
-                    'tipAdjustmentX' => 15,
131
-                    'tipAdjustmentY' => -40,
132
-                ),
133
-            ),
134
-            125 => array(
135
-                'class'   => 'bulkactions',
136
-                'content' => $this->_bulkactions_stop(),
137
-                'options' => array(
138
-                    'tipLocation'    => 'bottom',
139
-                    'tipAdjustmentY' => -30,
140
-                    'tipAdjustmentX' => 15,
141
-                ),
142
-            ),
143
-            130 => array(
144
-                'id'      => 'event_id',
145
-                'content' => $this->_event_selector_stop(),
146
-                'options' => array(
147
-                    'tipLocation'    => 'right',
148
-                    'tipAdjustmentY' => -50,
149
-                    'tipAdjustmentX' => 25,
150
-                ),
151
-            ),
152
-            135 => array(
153
-                'id'      => 'DTT_ID',
154
-                'content' => $this->_dtt_selector_stop(),
155
-                'options' => array(
156
-                    'tipLocation'    => 'bottom',
157
-                    'tipAdjustmentY' => -30,
158
-                    'tipAdjustmentX' => 15,
159
-                ),
160
-            ),
161
-            140 => array(
162
-                'id'      => 'event-espresso_page_espresso_registrations-search-input',
163
-                'content' => $this->_search_stop(),
164
-                'options' => array(
165
-                    'tipLocation'    => 'left',
166
-                    'tipAdjustmentY' => -50,
167
-                    'tipAdjustmentX' => -15,
168
-                ),
169
-            ),
170
-        );
171
-    }
29
+	protected function _set_tour_stops()
30
+	{
31
+		$this->_stops = array(
32
+			10  => array(
33
+				'content' => $this->_start(),
34
+			),
35
+			20  => array(
36
+				'id'      => '_REG_count',
37
+				'content' => $this->_reg_count_stop(),
38
+				'options' => array(
39
+					'tipLocation'    => 'top',
40
+					'tipAdjustmentX' => -5,
41
+					'tipAdjustmentY' => -20,
42
+				),
43
+			),
44
+			30  => array(
45
+				'id'      => 'ATT_name',
46
+				'content' => $this->_attendee_name_stop(),
47
+				'options' => array(
48
+					'tipLocation'    => 'top',
49
+					'tipAdjustmentX' => -5,
50
+					'tipAdjustmentY' => -20,
51
+				),
52
+			),
53
+			40  => array(
54
+				'id'      => 'ATT_email',
55
+				'content' => $this->_attendee_email_stop(),
56
+				'options' => array(
57
+					'tipLocation'    => 'top',
58
+					'tipAdjustmentX' => -5,
59
+					'tipAdjustmentY' => -20,
60
+				),
61
+			),
62
+			50  => array(
63
+				'id'      => '_REG_date',
64
+				'content' => $this->_reg_date_stop(),
65
+				'options' => array(
66
+					'tipLocation'    => 'top',
67
+					'tipAdjustmentX' => -5,
68
+					'tipAdjustmentY' => -20,
69
+				),
70
+			),
71
+			60  => array(
72
+				'id'      => '_REG_code',
73
+				'content' => $this->_reg_code_stop(),
74
+				'options' => array(
75
+					'tipLocation'    => 'top',
76
+					'tipAdjustmentX' => -5,
77
+					'tipAdjustmentY' => -20,
78
+				),
79
+			),
80
+			80  => array(
81
+				'id'      => '_REG_final_price',
82
+				'content' => $this->_reg_final_price_stop(),
83
+				'options' => array(
84
+					'tipLocation'    => 'top',
85
+					'tipAdjustmentX' => -5,
86
+					'tipAdjustmentY' => -20,
87
+				),
88
+			),
89
+			90  => array(
90
+				'id'      => 'TXN_paid',
91
+				'content' => $this->_txn_paid_stop(),
92
+				'options' => array(
93
+					'tipLocation'    => 'left',
94
+					'tipAdjustmentX' => 0,
95
+					'tipAdjustmentY' => -50,
96
+				),
97
+			),
98
+			100 => array(
99
+				'id'      => 'TXN_total',
100
+				'content' => $this->_txn_total_stop(),
101
+				'options' => array(
102
+					'tipLocation'    => 'left',
103
+					'tipAdjustmentX' => 0,
104
+					'tipAdjustmentY' => -50,
105
+				),
106
+			),
107
+			110 => array(
108
+				'id'      => 'PRC_name',
109
+				'content' => $this->_prc_name_stop(),
110
+				'options' => array(
111
+					'tipLocation'    => 'left',
112
+					'tipAdjustmentX' => 0,
113
+					'tipAdjustmentY' => -50,
114
+				),
115
+			),
116
+			115 => array(
117
+				'id'      => 'actions',
118
+				'content' => $this->_actions_stop(),
119
+				'options' => array(
120
+					'tipLocation'    => 'left',
121
+					'tipAdjustmentX' => 0,
122
+					'tipAdjustmentY' => -30,
123
+				),
124
+			),
125
+			120 => array(
126
+				'class'   => 'ee-list-table-legend-container',
127
+				'content' => $this->_legend_stop(),
128
+				'options' => array(
129
+					'tipLocation'    => 'top',
130
+					'tipAdjustmentX' => 15,
131
+					'tipAdjustmentY' => -40,
132
+				),
133
+			),
134
+			125 => array(
135
+				'class'   => 'bulkactions',
136
+				'content' => $this->_bulkactions_stop(),
137
+				'options' => array(
138
+					'tipLocation'    => 'bottom',
139
+					'tipAdjustmentY' => -30,
140
+					'tipAdjustmentX' => 15,
141
+				),
142
+			),
143
+			130 => array(
144
+				'id'      => 'event_id',
145
+				'content' => $this->_event_selector_stop(),
146
+				'options' => array(
147
+					'tipLocation'    => 'right',
148
+					'tipAdjustmentY' => -50,
149
+					'tipAdjustmentX' => 25,
150
+				),
151
+			),
152
+			135 => array(
153
+				'id'      => 'DTT_ID',
154
+				'content' => $this->_dtt_selector_stop(),
155
+				'options' => array(
156
+					'tipLocation'    => 'bottom',
157
+					'tipAdjustmentY' => -30,
158
+					'tipAdjustmentX' => 15,
159
+				),
160
+			),
161
+			140 => array(
162
+				'id'      => 'event-espresso_page_espresso_registrations-search-input',
163
+				'content' => $this->_search_stop(),
164
+				'options' => array(
165
+					'tipLocation'    => 'left',
166
+					'tipAdjustmentY' => -50,
167
+					'tipAdjustmentX' => -15,
168
+				),
169
+			),
170
+		);
171
+	}
172 172
 
173 173
 
174
-    protected function _start()
175
-    {
176
-        $content = '<h3>' . __('Event Check-in', 'event_espresso') . '</h3>';
177
-        if (isset($this->_req_data['event_id'])) {
178
-            $content .= '<p>'
179
-                        . __(
180
-                            'This tour of the Event Check-in page will go over different areas of the screen to help you understand what they are used for.<br /><br /> Note: You are currently viewing the check-in for a specific event so you can toggle the check-in status for attendees.',
181
-                            'event_espresso'
182
-                        ) . '</p>';
183
-        } else {
184
-            $content .= '<p>'
185
-                        . __(
186
-                            'This tour of the event check-in page will go over different areas of the screen to help you understand what they are used for. <br /><br /> Note: You must select an event from the dropdown menu before you can toggle the check-in status for an attendee.',
187
-                            'event_espresso'
188
-                        ) . '</p>';
189
-        }
190
-        return $content;
191
-    }
174
+	protected function _start()
175
+	{
176
+		$content = '<h3>' . __('Event Check-in', 'event_espresso') . '</h3>';
177
+		if (isset($this->_req_data['event_id'])) {
178
+			$content .= '<p>'
179
+						. __(
180
+							'This tour of the Event Check-in page will go over different areas of the screen to help you understand what they are used for.<br /><br /> Note: You are currently viewing the check-in for a specific event so you can toggle the check-in status for attendees.',
181
+							'event_espresso'
182
+						) . '</p>';
183
+		} else {
184
+			$content .= '<p>'
185
+						. __(
186
+							'This tour of the event check-in page will go over different areas of the screen to help you understand what they are used for. <br /><br /> Note: You must select an event from the dropdown menu before you can toggle the check-in status for an attendee.',
187
+							'event_espresso'
188
+						) . '</p>';
189
+		}
190
+		return $content;
191
+	}
192 192
 
193
-    protected function _reg_count_stop()
194
-    {
195
-        return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
196
-    }
193
+	protected function _reg_count_stop()
194
+	{
195
+		return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
196
+	}
197 197
 
198
-    protected function _attendee_name_stop()
199
-    {
200
-        return '<p>'
201
-               . __(
202
-                   'View name of registrant. Can be sorted in ascending or descending order.',
203
-                   'event_espresso'
204
-               ) . '</p>';
205
-    }
198
+	protected function _attendee_name_stop()
199
+	{
200
+		return '<p>'
201
+			   . __(
202
+				   'View name of registrant. Can be sorted in ascending or descending order.',
203
+				   'event_espresso'
204
+			   ) . '</p>';
205
+	}
206 206
 
207
-    protected function _attendee_email_stop()
208
-    {
209
-        return '<p>' . __('View email address for a registrant.', 'event_espresso') . '</p>';
210
-    }
207
+	protected function _attendee_email_stop()
208
+	{
209
+		return '<p>' . __('View email address for a registrant.', 'event_espresso') . '</p>';
210
+	}
211 211
 
212
-    protected function _reg_date_stop()
213
-    {
214
-        return '<p>'
215
-               . __(
216
-                   'View registration date. Can be sorted in ascending or descending order.',
217
-                   'event_espresso'
218
-               ) . '</p>';
219
-    }
212
+	protected function _reg_date_stop()
213
+	{
214
+		return '<p>'
215
+			   . __(
216
+				   'View registration date. Can be sorted in ascending or descending order.',
217
+				   'event_espresso'
218
+			   ) . '</p>';
219
+	}
220 220
 
221
-    protected function _reg_code_stop()
222
-    {
223
-        return '<p>'
224
-               . __(
225
-                   'View registration code. Can be sorted in ascending or descending order.',
226
-                   'event_espresso'
227
-               ) . '</p>';
228
-    }
221
+	protected function _reg_code_stop()
222
+	{
223
+		return '<p>'
224
+			   . __(
225
+				   'View registration code. Can be sorted in ascending or descending order.',
226
+				   'event_espresso'
227
+			   ) . '</p>';
228
+	}
229 229
 
230
-    protected function _reg_final_price_stop()
231
-    {
232
-        return '<p>' . __('View price for ticket.', 'event_espresso') . '</p>';
233
-    }
230
+	protected function _reg_final_price_stop()
231
+	{
232
+		return '<p>' . __('View price for ticket.', 'event_espresso') . '</p>';
233
+	}
234 234
 
235
-    protected function _txn_paid_stop()
236
-    {
237
-        return '<p>' . __('View if registrant has paid for ticket.', 'event_espresso') . '</p>';
238
-    }
235
+	protected function _txn_paid_stop()
236
+	{
237
+		return '<p>' . __('View if registrant has paid for ticket.', 'event_espresso') . '</p>';
238
+	}
239 239
 
240
-    protected function _txn_total_stop()
241
-    {
242
-        return '<p>' . __('View total amount paid.', 'event_espresso') . '</p>';
243
-    }
240
+	protected function _txn_total_stop()
241
+	{
242
+		return '<p>' . __('View total amount paid.', 'event_espresso') . '</p>';
243
+	}
244 244
 
245
-    protected function _prc_name_stop()
246
-    {
247
-        return '<p>' . __('View type of ticket.', 'event_espresso') . '</p>';
248
-    }
245
+	protected function _prc_name_stop()
246
+	{
247
+		return '<p>' . __('View type of ticket.', 'event_espresso') . '</p>';
248
+	}
249 249
 
250
-    protected function _actions_stop()
251
-    {
252
-        return '<p>'
253
-               . __(
254
-                   'Perform an action to a registration. See legend in bottom left corner.',
255
-                   'event_espresso'
256
-               ) . '</p>';
257
-    }
250
+	protected function _actions_stop()
251
+	{
252
+		return '<p>'
253
+			   . __(
254
+				   'Perform an action to a registration. See legend in bottom left corner.',
255
+				   'event_espresso'
256
+			   ) . '</p>';
257
+	}
258 258
 
259
-    protected function _legend_stop()
260
-    {
261
-        return '<p>'
262
-               . __(
263
-                   'This is the legend that describes the different check-in statuses. Also shows available status for registrations.',
264
-                   'event_espresso'
265
-               ) . '</p>';
266
-    }
259
+	protected function _legend_stop()
260
+	{
261
+		return '<p>'
262
+			   . __(
263
+				   'This is the legend that describes the different check-in statuses. Also shows available status for registrations.',
264
+				   'event_espresso'
265
+			   ) . '</p>';
266
+	}
267 267
 
268
-    protected function _bulkactions_stop()
269
-    {
270
-        return '<p>'
271
-               . __(
272
-                   'Perform a bulk action to multiple registrations (only available when viewing check-in for a specific event).',
273
-                   'event_espresso'
274
-               ) . '</p>';
275
-    }
268
+	protected function _bulkactions_stop()
269
+	{
270
+		return '<p>'
271
+			   . __(
272
+				   'Perform a bulk action to multiple registrations (only available when viewing check-in for a specific event).',
273
+				   'event_espresso'
274
+			   ) . '</p>';
275
+	}
276 276
 
277
-    protected function _event_selector_stop()
278
-    {
279
-        return '<p>'
280
-               . __(
281
-                   'Select an event from this dropdown and click the filter button to see the check-in registration list for a specific event. You will then be able to toggle the check-in status for a registration.',
282
-                   'event_espresso'
283
-               ) . '</p>';
284
-    }
277
+	protected function _event_selector_stop()
278
+	{
279
+		return '<p>'
280
+			   . __(
281
+				   'Select an event from this dropdown and click the filter button to see the check-in registration list for a specific event. You will then be able to toggle the check-in status for a registration.',
282
+				   'event_espresso'
283
+			   ) . '</p>';
284
+	}
285 285
 
286
-    protected function _dtt_selector_stop()
287
-    {
288
-        return '<p>'
289
-               . __(
290
-                   'This dropdown shows you the date and time that a displayed registration is attached to. You can switch to a different event by selecting another date and clicking on the filter button. You can also switch out of this view by clicking on the reset filters button.',
291
-                   'event_espresso'
292
-               ) . '</p>';
293
-    }
286
+	protected function _dtt_selector_stop()
287
+	{
288
+		return '<p>'
289
+			   . __(
290
+				   'This dropdown shows you the date and time that a displayed registration is attached to. You can switch to a different event by selecting another date and clicking on the filter button. You can also switch out of this view by clicking on the reset filters button.',
291
+				   'event_espresso'
292
+			   ) . '</p>';
293
+	}
294 294
 
295
-    protected function _search_stop()
296
-    {
297
-        return '<p>'
298
-               . __(
299
-                   'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
300
-                   'event_espresso'
301
-               ) . '</p>';
302
-    }
295
+	protected function _search_stop()
296
+	{
297
+		return '<p>'
298
+			   . __(
299
+				   'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
300
+				   'event_espresso'
301
+			   ) . '</p>';
302
+	}
303 303
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -173,26 +173,26 @@  discard block
 block discarded – undo
173 173
 
174 174
     protected function _start()
175 175
     {
176
-        $content = '<h3>' . __('Event Check-in', 'event_espresso') . '</h3>';
176
+        $content = '<h3>'.__('Event Check-in', 'event_espresso').'</h3>';
177 177
         if (isset($this->_req_data['event_id'])) {
178 178
             $content .= '<p>'
179 179
                         . __(
180 180
                             'This tour of the Event Check-in page will go over different areas of the screen to help you understand what they are used for.<br /><br /> Note: You are currently viewing the check-in for a specific event so you can toggle the check-in status for attendees.',
181 181
                             'event_espresso'
182
-                        ) . '</p>';
182
+                        ).'</p>';
183 183
         } else {
184 184
             $content .= '<p>'
185 185
                         . __(
186 186
                             'This tour of the event check-in page will go over different areas of the screen to help you understand what they are used for. <br /><br /> Note: You must select an event from the dropdown menu before you can toggle the check-in status for an attendee.',
187 187
                             'event_espresso'
188
-                        ) . '</p>';
188
+                        ).'</p>';
189 189
         }
190 190
         return $content;
191 191
     }
192 192
 
193 193
     protected function _reg_count_stop()
194 194
     {
195
-        return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
195
+        return '<p>'.__('View registration number.', 'event_espresso').'</p>';
196 196
     }
197 197
 
198 198
     protected function _attendee_name_stop()
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
                . __(
202 202
                    'View name of registrant. Can be sorted in ascending or descending order.',
203 203
                    'event_espresso'
204
-               ) . '</p>';
204
+               ).'</p>';
205 205
     }
206 206
 
207 207
     protected function _attendee_email_stop()
208 208
     {
209
-        return '<p>' . __('View email address for a registrant.', 'event_espresso') . '</p>';
209
+        return '<p>'.__('View email address for a registrant.', 'event_espresso').'</p>';
210 210
     }
211 211
 
212 212
     protected function _reg_date_stop()
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                . __(
216 216
                    'View registration date. Can be sorted in ascending or descending order.',
217 217
                    'event_espresso'
218
-               ) . '</p>';
218
+               ).'</p>';
219 219
     }
220 220
 
221 221
     protected function _reg_code_stop()
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
                . __(
225 225
                    'View registration code. Can be sorted in ascending or descending order.',
226 226
                    'event_espresso'
227
-               ) . '</p>';
227
+               ).'</p>';
228 228
     }
229 229
 
230 230
     protected function _reg_final_price_stop()
231 231
     {
232
-        return '<p>' . __('View price for ticket.', 'event_espresso') . '</p>';
232
+        return '<p>'.__('View price for ticket.', 'event_espresso').'</p>';
233 233
     }
234 234
 
235 235
     protected function _txn_paid_stop()
236 236
     {
237
-        return '<p>' . __('View if registrant has paid for ticket.', 'event_espresso') . '</p>';
237
+        return '<p>'.__('View if registrant has paid for ticket.', 'event_espresso').'</p>';
238 238
     }
239 239
 
240 240
     protected function _txn_total_stop()
241 241
     {
242
-        return '<p>' . __('View total amount paid.', 'event_espresso') . '</p>';
242
+        return '<p>'.__('View total amount paid.', 'event_espresso').'</p>';
243 243
     }
244 244
 
245 245
     protected function _prc_name_stop()
246 246
     {
247
-        return '<p>' . __('View type of ticket.', 'event_espresso') . '</p>';
247
+        return '<p>'.__('View type of ticket.', 'event_espresso').'</p>';
248 248
     }
249 249
 
250 250
     protected function _actions_stop()
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                . __(
254 254
                    'Perform an action to a registration. See legend in bottom left corner.',
255 255
                    'event_espresso'
256
-               ) . '</p>';
256
+               ).'</p>';
257 257
     }
258 258
 
259 259
     protected function _legend_stop()
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                . __(
263 263
                    'This is the legend that describes the different check-in statuses. Also shows available status for registrations.',
264 264
                    'event_espresso'
265
-               ) . '</p>';
265
+               ).'</p>';
266 266
     }
267 267
 
268 268
     protected function _bulkactions_stop()
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                . __(
272 272
                    'Perform a bulk action to multiple registrations (only available when viewing check-in for a specific event).',
273 273
                    'event_espresso'
274
-               ) . '</p>';
274
+               ).'</p>';
275 275
     }
276 276
 
277 277
     protected function _event_selector_stop()
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                . __(
281 281
                    'Select an event from this dropdown and click the filter button to see the check-in registration list for a specific event. You will then be able to toggle the check-in status for a registration.',
282 282
                    'event_espresso'
283
-               ) . '</p>';
283
+               ).'</p>';
284 284
     }
285 285
 
286 286
     protected function _dtt_selector_stop()
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                . __(
290 290
                    'This dropdown shows you the date and time that a displayed registration is attached to. You can switch to a different event by selecting another date and clicking on the filter button. You can also switch out of this view by clicking on the reset filters button.',
291 291
                    'event_espresso'
292
-               ) . '</p>';
292
+               ).'</p>';
293 293
     }
294 294
 
295 295
     protected function _search_stop()
@@ -298,6 +298,6 @@  discard block
 block discarded – undo
298 298
                . __(
299 299
                    'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
300 300
                    'event_espresso'
301
-               ) . '</p>';
301
+               ).'</p>';
302 302
     }
303 303
 }
Please login to merge, or discard this patch.
admin_pages/registrations/help_tours/Contact_List_Help_Tour.class.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -15,227 +15,227 @@
 block discarded – undo
15 15
 class Contact_List_Help_Tour extends EE_Help_Tour
16 16
 {
17 17
 
18
-    protected function _set_tour_properties()
19
-    {
20
-        $this->_label = __('Contact List Tour', 'event_espresso');
21
-        $this->_slug = 'contact-list-overview-joyride';
22
-    }
23
-
24
-
25
-    protected function _set_tour_stops()
26
-    {
27
-        $this->_stops = array(
28
-            10  => array(
29
-                'content' => $this->_start(),
30
-            ),
31
-            15  => array(
32
-                'id'      => 'ATT_ID',
33
-                'content' => $this->_attendee_id_stop(),
34
-                'options' => array(
35
-                    'tipLocation'    => 'top',
36
-                    'tipAdjustmentX' => -20,
37
-                    'tipAdjustmentY' => -30,
38
-                ),
39
-            ),
40
-            20  => array(
41
-                'id'      => 'ATT_fname',
42
-                'content' => $this->_attendee_name_stop(),
43
-                'options' => array(
44
-                    'tipLocation'    => 'top',
45
-                    'tipAdjustmentX' => 5,
46
-                    'tipAdjustmentY' => -30,
47
-                ),
48
-            ),
49
-            30  => array(
50
-                'id'      => 'ATT_lname',
51
-                'content' => $this->_att_lname_stop(),
52
-                'options' => array(
53
-                    'tipLocation'    => 'top',
54
-                    'tipAdjustmentX' => 5,
55
-                    'tipAdjustmentY' => -30,
56
-                ),
57
-            ),
58
-            40  => array(
59
-                'id'      => 'ATT_email',
60
-                'content' => $this->_att_email_stop(),
61
-                'options' => array(
62
-                    'tipLocation'    => 'top',
63
-                    'tipAdjustmentX' => 10,
64
-                    'tipAdjustmentY' => -30,
65
-                ),
66
-            ),
67
-            50  => array(
68
-                'id'      => 'ATT_phone',
69
-                'content' => $this->_att_phone_stop(),
70
-                'options' => array(
71
-                    'tipLocation'    => 'top',
72
-                    'tipAdjustmentX' => -5,
73
-                    'tipAdjustmentY' => -30,
74
-                ),
75
-            ),
76
-            60  => array(
77
-                'id'      => 'ATT_address',
78
-                'content' => $this->_att_address_stop(),
79
-                'options' => array(
80
-                    'tipLocation'    => 'top',
81
-                    'tipAdjustmentX' => 0,
82
-                    'tipAdjustmentY' => -30,
83
-                ),
84
-            ),
85
-            70  => array(
86
-                'id'      => 'ATT_city',
87
-                'content' => $this->_att_city_stop(),
88
-                'options' => array(
89
-                    'tipLocation'    => 'left',
90
-                    'tipAdjustmentX' => 0,
91
-                    'tipAdjustmentY' => -50,
92
-                ),
93
-            ),
94
-            80  => array(
95
-                'id'      => 'STA_ID',
96
-                'content' => $this->_sta_id_stop(),
97
-                'options' => array(
98
-                    'tipLocation'    => 'left',
99
-                    'tipAdjustmentX' => 0,
100
-                    'tipAdjustmentY' => -50,
101
-                ),
102
-            ),
103
-            90  => array(
104
-                'id'      => 'CNT_ISO',
105
-                'content' => $this->_cnt_iso_stop(),
106
-                'options' => array(
107
-                    'tipLocation'    => 'left',
108
-                    'tipAdjustmentX' => 0,
109
-                    'tipAdjustmentY' => -50,
110
-                ),
111
-            ),
112
-            100 => array(
113
-                'class'   => 'bulkactions',
114
-                'content' => $this->_bulkactions_stop(),
115
-                'options' => array(
116
-                    'tipLocation'    => 'bottom',
117
-                    'tipAdjustmentY' => -30,
118
-                    'tipAdjustmentX' => 15,
119
-                ),
120
-            ),
121
-            110 => array(
122
-                'id'      => 'event-espresso_page_espresso_registrations-search-input',
123
-                'content' => $this->_search_stop(),
124
-                'options' => array(
125
-                    'tipLocation'    => 'left',
126
-                    'tipAdjustmentY' => -50,
127
-                    'tipAdjustmentX' => -15,
128
-                ),
129
-            ),
130
-            120 => array(
131
-                'id'      => 'contact-list-csv-export',
132
-                'content' => $this->_contact_list_csv_export_stop(),
133
-                'options' => array(
134
-                    'tipLocation'    => 'right',
135
-                    'tipAdjustmentY' => -50,
136
-                    'tipAdjustmentX' => 25,
137
-                ),
138
-            ),
139
-        );
140
-    }
141
-
142
-
143
-    protected function _start()
144
-    {
145
-        $content = '<h3>' . __('Contact List', 'event_espresso') . '</h3>';
146
-        $content .= '<p>'
147
-                    . __(
148
-                        'This tour of the Contact List page will go over different areas of the screen to help you understand what they are used for.',
149
-                        'event_espresso'
150
-                    ) . '</p>';
151
-        return $content;
152
-    }
153
-
154
-    protected function _attendee_id_stop()
155
-    {
156
-        return '<p>'
157
-               . __(
158
-                   'View ID for registrants. Can be sorted in ascending or descending order.',
159
-                   'event_espresso'
160
-               ) . '</p>';
161
-    }
162
-
163
-    protected function _attendee_name_stop()
164
-    {
165
-        return '<p>'
166
-               . __(
167
-                   'View first name for registrants. Can be sorted in ascending or descending order.',
168
-                   'event_espresso'
169
-               ) . '</p>';
170
-    }
171
-
172
-    protected function _att_lname_stop()
173
-    {
174
-        return '<p>'
175
-               . __(
176
-                   'View last name for registrants. Can be sorted in ascending or descending order.',
177
-                   'event_espresso'
178
-               ) . '</p>';
179
-    }
180
-
181
-    protected function _att_email_stop()
182
-    {
183
-        return '<p>'
184
-               . __(
185
-                   'View email address for registrants. Can be sorted in ascending or descending order.',
186
-                   'event_espresso'
187
-               ) . '</p>';
188
-    }
189
-
190
-    protected function _att_phone_stop()
191
-    {
192
-        return '<p>' . __('View phone number for registrants.', 'event_espresso') . '</p>';
193
-    }
194
-
195
-    protected function _att_address_stop()
196
-    {
197
-        return '<p>' . __('View address for registrants.', 'event_espresso') . '</p>';
198
-    }
199
-
200
-    protected function _att_city_stop()
201
-    {
202
-        return '<p>' . __('View city for registrants.', 'event_espresso') . '</p>';
203
-    }
204
-
205
-    protected function _sta_id_stop()
206
-    {
207
-        return '<p>'
208
-               . __(
209
-                   'View state/province for registrants. Can be sorted in ascending or descending order.',
210
-                   'event_espresso'
211
-               ) . '</p>';
212
-    }
213
-
214
-    protected function _cnt_iso_stop()
215
-    {
216
-        return '<p>'
217
-               . __(
218
-                   'View country for registrants. Can be sorted in ascending or descending order.',
219
-                   'event_espresso'
220
-               ) . '</p>';
221
-    }
222
-
223
-    protected function _bulkactions_stop()
224
-    {
225
-        return '<p>' . __('Perform a bulk action to multiple registrants.', 'event_espresso') . '</p>';
226
-    }
227
-
228
-    protected function _search_stop()
229
-    {
230
-        return '<p>'
231
-               . __(
232
-                   'Search through contacts. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, and Registration Code.',
233
-                   'event_espresso'
234
-               ) . '</p>';
235
-    }
236
-
237
-    protected function _contact_list_csv_export_stop()
238
-    {
239
-        return '<p>' . __('Export your contact list to a CSV file.', 'event_espresso') . '</p>';
240
-    }
18
+	protected function _set_tour_properties()
19
+	{
20
+		$this->_label = __('Contact List Tour', 'event_espresso');
21
+		$this->_slug = 'contact-list-overview-joyride';
22
+	}
23
+
24
+
25
+	protected function _set_tour_stops()
26
+	{
27
+		$this->_stops = array(
28
+			10  => array(
29
+				'content' => $this->_start(),
30
+			),
31
+			15  => array(
32
+				'id'      => 'ATT_ID',
33
+				'content' => $this->_attendee_id_stop(),
34
+				'options' => array(
35
+					'tipLocation'    => 'top',
36
+					'tipAdjustmentX' => -20,
37
+					'tipAdjustmentY' => -30,
38
+				),
39
+			),
40
+			20  => array(
41
+				'id'      => 'ATT_fname',
42
+				'content' => $this->_attendee_name_stop(),
43
+				'options' => array(
44
+					'tipLocation'    => 'top',
45
+					'tipAdjustmentX' => 5,
46
+					'tipAdjustmentY' => -30,
47
+				),
48
+			),
49
+			30  => array(
50
+				'id'      => 'ATT_lname',
51
+				'content' => $this->_att_lname_stop(),
52
+				'options' => array(
53
+					'tipLocation'    => 'top',
54
+					'tipAdjustmentX' => 5,
55
+					'tipAdjustmentY' => -30,
56
+				),
57
+			),
58
+			40  => array(
59
+				'id'      => 'ATT_email',
60
+				'content' => $this->_att_email_stop(),
61
+				'options' => array(
62
+					'tipLocation'    => 'top',
63
+					'tipAdjustmentX' => 10,
64
+					'tipAdjustmentY' => -30,
65
+				),
66
+			),
67
+			50  => array(
68
+				'id'      => 'ATT_phone',
69
+				'content' => $this->_att_phone_stop(),
70
+				'options' => array(
71
+					'tipLocation'    => 'top',
72
+					'tipAdjustmentX' => -5,
73
+					'tipAdjustmentY' => -30,
74
+				),
75
+			),
76
+			60  => array(
77
+				'id'      => 'ATT_address',
78
+				'content' => $this->_att_address_stop(),
79
+				'options' => array(
80
+					'tipLocation'    => 'top',
81
+					'tipAdjustmentX' => 0,
82
+					'tipAdjustmentY' => -30,
83
+				),
84
+			),
85
+			70  => array(
86
+				'id'      => 'ATT_city',
87
+				'content' => $this->_att_city_stop(),
88
+				'options' => array(
89
+					'tipLocation'    => 'left',
90
+					'tipAdjustmentX' => 0,
91
+					'tipAdjustmentY' => -50,
92
+				),
93
+			),
94
+			80  => array(
95
+				'id'      => 'STA_ID',
96
+				'content' => $this->_sta_id_stop(),
97
+				'options' => array(
98
+					'tipLocation'    => 'left',
99
+					'tipAdjustmentX' => 0,
100
+					'tipAdjustmentY' => -50,
101
+				),
102
+			),
103
+			90  => array(
104
+				'id'      => 'CNT_ISO',
105
+				'content' => $this->_cnt_iso_stop(),
106
+				'options' => array(
107
+					'tipLocation'    => 'left',
108
+					'tipAdjustmentX' => 0,
109
+					'tipAdjustmentY' => -50,
110
+				),
111
+			),
112
+			100 => array(
113
+				'class'   => 'bulkactions',
114
+				'content' => $this->_bulkactions_stop(),
115
+				'options' => array(
116
+					'tipLocation'    => 'bottom',
117
+					'tipAdjustmentY' => -30,
118
+					'tipAdjustmentX' => 15,
119
+				),
120
+			),
121
+			110 => array(
122
+				'id'      => 'event-espresso_page_espresso_registrations-search-input',
123
+				'content' => $this->_search_stop(),
124
+				'options' => array(
125
+					'tipLocation'    => 'left',
126
+					'tipAdjustmentY' => -50,
127
+					'tipAdjustmentX' => -15,
128
+				),
129
+			),
130
+			120 => array(
131
+				'id'      => 'contact-list-csv-export',
132
+				'content' => $this->_contact_list_csv_export_stop(),
133
+				'options' => array(
134
+					'tipLocation'    => 'right',
135
+					'tipAdjustmentY' => -50,
136
+					'tipAdjustmentX' => 25,
137
+				),
138
+			),
139
+		);
140
+	}
141
+
142
+
143
+	protected function _start()
144
+	{
145
+		$content = '<h3>' . __('Contact List', 'event_espresso') . '</h3>';
146
+		$content .= '<p>'
147
+					. __(
148
+						'This tour of the Contact List page will go over different areas of the screen to help you understand what they are used for.',
149
+						'event_espresso'
150
+					) . '</p>';
151
+		return $content;
152
+	}
153
+
154
+	protected function _attendee_id_stop()
155
+	{
156
+		return '<p>'
157
+			   . __(
158
+				   'View ID for registrants. Can be sorted in ascending or descending order.',
159
+				   'event_espresso'
160
+			   ) . '</p>';
161
+	}
162
+
163
+	protected function _attendee_name_stop()
164
+	{
165
+		return '<p>'
166
+			   . __(
167
+				   'View first name for registrants. Can be sorted in ascending or descending order.',
168
+				   'event_espresso'
169
+			   ) . '</p>';
170
+	}
171
+
172
+	protected function _att_lname_stop()
173
+	{
174
+		return '<p>'
175
+			   . __(
176
+				   'View last name for registrants. Can be sorted in ascending or descending order.',
177
+				   'event_espresso'
178
+			   ) . '</p>';
179
+	}
180
+
181
+	protected function _att_email_stop()
182
+	{
183
+		return '<p>'
184
+			   . __(
185
+				   'View email address for registrants. Can be sorted in ascending or descending order.',
186
+				   'event_espresso'
187
+			   ) . '</p>';
188
+	}
189
+
190
+	protected function _att_phone_stop()
191
+	{
192
+		return '<p>' . __('View phone number for registrants.', 'event_espresso') . '</p>';
193
+	}
194
+
195
+	protected function _att_address_stop()
196
+	{
197
+		return '<p>' . __('View address for registrants.', 'event_espresso') . '</p>';
198
+	}
199
+
200
+	protected function _att_city_stop()
201
+	{
202
+		return '<p>' . __('View city for registrants.', 'event_espresso') . '</p>';
203
+	}
204
+
205
+	protected function _sta_id_stop()
206
+	{
207
+		return '<p>'
208
+			   . __(
209
+				   'View state/province for registrants. Can be sorted in ascending or descending order.',
210
+				   'event_espresso'
211
+			   ) . '</p>';
212
+	}
213
+
214
+	protected function _cnt_iso_stop()
215
+	{
216
+		return '<p>'
217
+			   . __(
218
+				   'View country for registrants. Can be sorted in ascending or descending order.',
219
+				   'event_espresso'
220
+			   ) . '</p>';
221
+	}
222
+
223
+	protected function _bulkactions_stop()
224
+	{
225
+		return '<p>' . __('Perform a bulk action to multiple registrants.', 'event_espresso') . '</p>';
226
+	}
227
+
228
+	protected function _search_stop()
229
+	{
230
+		return '<p>'
231
+			   . __(
232
+				   'Search through contacts. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, and Registration Code.',
233
+				   'event_espresso'
234
+			   ) . '</p>';
235
+	}
236
+
237
+	protected function _contact_list_csv_export_stop()
238
+	{
239
+		return '<p>' . __('Export your contact list to a CSV file.', 'event_espresso') . '</p>';
240
+	}
241 241
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 
143 143
     protected function _start()
144 144
     {
145
-        $content = '<h3>' . __('Contact List', 'event_espresso') . '</h3>';
145
+        $content = '<h3>'.__('Contact List', 'event_espresso').'</h3>';
146 146
         $content .= '<p>'
147 147
                     . __(
148 148
                         'This tour of the Contact List page will go over different areas of the screen to help you understand what they are used for.',
149 149
                         'event_espresso'
150
-                    ) . '</p>';
150
+                    ).'</p>';
151 151
         return $content;
152 152
     }
153 153
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                . __(
158 158
                    'View ID for registrants. Can be sorted in ascending or descending order.',
159 159
                    'event_espresso'
160
-               ) . '</p>';
160
+               ).'</p>';
161 161
     }
162 162
 
163 163
     protected function _attendee_name_stop()
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                . __(
167 167
                    'View first name for registrants. Can be sorted in ascending or descending order.',
168 168
                    'event_espresso'
169
-               ) . '</p>';
169
+               ).'</p>';
170 170
     }
171 171
 
172 172
     protected function _att_lname_stop()
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
                . __(
176 176
                    'View last name for registrants. Can be sorted in ascending or descending order.',
177 177
                    'event_espresso'
178
-               ) . '</p>';
178
+               ).'</p>';
179 179
     }
180 180
 
181 181
     protected function _att_email_stop()
@@ -184,22 +184,22 @@  discard block
 block discarded – undo
184 184
                . __(
185 185
                    'View email address for registrants. Can be sorted in ascending or descending order.',
186 186
                    'event_espresso'
187
-               ) . '</p>';
187
+               ).'</p>';
188 188
     }
189 189
 
190 190
     protected function _att_phone_stop()
191 191
     {
192
-        return '<p>' . __('View phone number for registrants.', 'event_espresso') . '</p>';
192
+        return '<p>'.__('View phone number for registrants.', 'event_espresso').'</p>';
193 193
     }
194 194
 
195 195
     protected function _att_address_stop()
196 196
     {
197
-        return '<p>' . __('View address for registrants.', 'event_espresso') . '</p>';
197
+        return '<p>'.__('View address for registrants.', 'event_espresso').'</p>';
198 198
     }
199 199
 
200 200
     protected function _att_city_stop()
201 201
     {
202
-        return '<p>' . __('View city for registrants.', 'event_espresso') . '</p>';
202
+        return '<p>'.__('View city for registrants.', 'event_espresso').'</p>';
203 203
     }
204 204
 
205 205
     protected function _sta_id_stop()
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
                . __(
209 209
                    'View state/province for registrants. Can be sorted in ascending or descending order.',
210 210
                    'event_espresso'
211
-               ) . '</p>';
211
+               ).'</p>';
212 212
     }
213 213
 
214 214
     protected function _cnt_iso_stop()
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
                . __(
218 218
                    'View country for registrants. Can be sorted in ascending or descending order.',
219 219
                    'event_espresso'
220
-               ) . '</p>';
220
+               ).'</p>';
221 221
     }
222 222
 
223 223
     protected function _bulkactions_stop()
224 224
     {
225
-        return '<p>' . __('Perform a bulk action to multiple registrants.', 'event_espresso') . '</p>';
225
+        return '<p>'.__('Perform a bulk action to multiple registrants.', 'event_espresso').'</p>';
226 226
     }
227 227
 
228 228
     protected function _search_stop()
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
                . __(
232 232
                    'Search through contacts. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, and Registration Code.',
233 233
                    'event_espresso'
234
-               ) . '</p>';
234
+               ).'</p>';
235 235
     }
236 236
 
237 237
     protected function _contact_list_csv_export_stop()
238 238
     {
239
-        return '<p>' . __('Export your contact list to a CSV file.', 'event_espresso') . '</p>';
239
+        return '<p>'.__('Export your contact list to a CSV file.', 'event_espresso').'</p>';
240 240
     }
241 241
 }
Please login to merge, or discard this patch.
registrations/help_tours/Registration_Overview_Help_Tour.class.php 2 patches
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -15,275 +15,275 @@
 block discarded – undo
15 15
 class Registration_Overview_Help_Tour extends EE_Help_Tour
16 16
 {
17 17
 
18
-    protected function _set_tour_properties()
19
-    {
20
-        $this->_label = __('Registrations Overview Tour', 'event_espresso');
21
-        if (isset($this->_req_data['event_id'])) {
22
-            $this->_slug = 'registration-per-event-overview-joyride';
23
-        } else {
24
-            $this->_slug = 'registration-overview-joyride';
25
-        }
26
-    }
18
+	protected function _set_tour_properties()
19
+	{
20
+		$this->_label = __('Registrations Overview Tour', 'event_espresso');
21
+		if (isset($this->_req_data['event_id'])) {
22
+			$this->_slug = 'registration-per-event-overview-joyride';
23
+		} else {
24
+			$this->_slug = 'registration-overview-joyride';
25
+		}
26
+	}
27 27
 
28 28
 
29
-    protected function _set_tour_stops()
30
-    {
31
-        $this->_stops = array(
32
-            10  => array(
33
-                'content' => $this->_start(),
34
-            ),
35
-            20  => array(
36
-                'id'      => '_REG_ID',
37
-                'content' => $this->_reg_id_stop(),
38
-                'options' => array(
39
-                    'tipLocation'    => 'top',
40
-                    'tipAdjustmentX' => -20,
41
-                    'tipAdjustmentY' => -30,
42
-                ),
43
-            ),
44
-            30  => array(
45
-                'id'      => '_REG_count',
46
-                'content' => $this->_reg_count_stop(),
47
-                'options' => array(
48
-                    'tipLocation'    => 'top',
49
-                    'tipAdjustmentX' => -5,
50
-                    'tipAdjustmentY' => -30,
51
-                ),
52
-            ),
53
-            40  => array(
54
-                'id'      => 'ATT_fname',
55
-                'content' => $this->_attendee_name_stop(),
56
-                'options' => array(
57
-                    'tipLocation'    => 'top',
58
-                    'tipAdjustmentX' => -5,
59
-                    'tipAdjustmentY' => -30,
60
-                ),
61
-            ),
62
-            50  => array(
63
-                'id'      => '_REG_date',
64
-                'content' => $this->_reg_date_stop(),
65
-                'options' => array(
66
-                    'tipLocation'    => 'top',
67
-                    'tipAdjustmentX' => 5,
68
-                    'tipAdjustmentY' => -30,
69
-                ),
70
-            ),
71
-            60  => array(
72
-                'id'      => 'event_name',
73
-                'content' => $this->_event_name_stop(),
74
-                'options' => array(
75
-                    'tipLocation'    => 'top',
76
-                    'tipAdjustmentX' => -5,
77
-                    'tipAdjustmentY' => -30,
78
-                ),
79
-            ),
80
-            70  => array(
81
-                'id'      => 'DTT_EVT_start',
82
-                'content' => $this->_dtt_evt_start_stop(),
83
-                'options' => array(
84
-                    'tipLocation'    => 'top',
85
-                    'tipAdjustmentX' => 5,
86
-                    'tipAdjustmentY' => -30,
87
-                ),
88
-            ),
89
-            80  => array(
90
-                'id'      => '_REG_code',
91
-                'content' => $this->_reg_code_stop(),
92
-                'options' => array(
93
-                    'tipLocation'    => 'top',
94
-                    'tipAdjustmentX' => 0,
95
-                    'tipAdjustmentY' => -30,
96
-                ),
97
-            ),
98
-            90  => array(
99
-                'id'      => '_REG_final_price',
100
-                'content' => $this->_txn_total_stop(),
101
-                'options' => array(
102
-                    'tipLocation'    => 'left',
103
-                    'tipAdjustmentX' => 5,
104
-                    'tipAdjustmentY' => -50,
105
-                ),
106
-            ),
107
-            100 => array(
108
-                'id'      => 'actions',
109
-                'content' => $this->_actions_stop(),
110
-                'options' => array(
111
-                    'tipLocation'    => 'left',
112
-                    'tipAdjustmentX' => 0,
113
-                    'tipAdjustmentY' => -50,
114
-                ),
115
-            ),
116
-            110 => array(
117
-                'class'   => 'ee-list-table-legend-container',
118
-                'content' => $this->_legend_stop(),
119
-                'options' => array(
120
-                    'tipLocation'    => 'right',
121
-                    'tipAdjustmentX' => 15,
122
-                    'tipAdjustmentY' => -40,
123
-                ),
124
-            ),
125
-            120 => array(
126
-                'class'   => 'subsubsub',
127
-                'content' => $this->_views_stop(),
128
-                'options' => array(
129
-                    'tipLocation'    => 'right',
130
-                    'tipAdjustmentY' => -50,
131
-                    'tipAdjustmentX' => 15,
132
-                ),
133
-            ),
134
-            130 => array(
135
-                'class'   => 'bulkactions',
136
-                'content' => $this->_bulkactions_stop(),
137
-                'options' => array(
138
-                    'tipLocation'    => 'bottom',
139
-                    'tipAdjustmentY' => -30,
140
-                    'tipAdjustmentX' => 15,
141
-                ),
142
-            ),
143
-            140 => array(
144
-                'id'      => 'EVT_CAT',
145
-                'content' => $this->_stop_about_filters(),
146
-                'options' => array(
147
-                    'tipLocation'    => 'top',
148
-                    'tipAdjustmentY' => -40,
149
-                    'tipAdjustmentX' => 25,
150
-                ),
151
-            ),
152
-            150 => array(
153
-                'id'      => 'event-espresso_page_espresso_registrations-search-input',
154
-                'content' => $this->_search_stop(),
155
-                'options' => array(
156
-                    'tipLocation'    => 'left',
157
-                    'tipAdjustmentY' => -50,
158
-                    'tipAdjustmentX' => -15,
159
-                ),
160
-            ),
161
-        );
162
-    }
29
+	protected function _set_tour_stops()
30
+	{
31
+		$this->_stops = array(
32
+			10  => array(
33
+				'content' => $this->_start(),
34
+			),
35
+			20  => array(
36
+				'id'      => '_REG_ID',
37
+				'content' => $this->_reg_id_stop(),
38
+				'options' => array(
39
+					'tipLocation'    => 'top',
40
+					'tipAdjustmentX' => -20,
41
+					'tipAdjustmentY' => -30,
42
+				),
43
+			),
44
+			30  => array(
45
+				'id'      => '_REG_count',
46
+				'content' => $this->_reg_count_stop(),
47
+				'options' => array(
48
+					'tipLocation'    => 'top',
49
+					'tipAdjustmentX' => -5,
50
+					'tipAdjustmentY' => -30,
51
+				),
52
+			),
53
+			40  => array(
54
+				'id'      => 'ATT_fname',
55
+				'content' => $this->_attendee_name_stop(),
56
+				'options' => array(
57
+					'tipLocation'    => 'top',
58
+					'tipAdjustmentX' => -5,
59
+					'tipAdjustmentY' => -30,
60
+				),
61
+			),
62
+			50  => array(
63
+				'id'      => '_REG_date',
64
+				'content' => $this->_reg_date_stop(),
65
+				'options' => array(
66
+					'tipLocation'    => 'top',
67
+					'tipAdjustmentX' => 5,
68
+					'tipAdjustmentY' => -30,
69
+				),
70
+			),
71
+			60  => array(
72
+				'id'      => 'event_name',
73
+				'content' => $this->_event_name_stop(),
74
+				'options' => array(
75
+					'tipLocation'    => 'top',
76
+					'tipAdjustmentX' => -5,
77
+					'tipAdjustmentY' => -30,
78
+				),
79
+			),
80
+			70  => array(
81
+				'id'      => 'DTT_EVT_start',
82
+				'content' => $this->_dtt_evt_start_stop(),
83
+				'options' => array(
84
+					'tipLocation'    => 'top',
85
+					'tipAdjustmentX' => 5,
86
+					'tipAdjustmentY' => -30,
87
+				),
88
+			),
89
+			80  => array(
90
+				'id'      => '_REG_code',
91
+				'content' => $this->_reg_code_stop(),
92
+				'options' => array(
93
+					'tipLocation'    => 'top',
94
+					'tipAdjustmentX' => 0,
95
+					'tipAdjustmentY' => -30,
96
+				),
97
+			),
98
+			90  => array(
99
+				'id'      => '_REG_final_price',
100
+				'content' => $this->_txn_total_stop(),
101
+				'options' => array(
102
+					'tipLocation'    => 'left',
103
+					'tipAdjustmentX' => 5,
104
+					'tipAdjustmentY' => -50,
105
+				),
106
+			),
107
+			100 => array(
108
+				'id'      => 'actions',
109
+				'content' => $this->_actions_stop(),
110
+				'options' => array(
111
+					'tipLocation'    => 'left',
112
+					'tipAdjustmentX' => 0,
113
+					'tipAdjustmentY' => -50,
114
+				),
115
+			),
116
+			110 => array(
117
+				'class'   => 'ee-list-table-legend-container',
118
+				'content' => $this->_legend_stop(),
119
+				'options' => array(
120
+					'tipLocation'    => 'right',
121
+					'tipAdjustmentX' => 15,
122
+					'tipAdjustmentY' => -40,
123
+				),
124
+			),
125
+			120 => array(
126
+				'class'   => 'subsubsub',
127
+				'content' => $this->_views_stop(),
128
+				'options' => array(
129
+					'tipLocation'    => 'right',
130
+					'tipAdjustmentY' => -50,
131
+					'tipAdjustmentX' => 15,
132
+				),
133
+			),
134
+			130 => array(
135
+				'class'   => 'bulkactions',
136
+				'content' => $this->_bulkactions_stop(),
137
+				'options' => array(
138
+					'tipLocation'    => 'bottom',
139
+					'tipAdjustmentY' => -30,
140
+					'tipAdjustmentX' => 15,
141
+				),
142
+			),
143
+			140 => array(
144
+				'id'      => 'EVT_CAT',
145
+				'content' => $this->_stop_about_filters(),
146
+				'options' => array(
147
+					'tipLocation'    => 'top',
148
+					'tipAdjustmentY' => -40,
149
+					'tipAdjustmentX' => 25,
150
+				),
151
+			),
152
+			150 => array(
153
+				'id'      => 'event-espresso_page_espresso_registrations-search-input',
154
+				'content' => $this->_search_stop(),
155
+				'options' => array(
156
+					'tipLocation'    => 'left',
157
+					'tipAdjustmentY' => -50,
158
+					'tipAdjustmentX' => -15,
159
+				),
160
+			),
161
+		);
162
+	}
163 163
 
164 164
 
165
-    protected function _start()
166
-    {
167
-        $content = '<h3>' . __('Registration Overview', 'event_espresso') . '</h3>';
168
-        if (isset($this->_req_data['event_id'])) {
169
-            $content .= '<p>'
170
-                        . __(
171
-                            'An introduction to the Registration Overview page for a single event. This view is pretty much the same as the default overview registration page except you are only seeing registrations for a specific event.  There are also some changes to the available columns in this view.',
172
-                            'event_espresso'
173
-                        ) . '</p>';
174
-        } else {
175
-            $content .= '<p>'
176
-                        . __(
177
-                            'This tour of the Registration Overview page will go over different areas of the screen to help you understand what they are used for.',
178
-                            'event_espresso'
179
-                        ) . '</p>';
180
-        }
181
-        return $content;
182
-    }
165
+	protected function _start()
166
+	{
167
+		$content = '<h3>' . __('Registration Overview', 'event_espresso') . '</h3>';
168
+		if (isset($this->_req_data['event_id'])) {
169
+			$content .= '<p>'
170
+						. __(
171
+							'An introduction to the Registration Overview page for a single event. This view is pretty much the same as the default overview registration page except you are only seeing registrations for a specific event.  There are also some changes to the available columns in this view.',
172
+							'event_espresso'
173
+						) . '</p>';
174
+		} else {
175
+			$content .= '<p>'
176
+						. __(
177
+							'This tour of the Registration Overview page will go over different areas of the screen to help you understand what they are used for.',
178
+							'event_espresso'
179
+						) . '</p>';
180
+		}
181
+		return $content;
182
+	}
183 183
 
184
-    protected function _reg_id_stop()
185
-    {
186
-        return '<p>'
187
-               . __(
188
-                   'View the registration ID. Can be sorted in ascending or descending order.',
189
-                   'event_espresso'
190
-               ) . '</p>';
191
-    }
184
+	protected function _reg_id_stop()
185
+	{
186
+		return '<p>'
187
+			   . __(
188
+				   'View the registration ID. Can be sorted in ascending or descending order.',
189
+				   'event_espresso'
190
+			   ) . '</p>';
191
+	}
192 192
 
193
-    protected function _reg_count_stop()
194
-    {
195
-        return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
196
-    }
193
+	protected function _reg_count_stop()
194
+	{
195
+		return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
196
+	}
197 197
 
198
-    protected function _attendee_name_stop()
199
-    {
200
-        return '<p>'
201
-               . __(
202
-                   'View the name of the registrant. Can be sorted in ascending or descending order.',
203
-                   'event_espresso'
204
-               ) . '</p>';
205
-    }
198
+	protected function _attendee_name_stop()
199
+	{
200
+		return '<p>'
201
+			   . __(
202
+				   'View the name of the registrant. Can be sorted in ascending or descending order.',
203
+				   'event_espresso'
204
+			   ) . '</p>';
205
+	}
206 206
 
207
-    protected function _reg_date_stop()
208
-    {
209
-        return '<p>'
210
-               . __(
211
-                   'View registration date. Can be sorted in ascending or descending order.',
212
-                   'event_espresso'
213
-               ) . '</p>';
214
-    }
207
+	protected function _reg_date_stop()
208
+	{
209
+		return '<p>'
210
+			   . __(
211
+				   'View registration date. Can be sorted in ascending or descending order.',
212
+				   'event_espresso'
213
+			   ) . '</p>';
214
+	}
215 215
 
216
-    protected function _event_name_stop()
217
-    {
218
-        return '<p>'
219
-               . __(
220
-                   'View the name of the event. Can be sorted in ascending or descending order.',
221
-                   'event_espresso'
222
-               ) . '</p>';
223
-    }
216
+	protected function _event_name_stop()
217
+	{
218
+		return '<p>'
219
+			   . __(
220
+				   'View the name of the event. Can be sorted in ascending or descending order.',
221
+				   'event_espresso'
222
+			   ) . '</p>';
223
+	}
224 224
 
225
-    protected function _dtt_evt_start_stop()
226
-    {
227
-        return '<p>'
228
-               . __(
229
-                   'View the date of the event. Can be sorted in ascending or descending order.',
230
-                   'event_espresso'
231
-               ) . '</p>';
232
-    }
225
+	protected function _dtt_evt_start_stop()
226
+	{
227
+		return '<p>'
228
+			   . __(
229
+				   'View the date of the event. Can be sorted in ascending or descending order.',
230
+				   'event_espresso'
231
+			   ) . '</p>';
232
+	}
233 233
 
234
-    protected function _reg_code_stop()
235
-    {
236
-        return '<p>' . __('View registration code for a registrant.', 'event_espresso') . '</p>';
237
-    }
234
+	protected function _reg_code_stop()
235
+	{
236
+		return '<p>' . __('View registration code for a registrant.', 'event_espresso') . '</p>';
237
+	}
238 238
 
239
-    protected function _txn_total_stop()
240
-    {
241
-        return '<p>' . __('View price of registration.', 'event_espresso') . '</p>';
242
-    }
239
+	protected function _txn_total_stop()
240
+	{
241
+		return '<p>' . __('View price of registration.', 'event_espresso') . '</p>';
242
+	}
243 243
 
244
-    protected function _actions_stop()
245
-    {
246
-        return '<p>'
247
-               . __(
248
-                   'Perform an action to a registration. See legend in bottom left corner.',
249
-                   'event_espresso'
250
-               ) . '</p>';
251
-    }
244
+	protected function _actions_stop()
245
+	{
246
+		return '<p>'
247
+			   . __(
248
+				   'Perform an action to a registration. See legend in bottom left corner.',
249
+				   'event_espresso'
250
+			   ) . '</p>';
251
+	}
252 252
 
253
-    protected function _legend_stop()
254
-    {
255
-        return '<p>'
256
-               . __(
257
-                   'This is the legend that describes the actions available in the actions column. Also shows available statuses for a registration.',
258
-                   'event_espresso'
259
-               ) . '</p>';
260
-    }
253
+	protected function _legend_stop()
254
+	{
255
+		return '<p>'
256
+			   . __(
257
+				   'This is the legend that describes the actions available in the actions column. Also shows available statuses for a registration.',
258
+				   'event_espresso'
259
+			   ) . '</p>';
260
+	}
261 261
 
262
-    protected function _views_stop()
263
-    {
264
-        return '<p>'
265
-               . __(
266
-                   'You can select different views by time period or look at registrations which have been moved to the trash.',
267
-                   'event_espresso'
268
-               ) . '</p>';
269
-    }
262
+	protected function _views_stop()
263
+	{
264
+		return '<p>'
265
+			   . __(
266
+				   'You can select different views by time period or look at registrations which have been moved to the trash.',
267
+				   'event_espresso'
268
+			   ) . '</p>';
269
+	}
270 270
 
271
-    protected function _bulkactions_stop()
272
-    {
273
-        return '<p>' . __('Perform a bulk action to multiple registrations.', 'event_espresso') . '</p>';
274
-    }
271
+	protected function _bulkactions_stop()
272
+	{
273
+		return '<p>' . __('Perform a bulk action to multiple registrations.', 'event_espresso') . '</p>';
274
+	}
275 275
 
276
-    protected function _stop_about_filters()
277
-    {
278
-        return '<p>' . __('Registrations can be filtered by date, categories, or status.', 'event_espresso') . '</p>';
279
-    }
276
+	protected function _stop_about_filters()
277
+	{
278
+		return '<p>' . __('Registrations can be filtered by date, categories, or status.', 'event_espresso') . '</p>';
279
+	}
280 280
 
281
-    protected function _search_stop()
282
-    {
283
-        return '<p>'
284
-               . __(
285
-                   'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
286
-                   'event_espresso'
287
-               ) . '</p>';
288
-    }
281
+	protected function _search_stop()
282
+	{
283
+		return '<p>'
284
+			   . __(
285
+				   'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
286
+				   'event_espresso'
287
+			   ) . '</p>';
288
+	}
289 289
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 
165 165
     protected function _start()
166 166
     {
167
-        $content = '<h3>' . __('Registration Overview', 'event_espresso') . '</h3>';
167
+        $content = '<h3>'.__('Registration Overview', 'event_espresso').'</h3>';
168 168
         if (isset($this->_req_data['event_id'])) {
169 169
             $content .= '<p>'
170 170
                         . __(
171 171
                             'An introduction to the Registration Overview page for a single event. This view is pretty much the same as the default overview registration page except you are only seeing registrations for a specific event.  There are also some changes to the available columns in this view.',
172 172
                             'event_espresso'
173
-                        ) . '</p>';
173
+                        ).'</p>';
174 174
         } else {
175 175
             $content .= '<p>'
176 176
                         . __(
177 177
                             'This tour of the Registration Overview page will go over different areas of the screen to help you understand what they are used for.',
178 178
                             'event_espresso'
179
-                        ) . '</p>';
179
+                        ).'</p>';
180 180
         }
181 181
         return $content;
182 182
     }
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
                . __(
188 188
                    'View the registration ID. Can be sorted in ascending or descending order.',
189 189
                    'event_espresso'
190
-               ) . '</p>';
190
+               ).'</p>';
191 191
     }
192 192
 
193 193
     protected function _reg_count_stop()
194 194
     {
195
-        return '<p>' . __('View registration number.', 'event_espresso') . '</p>';
195
+        return '<p>'.__('View registration number.', 'event_espresso').'</p>';
196 196
     }
197 197
 
198 198
     protected function _attendee_name_stop()
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                . __(
202 202
                    'View the name of the registrant. Can be sorted in ascending or descending order.',
203 203
                    'event_espresso'
204
-               ) . '</p>';
204
+               ).'</p>';
205 205
     }
206 206
 
207 207
     protected function _reg_date_stop()
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                . __(
211 211
                    'View registration date. Can be sorted in ascending or descending order.',
212 212
                    'event_espresso'
213
-               ) . '</p>';
213
+               ).'</p>';
214 214
     }
215 215
 
216 216
     protected function _event_name_stop()
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                . __(
220 220
                    'View the name of the event. Can be sorted in ascending or descending order.',
221 221
                    'event_espresso'
222
-               ) . '</p>';
222
+               ).'</p>';
223 223
     }
224 224
 
225 225
     protected function _dtt_evt_start_stop()
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                . __(
229 229
                    'View the date of the event. Can be sorted in ascending or descending order.',
230 230
                    'event_espresso'
231
-               ) . '</p>';
231
+               ).'</p>';
232 232
     }
233 233
 
234 234
     protected function _reg_code_stop()
235 235
     {
236
-        return '<p>' . __('View registration code for a registrant.', 'event_espresso') . '</p>';
236
+        return '<p>'.__('View registration code for a registrant.', 'event_espresso').'</p>';
237 237
     }
238 238
 
239 239
     protected function _txn_total_stop()
240 240
     {
241
-        return '<p>' . __('View price of registration.', 'event_espresso') . '</p>';
241
+        return '<p>'.__('View price of registration.', 'event_espresso').'</p>';
242 242
     }
243 243
 
244 244
     protected function _actions_stop()
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                . __(
248 248
                    'Perform an action to a registration. See legend in bottom left corner.',
249 249
                    'event_espresso'
250
-               ) . '</p>';
250
+               ).'</p>';
251 251
     }
252 252
 
253 253
     protected function _legend_stop()
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                . __(
257 257
                    'This is the legend that describes the actions available in the actions column. Also shows available statuses for a registration.',
258 258
                    'event_espresso'
259
-               ) . '</p>';
259
+               ).'</p>';
260 260
     }
261 261
 
262 262
     protected function _views_stop()
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
                . __(
266 266
                    'You can select different views by time period or look at registrations which have been moved to the trash.',
267 267
                    'event_espresso'
268
-               ) . '</p>';
268
+               ).'</p>';
269 269
     }
270 270
 
271 271
     protected function _bulkactions_stop()
272 272
     {
273
-        return '<p>' . __('Perform a bulk action to multiple registrations.', 'event_espresso') . '</p>';
273
+        return '<p>'.__('Perform a bulk action to multiple registrations.', 'event_espresso').'</p>';
274 274
     }
275 275
 
276 276
     protected function _stop_about_filters()
277 277
     {
278
-        return '<p>' . __('Registrations can be filtered by date, categories, or status.', 'event_espresso') . '</p>';
278
+        return '<p>'.__('Registrations can be filtered by date, categories, or status.', 'event_espresso').'</p>';
279 279
     }
280 280
 
281 281
     protected function _search_stop()
@@ -284,6 +284,6 @@  discard block
 block discarded – undo
284 284
                . __(
285 285
                    'Search through registrations. The following sources will be searched: Event Name, Event Description, First Name, Last Name, Biography, Email Address, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, and Ticket Description.',
286 286
                    'event_espresso'
287
-               ) . '</p>';
287
+               ).'</p>';
288 288
     }
289 289
 }
Please login to merge, or discard this patch.