Completed
Branch FET/add-copy-attendee-at-admin (36270b)
by
unknown
26:17 queued 17:58
created
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -37,103 +37,103 @@
 block discarded – undo
37 37
  * @since           4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
             <div class="error">
49 49
                 <p>
50 50
                     <?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
                 </p>
56 56
             </div>
57 57
             <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
             <div class="error">
74 74
                 <p>
75 75
                     <?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
85
-                    );
86
-                    ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
85
+					);
86
+					?>
87 87
                 </p>
88 88
             </div>
89 89
             <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.2.rc.057');
105
-        }
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.2.rc.057');
105
+		}
106 106
 
107
-        /**
108
-         * espresso_plugin_activation
109
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
110
-         */
111
-        function espresso_plugin_activation()
112
-        {
113
-            update_option('ee_espresso_activation', true);
114
-        }
107
+		/**
108
+		 * espresso_plugin_activation
109
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
110
+		 */
111
+		function espresso_plugin_activation()
112
+		{
113
+			update_option('ee_espresso_activation', true);
114
+		}
115 115
 
116
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
116
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117 117
 
118
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
119
-        bootstrap_espresso();
120
-    }
118
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
119
+		bootstrap_espresso();
120
+	}
121 121
 }
122 122
 if (! function_exists('espresso_deactivate_plugin')) {
123
-    /**
124
-     *    deactivate_plugin
125
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
126
-     *
127
-     * @access public
128
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
129
-     * @return    void
130
-     */
131
-    function espresso_deactivate_plugin($plugin_basename = '')
132
-    {
133
-        if (! function_exists('deactivate_plugins')) {
134
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
135
-        }
136
-        unset($_GET['activate'], $_REQUEST['activate']);
137
-        deactivate_plugins($plugin_basename);
138
-    }
123
+	/**
124
+	 *    deactivate_plugin
125
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
126
+	 *
127
+	 * @access public
128
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
129
+	 * @return    void
130
+	 */
131
+	function espresso_deactivate_plugin($plugin_basename = '')
132
+	{
133
+		if (! function_exists('deactivate_plugins')) {
134
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
135
+		}
136
+		unset($_GET['activate'], $_REQUEST['activate']);
137
+		deactivate_plugins($plugin_basename);
138
+	}
139 139
 }
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 1 patch
Indentation   +1423 added lines, -1423 removed lines patch added patch discarded remove patch
@@ -18,1431 +18,1431 @@
 block discarded – undo
