@@ -20,604 +20,604 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data |
22 | 22 | { |
23 | - // some specific properties we need for this class |
|
24 | - private $_events = []; |
|
25 | - |
|
26 | - private $_attendees = []; |
|
27 | - |
|
28 | - private $_registrations = []; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
33 | - * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
34 | - * we'll get the first three published events from the users database and use that as a source. |
|
35 | - * |
|
36 | - * @param array $data |
|
37 | - * @throws EE_Error |
|
38 | - * @throws EE_Error |
|
39 | - * @throws ReflectionException |
|
40 | - */ |
|
41 | - public function __construct($data = []) |
|
42 | - { |
|
43 | - $this->_data = isset($data['event_ids']) ? $data['event_ids'] : []; |
|
44 | - $this->_setup_attendees_events(); |
|
45 | - parent::__construct($data); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
51 | - * |
|
52 | - * @param array $data The incoming data to be prepped. |
|
53 | - * |
|
54 | - * @return array The prepped data for db |
|
55 | - */ |
|
56 | - public static function convert_data_for_persistent_storage($data) |
|
57 | - { |
|
58 | - return $data; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
64 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
65 | - * |
|
66 | - * @param array $data |
|
67 | - * |
|
68 | - * @return array |
|
69 | - */ |
|
70 | - public static function convert_data_from_persistent_storage($data) |
|
71 | - { |
|
72 | - return $data; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * This will just setup the _events property in the expected format. |
|
78 | - * |
|
79 | - * @throws EE_Error |
|
80 | - * @throws ReflectionException |
|
81 | - */ |
|
82 | - private function _setup_attendees_events() |
|
83 | - { |
|
84 | - |
|
85 | - // setup some attendee objects |
|
86 | - $attendees = $this->_get_some_attendees(); |
|
87 | - |
|
88 | - // if empty $data we'll do a query to get some events from the server. |
|
89 | - // otherwise we'll retrieve the event data for the given ids. |
|
90 | - $events = $this->_get_some_events($this->_data); |
|
91 | - |
|
92 | - $answers_n_questions = $this->_get_some_q_and_as(); |
|
93 | - |
|
94 | - if (count($events) < 1) { |
|
95 | - throw new EE_Error( |
|
96 | - esc_html__( |
|
97 | - 'We can\'t generate a preview for you because there are no active events in your database', |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
105 | - // we'll actually use the generated line_item identifiers for our loop |
|
106 | - $dtts = $tkts = []; |
|
107 | - foreach ($events as $id => $event) { |
|
108 | - if (! $event instanceof EE_Event) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - $this->_events[ $id ]['ID'] = $id; |
|
112 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
113 | - $datetime = $event->get_first_related('Datetime'); |
|
114 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
115 | - 'Ticket', |
|
116 | - ['default_where_conditions' => 'none'] |
|
117 | - ) : []; |
|
118 | - $this->_events[ $id ]['event'] = $event; |
|
119 | - $this->_events[ $id ]['reg_objs'] = []; |
|
120 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
121 | - $this->_events[ $id ]['dtt_objs'] = []; |
|
122 | - |
|
123 | - $tkts = []; |
|
124 | - foreach ($tickets as $ticket) { |
|
125 | - if (! $ticket instanceof EE_Ticket) { |
|
126 | - continue; |
|
127 | - } |
|
128 | - $reldatetime = $ticket->datetimes(); |
|
129 | - $tkts[ $ticket->ID() ] = []; |
|
130 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
131 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
132 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
133 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
134 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
135 | - foreach ($reldatetime as $datetime) { |
|
136 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
137 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
138 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
139 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
140 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
146 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
147 | - |
|
148 | - // let's also setup the dummy attendees property! |
|
149 | - foreach ($attendees as $att_key => $attendee) { |
|
150 | - if (! $attendee instanceof EE_Attendee) { |
|
151 | - continue; |
|
152 | - } |
|
153 | - $this->_attendees[ $att_key ]['line_ref'][] = |
|
154 | - $id; // so later it can be determined what events this attendee registered for! |
|
155 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
156 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
157 | - // $this->_attendees[$att_key]['registration_id'] = 0; |
|
158 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
159 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
160 | - if ($att_key == 999999991) { |
|
161 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
162 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
163 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
164 | - } elseif ($att_key == 999999992) { |
|
165 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
166 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
167 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
168 | - } elseif ($att_key == 999999993) { |
|
169 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
170 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
171 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - $this->tickets = $tkts; |
|
177 | - $this->datetimes = $dtts; |
|
178 | - $this->answers = $answers_n_questions['answers']; |
|
179 | - $this->questions = $answers_n_questions['questions']; |
|
180 | - $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
186 | - * |
|
187 | - * @access private |
|
188 | - * @return array an array of attendee objects |
|
189 | - * @throws EE_Error |
|
190 | - * @throws EE_Error |
|
191 | - */ |
|
192 | - private function _get_some_attendees() |
|
193 | - { |
|
194 | - // let's just setup a dummy array of various attendee details |
|
195 | - $dummy_attendees = [ |
|
196 | - 0 => [ |
|
197 | - 'Luke', |
|
198 | - 'Skywalker', |
|
199 | - '[email protected]', |
|
200 | - '804 Bantha Dr.', |
|
201 | - 'Complex 8', |
|
202 | - 'Mos Eisley', |
|
203 | - 32, |
|
204 | - 'US', |
|
205 | - 'f0r3e', |
|
206 | - '222-333-4763', |
|
207 | - false, |
|
208 | - '999999991', |
|
209 | - ], |
|
210 | - 1 => [ |
|
211 | - 'Princess', |
|
212 | - 'Leia', |
|
213 | - '[email protected]', |
|
214 | - '1456 Valley Way Boulevard', |
|
215 | - 'Suite 9', |
|
216 | - 'Alderaan', |
|
217 | - 15, |
|
218 | - 'US', |
|
219 | - 'c1h2c', |
|
220 | - '78-123-111-1111', |
|
221 | - false, |
|
222 | - '999999992', |
|
223 | - ], |
|
224 | - 2 => [ |
|
225 | - 'Yoda', |
|
226 | - 'I Am', |
|
227 | - '[email protected]', |
|
228 | - '4th Tree', |
|
229 | - '5th Knot', |
|
230 | - 'Marsh', |
|
231 | - 22, |
|
232 | - 'US', |
|
233 | - 'l18n', |
|
234 | - '999-999-9999', |
|
235 | - false, |
|
236 | - '999999993', |
|
237 | - ], |
|
238 | - ]; |
|
239 | - |
|
240 | - // let's generate the attendee objects |
|
241 | - $attendees = []; |
|
242 | - $var_array = [ |
|
243 | - 'fname', |
|
244 | - 'lname', |
|
245 | - 'email', |
|
246 | - 'address', |
|
247 | - 'address2', |
|
248 | - 'city', |
|
249 | - 'staid', |
|
250 | - 'cntry', |
|
251 | - 'zip', |
|
252 | - 'phone', |
|
253 | - 'deleted', |
|
254 | - 'attid', |
|
255 | - ]; |
|
256 | - |
|
257 | - // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
258 | - foreach ($dummy_attendees as $dummy) { |
|
259 | - $att = array_combine($var_array, $dummy); |
|
260 | - extract($att); |
|
261 | - /** @var $fname string */ |
|
262 | - /** @var $lname string */ |
|
263 | - /** @var $address string */ |
|
264 | - /** @var $address2 string */ |
|
265 | - /** @var $city string */ |
|
266 | - /** @var $staid string */ |
|
267 | - /** @var $cntry string */ |
|
268 | - /** @var $zip string */ |
|
269 | - /** @var $email string */ |
|
270 | - /** @var $phone string */ |
|
271 | - /** @var $attid string */ |
|
272 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
273 | - [ |
|
274 | - 'ATT_fname' => $fname, |
|
275 | - 'ATT_lname' => $lname, |
|
276 | - 'ATT_address' => $address, |
|
277 | - 'ATT_address2' => $address2, |
|
278 | - 'ATT_city' => $city, |
|
279 | - 'STA_ID' => $staid, |
|
280 | - 'CNT_ISO' => $cntry, |
|
281 | - 'ATT_zip' => $zip, |
|
282 | - 'ATT_email' => $email, |
|
283 | - 'ATT_phone' => $phone, |
|
284 | - 'ATT_ID' => $attid, |
|
285 | - ] |
|
286 | - ); |
|
287 | - } |
|
288 | - |
|
289 | - return $attendees; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
295 | - * This will be used in our dummy data setup |
|
296 | - * |
|
297 | - * @return array |
|
298 | - * @throws EE_Error |
|
299 | - * @throws ReflectionException |
|
300 | - */ |
|
301 | - private function _get_some_q_and_as() |
|
302 | - { |
|
303 | - $questions_data = [ |
|
304 | - 0 => [ |
|
305 | - 555, |
|
306 | - esc_html__('What is your favorite planet?', 'event_espresso'), |
|
307 | - 0, |
|
308 | - ], |
|
309 | - 1 => [ |
|
310 | - 556, |
|
311 | - esc_html__('What is your favorite food?', 'event_espresso'), |
|
312 | - 0, |
|
313 | - ], |
|
314 | - 2 => [ |
|
315 | - 557, |
|
316 | - esc_html__('How many lightyears have you travelled', 'event_espresso'), |
|
317 | - 0, |
|
318 | - ], |
|
319 | - ]; |
|
320 | - |
|
321 | - $answers_data = [ |
|
322 | - 0 => [ |
|
323 | - 999, |
|
324 | - 555, |
|
325 | - 'Tattoine', |
|
326 | - ], |
|
327 | - 1 => [ |
|
328 | - 1000, |
|
329 | - 555, |
|
330 | - 'Alderaan', |
|
331 | - ], |
|
332 | - 2 => [ |
|
333 | - 1001, |
|
334 | - 555, |
|
335 | - 'Dantooine', |
|
336 | - ], |
|
337 | - 3 => [ |
|
338 | - 1002, |
|
339 | - 556, |
|
340 | - 'Fish Fingers', |
|
341 | - ], |
|
342 | - 4 => [ |
|
343 | - 1003, |
|
344 | - 556, |
|
345 | - 'Sushi', |
|
346 | - ], |
|
347 | - 5 => [ |
|
348 | - 1004, |
|
349 | - 556, |
|
350 | - 'Water', |
|
351 | - ], |
|
352 | - 6 => [ |
|
353 | - 1005, |
|
354 | - 557, |
|
355 | - 'A lot', |
|
356 | - ], |
|
357 | - 7 => [ |
|
358 | - 1006, |
|
359 | - 557, |
|
360 | - "That's none of your business.", |
|
361 | - ], |
|
362 | - 8 => [ |
|
363 | - 1007, |
|
364 | - 557, |
|
365 | - "People less travel me then.", |
|
366 | - ], |
|
367 | - ]; |
|
368 | - |
|
369 | - $question_columns = ['QST_ID', 'QST_display_text', 'QST_system']; |
|
370 | - $answer_columns = ['ANS_ID', 'QST_ID', 'ANS_value']; |
|
371 | - |
|
372 | - // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
373 | - // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
374 | - |
|
375 | - $questions = []; |
|
376 | - // first the questions |
|
377 | - foreach ($questions_data as $question_data) { |
|
378 | - $question_data_with_keys = array_combine($question_columns, $question_data); |
|
379 | - $question = EE_Question::new_instance($question_data_with_keys); |
|
380 | - $questions[ $question->ID() ] = $question; |
|
381 | - } |
|
382 | - |
|
383 | - // now the answers (and we'll setup our arrays) |
|
384 | - $questions_and_answers = []; |
|
385 | - foreach ($answers_data as $answer_data) { |
|
386 | - $answer_data_with_keys = array_combine($answer_columns, $answer_data); |
|
387 | - $answer = EE_Answer::new_instance($answer_data_with_keys); |
|
388 | - $questions_and_answers['answers'][ $answer->ID() ] = $answer; |
|
389 | - $questions_and_answers['questions'][ $answer->ID() ] = $questions[ $answer->question_ID() ]; |
|
390 | - } |
|
391 | - |
|
392 | - return $questions_and_answers; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * Return an array of event objects from the database |
|
398 | - * |
|
399 | - * If event ids are not included then we'll just retrieve the first published event from the database. |
|
400 | - * |
|
401 | - * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
402 | - * |
|
403 | - * @return array An array of event objects from the db. |
|
404 | - * @throws EE_Error |
|
405 | - */ |
|
406 | - private function _get_some_events(array $event_ids = []) |
|
407 | - { |
|
408 | - /** @var RequestInterface $request */ |
|
409 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
410 | - // if we have an evt_id then we want to make sure we use that for the preview |
|
411 | - // (because a specific event template is being viewed); |
|
412 | - $event_ids = $request->getRequestParam('evt_id', $event_ids, 'int', true); |
|
413 | - // clear out any invalid IDs, like 0 |
|
414 | - $event_ids = array_filter($event_ids); |
|
415 | - $limit = ! empty($event_ids) |
|
416 | - ? null |
|
417 | - : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
418 | - |
|
419 | - $where = ! empty($event_ids) |
|
420 | - ? [ |
|
421 | - 'EVT_ID' => ['IN', $event_ids], |
|
422 | - 'Datetime.Ticket.TKT_ID' => ['>', 1], |
|
423 | - ] |
|
424 | - : ['Datetime.Ticket.TKT_ID' => ['>', 1]]; |
|
425 | - |
|
426 | - return EEM_Event::instance()->get_all([$where, 'limit' => $limit]); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * @throws EE_Error |
|
432 | - * @throws ReflectionException |
|
433 | - */ |
|
434 | - protected function _setup_data() |
|
435 | - { |
|
436 | - // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
437 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
438 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
439 | - $session = EE_Registry::instance()->SSN; |
|
440 | - } else { |
|
441 | - $session = EE_Registry::instance()->load_core('Session'); |
|
442 | - } |
|
443 | - $cart = EE_Cart::instance(null, $session); |
|
444 | - |
|
445 | - // add tickets to cart |
|
446 | - foreach ($this->tickets as $ticket) { |
|
447 | - $cart->add_ticket_to_cart($ticket['ticket']); |
|
448 | - } |
|
449 | - |
|
450 | - // setup txn property |
|
451 | - $this->txn = EE_Transaction::new_instance( |
|
452 | - [ |
|
453 | - 'TXN_timestamp' => time(), // unix timestamp |
|
454 | - 'TXN_total' => 0, // txn_total |
|
455 | - 'TXN_paid' => 0, // txn_paid |
|
456 | - 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
457 | - 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
458 | - 'TXN_hash_salt' => null, // hash salt blank as well |
|
459 | - 'TXN_ID' => 999999, |
|
460 | - ] |
|
461 | - ); |
|
462 | - |
|
463 | - |
|
464 | - // setup reg_objects |
|
465 | - // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
466 | - $this->reg_objs = []; |
|
467 | - $regid = 9999990; |
|
468 | - foreach ($this->_attendees as $key => $attendee) { |
|
469 | - // note we need to setup reg_objects for each event this attendee belongs to |
|
470 | - $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
471 | - $regtxn = $this->txn->ID(); |
|
472 | - $regcnt = 1; |
|
473 | - foreach ($attendee['line_ref'] as $evtid) { |
|
474 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
475 | - if (! $ticket instanceof EE_Ticket) { |
|
476 | - continue; |
|
477 | - } |
|
478 | - $reg_array = [ |
|
479 | - 'EVT_ID' => $evtid, |
|
480 | - 'ATT_ID' => $regatt, |
|
481 | - 'TXN_ID' => $regtxn, |
|
482 | - 'TKT_ID' => $ticket->ID(), |
|
483 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
484 | - 'REG_date' => time(), |
|
485 | - 'REG_final_price' => $ticket->get('TKT_price'), |
|
486 | - 'REG_session' => 'dummy_session_id', |
|
487 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
488 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
489 | - 'REG_count' => $regcnt, |
|
490 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
491 | - 'REG_att_is_going' => true, |
|
492 | - 'REG_ID' => $regid, |
|
493 | - ]; |
|
494 | - $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
495 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
496 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
497 | - $this->reg_objs[] = $REG_OBJ; |
|
498 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
499 | - |
|
500 | - $regcnt++; |
|
501 | - $regid++; |
|
502 | - } |
|
503 | - } |
|
504 | - } |
|
505 | - |
|
506 | - |
|
507 | - // setup line items! |
|
508 | - $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
509 | - |
|
510 | - // add tickets |
|
511 | - foreach ($this->tickets as $item) { |
|
512 | - $qty = $item['count']; |
|
513 | - $ticket = $item['ticket']; |
|
514 | - EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
515 | - } |
|
516 | - |
|
517 | - $shipping_line_item = EE_Line_Item::new_instance( |
|
518 | - [ |
|
519 | - 'LIN_name' => esc_html__( |
|
520 | - 'Shipping Surcharge', |
|
521 | - 'event_espresso' |
|
522 | - ), |
|
523 | - 'LIN_desc' => esc_html__( |
|
524 | - 'Sent via Millenium Falcon', |
|
525 | - 'event_espresso' |
|
526 | - ), |
|
527 | - 'LIN_unit_price' => 20, |
|
528 | - 'LIN_quantity' => 1, |
|
529 | - 'LIN_is_taxable' => true, |
|
530 | - 'LIN_total' => 20, |
|
531 | - 'LIN_type' => EEM_Line_Item::type_line_item, |
|
532 | - ] |
|
533 | - ); |
|
534 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
535 | - $this->additional_line_items = [$shipping_line_item]; |
|
536 | - |
|
537 | - // now let's add taxes |
|
538 | - EEH_Line_Item::apply_taxes($line_item_total); |
|
539 | - |
|
540 | - // now we should be able to get the items we need from this object |
|
541 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
542 | - $line_items = []; |
|
543 | - foreach ($event_line_items as $line_item) { |
|
544 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
545 | - continue; |
|
546 | - } |
|
547 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
548 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
549 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
550 | - continue; |
|
551 | - } |
|
552 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
553 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
554 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
555 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = |
|
556 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
557 | - } |
|
558 | - } |
|
559 | - |
|
560 | - $this->line_items_with_children = $line_items; |
|
561 | - $this->tax_line_items = $line_item_total->tax_descendants(); |
|
562 | - |
|
563 | - // add proper total to transaction object. |
|
564 | - $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
565 | - $this->grand_total_line_item = $line_item_total; |
|
566 | - $this->txn->set_total($grand_total); |
|
567 | - |
|
568 | - |
|
569 | - // add additional details for each registration |
|
570 | - foreach ($this->reg_objs as $reg) { |
|
571 | - if (! $reg instanceof EE_Registration) { |
|
572 | - continue; |
|
573 | - } |
|
574 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
575 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
576 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
577 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
578 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
579 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - // events and attendees |
|
584 | - $this->events = $this->_events; |
|
585 | - $this->attendees = $this->_attendees; |
|
586 | - $this->registrations = $this->_registrations; |
|
587 | - |
|
588 | - $attendees_to_shift = $this->_attendees; |
|
589 | - |
|
590 | - // setup primary attendee property |
|
591 | - $this->primary_attendee_data = [ |
|
592 | - 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
593 | - ? $this->_attendees[999999991]['att_obj']->fname() |
|
594 | - : '', |
|
595 | - |
|
596 | - 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
597 | - ? $this->_attendees[999999991]['att_obj']->lname() |
|
598 | - : '', |
|
599 | - |
|
600 | - 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
601 | - ? $this->_attendees[999999991]['att_obj']->email() |
|
602 | - : '', |
|
603 | - |
|
604 | - 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
605 | - |
|
606 | - 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']), |
|
607 | - ]; |
|
608 | - |
|
609 | - // reg_info property |
|
610 | - // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
611 | - $this->reg_info = []; |
|
612 | - |
|
613 | - // let's set a reg_obj for messengers expecting one. |
|
614 | - $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
615 | - |
|
616 | - // the below are just dummy items. |
|
617 | - $this->user_id = 1; |
|
618 | - $this->ip_address = '192.0.2.1'; |
|
619 | - $this->user_agent = ''; |
|
620 | - $this->init_access = time(); |
|
621 | - $this->last_access = time(); |
|
622 | - } |
|
23 | + // some specific properties we need for this class |
|
24 | + private $_events = []; |
|
25 | + |
|
26 | + private $_attendees = []; |
|
27 | + |
|
28 | + private $_registrations = []; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
33 | + * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
34 | + * we'll get the first three published events from the users database and use that as a source. |
|
35 | + * |
|
36 | + * @param array $data |
|
37 | + * @throws EE_Error |
|
38 | + * @throws EE_Error |
|
39 | + * @throws ReflectionException |
|
40 | + */ |
|
41 | + public function __construct($data = []) |
|
42 | + { |
|
43 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : []; |
|
44 | + $this->_setup_attendees_events(); |
|
45 | + parent::__construct($data); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
51 | + * |
|
52 | + * @param array $data The incoming data to be prepped. |
|
53 | + * |
|
54 | + * @return array The prepped data for db |
|
55 | + */ |
|
56 | + public static function convert_data_for_persistent_storage($data) |
|
57 | + { |
|
58 | + return $data; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
64 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
65 | + * |
|
66 | + * @param array $data |
|
67 | + * |
|
68 | + * @return array |
|
69 | + */ |
|
70 | + public static function convert_data_from_persistent_storage($data) |
|
71 | + { |
|
72 | + return $data; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * This will just setup the _events property in the expected format. |
|
78 | + * |
|
79 | + * @throws EE_Error |
|
80 | + * @throws ReflectionException |
|
81 | + */ |
|
82 | + private function _setup_attendees_events() |
|
83 | + { |
|
84 | + |
|
85 | + // setup some attendee objects |
|
86 | + $attendees = $this->_get_some_attendees(); |
|
87 | + |
|
88 | + // if empty $data we'll do a query to get some events from the server. |
|
89 | + // otherwise we'll retrieve the event data for the given ids. |
|
90 | + $events = $this->_get_some_events($this->_data); |
|
91 | + |
|
92 | + $answers_n_questions = $this->_get_some_q_and_as(); |
|
93 | + |
|
94 | + if (count($events) < 1) { |
|
95 | + throw new EE_Error( |
|
96 | + esc_html__( |
|
97 | + 'We can\'t generate a preview for you because there are no active events in your database', |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
105 | + // we'll actually use the generated line_item identifiers for our loop |
|
106 | + $dtts = $tkts = []; |
|
107 | + foreach ($events as $id => $event) { |
|
108 | + if (! $event instanceof EE_Event) { |
|
109 | + continue; |
|
110 | + } |
|
111 | + $this->_events[ $id ]['ID'] = $id; |
|
112 | + $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
113 | + $datetime = $event->get_first_related('Datetime'); |
|
114 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
115 | + 'Ticket', |
|
116 | + ['default_where_conditions' => 'none'] |
|
117 | + ) : []; |
|
118 | + $this->_events[ $id ]['event'] = $event; |
|
119 | + $this->_events[ $id ]['reg_objs'] = []; |
|
120 | + $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
121 | + $this->_events[ $id ]['dtt_objs'] = []; |
|
122 | + |
|
123 | + $tkts = []; |
|
124 | + foreach ($tickets as $ticket) { |
|
125 | + if (! $ticket instanceof EE_Ticket) { |
|
126 | + continue; |
|
127 | + } |
|
128 | + $reldatetime = $ticket->datetimes(); |
|
129 | + $tkts[ $ticket->ID() ] = []; |
|
130 | + $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
131 | + $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
132 | + $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
133 | + $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
134 | + $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
135 | + foreach ($reldatetime as $datetime) { |
|
136 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
137 | + $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
138 | + $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
139 | + $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
140 | + $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
146 | + $this->_events[ $id ]['att_objs'] = $attendees; |
|
147 | + |
|
148 | + // let's also setup the dummy attendees property! |
|
149 | + foreach ($attendees as $att_key => $attendee) { |
|
150 | + if (! $attendee instanceof EE_Attendee) { |
|
151 | + continue; |
|
152 | + } |
|
153 | + $this->_attendees[ $att_key ]['line_ref'][] = |
|
154 | + $id; // so later it can be determined what events this attendee registered for! |
|
155 | + $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
156 | + $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
157 | + // $this->_attendees[$att_key]['registration_id'] = 0; |
|
158 | + $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
159 | + $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
160 | + if ($att_key == 999999991) { |
|
161 | + $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
162 | + $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
163 | + $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
164 | + } elseif ($att_key == 999999992) { |
|
165 | + $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
166 | + $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
167 | + $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
168 | + } elseif ($att_key == 999999993) { |
|
169 | + $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
170 | + $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
171 | + $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + $this->tickets = $tkts; |
|
177 | + $this->datetimes = $dtts; |
|
178 | + $this->answers = $answers_n_questions['answers']; |
|
179 | + $this->questions = $answers_n_questions['questions']; |
|
180 | + $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
186 | + * |
|
187 | + * @access private |
|
188 | + * @return array an array of attendee objects |
|
189 | + * @throws EE_Error |
|
190 | + * @throws EE_Error |
|
191 | + */ |
|
192 | + private function _get_some_attendees() |
|
193 | + { |
|
194 | + // let's just setup a dummy array of various attendee details |
|
195 | + $dummy_attendees = [ |
|
196 | + 0 => [ |
|
197 | + 'Luke', |
|
198 | + 'Skywalker', |
|
199 | + '[email protected]', |
|
200 | + '804 Bantha Dr.', |
|
201 | + 'Complex 8', |
|
202 | + 'Mos Eisley', |
|
203 | + 32, |
|
204 | + 'US', |
|
205 | + 'f0r3e', |
|
206 | + '222-333-4763', |
|
207 | + false, |
|
208 | + '999999991', |
|
209 | + ], |
|
210 | + 1 => [ |
|
211 | + 'Princess', |
|
212 | + 'Leia', |
|
213 | + '[email protected]', |
|
214 | + '1456 Valley Way Boulevard', |
|
215 | + 'Suite 9', |
|
216 | + 'Alderaan', |
|
217 | + 15, |
|
218 | + 'US', |
|
219 | + 'c1h2c', |
|
220 | + '78-123-111-1111', |
|
221 | + false, |
|
222 | + '999999992', |
|
223 | + ], |
|
224 | + 2 => [ |
|
225 | + 'Yoda', |
|
226 | + 'I Am', |
|
227 | + '[email protected]', |
|
228 | + '4th Tree', |
|
229 | + '5th Knot', |
|
230 | + 'Marsh', |
|
231 | + 22, |
|
232 | + 'US', |
|
233 | + 'l18n', |
|
234 | + '999-999-9999', |
|
235 | + false, |
|
236 | + '999999993', |
|
237 | + ], |
|
238 | + ]; |
|
239 | + |
|
240 | + // let's generate the attendee objects |
|
241 | + $attendees = []; |
|
242 | + $var_array = [ |
|
243 | + 'fname', |
|
244 | + 'lname', |
|
245 | + 'email', |
|
246 | + 'address', |
|
247 | + 'address2', |
|
248 | + 'city', |
|
249 | + 'staid', |
|
250 | + 'cntry', |
|
251 | + 'zip', |
|
252 | + 'phone', |
|
253 | + 'deleted', |
|
254 | + 'attid', |
|
255 | + ]; |
|
256 | + |
|
257 | + // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
258 | + foreach ($dummy_attendees as $dummy) { |
|
259 | + $att = array_combine($var_array, $dummy); |
|
260 | + extract($att); |
|
261 | + /** @var $fname string */ |
|
262 | + /** @var $lname string */ |
|
263 | + /** @var $address string */ |
|
264 | + /** @var $address2 string */ |
|
265 | + /** @var $city string */ |
|
266 | + /** @var $staid string */ |
|
267 | + /** @var $cntry string */ |
|
268 | + /** @var $zip string */ |
|
269 | + /** @var $email string */ |
|
270 | + /** @var $phone string */ |
|
271 | + /** @var $attid string */ |
|
272 | + $attendees[ $attid ] = EE_Attendee::new_instance( |
|
273 | + [ |
|
274 | + 'ATT_fname' => $fname, |
|
275 | + 'ATT_lname' => $lname, |
|
276 | + 'ATT_address' => $address, |
|
277 | + 'ATT_address2' => $address2, |
|
278 | + 'ATT_city' => $city, |
|
279 | + 'STA_ID' => $staid, |
|
280 | + 'CNT_ISO' => $cntry, |
|
281 | + 'ATT_zip' => $zip, |
|
282 | + 'ATT_email' => $email, |
|
283 | + 'ATT_phone' => $phone, |
|
284 | + 'ATT_ID' => $attid, |
|
285 | + ] |
|
286 | + ); |
|
287 | + } |
|
288 | + |
|
289 | + return $attendees; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
295 | + * This will be used in our dummy data setup |
|
296 | + * |
|
297 | + * @return array |
|
298 | + * @throws EE_Error |
|
299 | + * @throws ReflectionException |
|
300 | + */ |
|
301 | + private function _get_some_q_and_as() |
|
302 | + { |
|
303 | + $questions_data = [ |
|
304 | + 0 => [ |
|
305 | + 555, |
|
306 | + esc_html__('What is your favorite planet?', 'event_espresso'), |
|
307 | + 0, |
|
308 | + ], |
|
309 | + 1 => [ |
|
310 | + 556, |
|
311 | + esc_html__('What is your favorite food?', 'event_espresso'), |
|
312 | + 0, |
|
313 | + ], |
|
314 | + 2 => [ |
|
315 | + 557, |
|
316 | + esc_html__('How many lightyears have you travelled', 'event_espresso'), |
|
317 | + 0, |
|
318 | + ], |
|
319 | + ]; |
|
320 | + |
|
321 | + $answers_data = [ |
|
322 | + 0 => [ |
|
323 | + 999, |
|
324 | + 555, |
|
325 | + 'Tattoine', |
|
326 | + ], |
|
327 | + 1 => [ |
|
328 | + 1000, |
|
329 | + 555, |
|
330 | + 'Alderaan', |
|
331 | + ], |
|
332 | + 2 => [ |
|
333 | + 1001, |
|
334 | + 555, |
|
335 | + 'Dantooine', |
|
336 | + ], |
|
337 | + 3 => [ |
|
338 | + 1002, |
|
339 | + 556, |
|
340 | + 'Fish Fingers', |
|
341 | + ], |
|
342 | + 4 => [ |
|
343 | + 1003, |
|
344 | + 556, |
|
345 | + 'Sushi', |
|
346 | + ], |
|
347 | + 5 => [ |
|
348 | + 1004, |
|
349 | + 556, |
|
350 | + 'Water', |
|
351 | + ], |
|
352 | + 6 => [ |
|
353 | + 1005, |
|
354 | + 557, |
|
355 | + 'A lot', |
|
356 | + ], |
|
357 | + 7 => [ |
|
358 | + 1006, |
|
359 | + 557, |
|
360 | + "That's none of your business.", |
|
361 | + ], |
|
362 | + 8 => [ |
|
363 | + 1007, |
|
364 | + 557, |
|
365 | + "People less travel me then.", |
|
366 | + ], |
|
367 | + ]; |
|
368 | + |
|
369 | + $question_columns = ['QST_ID', 'QST_display_text', 'QST_system']; |
|
370 | + $answer_columns = ['ANS_ID', 'QST_ID', 'ANS_value']; |
|
371 | + |
|
372 | + // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
373 | + // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
374 | + |
|
375 | + $questions = []; |
|
376 | + // first the questions |
|
377 | + foreach ($questions_data as $question_data) { |
|
378 | + $question_data_with_keys = array_combine($question_columns, $question_data); |
|
379 | + $question = EE_Question::new_instance($question_data_with_keys); |
|
380 | + $questions[ $question->ID() ] = $question; |
|
381 | + } |
|
382 | + |
|
383 | + // now the answers (and we'll setup our arrays) |
|
384 | + $questions_and_answers = []; |
|
385 | + foreach ($answers_data as $answer_data) { |
|
386 | + $answer_data_with_keys = array_combine($answer_columns, $answer_data); |
|
387 | + $answer = EE_Answer::new_instance($answer_data_with_keys); |
|
388 | + $questions_and_answers['answers'][ $answer->ID() ] = $answer; |
|
389 | + $questions_and_answers['questions'][ $answer->ID() ] = $questions[ $answer->question_ID() ]; |
|
390 | + } |
|
391 | + |
|
392 | + return $questions_and_answers; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * Return an array of event objects from the database |
|
398 | + * |
|
399 | + * If event ids are not included then we'll just retrieve the first published event from the database. |
|
400 | + * |
|
401 | + * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
402 | + * |
|
403 | + * @return array An array of event objects from the db. |
|
404 | + * @throws EE_Error |
|
405 | + */ |
|
406 | + private function _get_some_events(array $event_ids = []) |
|
407 | + { |
|
408 | + /** @var RequestInterface $request */ |
|
409 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
410 | + // if we have an evt_id then we want to make sure we use that for the preview |
|
411 | + // (because a specific event template is being viewed); |
|
412 | + $event_ids = $request->getRequestParam('evt_id', $event_ids, 'int', true); |
|
413 | + // clear out any invalid IDs, like 0 |
|
414 | + $event_ids = array_filter($event_ids); |
|
415 | + $limit = ! empty($event_ids) |
|
416 | + ? null |
|
417 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
418 | + |
|
419 | + $where = ! empty($event_ids) |
|
420 | + ? [ |
|
421 | + 'EVT_ID' => ['IN', $event_ids], |
|
422 | + 'Datetime.Ticket.TKT_ID' => ['>', 1], |
|
423 | + ] |
|
424 | + : ['Datetime.Ticket.TKT_ID' => ['>', 1]]; |
|
425 | + |
|
426 | + return EEM_Event::instance()->get_all([$where, 'limit' => $limit]); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * @throws EE_Error |
|
432 | + * @throws ReflectionException |
|
433 | + */ |
|
434 | + protected function _setup_data() |
|
435 | + { |
|
436 | + // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
437 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
438 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
439 | + $session = EE_Registry::instance()->SSN; |
|
440 | + } else { |
|
441 | + $session = EE_Registry::instance()->load_core('Session'); |
|
442 | + } |
|
443 | + $cart = EE_Cart::instance(null, $session); |
|
444 | + |
|
445 | + // add tickets to cart |
|
446 | + foreach ($this->tickets as $ticket) { |
|
447 | + $cart->add_ticket_to_cart($ticket['ticket']); |
|
448 | + } |
|
449 | + |
|
450 | + // setup txn property |
|
451 | + $this->txn = EE_Transaction::new_instance( |
|
452 | + [ |
|
453 | + 'TXN_timestamp' => time(), // unix timestamp |
|
454 | + 'TXN_total' => 0, // txn_total |
|
455 | + 'TXN_paid' => 0, // txn_paid |
|
456 | + 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
457 | + 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
458 | + 'TXN_hash_salt' => null, // hash salt blank as well |
|
459 | + 'TXN_ID' => 999999, |
|
460 | + ] |
|
461 | + ); |
|
462 | + |
|
463 | + |
|
464 | + // setup reg_objects |
|
465 | + // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
466 | + $this->reg_objs = []; |
|
467 | + $regid = 9999990; |
|
468 | + foreach ($this->_attendees as $key => $attendee) { |
|
469 | + // note we need to setup reg_objects for each event this attendee belongs to |
|
470 | + $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
471 | + $regtxn = $this->txn->ID(); |
|
472 | + $regcnt = 1; |
|
473 | + foreach ($attendee['line_ref'] as $evtid) { |
|
474 | + foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
475 | + if (! $ticket instanceof EE_Ticket) { |
|
476 | + continue; |
|
477 | + } |
|
478 | + $reg_array = [ |
|
479 | + 'EVT_ID' => $evtid, |
|
480 | + 'ATT_ID' => $regatt, |
|
481 | + 'TXN_ID' => $regtxn, |
|
482 | + 'TKT_ID' => $ticket->ID(), |
|
483 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
484 | + 'REG_date' => time(), |
|
485 | + 'REG_final_price' => $ticket->get('TKT_price'), |
|
486 | + 'REG_session' => 'dummy_session_id', |
|
487 | + 'REG_code' => $regid . '-dummy-generated-code', |
|
488 | + 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
489 | + 'REG_count' => $regcnt, |
|
490 | + 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
491 | + 'REG_att_is_going' => true, |
|
492 | + 'REG_ID' => $regid, |
|
493 | + ]; |
|
494 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
495 | + $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
496 | + $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
497 | + $this->reg_objs[] = $REG_OBJ; |
|
498 | + $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
499 | + |
|
500 | + $regcnt++; |
|
501 | + $regid++; |
|
502 | + } |
|
503 | + } |
|
504 | + } |
|
505 | + |
|
506 | + |
|
507 | + // setup line items! |
|
508 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
509 | + |
|
510 | + // add tickets |
|
511 | + foreach ($this->tickets as $item) { |
|
512 | + $qty = $item['count']; |
|
513 | + $ticket = $item['ticket']; |
|
514 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
515 | + } |
|
516 | + |
|
517 | + $shipping_line_item = EE_Line_Item::new_instance( |
|
518 | + [ |
|
519 | + 'LIN_name' => esc_html__( |
|
520 | + 'Shipping Surcharge', |
|
521 | + 'event_espresso' |
|
522 | + ), |
|
523 | + 'LIN_desc' => esc_html__( |
|
524 | + 'Sent via Millenium Falcon', |
|
525 | + 'event_espresso' |
|
526 | + ), |
|
527 | + 'LIN_unit_price' => 20, |
|
528 | + 'LIN_quantity' => 1, |
|
529 | + 'LIN_is_taxable' => true, |
|
530 | + 'LIN_total' => 20, |
|
531 | + 'LIN_type' => EEM_Line_Item::type_line_item, |
|
532 | + ] |
|
533 | + ); |
|
534 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
535 | + $this->additional_line_items = [$shipping_line_item]; |
|
536 | + |
|
537 | + // now let's add taxes |
|
538 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
539 | + |
|
540 | + // now we should be able to get the items we need from this object |
|
541 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
542 | + $line_items = []; |
|
543 | + foreach ($event_line_items as $line_item) { |
|
544 | + if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
545 | + continue; |
|
546 | + } |
|
547 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
548 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
549 | + if (! $ticket_line_item instanceof EE_Line_Item) { |
|
550 | + continue; |
|
551 | + } |
|
552 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
553 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
554 | + $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
555 | + $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = |
|
556 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
557 | + } |
|
558 | + } |
|
559 | + |
|
560 | + $this->line_items_with_children = $line_items; |
|
561 | + $this->tax_line_items = $line_item_total->tax_descendants(); |
|
562 | + |
|
563 | + // add proper total to transaction object. |
|
564 | + $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
565 | + $this->grand_total_line_item = $line_item_total; |
|
566 | + $this->txn->set_total($grand_total); |
|
567 | + |
|
568 | + |
|
569 | + // add additional details for each registration |
|
570 | + foreach ($this->reg_objs as $reg) { |
|
571 | + if (! $reg instanceof EE_Registration) { |
|
572 | + continue; |
|
573 | + } |
|
574 | + $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
575 | + $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
576 | + $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
577 | + $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
578 | + $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
579 | + $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + // events and attendees |
|
584 | + $this->events = $this->_events; |
|
585 | + $this->attendees = $this->_attendees; |
|
586 | + $this->registrations = $this->_registrations; |
|
587 | + |
|
588 | + $attendees_to_shift = $this->_attendees; |
|
589 | + |
|
590 | + // setup primary attendee property |
|
591 | + $this->primary_attendee_data = [ |
|
592 | + 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
593 | + ? $this->_attendees[999999991]['att_obj']->fname() |
|
594 | + : '', |
|
595 | + |
|
596 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
597 | + ? $this->_attendees[999999991]['att_obj']->lname() |
|
598 | + : '', |
|
599 | + |
|
600 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
601 | + ? $this->_attendees[999999991]['att_obj']->email() |
|
602 | + : '', |
|
603 | + |
|
604 | + 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
605 | + |
|
606 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']), |
|
607 | + ]; |
|
608 | + |
|
609 | + // reg_info property |
|
610 | + // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
611 | + $this->reg_info = []; |
|
612 | + |
|
613 | + // let's set a reg_obj for messengers expecting one. |
|
614 | + $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
615 | + |
|
616 | + // the below are just dummy items. |
|
617 | + $this->user_id = 1; |
|
618 | + $this->ip_address = '192.0.2.1'; |
|
619 | + $this->user_agent = ''; |
|
620 | + $this->init_access = time(); |
|
621 | + $this->last_access = time(); |
|
622 | + } |
|
623 | 623 | } |
@@ -105,70 +105,70 @@ discard block |
||
105 | 105 | // we'll actually use the generated line_item identifiers for our loop |
106 | 106 | $dtts = $tkts = []; |
107 | 107 | foreach ($events as $id => $event) { |
108 | - if (! $event instanceof EE_Event) { |
|
108 | + if ( ! $event instanceof EE_Event) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | - $this->_events[ $id ]['ID'] = $id; |
|
112 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
111 | + $this->_events[$id]['ID'] = $id; |
|
112 | + $this->_events[$id]['name'] = $event->get('EVT_name'); |
|
113 | 113 | $datetime = $event->get_first_related('Datetime'); |
114 | 114 | $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
115 | 115 | 'Ticket', |
116 | 116 | ['default_where_conditions' => 'none'] |
117 | 117 | ) : []; |
118 | - $this->_events[ $id ]['event'] = $event; |
|
119 | - $this->_events[ $id ]['reg_objs'] = []; |
|
120 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
121 | - $this->_events[ $id ]['dtt_objs'] = []; |
|
118 | + $this->_events[$id]['event'] = $event; |
|
119 | + $this->_events[$id]['reg_objs'] = []; |
|
120 | + $this->_events[$id]['tkt_objs'] = $tickets; |
|
121 | + $this->_events[$id]['dtt_objs'] = []; |
|
122 | 122 | |
123 | - $tkts = []; |
|
123 | + $tkts = []; |
|
124 | 124 | foreach ($tickets as $ticket) { |
125 | - if (! $ticket instanceof EE_Ticket) { |
|
125 | + if ( ! $ticket instanceof EE_Ticket) { |
|
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | $reldatetime = $ticket->datetimes(); |
129 | - $tkts[ $ticket->ID() ] = []; |
|
130 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
131 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
132 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
133 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
134 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
129 | + $tkts[$ticket->ID()] = []; |
|
130 | + $tkts[$ticket->ID()]['ticket'] = $ticket; |
|
131 | + $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime; |
|
132 | + $tkts[$ticket->ID()]['att_objs'] = $attendees; |
|
133 | + $tkts[$ticket->ID()]['count'] = count($attendees); |
|
134 | + $tkts[$ticket->ID()]['EE_Event'] = $event; |
|
135 | 135 | foreach ($reldatetime as $datetime) { |
136 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
137 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
138 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
139 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
140 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
136 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) { |
|
137 | + $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime; |
|
138 | + $dtts[$datetime->ID()]['datetime'] = $datetime; |
|
139 | + $dtts[$datetime->ID()]['tkt_objs'][] = $ticket; |
|
140 | + $dtts[$datetime->ID()]['evt_objs'][] = $event; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
146 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
145 | + $this->_events[$id]['total_attendees'] = count($attendees); |
|
146 | + $this->_events[$id]['att_objs'] = $attendees; |
|
147 | 147 | |
148 | 148 | // let's also setup the dummy attendees property! |
149 | 149 | foreach ($attendees as $att_key => $attendee) { |
150 | - if (! $attendee instanceof EE_Attendee) { |
|
150 | + if ( ! $attendee instanceof EE_Attendee) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | - $this->_attendees[ $att_key ]['line_ref'][] = |
|
154 | - $id; // so later it can be determined what events this attendee registered for! |
|
155 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
156 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
153 | + $this->_attendees[$att_key]['line_ref'][] = |
|
154 | + $id; // so later it can be determined what events this attendee registered for! |
|
155 | + $this->_attendees[$att_key]['evt_objs'][] = $event; |
|
156 | + $this->_attendees[$att_key]['att_obj'] = $attendee; |
|
157 | 157 | // $this->_attendees[$att_key]['registration_id'] = 0; |
158 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
159 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
158 | + $this->_attendees[$att_key]['attendee_email'] = $attendee->email(); |
|
159 | + $this->_attendees[$att_key]['tkt_objs'] = $tickets; |
|
160 | 160 | if ($att_key == 999999991) { |
161 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
162 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
163 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
161 | + $this->_attendees[$att_key]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
162 | + $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
163 | + $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
164 | 164 | } elseif ($att_key == 999999992) { |
165 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
166 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
167 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
165 | + $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
166 | + $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
167 | + $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
168 | 168 | } elseif ($att_key == 999999993) { |
169 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
170 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
171 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
169 | + $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
170 | + $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
171 | + $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | /** @var $email string */ |
270 | 270 | /** @var $phone string */ |
271 | 271 | /** @var $attid string */ |
272 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
272 | + $attendees[$attid] = EE_Attendee::new_instance( |
|
273 | 273 | [ |
274 | 274 | 'ATT_fname' => $fname, |
275 | 275 | 'ATT_lname' => $lname, |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | foreach ($questions_data as $question_data) { |
378 | 378 | $question_data_with_keys = array_combine($question_columns, $question_data); |
379 | 379 | $question = EE_Question::new_instance($question_data_with_keys); |
380 | - $questions[ $question->ID() ] = $question; |
|
380 | + $questions[$question->ID()] = $question; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // now the answers (and we'll setup our arrays) |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | foreach ($answers_data as $answer_data) { |
386 | 386 | $answer_data_with_keys = array_combine($answer_columns, $answer_data); |
387 | 387 | $answer = EE_Answer::new_instance($answer_data_with_keys); |
388 | - $questions_and_answers['answers'][ $answer->ID() ] = $answer; |
|
389 | - $questions_and_answers['questions'][ $answer->ID() ] = $questions[ $answer->question_ID() ]; |
|
388 | + $questions_and_answers['answers'][$answer->ID()] = $answer; |
|
389 | + $questions_and_answers['questions'][$answer->ID()] = $questions[$answer->question_ID()]; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $questions_and_answers; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | $regtxn = $this->txn->ID(); |
472 | 472 | $regcnt = 1; |
473 | 473 | foreach ($attendee['line_ref'] as $evtid) { |
474 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
475 | - if (! $ticket instanceof EE_Ticket) { |
|
474 | + foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) { |
|
475 | + if ( ! $ticket instanceof EE_Ticket) { |
|
476 | 476 | continue; |
477 | 477 | } |
478 | - $reg_array = [ |
|
478 | + $reg_array = [ |
|
479 | 479 | 'EVT_ID' => $evtid, |
480 | 480 | 'ATT_ID' => $regatt, |
481 | 481 | 'TXN_ID' => $regtxn, |
@@ -484,18 +484,18 @@ discard block |
||
484 | 484 | 'REG_date' => time(), |
485 | 485 | 'REG_final_price' => $ticket->get('TKT_price'), |
486 | 486 | 'REG_session' => 'dummy_session_id', |
487 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
488 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
487 | + 'REG_code' => $regid.'-dummy-generated-code', |
|
488 | + 'REG_url_link' => $regcnt.'-daafpapasdlfakasdfpqasdfasdf', |
|
489 | 489 | 'REG_count' => $regcnt, |
490 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
490 | + 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
|
491 | 491 | 'REG_att_is_going' => true, |
492 | 492 | 'REG_ID' => $regid, |
493 | 493 | ]; |
494 | 494 | $REG_OBJ = EE_Registration::new_instance($reg_array); |
495 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
496 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
495 | + $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ; |
|
496 | + $this->_events[$evtid]['reg_objs'][] = $REG_OBJ; |
|
497 | 497 | $this->reg_objs[] = $REG_OBJ; |
498 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
498 | + $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ; |
|
499 | 499 | |
500 | 500 | $regcnt++; |
501 | 501 | $regid++; |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
542 | 542 | $line_items = []; |
543 | 543 | foreach ($event_line_items as $line_item) { |
544 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
544 | + if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
545 | 545 | continue; |
546 | 546 | } |
547 | 547 | $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
548 | 548 | foreach ($ticket_line_items as $ticket_line_item) { |
549 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
549 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
550 | 550 | continue; |
551 | 551 | } |
552 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
553 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
554 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
555 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = |
|
556 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
552 | + $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item; |
|
553 | + $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children(); |
|
554 | + $line_items[$ticket_line_item->ID()]['children'] = $ticket_line_item->children(); |
|
555 | + $line_items[$ticket_line_item->ID()]['EE_Ticket'] = |
|
556 | + $this->tickets[$ticket_line_item->OBJ_ID()]['ticket']; |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
@@ -568,15 +568,15 @@ discard block |
||
568 | 568 | |
569 | 569 | // add additional details for each registration |
570 | 570 | foreach ($this->reg_objs as $reg) { |
571 | - if (! $reg instanceof EE_Registration) { |
|
571 | + if ( ! $reg instanceof EE_Registration) { |
|
572 | 572 | continue; |
573 | 573 | } |
574 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
575 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
576 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
577 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
578 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
579 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
574 | + $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket']; |
|
575 | + $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event']; |
|
576 | + $this->_registrations[$reg->ID()]['reg_obj'] = $reg; |
|
577 | + $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs']; |
|
578 | + $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj']; |
|
579 | + $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs']; |
|
580 | 580 | } |
581 | 581 | |
582 | 582 |