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