18 18
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
19 19
 {
20 20
 
21
-    /**
22
-     * @type bool $_print_copy_info
23
-     */
24
-    private $_print_copy_info = false;
25
-
26
-    /**
27
-     * @type array $_attendee_data
28
-     */
29
-    private $_attendee_data = array();
30
-
31
-    /**
32
-     * @type array $_required_questions
33
-     */
34
-    private $_required_questions = array();
35
-
36
-    /**
37
-     * @type array $_registration_answers
38
-     */
39
-    private $_registration_answers = array();
40
-
41
-
42
-    /**
43
-     *    class constructor
44
-     *
45
-     * @access    public
46
-     * @param    EE_Checkout $checkout
47
-     */
48
-    public function __construct(EE_Checkout $checkout)
49
-    {
50
-        $this->_slug = 'attendee_information';
51
-        $this->_name = esc_html__('Attendee Information', 'event_espresso');
52
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php';
53
-        $this->checkout = $checkout;
54
-        $this->_reset_success_message();
55
-        $this->set_instructions(
56
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
57
-        );
58
-    }
59
-
60
-
61
-    public function translate_js_strings()
62
-    {
63
-        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
64
-            ' is a required question.',
65
-            'event_espresso'
66
-        );
67
-        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
68
-            ' is a required question. Please enter a value for at least one of the options.',
69
-            'event_espresso'
70
-        );
71
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
72
-            'Please answer all required questions correctly before proceeding.',
73
-            'event_espresso'
74
-        );
75
-        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
76
-            esc_html_x(
77
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
78
-                'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
79
-                'event_espresso'
80
-            ),
81
-            '<br/>'
82
-        );
83
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
84
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
85
-            'event_espresso'
86
-        );
87
-        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
88
-            'You must enter a valid email address.',
89
-            'event_espresso'
90
-        );
91
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
92
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
93
-            'event_espresso'
94
-        );
95
-    }
96
-
97
-
98
-    public function enqueue_styles_and_scripts()
99
-    {
100
-    }
101
-
102
-
103
-    /**
104
-     * @return boolean
105
-     */
106
-    public function initialize_reg_step()
107
-    {
108
-        return true;
109
-    }
110
-
111
-
112
-    /**
113
-     * @return EE_Form_Section_Proper
114
-     * @throws DomainException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws ReflectionException
118
-     * @throws EntityNotFoundException
119
-     * @throws InvalidDataTypeException
120
-     * @throws InvalidInterfaceException
121
-     */
122
-    public function generate_reg_form()
123
-    {
124
-        /**
125
-         * @var $reg_config EE_Registration_Config
126
-         */
127
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
21
+	/**
22
+	 * @type bool $_print_copy_info
23
+	 */
24
+	private $_print_copy_info = false;
25
+
26
+	/**
27
+	 * @type array $_attendee_data
28
+	 */
29
+	private $_attendee_data = array();
30
+
31
+	/**
32
+	 * @type array $_required_questions
33
+	 */
34
+	private $_required_questions = array();
35
+
36
+	/**
37
+	 * @type array $_registration_answers
38
+	 */
39
+	private $_registration_answers = array();
40
+
41
+
42
+	/**
43
+	 *    class constructor
44
+	 *
45
+	 * @access    public
46
+	 * @param    EE_Checkout $checkout
47
+	 */
48
+	public function __construct(EE_Checkout $checkout)
49
+	{
50
+		$this->_slug = 'attendee_information';
51
+		$this->_name = esc_html__('Attendee Information', 'event_espresso');
52
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php';
53
+		$this->checkout = $checkout;
54
+		$this->_reset_success_message();
55
+		$this->set_instructions(
56
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
57
+		);
58
+	}
59
+
60
+
61
+	public function translate_js_strings()
62
+	{
63
+		EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
64
+			' is a required question.',
65
+			'event_espresso'
66
+		);
67
+		EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
68
+			' is a required question. Please enter a value for at least one of the options.',
69
+			'event_espresso'
70
+		);
71
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
72
+			'Please answer all required questions correctly before proceeding.',
73
+			'event_espresso'
74
+		);
75
+		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
76
+			esc_html_x(
77
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
78
+				'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
79
+				'event_espresso'
80
+			),
81
+			'<br/>'
82
+		);
83
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
84
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
85
+			'event_espresso'
86
+		);
87
+		EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
88
+			'You must enter a valid email address.',
89
+			'event_espresso'
90
+		);
91
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
92
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
93
+			'event_espresso'
94
+		);
95
+	}
96
+
97
+
98
+	public function enqueue_styles_and_scripts()
99
+	{
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return boolean
105
+	 */
106
+	public function initialize_reg_step()
107
+	{
108
+		return true;
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return EE_Form_Section_Proper
114
+	 * @throws DomainException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws ReflectionException
118
+	 * @throws EntityNotFoundException
119
+	 * @throws InvalidDataTypeException
120
+	 * @throws InvalidInterfaceException
121
+	 */
122
+	public function generate_reg_form()
123
+	{
124
+		/**
125
+		 * @var $reg_config EE_Registration_Config
126
+		 */
127
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
128 128
  
129
-        $this->_print_copy_info = apply_filters(
130
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__generate_reg_form___printCopyInfo',
131
-            $reg_config->copyAttendeeInfo()
132
-        );
133
-
134
-        $primary_registrant = null;
135
-        // autoload Line_Item_Display classes
136
-        EEH_Autoloader::register_line_item_display_autoloaders();
137
-        $Line_Item_Display = new EE_Line_Item_Display();
138
-        // calculate taxes
139
-        $Line_Item_Display->display_line_item(
140
-            $this->checkout->cart->get_grand_total(),
141
-            array('set_tax_rate' => true)
142
-        );
143
-        /** @var $subsections EE_Form_Section_Proper[] */
144
-        $extra_inputs_section = $this->reg_step_hidden_inputs();
145
-        $subsections = array(
146
-            'default_hidden_inputs' => $extra_inputs_section,
147
-        );
148
-
149
-        // if this isn't a revisit, and they have the privacy consent box enalbed, add it
150
-        if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) {
151
-            $extra_inputs_section->add_subsections(
152
-                array(
153
-                    'consent_box' => new EE_Form_Section_Proper(
154
-                        array(
155
-                            'layout_strategy' =>
156
-                                new EE_Template_Layout(
157
-                                    array(
158
-                                        'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php',
159
-                                    )
160
-                                ),
161
-                            'subsections'     => array(
162
-                                'consent' => new EE_Checkbox_Multi_Input(
163
-                                    array(
164
-                                        'consent' => $reg_config->getConsentCheckboxLabelText(),
165
-                                    ),
166
-                                    array(
167
-                                        'required'                          => true,
168
-                                        'required_validation_error_message' => esc_html__(
169
-                                            'You must consent to these terms in order to register.',
170
-                                            'event_espresso'
171
-                                        ),
172
-                                        'html_label_text'                   => '',
173
-                                    )
174
-                                ),
175
-                            ),
176
-                        )
177
-                    ),
178
-                ),
179
-                null,
180
-                false
181
-            );
182
-        }
183
-        $template_args = array(
184
-            'revisit'       => $this->checkout->revisit,
185
-            'registrations' => array(),
186
-            'ticket_count'  => array(),
187
-        );
188
-        // grab the saved registrations from the transaction
189
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
190
-        if ($registrations) {
191
-            foreach ($registrations as $registration) {
192
-                // can this registration be processed during this visit ?
193
-                if ($registration instanceof EE_Registration
194
-                    && $this->checkout->visit_allows_processing_of_this_registration($registration)
195
-                ) {
196
-                    $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration);
197
-                    $template_args['registrations'][ $registration->reg_url_link() ] = $registration;
198
-                    $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
199
-                        $template_args['ticket_count'][ $registration->ticket()->ID() ]
200
-                    )
201
-                        ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
202
-                        : 1;
203
-                    $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
204
-                        $this->checkout->cart->get_grand_total(),
205
-                        'Ticket',
206
-                        array($registration->ticket()->ID())
207
-                    );
208
-                    $ticket_line_item = is_array($ticket_line_item)
209
-                        ? reset($ticket_line_item)
210
-                        : $ticket_line_item;
211
-                    $template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
212
-                        $Line_Item_Display->display_line_item($ticket_line_item);
213
-                    if ($registration->is_primary_registrant()) {
214
-                        $primary_registrant = $registration->reg_url_link();
215
-                    }
216
-                }
217
-            }
218
-
219
-            if ($primary_registrant && count($registrations) > 1) {
220
-                $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
221
-                    ? $this->_copy_attendee_info_form()
222
-                    : $this->_auto_copy_attendee_info();
223
-                // generate hidden input
224
-                if (isset($subsections[ $primary_registrant ])
225
-                    && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
226
-                ) {
227
-                    $subsections[ $primary_registrant ]->add_subsections(
228
-                        $copy_options,
229
-                        'primary_registrant',
230
-                        false
231
-                    );
232
-                }
233
-            }
234
-        }
235
-        return new EE_Form_Section_Proper(
236
-            array(
237
-                'name'            => $this->reg_form_name(),
238
-                'html_id'         => $this->reg_form_name(),
239
-                'subsections'     => $subsections,
240
-                'layout_strategy' => new EE_Template_Layout(
241
-                    array(
242
-                        'layout_template_file' => $this->_template, // layout_template
243
-                        'template_args'        => $template_args,
244
-                    )
245
-                ),
246
-            )
247
-        );
248
-    }
249
-
250
-
251
-    /**
252
-     * @param EE_Registration $registration
253
-     * @return EE_Form_Section_Base
254
-     * @throws EE_Error
255
-     * @throws InvalidArgumentException
256
-     * @throws EntityNotFoundException
257
-     * @throws InvalidDataTypeException
258
-     * @throws InvalidInterfaceException
259
-     * @throws ReflectionException
260
-     */
261
-    private function _registrations_reg_form(EE_Registration $registration)
262
-    {
263
-        static $attendee_nmbr = 1;
264
-        $form_args = array();
265
-        // verify that registration has valid event
266
-        if ($registration->event() instanceof EE_Event) {
267
-            $field_name = 'Event_Question_Group.'
268
-                . EEM_Event_Question_Group::instance()->fieldNameForContext(
269
-                    $registration->is_primary_registrant()
270
-                );
271
-            $question_groups = $registration->event()->question_groups(
272
-                apply_filters(
273
-                    // @codingStandardsIgnoreStart
274
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
275
-                    // @codingStandardsIgnoreEnd
276
-                    [
277
-                        [
278
-                            'Event.EVT_ID'                     => $registration->event()->ID(),
279
-                            $field_name => true,
280
-                        ],
281
-                        'order_by' => ['QSG_order' => 'ASC'],
282
-                    ],
283
-                    $registration,
284
-                    $this
285
-                )
286
-            );
287
-            if ($question_groups) {
288
-                // array of params to pass to parent constructor
289
-                $form_args = array(
290
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
291
-                    'html_class'      => 'ee-reg-form-attendee-dv',
292
-                    'html_style'      => $this->checkout->admin_request
293
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
294
-                        : '',
295
-                    'subsections'     => array(),
296
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
297
-                        array(
298
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
299
-                            'legend_text'  => sprintf(
300
-                                esc_html_x(
301
-                                    'Attendee %d',
302
-                                    'Attendee 123',
303
-                                    'event_espresso'
304
-                                ),
305
-                                $attendee_nmbr
306
-                            ),
307
-                        )
308
-                    ),
309
-                );
310
-                foreach ($question_groups as $question_group) {
311
-                    if ($question_group instanceof EE_Question_Group) {
312
-                        $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
313
-                            $registration,
314
-                            $question_group
315
-                        );
316
-                    }
317
-                }
318
-                // add hidden input
319
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
320
-                    $registration
321
-                );
322
-
323
-                /**
324
-                 * @var $reg_config EE_Registration_Config
325
-                 */
326
-                $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
327
-
328
-                // if we have question groups for additional attendees, then display the copy options
329
-                $this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false;
330
-                if ($registration->is_primary_registrant()) {
331
-                    // generate hidden input
332
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
333
-                        $registration
334
-                    );
335
-                }
336
-            }
337
-        }
338
-        $attendee_nmbr++;
339
-        return ! empty($form_args)
340
-            ? new EE_Form_Section_Proper($form_args)
341
-            : new EE_Form_Section_HTML();
342
-    }
343
-
344
-
345
-    /**
346
-     * @param EE_Registration $registration
347
-     * @param bool            $additional_attendee_reg_info
348
-     * @return EE_Form_Input_Base
349
-     * @throws EE_Error
350
-     */
351
-    private function _additional_attendee_reg_info_input(
352
-        EE_Registration $registration,
353
-        $additional_attendee_reg_info = true
354
-    ) {
355
-        // generate hidden input
356
-        return new EE_Hidden_Input(
357
-            array(
358
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
359
-                'default' => $additional_attendee_reg_info,
360
-            )
361
-        );
362
-    }
363
-
364
-
365
-    /**
366
-     * @param EE_Registration   $registration
367
-     * @param EE_Question_Group $question_group
368
-     * @return EE_Form_Section_Proper
369
-     * @throws EE_Error
370
-     * @throws InvalidArgumentException
371
-     * @throws InvalidDataTypeException
372
-     * @throws InvalidInterfaceException
373
-     * @throws ReflectionException
374
-     */
375
-    private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
376
-    {
377
-        // array of params to pass to parent constructor
378
-        $form_args = array(
379
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
380
-            'html_class'      => $this->checkout->admin_request
381
-                ? 'form-table ee-reg-form-qstn-grp-dv'
382
-                : 'ee-reg-form-qstn-grp-dv',
383
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
384
-                                 . $registration->ID() . '-lbl',
385
-            'subsections'     => array(
386
-                'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
387
-            ),
388
-            'layout_strategy' => $this->checkout->admin_request
389
-                ? new EE_Admin_Two_Column_Layout()
390
-                : new EE_Div_Per_Section_Layout(),
391
-        );
392
-        // where params
393
-        $query_params = array('QST_deleted' => 0);
394
-        // don't load admin only questions on the frontend
395
-        if (! $this->checkout->admin_request) {
396
-            $query_params['QST_admin_only'] = array('!=', true);
397
-        }
398
-        $questions = $question_group->get_many_related(
399
-            'Question',
400
-            apply_filters(
401
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
402
-                array(
403
-                    $query_params,
404
-                    'order_by' => array(
405
-                        'Question_Group_Question.QGQ_order' => 'ASC',
406
-                    ),
407
-                ),
408
-                $question_group,
409
-                $registration,
410
-                $this
411
-            )
412
-        );
413
-        // filter for additional content before questions
414
-        $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
415
-            apply_filters(
416
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
417
-                '',
418
-                $registration,
419
-                $question_group,
420
-                $this
421
-            )
422
-        );
423
-        // loop thru questions
424
-        foreach ($questions as $question) {
425
-            if ($question instanceof EE_Question) {
426
-                $identifier = $question->is_system_question()
427
-                    ? $question->system_ID()
428
-                    : $question->ID();
429
-                $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
430
-            }
431
-        }
432
-        $form_args['subsections'] = apply_filters(
433
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
434
-            $form_args['subsections'],
435
-            $registration,
436
-            $question_group,
437
-            $this
438
-        );
439
-        // filter for additional content after questions
440
-        $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
441
-            apply_filters(
442
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
443
-                '',
444
-                $registration,
445
-                $question_group,
446
-                $this
447
-            )
448
-        );
449
-        // d($form_args);
450
-        $question_group_reg_form = new EE_Form_Section_Proper($form_args);
451
-        return apply_filters(
452
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
453
-            $question_group_reg_form,
454
-            $registration,
455
-            $question_group,
456
-            $this
457
-        );
458
-    }
459
-
460
-
461
-    /**
462
-     * @param EE_Question_Group $question_group
463
-     * @return    EE_Form_Section_HTML
464
-     */
465
-    private function _question_group_header(EE_Question_Group $question_group)
466
-    {
467
-        $html = '';
468
-        // group_name
469
-        if ($question_group->show_group_name() && $question_group->name() !== '') {
470
-            if ($this->checkout->admin_request) {
471
-                $html .= EEH_HTML::br();
472
-                $html .= EEH_HTML::h3(
473
-                    $question_group->name(),
474
-                    '',
475
-                    'ee-reg-form-qstn-grp-title title',
476
-                    'font-size: 1.3em; padding-left:0;'
477
-                );
478
-            } else {
479
-                $html .= EEH_HTML::h4(
480
-                    $question_group->name(),
481
-                    '',
482
-                    'ee-reg-form-qstn-grp-title section-title'
483
-                );
484
-            }
485
-        }
486
-        // group_desc
487
-        if ($question_group->show_group_desc() && $question_group->desc() !== '') {
488
-            $html .= EEH_HTML::p(
489
-                $question_group->desc(),
490
-                '',
491
-                $this->checkout->admin_request
492
-                    ? 'ee-reg-form-qstn-grp-desc-pg'
493
-                    : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
494
-            );
495
-        }
496
-        return new EE_Form_Section_HTML($html);
497
-    }
498
-
499
-
500
-    /**
501
-     * @return    EE_Form_Section_Proper
502
-     * @throws EE_Error
503
-     * @throws InvalidArgumentException
504
-     * @throws ReflectionException
505
-     * @throws InvalidDataTypeException
506
-     * @throws InvalidInterfaceException
507
-     */
508
-    private function _copy_attendee_info_form()
509
-    {
510
-        // array of params to pass to parent constructor
511
-        return new EE_Form_Section_Proper(
512
-            array(
513
-                'subsections'     => $this->_copy_attendee_info_inputs(),
514
-                'layout_strategy' => new EE_Template_Layout(
515
-                    array(
516
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
517
-                                                      . $this->_slug
518
-                                                      . '/copy_attendee_info.template.php',
519
-                        'begin_template_file'      => null,
520
-                        'input_template_file'      => null,
521
-                        'subsection_template_file' => null,
522
-                        'end_template_file'        => null,
523
-                    )
524
-                ),
525
-            )
526
-        );
527
-    }
528
-
529
-
530
-    /**
531
-     * @return EE_Form_Section_HTML
532
-     * @throws DomainException
533
-     * @throws InvalidArgumentException
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidInterfaceException
536
-     */
537
-    private function _auto_copy_attendee_info()
538
-    {
539
-        return new EE_Form_Section_HTML(
540
-            EEH_Template::locate_template(
541
-                SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php',
542
-                apply_filters(
543
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
544
-                    array()
545
-                ),
546
-                true,
547
-                true
548
-            )
549
-        );
550
-    }
551
-
552
-
553
-    /**
554
-     * @return array
555
-     * @throws EE_Error
556
-     * @throws InvalidArgumentException
557
-     * @throws ReflectionException
558
-     * @throws InvalidDataTypeException
559
-     * @throws InvalidInterfaceException
560
-     */
561
-    private function _copy_attendee_info_inputs()
562
-    {
563
-        $copy_attendee_info_inputs = array();
564
-        $prev_ticket = null;
565
-        // grab the saved registrations from the transaction
566
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
567
-        foreach ($registrations as $registration) {
568
-            // for all  attendees other than the primary attendee
569
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
570
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
571
-                if ($registration->ticket()->ID() !== $prev_ticket) {
572
-                    $item_name = $registration->ticket()->name();
573
-                    $item_name .= $registration->ticket()->description() !== ''
574
-                        ? ' - ' . $registration->ticket()->description()
575
-                        : '';
576
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
577
-                    ) . ']' ] =
578
-                        new EE_Form_Section_HTML(
579
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
580
-                        );
581
-                    $prev_ticket = $registration->ticket()->ID();
582
-                }
583
-
584
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
585
-                    new EE_Checkbox_Multi_Input(
586
-                        array(
587
-                            $registration->ID() => sprintf(
588
-                                esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
589
-                                $registration->count()
590
-                            ),
591
-                        ),
592
-                        array(
593
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
594
-                            'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
595
-                            'display_html_label_text' => false,
596
-                        )
597
-                    );
598
-            }
599
-        }
600
-        return $copy_attendee_info_inputs;
601
-    }
602
-
603
-
604
-    /**
605
-     * @param EE_Registration $registration
606
-     * @return    EE_Form_Input_Base
607
-     * @throws EE_Error
608
-     */
609
-    private function _additional_primary_registrant_inputs(EE_Registration $registration)
610
-    {
611
-        // generate hidden input
612
-        return new EE_Hidden_Input(
613
-            array(
614
-                'html_id' => 'primary_registrant',
615
-                'default' => $registration->reg_url_link(),
616
-            )
617
-        );
618
-    }
619
-
620
-
621
-    /**
622
-     * @param EE_Registration $registration
623
-     * @param EE_Question     $question
624
-     * @return EE_Form_Input_Base
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    public function reg_form_question(EE_Registration $registration, EE_Question $question)
632
-    {
633
-
634
-        // if this question was for an attendee detail, then check for that answer
635
-        $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
636
-            $registration,
637
-            $question->system_ID()
638
-        );
639
-        $answer = $answer_value === null
640
-            ? EEM_Answer::instance()->get_one(
641
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
642
-            )
643
-            : null;
644
-        // if NOT returning to edit an existing registration
645
-        // OR if this question is for an attendee property
646
-        // OR we still don't have an EE_Answer object
647
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
648
-            // create an EE_Answer object for storing everything in
649
-            $answer = EE_Answer::new_instance(
650
-                array(
651
-                    'QST_ID' => $question->ID(),
652
-                    'REG_ID' => $registration->ID(),
653
-                )
654
-            );
655
-        }
656
-        // verify instance
657
-        if ($answer instanceof EE_Answer) {
658
-            if (! empty($answer_value)) {
659
-                $answer->set('ANS_value', $answer_value);
660
-            }
661
-            $answer->cache('Question', $question);
662
-            // remember system ID had a bug where sometimes it could be null
663
-            $answer_cache_id = $question->is_system_question()
664
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
665
-                : $question->ID() . '-' . $registration->reg_url_link();
666
-            $registration->cache('Answer', $answer, $answer_cache_id);
667
-        }
668
-        return $this->_generate_question_input($registration, $question, $answer);
669
-    }
670
-
671
-
672
-    /**
673
-     * @param EE_Registration $registration
674
-     * @param EE_Question     $question
675
-     * @param                 $answer
676
-     * @return EE_Form_Input_Base
677
-     * @throws EE_Error
678
-     * @throws InvalidArgumentException
679
-     * @throws ReflectionException
680
-     * @throws InvalidDataTypeException
681
-     * @throws InvalidInterfaceException
682
-     */
683
-    private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
684
-    {
685
-        $identifier = $question->is_system_question()
686
-            ? $question->system_ID()
687
-            : $question->ID();
688
-        $this->_required_questions[ $identifier ] = $question->required() ? true : false;
689
-        add_filter(
690
-            'FHEE__EE_Question__generate_form_input__country_options',
691
-            array($this, 'use_cached_countries_for_form_input'),
692
-            10,
693
-            4
694
-        );
695
-        add_filter(
696
-            'FHEE__EE_Question__generate_form_input__state_options',
697
-            array($this, 'use_cached_states_for_form_input'),
698
-            10,
699
-            4
700
-        );
701
-        $input_constructor_args = array(
702
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
703
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
704
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
705
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
706
-            'html_label_class' => 'ee-reg-qstn',
707
-        );
708
-        $input_constructor_args['html_label_id'] .= '-lbl';
709
-        if ($answer instanceof EE_Answer && $answer->ID()) {
710
-            $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
711
-            $input_constructor_args['html_id'] .= '-' . $answer->ID();
712
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
713
-        }
714
-        $form_input = $question->generate_form_input(
715
-            $registration,
716
-            $answer,
717
-            $input_constructor_args
718
-        );
719
-        remove_filter(
720
-            'FHEE__EE_Question__generate_form_input__country_options',
721
-            array($this, 'use_cached_countries_for_form_input')
722
-        );
723
-        remove_filter(
724
-            'FHEE__EE_Question__generate_form_input__state_options',
725
-            array($this, 'use_cached_states_for_form_input')
726
-        );
727
-        return $form_input;
728
-    }
729
-
730
-
731
-    /**
732
-     * Gets the list of countries for the form input
733
-     *
734
-     * @param array|null      $countries_list
735
-     * @param EE_Question     $question
736
-     * @param EE_Registration $registration
737
-     * @param EE_Answer       $answer
738
-     * @return array 2d keys are country IDs, values are their names
739
-     * @throws EE_Error
740
-     * @throws InvalidArgumentException
741
-     * @throws InvalidDataTypeException
742
-     * @throws InvalidInterfaceException
743
-     * @throws ReflectionException
744
-     */
745
-    public function use_cached_countries_for_form_input(
746
-        $countries_list,
747
-        EE_Question $question = null,
748
-        EE_Registration $registration = null,
749
-        EE_Answer $answer = null
750
-    ) {
751
-        $country_options = array('' => '');
752
-        // get possibly cached list of countries
753
-        $countries = $this->checkout->action === 'process_reg_step'
754
-            ? EEM_Country::instance()->get_all_countries()
755
-            : EEM_Country::instance()->get_all_active_countries();
756
-        if (! empty($countries)) {
757
-            foreach ($countries as $country) {
758
-                if ($country instanceof EE_Country) {
759
-                    $country_options[ $country->ID() ] = $country->name();
760
-                }
761
-            }
762
-        }
763
-        if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
764
-            $answer = EEM_Answer::instance()->get_one(
765
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
766
-            );
767
-        } else {
768
-            $answer = EE_Answer::new_instance();
769
-        }
770
-        $country_options = apply_filters(
771
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
772
-            $country_options,
773
-            $this,
774
-            $registration,
775
-            $question,
776
-            $answer
777
-        );
778
-        return $country_options;
779
-    }
780
-
781
-
782
-    /**
783
-     * Gets the list of states for the form input
784
-     *
785
-     * @param array|null      $states_list
786
-     * @param EE_Question     $question
787
-     * @param EE_Registration $registration
788
-     * @param EE_Answer       $answer
789
-     * @return array 2d keys are state IDs, values are their names
790
-     * @throws EE_Error
791
-     * @throws InvalidArgumentException
792
-     * @throws InvalidDataTypeException
793
-     * @throws InvalidInterfaceException
794
-     * @throws ReflectionException
795
-     */
796
-    public function use_cached_states_for_form_input(
797
-        $states_list,
798
-        EE_Question $question = null,
799
-        EE_Registration $registration = null,
800
-        EE_Answer $answer = null
801
-    ) {
802
-        $state_options = array('' => array('' => ''));
803
-        $states = $this->checkout->action === 'process_reg_step'
804
-            ? EEM_State::instance()->get_all_states()
805
-            : EEM_State::instance()->get_all_active_states();
806
-        if (! empty($states)) {
807
-            foreach ($states as $state) {
808
-                if ($state instanceof EE_State) {
809
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
810
-                }
811
-            }
812
-        }
813
-        $state_options = apply_filters(
814
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
815
-            $state_options,
816
-            $this,
817
-            $registration,
818
-            $question,
819
-            $answer
820
-        );
821
-        return $state_options;
822
-    }
823
-
824
-
825
-    /********************************************************************************************************/
826
-    /****************************************  PROCESS REG STEP  ****************************************/
827
-    /********************************************************************************************************/
828
-
829
-
830
-    /**
831
-     * @return bool
832
-     * @throws EE_Error
833
-     * @throws InvalidArgumentException
834
-     * @throws ReflectionException
835
-     * @throws RuntimeException
836
-     * @throws InvalidDataTypeException
837
-     * @throws InvalidInterfaceException
838
-     */
839
-    public function process_reg_step()
840
-    {
841
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
842
-        // grab validated data from form
843
-        $valid_data = $this->checkout->current_step->valid_data();
844
-        // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
845
-        // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
846
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
847
-        if (empty($valid_data)) {
848
-            EE_Error::add_error(
849
-                esc_html__('No valid question responses were received.', 'event_espresso'),
850
-                __FILE__,
851
-                __FUNCTION__,
852
-                __LINE__
853
-            );
854
-            return false;
855
-        }
856
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
857
-            EE_Error::add_error(
858
-                esc_html__(
859
-                    'A valid transaction could not be initiated for processing your registrations.',
860
-                    'event_espresso'
861
-                ),
862
-                __FILE__,
863
-                __FUNCTION__,
864
-                __LINE__
865
-            );
866
-            return false;
867
-        }
868
-        // get cached registrations
869
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
870
-        // verify we got the goods
871
-        if (empty($registrations)) {
872
-            // combine the old translated string with a new one, in order to not break translations
873
-            $error_message = esc_html__(
874
-                'Your form data could not be applied to any valid registrations.',
875
-                'event_espresso'
876
-            )
877
-            . sprintf(
878
-                esc_html_x(
879
-                    '%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.',
880
-                    '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
881
-                    'event_espresso'
882
-                ),
883
-                '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
884
-                '</a>',
885
-                '<br />'
886
-            );
887
-            EE_Error::add_error(
888
-                $error_message,
889
-                __FILE__,
890
-                __FUNCTION__,
891
-                __LINE__
892
-            );
893
-            return false;
894
-        }
895
-        // extract attendee info from form data and save to model objects
896
-        $registrations_processed = $this->_process_registrations($registrations, $valid_data);
897
-        // if first pass thru SPCO,
898
-        // then let's check processed registrations against the total number of tickets in the cart
899
-        if ($registrations_processed === false) {
900
-            // but return immediately if the previous step exited early due to errors
901
-            return false;
902
-        }
903
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
904
-            // generate a correctly translated string for all possible singular/plural combinations
905
-            if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
906
-                $error_msg = sprintf(
907
-                    esc_html_x(
908
-                        'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
909
-                        'There was 1 ticket in the Event Queue, but 2 registrations were processed',
910
-                        'event_espresso'
911
-                    ),
912
-                    $this->checkout->total_ticket_count,
913
-                    $registrations_processed
914
-                );
915
-            } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
916
-                $error_msg = sprintf(
917
-                    esc_html_x(
918
-                        'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
919
-                        'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
920
-                        'event_espresso'
921
-                    ),
922
-                    $this->checkout->total_ticket_count,
923
-                    $registrations_processed
924
-                );
925
-            } else {
926
-                $error_msg = sprintf(
927
-                    esc_html__(
928
-                        'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
929
-                        'event_espresso'
930
-                    ),
931
-                    $this->checkout->total_ticket_count,
932
-                    $registrations_processed
933
-                );
934
-            }
935
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
936
-            return false;
937
-        }
938
-        // mark this reg step as completed
939
-        $this->set_completed();
940
-        $this->_set_success_message(
941
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
942
-        );
943
-        // do action in case a plugin wants to do something with the data submitted in step 1.
944
-        // passes EE_Single_Page_Checkout, and it's posted data
945
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
946
-        return true;
947
-    }
948
-
949
-
950
-    /**
951
-     *    _process_registrations
952
-     *
953
-     * @param EE_Registration[] $registrations
954
-     * @param array[][]         $valid_data
955
-     * @return bool|int
956
-     * @throws EntityNotFoundException
957
-     * @throws EE_Error
958
-     * @throws InvalidArgumentException
959
-     * @throws ReflectionException
960
-     * @throws RuntimeException
961
-     * @throws InvalidDataTypeException
962
-     * @throws InvalidInterfaceException
963
-     */
964
-    private function _process_registrations($registrations = array(), $valid_data = array())
965
-    {
966
-        // load resources and set some defaults
967
-        EE_Registry::instance()->load_model('Attendee');
968
-        // holder for primary registrant attendee object
969
-        $this->checkout->primary_attendee_obj = null;
970
-        // array for tracking reg form data for the primary registrant
971
-        $primary_registrant = array(
972
-            'line_item_id' => null,
973
-        );
974
-        $copy_primary = false;
975
-        // reg form sections that do not contain inputs
976
-        $non_input_form_sections = array(
977
-            'primary_registrant',
978
-            'additional_attendee_reg_info',
979
-            'spco_copy_attendee_chk',
980
-        );
981
-        // attendee counter
982
-        $att_nmbr = 0;
983
-        // grab the saved registrations from the transaction
984
-        foreach ($registrations as $registration) {
985
-            // verify EE_Registration object
986
-            if (! $registration instanceof EE_Registration) {
987
-                EE_Error::add_error(
988
-                    esc_html__(
989
-                        'An invalid Registration object was discovered when attempting to process your registration information.',
990
-                        'event_espresso'
991
-                    ),
992
-                    __FILE__,
993
-                    __FUNCTION__,
994
-                    __LINE__
995
-                );
996
-                return false;
997
-            }
998
-            /** @var string $reg_url_link */
999
-            $reg_url_link = $registration->reg_url_link();
1000
-            // reg_url_link exists ?
1001
-            if (! empty($reg_url_link)) {
1002
-                // should this registration be processed during this visit ?
1003
-                if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
1004
-                    // if NOT revisiting, then let's save the registration now,
1005
-                    // so that we have a REG_ID to use when generating other objects
1006
-                    if (! $this->checkout->revisit) {
1007
-                        $registration->save();
1008
-                    }
1009
-                    /**
1010
-                     * This allows plugins to trigger a fail on processing of a
1011
-                     * registration for any conditions they may have for it to pass.
1012
-                     *
1013
-                     * @var bool   if true is returned by the plugin then the
1014
-                     *            registration processing is halted.
1015
-                     */
1016
-                    if (apply_filters(
1017
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
1018
-                        false,
1019
-                        $att_nmbr,
1020
-                        $registration,
1021
-                        $registrations,
1022
-                        $valid_data,
1023
-                        $this
1024
-                    )) {
1025
-                        return false;
1026
-                    }
1027
-
1028
-                    // Houston, we have a registration!
1029
-                    $att_nmbr++;
1030
-                    $this->_attendee_data[ $reg_url_link ] = array();
1031
-                    // grab any existing related answer objects
1032
-                    $this->_registration_answers = $registration->answers();
1033
-                    // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
1034
-                    if (isset($valid_data[ $reg_url_link ])) {
1035
-                        // do we need to copy basic info from primary attendee ?
1036
-                        $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
1037
-                                        && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
1038
-                        // filter form input data for this registration
1039
-                        $valid_data[ $reg_url_link ] = (array) apply_filters(
1040
-                            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
1041
-                            $valid_data[ $reg_url_link ]
1042
-                        );
1043
-                        if (isset($valid_data['primary_attendee'])) {
1044
-                            $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
1045
-                                ? $valid_data['primary_attendee']
1046
-                                : false;
1047
-                            unset($valid_data['primary_attendee']);
1048
-                        }
1049
-                        // now loop through our array of valid post data && process attendee reg forms
1050
-                        foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
1051
-                            if (! in_array($form_section, $non_input_form_sections, true)) {
1052
-                                foreach ($form_inputs as $form_input => $input_value) {
1053
-                                    // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
1054
-                                    // check for critical inputs
1055
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
1056
-                                        $form_input,
1057
-                                        $input_value
1058
-                                    )
1059
-                                    ) {
1060
-                                        return false;
1061
-                                    }
1062
-                                    // store a bit of data about the primary attendee
1063
-                                    if ($att_nmbr === 1
1064
-                                        && ! empty($input_value)
1065
-                                        && $reg_url_link === $primary_registrant['line_item_id']
1066
-                                    ) {
1067
-                                        $primary_registrant[ $form_input ] = $input_value;
1068
-                                    } elseif ($copy_primary
1069
-                                              && $input_value === null
1070
-                                              && isset($primary_registrant[ $form_input ])
1071
-                                    ) {
1072
-                                        $input_value = $primary_registrant[ $form_input ];
1073
-                                    }
1074
-                                    // now attempt to save the input data
1075
-                                    if (! $this->_save_registration_form_input(
1076
-                                        $registration,
1077
-                                        $form_input,
1078
-                                        $input_value
1079
-                                    )
1080
-                                    ) {
1081
-                                        EE_Error::add_error(
1082
-                                            sprintf(
1083
-                                                esc_html_x(
1084
-                                                    'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1085
-                                                    'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
1086
-                                                    'event_espresso'
1087
-                                                ),
1088
-                                                $form_input,
1089
-                                                $input_value
1090
-                                            ),
1091
-                                            __FILE__,
1092
-                                            __FUNCTION__,
1093
-                                            __LINE__
1094
-                                        );
1095
-                                        return false;
1096
-                                    }
1097
-                                }
1098
-                            }
1099
-                        }  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1100
-                    }
1101
-                    // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1102
-                    // this registration does not require additional attendee information ?
1103
-                    if ($copy_primary
1104
-                        && $att_nmbr > 1
1105
-                        && $this->checkout->primary_attendee_obj instanceof EE_Attendee
1106
-                    ) {
1107
-                        // just copy the primary registrant
1108
-                        $attendee = $this->checkout->primary_attendee_obj;
1109
-                    } else {
1110
-                        // ensure critical details are set for additional attendees
1111
-                        $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1112
-                            ? $this->_copy_critical_attendee_details_from_primary_registrant(
1113
-                                $this->_attendee_data[ $reg_url_link ]
1114
-                            )
1115
-                            : $this->_attendee_data[ $reg_url_link ];
1116
-                        // execute create attendee command (which may return an existing attendee)
1117
-                        $attendee = EE_Registry::instance()->BUS->execute(
1118
-                            new CreateAttendeeCommand(
1119
-                                $this->_attendee_data[ $reg_url_link ],
1120
-                                $registration
1121
-                            )
1122
-                        );
1123
-                        // who's #1 ?
1124
-                        if ($att_nmbr === 1) {
1125
-                            $this->checkout->primary_attendee_obj = $attendee;
1126
-                        }
1127
-                    }
1128
-                    // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1129
-                    // add relation to registration, set attendee ID, and cache attendee
1130
-                    $this->_associate_attendee_with_registration($registration, $attendee);
1131
-                    // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1132
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1133
-                        EE_Error::add_error(
1134
-                            sprintf(
1135
-                                esc_html_x(
1136
-                                    'Registration %s has an invalid or missing Attendee object.',
1137
-                                    'Registration 123-456-789 has an invalid or missing Attendee object.',
1138
-                                    'event_espresso'
1139
-                                ),
1140
-                                $reg_url_link
1141
-                            ),
1142
-                            __FILE__,
1143
-                            __FUNCTION__,
1144
-                            __LINE__
1145
-                        );
1146
-                        return false;
1147
-                    }
1148
-                    /** @type EE_Registration_Processor $registration_processor */
1149
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1150
-                    // at this point, we should have enough details about the registrant to consider the registration
1151
-                    // NOT incomplete
1152
-                    $registration_processor->toggle_incomplete_registration_status_to_default(
1153
-                        $registration,
1154
-                        false,
1155
-                        new Context(
1156
-                            'spco_reg_step_attendee_information_process_registrations',
1157
-                            esc_html__(
1158
-                                'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1159
-                                'event_espresso'
1160
-                            )
1161
-                        )
1162
-                    );
1163
-                    // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1164
-                    // abandoned
1165
-                    $this->checkout->transaction->toggle_failed_transaction_status();
1166
-                    // if we've gotten this far, then let's save what we have
1167
-                    $registration->save();
1168
-                    // add relation between TXN and registration
1169
-                    $this->_associate_registration_with_transaction($registration);
1170
-                }
1171
-            } else {
1172
-                EE_Error::add_error(
1173
-                    esc_html__(
1174
-                        'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1175
-                        'event_espresso'
1176
-                    ),
1177
-                    __FILE__,
1178
-                    __FUNCTION__,
1179
-                    __LINE__
1180
-                );
1181
-                // remove malformed data
1182
-                unset($valid_data[ $reg_url_link ]);
1183
-                return false;
1184
-            }
1185
-        } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1186
-        return $att_nmbr;
1187
-    }
1188
-
1189
-
1190
-    /**
1191
-     *    _save_registration_form_input
1192
-     *
1193
-     * @param EE_Registration $registration
1194
-     * @param string          $form_input
1195
-     * @param string          $input_value
1196
-     * @return bool
1197
-     * @throws EE_Error
1198
-     * @throws InvalidArgumentException
1199
-     * @throws InvalidDataTypeException
1200
-     * @throws InvalidInterfaceException
1201
-     * @throws ReflectionException
1202
-     */
1203
-    private function _save_registration_form_input(
1204
-        EE_Registration $registration,
1205
-        $form_input = '',
1206
-        $input_value = ''
1207
-    ) {
1208
-        // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1209
-        // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1210
-        // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1211
-        // allow for plugins to hook in and do their own processing of the form input.
1212
-        // For plugins to bypass normal processing here, they just need to return a boolean value.
1213
-        if (apply_filters(
1214
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1215
-            false,
1216
-            $registration,
1217
-            $form_input,
1218
-            $input_value,
1219
-            $this
1220
-        )) {
1221
-            return true;
1222
-        }
1223
-        /*
129
+		$this->_print_copy_info = apply_filters(
130
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__generate_reg_form___printCopyInfo',
131
+			$reg_config->copyAttendeeInfo()
132
+		);
133
+
134
+		$primary_registrant = null;
135
+		// autoload Line_Item_Display classes
136
+		EEH_Autoloader::register_line_item_display_autoloaders();
137
+		$Line_Item_Display = new EE_Line_Item_Display();
138
+		// calculate taxes
139
+		$Line_Item_Display->display_line_item(
140
+			$this->checkout->cart->get_grand_total(),
141
+			array('set_tax_rate' => true)
142
+		);
143
+		/** @var $subsections EE_Form_Section_Proper[] */
144
+		$extra_inputs_section = $this->reg_step_hidden_inputs();
145
+		$subsections = array(
146
+			'default_hidden_inputs' => $extra_inputs_section,
147
+		);
148
+
149
+		// if this isn't a revisit, and they have the privacy consent box enalbed, add it
150
+		if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) {
151
+			$extra_inputs_section->add_subsections(
152
+				array(
153
+					'consent_box' => new EE_Form_Section_Proper(
154
+						array(
155
+							'layout_strategy' =>
156
+								new EE_Template_Layout(
157
+									array(
158
+										'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php',
159
+									)
160
+								),
161
+							'subsections'     => array(
162
+								'consent' => new EE_Checkbox_Multi_Input(
163
+									array(
164
+										'consent' => $reg_config->getConsentCheckboxLabelText(),
165
+									),
166
+									array(
167
+										'required'                          => true,
168
+										'required_validation_error_message' => esc_html__(
169
+											'You must consent to these terms in order to register.',
170
+											'event_espresso'
171
+										),
172
+										'html_label_text'                   => '',
173
+									)
174
+								),
175
+							),
176
+						)
177
+					),
178
+				),
179
+				null,
180
+				false
181
+			);
182
+		}
183
+		$template_args = array(
184
+			'revisit'       => $this->checkout->revisit,
185
+			'registrations' => array(),
186
+			'ticket_count'  => array(),
187
+		);
188
+		// grab the saved registrations from the transaction
189
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
190
+		if ($registrations) {
191
+			foreach ($registrations as $registration) {
192
+				// can this registration be processed during this visit ?
193
+				if ($registration instanceof EE_Registration
194
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
195
+				) {
196
+					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration);
197
+					$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
198
+					$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
199
+						$template_args['ticket_count'][ $registration->ticket()->ID() ]
200
+					)
201
+						? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
202
+						: 1;
203
+					$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
204
+						$this->checkout->cart->get_grand_total(),
205
+						'Ticket',
206
+						array($registration->ticket()->ID())
207
+					);
208
+					$ticket_line_item = is_array($ticket_line_item)
209
+						? reset($ticket_line_item)
210
+						: $ticket_line_item;
211
+					$template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
212
+						$Line_Item_Display->display_line_item($ticket_line_item);
213
+					if ($registration->is_primary_registrant()) {
214
+						$primary_registrant = $registration->reg_url_link();
215
+					}
216
+				}
217
+			}
218
+
219
+			if ($primary_registrant && count($registrations) > 1) {
220
+				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
221
+					? $this->_copy_attendee_info_form()
222
+					: $this->_auto_copy_attendee_info();
223
+				// generate hidden input
224
+				if (isset($subsections[ $primary_registrant ])
225
+					&& $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
226
+				) {
227
+					$subsections[ $primary_registrant ]->add_subsections(
228
+						$copy_options,
229
+						'primary_registrant',
230
+						false
231
+					);
232
+				}
233
+			}
234
+		}
235
+		return new EE_Form_Section_Proper(
236
+			array(
237
+				'name'            => $this->reg_form_name(),
238
+				'html_id'         => $this->reg_form_name(),
239
+				'subsections'     => $subsections,
240
+				'layout_strategy' => new EE_Template_Layout(
241
+					array(
242
+						'layout_template_file' => $this->_template, // layout_template
243
+						'template_args'        => $template_args,
244
+					)
245
+				),
246
+			)
247
+		);
248
+	}
249
+
250
+
251
+	/**
252
+	 * @param EE_Registration $registration
253
+	 * @return EE_Form_Section_Base
254
+	 * @throws EE_Error
255
+	 * @throws InvalidArgumentException
256
+	 * @throws EntityNotFoundException
257
+	 * @throws InvalidDataTypeException
258
+	 * @throws InvalidInterfaceException
259
+	 * @throws ReflectionException
260
+	 */
261
+	private function _registrations_reg_form(EE_Registration $registration)
262
+	{
263
+		static $attendee_nmbr = 1;
264
+		$form_args = array();
265
+		// verify that registration has valid event
266
+		if ($registration->event() instanceof EE_Event) {
267
+			$field_name = 'Event_Question_Group.'
268
+				. EEM_Event_Question_Group::instance()->fieldNameForContext(
269
+					$registration->is_primary_registrant()
270
+				);
271
+			$question_groups = $registration->event()->question_groups(
272
+				apply_filters(
273
+					// @codingStandardsIgnoreStart
274
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
275
+					// @codingStandardsIgnoreEnd
276
+					[
277
+						[
278
+							'Event.EVT_ID'                     => $registration->event()->ID(),
279
+							$field_name => true,
280
+						],
281
+						'order_by' => ['QSG_order' => 'ASC'],
282
+					],
283
+					$registration,
284
+					$this
285
+				)
286
+			);
287
+			if ($question_groups) {
288
+				// array of params to pass to parent constructor
289
+				$form_args = array(
290
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
291
+					'html_class'      => 'ee-reg-form-attendee-dv',
292
+					'html_style'      => $this->checkout->admin_request
293
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
294
+						: '',
295
+					'subsections'     => array(),
296
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
297
+						array(
298
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
299
+							'legend_text'  => sprintf(
300
+								esc_html_x(
301
+									'Attendee %d',
302
+									'Attendee 123',
303
+									'event_espresso'
304
+								),
305
+								$attendee_nmbr
306
+							),
307
+						)
308
+					),
309
+				);
310
+				foreach ($question_groups as $question_group) {
311
+					if ($question_group instanceof EE_Question_Group) {
312
+						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
313
+							$registration,
314
+							$question_group
315
+						);
316
+					}
317
+				}
318
+				// add hidden input
319
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
320
+					$registration
321
+				);
322
+
323
+				/**
324
+				 * @var $reg_config EE_Registration_Config
325
+				 */
326
+				$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
327
+
328
+				// if we have question groups for additional attendees, then display the copy options
329
+				$this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false;
330
+				if ($registration->is_primary_registrant()) {
331
+					// generate hidden input
332
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
333
+						$registration
334
+					);
335
+				}
336
+			}
337
+		}
338
+		$attendee_nmbr++;
339
+		return ! empty($form_args)
340
+			? new EE_Form_Section_Proper($form_args)
341
+			: new EE_Form_Section_HTML();
342
+	}
343
+
344
+
345
+	/**
346
+	 * @param EE_Registration $registration
347
+	 * @param bool            $additional_attendee_reg_info
348
+	 * @return EE_Form_Input_Base
349
+	 * @throws EE_Error
350
+	 */
351
+	private function _additional_attendee_reg_info_input(
352
+		EE_Registration $registration,
353
+		$additional_attendee_reg_info = true
354
+	) {
355
+		// generate hidden input
356
+		return new EE_Hidden_Input(
357
+			array(
358
+				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
359
+				'default' => $additional_attendee_reg_info,
360
+			)
361
+		);
362
+	}
363
+
364
+
365
+	/**
366
+	 * @param EE_Registration   $registration
367
+	 * @param EE_Question_Group $question_group
368
+	 * @return EE_Form_Section_Proper
369
+	 * @throws EE_Error
370
+	 * @throws InvalidArgumentException
371
+	 * @throws InvalidDataTypeException
372
+	 * @throws InvalidInterfaceException
373
+	 * @throws ReflectionException
374
+	 */
375
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
376
+	{
377
+		// array of params to pass to parent constructor
378
+		$form_args = array(
379
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
380
+			'html_class'      => $this->checkout->admin_request
381
+				? 'form-table ee-reg-form-qstn-grp-dv'
382
+				: 'ee-reg-form-qstn-grp-dv',
383
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
384
+								 . $registration->ID() . '-lbl',
385
+			'subsections'     => array(
386
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
387
+			),
388
+			'layout_strategy' => $this->checkout->admin_request
389
+				? new EE_Admin_Two_Column_Layout()
390
+				: new EE_Div_Per_Section_Layout(),
391
+		);
392
+		// where params
393
+		$query_params = array('QST_deleted' => 0);
394
+		// don't load admin only questions on the frontend
395
+		if (! $this->checkout->admin_request) {
396
+			$query_params['QST_admin_only'] = array('!=', true);
397
+		}
398
+		$questions = $question_group->get_many_related(
399
+			'Question',
400
+			apply_filters(
401
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
402
+				array(
403
+					$query_params,
404
+					'order_by' => array(
405
+						'Question_Group_Question.QGQ_order' => 'ASC',
406
+					),
407
+				),
408
+				$question_group,
409
+				$registration,
410
+				$this
411
+			)
412
+		);
413
+		// filter for additional content before questions
414
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
415
+			apply_filters(
416
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
417
+				'',
418
+				$registration,
419
+				$question_group,
420
+				$this
421
+			)
422
+		);
423
+		// loop thru questions
424
+		foreach ($questions as $question) {
425
+			if ($question instanceof EE_Question) {
426
+				$identifier = $question->is_system_question()
427
+					? $question->system_ID()
428
+					: $question->ID();
429
+				$form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
430
+			}
431
+		}
432
+		$form_args['subsections'] = apply_filters(
433
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
434
+			$form_args['subsections'],
435
+			$registration,
436
+			$question_group,
437
+			$this
438
+		);
439
+		// filter for additional content after questions
440
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
441
+			apply_filters(
442
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
443
+				'',
444
+				$registration,
445
+				$question_group,
446
+				$this
447
+			)
448
+		);
449
+		// d($form_args);
450
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
451
+		return apply_filters(
452
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
453
+			$question_group_reg_form,
454
+			$registration,
455
+			$question_group,
456
+			$this
457
+		);
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param EE_Question_Group $question_group
463
+	 * @return    EE_Form_Section_HTML
464
+	 */
465
+	private function _question_group_header(EE_Question_Group $question_group)
466
+	{
467
+		$html = '';
468
+		// group_name
469
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
470
+			if ($this->checkout->admin_request) {
471
+				$html .= EEH_HTML::br();
472
+				$html .= EEH_HTML::h3(
473
+					$question_group->name(),
474
+					'',
475
+					'ee-reg-form-qstn-grp-title title',
476
+					'font-size: 1.3em; padding-left:0;'
477
+				);
478
+			} else {
479
+				$html .= EEH_HTML::h4(
480
+					$question_group->name(),
481
+					'',
482
+					'ee-reg-form-qstn-grp-title section-title'
483
+				);
484
+			}
485
+		}
486
+		// group_desc
487
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
488
+			$html .= EEH_HTML::p(
489
+				$question_group->desc(),
490
+				'',
491
+				$this->checkout->admin_request
492
+					? 'ee-reg-form-qstn-grp-desc-pg'
493
+					: 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
494
+			);
495
+		}
496
+		return new EE_Form_Section_HTML($html);
497
+	}
498
+
499
+
500
+	/**
501
+	 * @return    EE_Form_Section_Proper
502
+	 * @throws EE_Error
503
+	 * @throws InvalidArgumentException
504
+	 * @throws ReflectionException
505
+	 * @throws InvalidDataTypeException
506
+	 * @throws InvalidInterfaceException
507
+	 */
508
+	private function _copy_attendee_info_form()
509
+	{
510
+		// array of params to pass to parent constructor
511
+		return new EE_Form_Section_Proper(
512
+			array(
513
+				'subsections'     => $this->_copy_attendee_info_inputs(),
514
+				'layout_strategy' => new EE_Template_Layout(
515
+					array(
516
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
517
+													  . $this->_slug
518
+													  . '/copy_attendee_info.template.php',
519
+						'begin_template_file'      => null,
520
+						'input_template_file'      => null,
521
+						'subsection_template_file' => null,
522
+						'end_template_file'        => null,
523
+					)
524
+				),
525
+			)
526
+		);
527
+	}
528
+
529
+
530
+	/**
531
+	 * @return EE_Form_Section_HTML
532
+	 * @throws DomainException
533
+	 * @throws InvalidArgumentException
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidInterfaceException
536
+	 */
537
+	private function _auto_copy_attendee_info()
538
+	{
539
+		return new EE_Form_Section_HTML(
540
+			EEH_Template::locate_template(
541
+				SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php',
542
+				apply_filters(
543
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
544
+					array()
545
+				),
546
+				true,
547
+				true
548
+			)
549
+		);
550
+	}
551
+
552
+
553
+	/**
554
+	 * @return array
555
+	 * @throws EE_Error
556
+	 * @throws InvalidArgumentException
557
+	 * @throws ReflectionException
558
+	 * @throws InvalidDataTypeException
559
+	 * @throws InvalidInterfaceException
560
+	 */
561
+	private function _copy_attendee_info_inputs()
562
+	{
563
+		$copy_attendee_info_inputs = array();
564
+		$prev_ticket = null;
565
+		// grab the saved registrations from the transaction
566
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
567
+		foreach ($registrations as $registration) {
568
+			// for all  attendees other than the primary attendee
569
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
570
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
571
+				if ($registration->ticket()->ID() !== $prev_ticket) {
572
+					$item_name = $registration->ticket()->name();
573
+					$item_name .= $registration->ticket()->description() !== ''
574
+						? ' - ' . $registration->ticket()->description()
575
+						: '';
576
+					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
577
+					) . ']' ] =
578
+						new EE_Form_Section_HTML(
579
+							'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
580
+						);
581
+					$prev_ticket = $registration->ticket()->ID();
582
+				}
583
+
584
+				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
585
+					new EE_Checkbox_Multi_Input(
586
+						array(
587
+							$registration->ID() => sprintf(
588
+								esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
589
+								$registration->count()
590
+							),
591
+						),
592
+						array(
593
+							'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
594
+							'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
595
+							'display_html_label_text' => false,
596
+						)
597
+					);
598
+			}
599
+		}
600
+		return $copy_attendee_info_inputs;
601
+	}
602
+
603
+
604
+	/**
605
+	 * @param EE_Registration $registration
606
+	 * @return    EE_Form_Input_Base
607
+	 * @throws EE_Error
608
+	 */
609
+	private function _additional_primary_registrant_inputs(EE_Registration $registration)
610
+	{
611
+		// generate hidden input
612
+		return new EE_Hidden_Input(
613
+			array(
614
+				'html_id' => 'primary_registrant',
615
+				'default' => $registration->reg_url_link(),
616
+			)
617
+		);
618
+	}
619
+
620
+
621
+	/**
622
+	 * @param EE_Registration $registration
623
+	 * @param EE_Question     $question
624
+	 * @return EE_Form_Input_Base
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	public function reg_form_question(EE_Registration $registration, EE_Question $question)
632
+	{
633
+
634
+		// if this question was for an attendee detail, then check for that answer
635
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
636
+			$registration,
637
+			$question->system_ID()
638
+		);
639
+		$answer = $answer_value === null
640
+			? EEM_Answer::instance()->get_one(
641
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
642
+			)
643
+			: null;
644
+		// if NOT returning to edit an existing registration
645
+		// OR if this question is for an attendee property
646
+		// OR we still don't have an EE_Answer object
647
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
648
+			// create an EE_Answer object for storing everything in
649
+			$answer = EE_Answer::new_instance(
650
+				array(
651
+					'QST_ID' => $question->ID(),
652
+					'REG_ID' => $registration->ID(),
653
+				)
654
+			);
655
+		}
656
+		// verify instance
657
+		if ($answer instanceof EE_Answer) {
658
+			if (! empty($answer_value)) {
659
+				$answer->set('ANS_value', $answer_value);
660
+			}
661
+			$answer->cache('Question', $question);
662
+			// remember system ID had a bug where sometimes it could be null
663
+			$answer_cache_id = $question->is_system_question()
664
+				? $question->system_ID() . '-' . $registration->reg_url_link()
665
+				: $question->ID() . '-' . $registration->reg_url_link();
666
+			$registration->cache('Answer', $answer, $answer_cache_id);
667
+		}
668
+		return $this->_generate_question_input($registration, $question, $answer);
669
+	}
670
+
671
+
672
+	/**
673
+	 * @param EE_Registration $registration
674
+	 * @param EE_Question     $question
675
+	 * @param                 $answer
676
+	 * @return EE_Form_Input_Base
677
+	 * @throws EE_Error
678
+	 * @throws InvalidArgumentException
679
+	 * @throws ReflectionException
680
+	 * @throws InvalidDataTypeException
681
+	 * @throws InvalidInterfaceException
682
+	 */
683
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
684
+	{
685
+		$identifier = $question->is_system_question()
686
+			? $question->system_ID()
687
+			: $question->ID();
688
+		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
689
+		add_filter(
690
+			'FHEE__EE_Question__generate_form_input__country_options',
691
+			array($this, 'use_cached_countries_for_form_input'),
692
+			10,
693
+			4
694
+		);
695
+		add_filter(
696
+			'FHEE__EE_Question__generate_form_input__state_options',
697
+			array($this, 'use_cached_states_for_form_input'),
698
+			10,
699
+			4
700
+		);
701
+		$input_constructor_args = array(
702
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
703
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
704
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
705
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
706
+			'html_label_class' => 'ee-reg-qstn',
707
+		);
708
+		$input_constructor_args['html_label_id'] .= '-lbl';
709
+		if ($answer instanceof EE_Answer && $answer->ID()) {
710
+			$input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
711
+			$input_constructor_args['html_id'] .= '-' . $answer->ID();
712
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
713
+		}
714
+		$form_input = $question->generate_form_input(
715
+			$registration,
716
+			$answer,
717
+			$input_constructor_args
718
+		);
719
+		remove_filter(
720
+			'FHEE__EE_Question__generate_form_input__country_options',
721
+			array($this, 'use_cached_countries_for_form_input')
722
+		);
723
+		remove_filter(
724
+			'FHEE__EE_Question__generate_form_input__state_options',
725
+			array($this, 'use_cached_states_for_form_input')
726
+		);
727
+		return $form_input;
728
+	}
729
+
730
+
731
+	/**
732
+	 * Gets the list of countries for the form input
733
+	 *
734
+	 * @param array|null      $countries_list
735
+	 * @param EE_Question     $question
736
+	 * @param EE_Registration $registration
737
+	 * @param EE_Answer       $answer
738
+	 * @return array 2d keys are country IDs, values are their names
739
+	 * @throws EE_Error
740
+	 * @throws InvalidArgumentException
741
+	 * @throws InvalidDataTypeException
742
+	 * @throws InvalidInterfaceException
743
+	 * @throws ReflectionException
744
+	 */
745
+	public function use_cached_countries_for_form_input(
746
+		$countries_list,
747
+		EE_Question $question = null,
748
+		EE_Registration $registration = null,
749
+		EE_Answer $answer = null
750
+	) {
751
+		$country_options = array('' => '');
752
+		// get possibly cached list of countries
753
+		$countries = $this->checkout->action === 'process_reg_step'
754
+			? EEM_Country::instance()->get_all_countries()
755
+			: EEM_Country::instance()->get_all_active_countries();
756
+		if (! empty($countries)) {
757
+			foreach ($countries as $country) {
758
+				if ($country instanceof EE_Country) {
759
+					$country_options[ $country->ID() ] = $country->name();
760
+				}
761
+			}
762
+		}
763
+		if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
764
+			$answer = EEM_Answer::instance()->get_one(
765
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
766
+			);
767
+		} else {
768
+			$answer = EE_Answer::new_instance();
769
+		}
770
+		$country_options = apply_filters(
771
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
772
+			$country_options,
773
+			$this,
774
+			$registration,
775
+			$question,
776
+			$answer
777
+		);
778
+		return $country_options;
779
+	}
780
+
781
+
782
+	/**
783
+	 * Gets the list of states for the form input
784
+	 *
785
+	 * @param array|null      $states_list
786
+	 * @param EE_Question     $question
787
+	 * @param EE_Registration $registration
788
+	 * @param EE_Answer       $answer
789
+	 * @return array 2d keys are state IDs, values are their names
790
+	 * @throws EE_Error
791
+	 * @throws InvalidArgumentException
792
+	 * @throws InvalidDataTypeException
793
+	 * @throws InvalidInterfaceException
794
+	 * @throws ReflectionException
795
+	 */
796
+	public function use_cached_states_for_form_input(
797
+		$states_list,
798
+		EE_Question $question = null,
799
+		EE_Registration $registration = null,
800
+		EE_Answer $answer = null
801
+	) {
802
+		$state_options = array('' => array('' => ''));
803
+		$states = $this->checkout->action === 'process_reg_step'
804
+			? EEM_State::instance()->get_all_states()
805
+			: EEM_State::instance()->get_all_active_states();
806
+		if (! empty($states)) {
807
+			foreach ($states as $state) {
808
+				if ($state instanceof EE_State) {
809
+					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
810
+				}
811
+			}
812
+		}
813
+		$state_options = apply_filters(
814
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
815
+			$state_options,
816
+			$this,
817
+			$registration,
818
+			$question,
819
+			$answer
820
+		);
821
+		return $state_options;
822
+	}
823
+
824
+
825
+	/********************************************************************************************************/
826
+	/****************************************  PROCESS REG STEP  ****************************************/
827
+	/********************************************************************************************************/
828
+
829
+
830
+	/**
831
+	 * @return bool
832
+	 * @throws EE_Error
833
+	 * @throws InvalidArgumentException
834
+	 * @throws ReflectionException
835
+	 * @throws RuntimeException
836
+	 * @throws InvalidDataTypeException
837
+	 * @throws InvalidInterfaceException
838
+	 */
839
+	public function process_reg_step()
840
+	{
841
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
842
+		// grab validated data from form
843
+		$valid_data = $this->checkout->current_step->valid_data();
844
+		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
845
+		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
846
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
847
+		if (empty($valid_data)) {
848
+			EE_Error::add_error(
849
+				esc_html__('No valid question responses were received.', 'event_espresso'),
850
+				__FILE__,
851
+				__FUNCTION__,
852
+				__LINE__
853
+			);
854
+			return false;
855
+		}
856
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
857
+			EE_Error::add_error(
858
+				esc_html__(
859
+					'A valid transaction could not be initiated for processing your registrations.',
860
+					'event_espresso'
861
+				),
862
+				__FILE__,
863
+				__FUNCTION__,
864
+				__LINE__
865
+			);
866
+			return false;
867
+		}
868
+		// get cached registrations
869
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
870
+		// verify we got the goods
871
+		if (empty($registrations)) {
872
+			// combine the old translated string with a new one, in order to not break translations
873
+			$error_message = esc_html__(
874
+				'Your form data could not be applied to any valid registrations.',
875
+				'event_espresso'
876
+			)
877
+			. sprintf(
878
+				esc_html_x(
879
+					'%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.',
880
+					'(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
881
+					'event_espresso'
882
+				),
883
+				'<a href="' . get_post_type_archive_link('espresso_events') . '" >',
884
+				'</a>',
885
+				'<br />'
886
+			);
887
+			EE_Error::add_error(
888
+				$error_message,
889
+				__FILE__,
890
+				__FUNCTION__,
891
+				__LINE__
892
+			);
893
+			return false;
894
+		}
895
+		// extract attendee info from form data and save to model objects
896
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
897
+		// if first pass thru SPCO,
898
+		// then let's check processed registrations against the total number of tickets in the cart
899
+		if ($registrations_processed === false) {
900
+			// but return immediately if the previous step exited early due to errors
901
+			return false;
902
+		}
903
+		if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
904
+			// generate a correctly translated string for all possible singular/plural combinations
905
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
906
+				$error_msg = sprintf(
907
+					esc_html_x(
908
+						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
909
+						'There was 1 ticket in the Event Queue, but 2 registrations were processed',
910
+						'event_espresso'
911
+					),
912
+					$this->checkout->total_ticket_count,
913
+					$registrations_processed
914
+				);
915
+			} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
916
+				$error_msg = sprintf(
917
+					esc_html_x(
918
+						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
919
+						'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
920
+						'event_espresso'
921
+					),
922
+					$this->checkout->total_ticket_count,
923
+					$registrations_processed
924
+				);
925
+			} else {
926
+				$error_msg = sprintf(
927
+					esc_html__(
928
+						'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
929
+						'event_espresso'
930
+					),
931
+					$this->checkout->total_ticket_count,
932
+					$registrations_processed
933
+				);
934
+			}
935
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
936
+			return false;
937
+		}
938
+		// mark this reg step as completed
939
+		$this->set_completed();
940
+		$this->_set_success_message(
941
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
942
+		);
943
+		// do action in case a plugin wants to do something with the data submitted in step 1.
944
+		// passes EE_Single_Page_Checkout, and it's posted data
945
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
946
+		return true;
947
+	}
948
+
949
+
950
+	/**
951
+	 *    _process_registrations
952
+	 *
953
+	 * @param EE_Registration[] $registrations
954
+	 * @param array[][]         $valid_data
955
+	 * @return bool|int
956
+	 * @throws EntityNotFoundException
957
+	 * @throws EE_Error
958
+	 * @throws InvalidArgumentException
959
+	 * @throws ReflectionException
960
+	 * @throws RuntimeException
961
+	 * @throws InvalidDataTypeException
962
+	 * @throws InvalidInterfaceException
963
+	 */
964
+	private function _process_registrations($registrations = array(), $valid_data = array())
965
+	{
966
+		// load resources and set some defaults
967
+		EE_Registry::instance()->load_model('Attendee');
968
+		// holder for primary registrant attendee object
969
+		$this->checkout->primary_attendee_obj = null;
970
+		// array for tracking reg form data for the primary registrant
971
+		$primary_registrant = array(
972
+			'line_item_id' => null,
973
+		);
974
+		$copy_primary = false;
975
+		// reg form sections that do not contain inputs
976
+		$non_input_form_sections = array(
977
+			'primary_registrant',
978
+			'additional_attendee_reg_info',
979
+			'spco_copy_attendee_chk',
980
+		);
981
+		// attendee counter
982
+		$att_nmbr = 0;
983
+		// grab the saved registrations from the transaction
984
+		foreach ($registrations as $registration) {
985
+			// verify EE_Registration object
986
+			if (! $registration instanceof EE_Registration) {
987
+				EE_Error::add_error(
988
+					esc_html__(
989
+						'An invalid Registration object was discovered when attempting to process your registration information.',
990
+						'event_espresso'
991
+					),
992
+					__FILE__,
993
+					__FUNCTION__,
994
+					__LINE__
995
+				);
996
+				return false;
997
+			}
998
+			/** @var string $reg_url_link */
999
+			$reg_url_link = $registration->reg_url_link();
1000
+			// reg_url_link exists ?
1001
+			if (! empty($reg_url_link)) {
1002
+				// should this registration be processed during this visit ?
1003
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
1004
+					// if NOT revisiting, then let's save the registration now,
1005
+					// so that we have a REG_ID to use when generating other objects
1006
+					if (! $this->checkout->revisit) {
1007
+						$registration->save();
1008
+					}
1009
+					/**
1010
+					 * This allows plugins to trigger a fail on processing of a
1011
+					 * registration for any conditions they may have for it to pass.
1012
+					 *
1013
+					 * @var bool   if true is returned by the plugin then the
1014
+					 *            registration processing is halted.
1015
+					 */
1016
+					if (apply_filters(
1017
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
1018
+						false,
1019
+						$att_nmbr,
1020
+						$registration,
1021
+						$registrations,
1022
+						$valid_data,
1023
+						$this
1024
+					)) {
1025
+						return false;
1026
+					}
1027
+
1028
+					// Houston, we have a registration!
1029
+					$att_nmbr++;
1030
+					$this->_attendee_data[ $reg_url_link ] = array();
1031
+					// grab any existing related answer objects
1032
+					$this->_registration_answers = $registration->answers();
1033
+					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
1034
+					if (isset($valid_data[ $reg_url_link ])) {
1035
+						// do we need to copy basic info from primary attendee ?
1036
+						$copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
1037
+										&& absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
1038
+						// filter form input data for this registration
1039
+						$valid_data[ $reg_url_link ] = (array) apply_filters(
1040
+							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
1041
+							$valid_data[ $reg_url_link ]
1042
+						);
1043
+						if (isset($valid_data['primary_attendee'])) {
1044
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
1045
+								? $valid_data['primary_attendee']
1046
+								: false;
1047
+							unset($valid_data['primary_attendee']);
1048
+						}
1049
+						// now loop through our array of valid post data && process attendee reg forms
1050
+						foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
1051
+							if (! in_array($form_section, $non_input_form_sections, true)) {
1052
+								foreach ($form_inputs as $form_input => $input_value) {
1053
+									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
1054
+									// check for critical inputs
1055
+									if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
1056
+										$form_input,
1057
+										$input_value
1058
+									)
1059
+									) {
1060
+										return false;
1061
+									}
1062
+									// store a bit of data about the primary attendee
1063
+									if ($att_nmbr === 1
1064
+										&& ! empty($input_value)
1065
+										&& $reg_url_link === $primary_registrant['line_item_id']
1066
+									) {
1067
+										$primary_registrant[ $form_input ] = $input_value;
1068
+									} elseif ($copy_primary
1069
+											  && $input_value === null
1070
+											  && isset($primary_registrant[ $form_input ])
1071
+									) {
1072
+										$input_value = $primary_registrant[ $form_input ];
1073
+									}
1074
+									// now attempt to save the input data
1075
+									if (! $this->_save_registration_form_input(
1076
+										$registration,
1077
+										$form_input,
1078
+										$input_value
1079
+									)
1080
+									) {
1081
+										EE_Error::add_error(
1082
+											sprintf(
1083
+												esc_html_x(
1084
+													'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1085
+													'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
1086
+													'event_espresso'
1087
+												),
1088
+												$form_input,
1089
+												$input_value
1090
+											),
1091
+											__FILE__,
1092
+											__FUNCTION__,
1093
+											__LINE__
1094
+										);
1095
+										return false;
1096
+									}
1097
+								}
1098
+							}
1099
+						}  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1100
+					}
1101
+					// EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1102
+					// this registration does not require additional attendee information ?
1103
+					if ($copy_primary
1104
+						&& $att_nmbr > 1
1105
+						&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1106
+					) {
1107
+						// just copy the primary registrant
1108
+						$attendee = $this->checkout->primary_attendee_obj;
1109
+					} else {
1110
+						// ensure critical details are set for additional attendees
1111
+						$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1112
+							? $this->_copy_critical_attendee_details_from_primary_registrant(
1113
+								$this->_attendee_data[ $reg_url_link ]
1114
+							)
1115
+							: $this->_attendee_data[ $reg_url_link ];
1116
+						// execute create attendee command (which may return an existing attendee)
1117
+						$attendee = EE_Registry::instance()->BUS->execute(
1118
+							new CreateAttendeeCommand(
1119
+								$this->_attendee_data[ $reg_url_link ],
1120
+								$registration
1121
+							)
1122
+						);
1123
+						// who's #1 ?
1124
+						if ($att_nmbr === 1) {
1125
+							$this->checkout->primary_attendee_obj = $attendee;
1126
+						}
1127
+					}
1128
+					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1129
+					// add relation to registration, set attendee ID, and cache attendee
1130
+					$this->_associate_attendee_with_registration($registration, $attendee);
1131
+					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1132
+					if (! $registration->attendee() instanceof EE_Attendee) {
1133
+						EE_Error::add_error(
1134
+							sprintf(
1135
+								esc_html_x(
1136
+									'Registration %s has an invalid or missing Attendee object.',
1137
+									'Registration 123-456-789 has an invalid or missing Attendee object.',
1138
+									'event_espresso'
1139
+								),
1140
+								$reg_url_link
1141
+							),
1142
+							__FILE__,
1143
+							__FUNCTION__,
1144
+							__LINE__
1145
+						);
1146
+						return false;
1147
+					}
1148
+					/** @type EE_Registration_Processor $registration_processor */
1149
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1150
+					// at this point, we should have enough details about the registrant to consider the registration
1151
+					// NOT incomplete
1152
+					$registration_processor->toggle_incomplete_registration_status_to_default(
1153
+						$registration,
1154
+						false,
1155
+						new Context(
1156
+							'spco_reg_step_attendee_information_process_registrations',
1157
+							esc_html__(
1158
+								'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1159
+								'event_espresso'
1160
+							)
1161
+						)
1162
+					);
1163
+					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1164
+					// abandoned
1165
+					$this->checkout->transaction->toggle_failed_transaction_status();
1166
+					// if we've gotten this far, then let's save what we have
1167
+					$registration->save();
1168
+					// add relation between TXN and registration
1169
+					$this->_associate_registration_with_transaction($registration);
1170
+				}
1171
+			} else {
1172
+				EE_Error::add_error(
1173
+					esc_html__(
1174
+						'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1175
+						'event_espresso'
1176
+					),
1177
+					__FILE__,
1178
+					__FUNCTION__,
1179
+					__LINE__
1180
+				);
1181
+				// remove malformed data
1182
+				unset($valid_data[ $reg_url_link ]);
1183
+				return false;
1184
+			}
1185
+		} // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1186
+		return $att_nmbr;
1187
+	}
1188
+
1189
+
1190
+	/**
1191
+	 *    _save_registration_form_input
1192
+	 *
1193
+	 * @param EE_Registration $registration
1194
+	 * @param string          $form_input
1195
+	 * @param string          $input_value
1196
+	 * @return bool
1197
+	 * @throws EE_Error
1198
+	 * @throws InvalidArgumentException
1199
+	 * @throws InvalidDataTypeException
1200
+	 * @throws InvalidInterfaceException
1201
+	 * @throws ReflectionException
1202
+	 */
1203
+	private function _save_registration_form_input(
1204
+		EE_Registration $registration,
1205
+		$form_input = '',
1206
+		$input_value = ''
1207
+	) {
1208
+		// \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1209
+		// \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1210
+		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1211
+		// allow for plugins to hook in and do their own processing of the form input.
1212
+		// For plugins to bypass normal processing here, they just need to return a boolean value.
1213
+		if (apply_filters(
1214
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1215
+			false,
1216
+			$registration,
1217
+			$form_input,
1218
+			$input_value,
1219
+			$this
1220
+		)) {
1221
+			return true;
1222
+		}
1223
+		/*
1224 1224
          * $answer_cache_id is the key used to find the EE_Answer we want
1225 1225
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1226 1226
          */
1227
-        $answer_cache_id = $this->checkout->reg_url_link
1228
-            ? $form_input . '-' . $registration->reg_url_link()
1229
-            : $form_input;
1230
-        $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1231
-                         && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer;
1232
-        // rename form_inputs if they are EE_Attendee properties
1233
-        switch ((string) $form_input) {
1234
-            case 'state':
1235
-            case 'STA_ID':
1236
-                $attendee_property = true;
1237
-                $form_input = 'STA_ID';
1238
-                break;
1239
-
1240
-            case 'country':
1241
-            case 'CNT_ISO':
1242
-                $attendee_property = true;
1243
-                $form_input = 'CNT_ISO';
1244
-                break;
1245
-
1246
-            default:
1247
-                $ATT_input = 'ATT_' . $form_input;
1248
-                // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1249
-                $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1250
-                $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1251
-        }
1252
-        // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1253
-        // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1254
-        // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1255
-        // if this form input has a corresponding attendee property
1256
-        if ($attendee_property) {
1257
-            $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1258
-            if ($answer_is_obj) {
1259
-                // and delete the corresponding answer since we won't be storing this data in that object
1260
-                $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1261
-                $this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1262
-            }
1263
-            return true;
1264
-        }
1265
-        if ($answer_is_obj) {
1266
-            // save this data to the answer object
1267
-            $this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1268
-            $result = $this->_registration_answers[ $answer_cache_id ]->save();
1269
-            return $result !== false;
1270
-        }
1271
-        foreach ($this->_registration_answers as $answer) {
1272
-            if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1273
-                $answer->set_value($input_value);
1274
-                $result = $answer->save();
1275
-                return $result !== false;
1276
-            }
1277
-        }
1278
-        return false;
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     *    _verify_critical_attendee_details_are_set
1284
-     *
1285
-     * @param string $form_input
1286
-     * @param string $input_value
1287
-     * @return boolean
1288
-     */
1289
-    private function _verify_critical_attendee_details_are_set_and_validate_email(
1290
-        $form_input = '',
1291
-        $input_value = ''
1292
-    ) {
1293
-        if (empty($input_value)) {
1294
-            // if the form input isn't marked as being required, then just return
1295
-            if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1296
-                return true;
1297
-            }
1298
-            switch ($form_input) {
1299
-                case 'fname':
1300
-                    EE_Error::add_error(
1301
-                        esc_html__('First Name is a required value.', 'event_espresso'),
1302
-                        __FILE__,
1303
-                        __FUNCTION__,
1304
-                        __LINE__
1305
-                    );
1306
-                    return false;
1307
-                    break;
1308
-                case 'lname':
1309
-                    EE_Error::add_error(
1310
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
1311
-                        __FILE__,
1312
-                        __FUNCTION__,
1313
-                        __LINE__
1314
-                    );
1315
-                    return false;
1316
-                    break;
1317
-                case 'email':
1318
-                    EE_Error::add_error(
1319
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
1320
-                        __FILE__,
1321
-                        __FUNCTION__,
1322
-                        __LINE__
1323
-                    );
1324
-                    return false;
1325
-                    break;
1326
-            }
1327
-        }
1328
-        return true;
1329
-    }
1330
-
1331
-
1332
-    /**
1333
-     *    _associate_attendee_with_registration
1334
-     *
1335
-     * @param EE_Registration $registration
1336
-     * @param EE_Attendee     $attendee
1337
-     * @return void
1338
-     * @throws EE_Error
1339
-     * @throws InvalidArgumentException
1340
-     * @throws ReflectionException
1341
-     * @throws RuntimeException
1342
-     * @throws InvalidDataTypeException
1343
-     * @throws InvalidInterfaceException
1344
-     */
1345
-    private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1346
-    {
1347
-        // add relation to attendee
1348
-        $registration->_add_relation_to($attendee, 'Attendee');
1349
-        $registration->set_attendee_id($attendee->ID());
1350
-        $registration->update_cache_after_object_save('Attendee', $attendee);
1351
-    }
1352
-
1353
-
1354
-    /**
1355
-     *    _associate_registration_with_transaction
1356
-     *
1357
-     * @param EE_Registration $registration
1358
-     * @return void
1359
-     * @throws EE_Error
1360
-     * @throws InvalidArgumentException
1361
-     * @throws ReflectionException
1362
-     * @throws InvalidDataTypeException
1363
-     * @throws InvalidInterfaceException
1364
-     */
1365
-    private function _associate_registration_with_transaction(EE_Registration $registration)
1366
-    {
1367
-        // add relation to registration
1368
-        $this->checkout->transaction->_add_relation_to($registration, 'Registration');
1369
-        $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1370
-    }
1371
-
1372
-
1373
-    /**
1374
-     *    _copy_critical_attendee_details_from_primary_registrant
1375
-     *    ensures that all attendees at least have data for first name, last name, and email address
1376
-     *
1377
-     * @param array $attendee_data
1378
-     * @return array
1379
-     * @throws EE_Error
1380
-     * @throws InvalidArgumentException
1381
-     * @throws ReflectionException
1382
-     * @throws InvalidDataTypeException
1383
-     * @throws InvalidInterfaceException
1384
-     */
1385
-    private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1386
-    {
1387
-        // bare minimum critical details include first name, last name, email address
1388
-        $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1389
-        // add address info to critical details?
1390
-        if (apply_filters(
1391
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1392
-            false
1393
-        )) {
1394
-            $address_details = array(
1395
-                'ATT_address',
1396
-                'ATT_address2',
1397
-                'ATT_city',
1398
-                'STA_ID',
1399
-                'CNT_ISO',
1400
-                'ATT_zip',
1401
-                'ATT_phone',
1402
-            );
1403
-            $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1404
-        }
1405
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
1406
-            if (! isset($attendee_data[ $critical_attendee_detail ])
1407
-                || empty($attendee_data[ $critical_attendee_detail ])
1408
-            ) {
1409
-                $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1410
-                    $critical_attendee_detail
1411
-                );
1412
-            }
1413
-        }
1414
-        return $attendee_data;
1415
-    }
1416
-
1417
-
1418
-    /**
1419
-     *    update_reg_step
1420
-     *    this is the final step after a user  revisits the site to edit their attendee information
1421
-     *    this gets called AFTER the process_reg_step() method above
1422
-     *
1423
-     * @return bool
1424
-     * @throws EE_Error
1425
-     * @throws InvalidArgumentException
1426
-     * @throws ReflectionException
1427
-     * @throws RuntimeException
1428
-     * @throws InvalidDataTypeException
1429
-     * @throws InvalidInterfaceException
1430
-     */
1431
-    public function update_reg_step()
1432
-    {
1433
-        // save everything
1434
-        if ($this->process_reg_step()) {
1435
-            $this->checkout->redirect = true;
1436
-            $this->checkout->redirect_url = add_query_arg(
1437
-                array(
1438
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
1439
-                    'revisit'        => true,
1440
-                ),
1441
-                $this->checkout->thank_you_page_url
1442
-            );
1443
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1444
-            return true;
1445
-        }
1446
-        return false;
1447
-    }
1227
+		$answer_cache_id = $this->checkout->reg_url_link
1228
+			? $form_input . '-' . $registration->reg_url_link()
1229
+			: $form_input;
1230
+		$answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1231
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer;
1232
+		// rename form_inputs if they are EE_Attendee properties
1233
+		switch ((string) $form_input) {
1234
+			case 'state':
1235
+			case 'STA_ID':
1236
+				$attendee_property = true;
1237
+				$form_input = 'STA_ID';
1238
+				break;
1239
+
1240
+			case 'country':
1241
+			case 'CNT_ISO':
1242
+				$attendee_property = true;
1243
+				$form_input = 'CNT_ISO';
1244
+				break;
1245
+
1246
+			default:
1247
+				$ATT_input = 'ATT_' . $form_input;
1248
+				// EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1249
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1250
+				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1251
+		}
1252
+		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1253
+		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1254
+		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1255
+		// if this form input has a corresponding attendee property
1256
+		if ($attendee_property) {
1257
+			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1258
+			if ($answer_is_obj) {
1259
+				// and delete the corresponding answer since we won't be storing this data in that object
1260
+				$registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1261
+				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1262
+			}
1263
+			return true;
1264
+		}
1265
+		if ($answer_is_obj) {
1266
+			// save this data to the answer object
1267
+			$this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1268
+			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1269
+			return $result !== false;
1270
+		}
1271
+		foreach ($this->_registration_answers as $answer) {
1272
+			if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1273
+				$answer->set_value($input_value);
1274
+				$result = $answer->save();
1275
+				return $result !== false;
1276
+			}
1277
+		}
1278
+		return false;
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 *    _verify_critical_attendee_details_are_set
1284
+	 *
1285
+	 * @param string $form_input
1286
+	 * @param string $input_value
1287
+	 * @return boolean
1288
+	 */
1289
+	private function _verify_critical_attendee_details_are_set_and_validate_email(
1290
+		$form_input = '',
1291
+		$input_value = ''
1292
+	) {
1293
+		if (empty($input_value)) {
1294
+			// if the form input isn't marked as being required, then just return
1295
+			if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1296
+				return true;
1297
+			}
1298
+			switch ($form_input) {
1299
+				case 'fname':
1300
+					EE_Error::add_error(
1301
+						esc_html__('First Name is a required value.', 'event_espresso'),
1302
+						__FILE__,
1303
+						__FUNCTION__,
1304
+						__LINE__
1305
+					);
1306
+					return false;
1307
+					break;
1308
+				case 'lname':
1309
+					EE_Error::add_error(
1310
+						esc_html__('Last Name is a required value.', 'event_espresso'),
1311
+						__FILE__,
1312
+						__FUNCTION__,
1313
+						__LINE__
1314
+					);
1315
+					return false;
1316
+					break;
1317
+				case 'email':
1318
+					EE_Error::add_error(
1319
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
1320
+						__FILE__,
1321
+						__FUNCTION__,
1322
+						__LINE__
1323
+					);
1324
+					return false;
1325
+					break;
1326
+			}
1327
+		}
1328
+		return true;
1329
+	}
1330
+
1331
+
1332
+	/**
1333
+	 *    _associate_attendee_with_registration
1334
+	 *
1335
+	 * @param EE_Registration $registration
1336
+	 * @param EE_Attendee     $attendee
1337
+	 * @return void
1338
+	 * @throws EE_Error
1339
+	 * @throws InvalidArgumentException
1340
+	 * @throws ReflectionException
1341
+	 * @throws RuntimeException
1342
+	 * @throws InvalidDataTypeException
1343
+	 * @throws InvalidInterfaceException
1344
+	 */
1345
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1346
+	{
1347
+		// add relation to attendee
1348
+		$registration->_add_relation_to($attendee, 'Attendee');
1349
+		$registration->set_attendee_id($attendee->ID());
1350
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1351
+	}
1352
+
1353
+
1354
+	/**
1355
+	 *    _associate_registration_with_transaction
1356
+	 *
1357
+	 * @param EE_Registration $registration
1358
+	 * @return void
1359
+	 * @throws EE_Error
1360
+	 * @throws InvalidArgumentException
1361
+	 * @throws ReflectionException
1362
+	 * @throws InvalidDataTypeException
1363
+	 * @throws InvalidInterfaceException
1364
+	 */
1365
+	private function _associate_registration_with_transaction(EE_Registration $registration)
1366
+	{
1367
+		// add relation to registration
1368
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1369
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1370
+	}
1371
+
1372
+
1373
+	/**
1374
+	 *    _copy_critical_attendee_details_from_primary_registrant
1375
+	 *    ensures that all attendees at least have data for first name, last name, and email address
1376
+	 *
1377
+	 * @param array $attendee_data
1378
+	 * @return array
1379
+	 * @throws EE_Error
1380
+	 * @throws InvalidArgumentException
1381
+	 * @throws ReflectionException
1382
+	 * @throws InvalidDataTypeException
1383
+	 * @throws InvalidInterfaceException
1384
+	 */
1385
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1386
+	{
1387
+		// bare minimum critical details include first name, last name, email address
1388
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1389
+		// add address info to critical details?
1390
+		if (apply_filters(
1391
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1392
+			false
1393
+		)) {
1394
+			$address_details = array(
1395
+				'ATT_address',
1396
+				'ATT_address2',
1397
+				'ATT_city',
1398
+				'STA_ID',
1399
+				'CNT_ISO',
1400
+				'ATT_zip',
1401
+				'ATT_phone',
1402
+			);
1403
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1404
+		}
1405
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1406
+			if (! isset($attendee_data[ $critical_attendee_detail ])
1407
+				|| empty($attendee_data[ $critical_attendee_detail ])
1408
+			) {
1409
+				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1410
+					$critical_attendee_detail
1411
+				);
1412
+			}
1413
+		}
1414
+		return $attendee_data;
1415
+	}
1416
+
1417
+
1418
+	/**
1419
+	 *    update_reg_step
1420
+	 *    this is the final step after a user  revisits the site to edit their attendee information
1421
+	 *    this gets called AFTER the process_reg_step() method above
1422
+	 *
1423
+	 * @return bool
1424
+	 * @throws EE_Error
1425
+	 * @throws InvalidArgumentException
1426
+	 * @throws ReflectionException
1427
+	 * @throws RuntimeException
1428
+	 * @throws InvalidDataTypeException
1429
+	 * @throws InvalidInterfaceException
1430
+	 */
1431
+	public function update_reg_step()
1432
+	{
1433
+		// save everything
1434
+		if ($this->process_reg_step()) {
1435
+			$this->checkout->redirect = true;
1436
+			$this->checkout->redirect_url = add_query_arg(
1437
+				array(
1438
+					'e_reg_url_link' => $this->checkout->reg_url_link,
1439
+					'revisit'        => true,
1440
+				),
1441
+				$this->checkout->thank_you_page_url
1442
+			);
1443
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1444
+			return true;
1445
+		}
1446
+		return false;
1447
+	}
1448 1448
 }
Please login to merge, or discard this patch.