@@ -565,7 +565,7 @@ |
||
565 | 565 | * @since 4.9.1 |
566 | 566 | * @param int $att_nmbr |
567 | 567 | * @param EE_Line_Item | string $item |
568 | - * @return string |
|
568 | + * @return RegUrlLink |
|
569 | 569 | */ |
570 | 570 | public function generate_reg_url_link($att_nmbr, $item) |
571 | 571 | { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
217 | 217 | if ( ! EE_Processor_Base::$IPN ) { |
218 | - // otherwise, send out notifications |
|
218 | + // otherwise, send out notifications |
|
219 | 219 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
220 | 220 | } |
221 | 221 | // DEBUG LOG |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
264 | 264 | if ( ! EE_Processor_Base::$IPN ) { |
265 | - // otherwise, send out notifications |
|
265 | + // otherwise, send out notifications |
|
266 | 266 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
267 | 267 | } |
268 | 268 | // DEBUG LOG |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
351 | 351 | if ( ! EE_Processor_Base::$IPN ) { |
352 | - // otherwise, send out notifications |
|
352 | + // otherwise, send out notifications |
|
353 | 353 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
354 | 354 | } |
355 | 355 | // DEBUG LOG |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | // false, |
391 | 391 | // 'EE_Transaction: ' . $registration->transaction()->ID() |
392 | 392 | // ); |
393 | - if ( ! $registration->is_primary_registrant()) { |
|
394 | - return; |
|
395 | - } |
|
396 | - do_action( |
|
393 | + if ( ! $registration->is_primary_registrant()) { |
|
394 | + return; |
|
395 | + } |
|
396 | + do_action( |
|
397 | 397 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
398 | 398 | $registration, |
399 | 399 | $additional_details |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | // set new REG_Status |
429 | 429 | $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
430 | 430 | return $this->reg_status_updated( $registration->ID() ) |
431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
431 | + && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
432 | 432 | ? true |
433 | 433 | : false; |
434 | 434 | } |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | |
509 | 509 | |
510 | 510 | |
511 | - /** |
|
512 | - * update_registration_after_being_canceled_or_declined |
|
513 | - * |
|
514 | - * @param \EE_Registration $registration |
|
515 | - * @param array $closed_reg_statuses |
|
516 | - * @param bool $update_reg |
|
517 | - * @return bool |
|
518 | - * @throws \EE_Error |
|
519 | - */ |
|
511 | + /** |
|
512 | + * update_registration_after_being_canceled_or_declined |
|
513 | + * |
|
514 | + * @param \EE_Registration $registration |
|
515 | + * @param array $closed_reg_statuses |
|
516 | + * @param bool $update_reg |
|
517 | + * @return bool |
|
518 | + * @throws \EE_Error |
|
519 | + */ |
|
520 | 520 | public function update_registration_after_being_canceled_or_declined( |
521 | 521 | EE_Registration $registration, |
522 | 522 | $closed_reg_statuses = array(), |
@@ -524,14 +524,14 @@ discard block |
||
524 | 524 | ) { |
525 | 525 | // these reg statuses should not be considered in any calculations involving monies owing |
526 | 526 | $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
527 | - ? $closed_reg_statuses |
|
527 | + ? $closed_reg_statuses |
|
528 | 528 | : EEM_Registration::closed_reg_statuses(); |
529 | 529 | if ( ! in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
530 | 530 | return false; |
531 | 531 | } |
532 | - // release a reserved ticket by decrementing ticket and datetime reserved values |
|
533 | - $registration->release_reserved_ticket(true); |
|
534 | - $registration->set_final_price(0); |
|
532 | + // release a reserved ticket by decrementing ticket and datetime reserved values |
|
533 | + $registration->release_reserved_ticket(true); |
|
534 | + $registration->set_final_price(0); |
|
535 | 535 | if ( $update_reg ) { |
536 | 536 | $registration->save(); |
537 | 537 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\core\domain\entities\RegUrlLink; |
4 | 4 | use EventEspresso\core\domain\services\registration\CreateRegistrationService; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Class EE_Registration_Processor |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function instance() { |
68 | 68 | // check if class object is instantiated |
69 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
69 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
70 | 70 | self::$_instance = new self(); |
71 | 71 | } |
72 | 72 | return self::$_instance; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param int $REG_ID |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function old_reg_status( $REG_ID ) { |
|
90 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
89 | + public function old_reg_status($REG_ID) { |
|
90 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @param int $REG_ID |
97 | 97 | * @param string $old_reg_status |
98 | 98 | */ |
99 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
99 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
100 | 100 | // only set the first time |
101 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
102 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
101 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
102 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param int $REG_ID |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function new_reg_status( $REG_ID ) { |
|
113 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
112 | + public function new_reg_status($REG_ID) { |
|
113 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param int $REG_ID |
120 | 120 | * @param string $new_reg_status |
121 | 121 | */ |
122 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
123 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
122 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
123 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param int $REG_ID |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - public function reg_status_updated( $REG_ID ) { |
|
135 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
134 | + public function reg_status_updated($REG_ID) { |
|
135 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @param \EE_Registration $registration |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) { |
|
145 | - $this->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
146 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ); |
|
147 | - $this->toggle_registration_status_if_no_monies_owing( $registration, false ); |
|
144 | + public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) { |
|
145 | + $this->toggle_incomplete_registration_status_to_default($registration, false); |
|
146 | + $this->toggle_registration_status_for_default_approved_events($registration, false); |
|
147 | + $this->toggle_registration_status_if_no_monies_owing($registration, false); |
|
148 | 148 | $registration->save(); |
149 | 149 | // trigger notifications |
150 | - $this->trigger_registration_update_notifications( $registration ); |
|
150 | + $this->trigger_registration_update_notifications($registration); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | * @return boolean |
163 | 163 | * @throws \EE_Error |
164 | 164 | */ |
165 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
165 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
166 | 166 | // set initial REG_Status |
167 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
167 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
168 | 168 | // set incoming REG_Status |
169 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
169 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
170 | 170 | // toggle reg status but only if it has changed and the user can do so |
171 | 171 | if ( |
172 | - $this->reg_status_updated( $registration->ID() ) && |
|
173 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
172 | + $this->reg_status_updated($registration->ID()) && |
|
173 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
174 | 174 | ) { |
175 | 175 | // change status to new value |
176 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) { |
|
176 | + if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) { |
|
177 | 177 | $registration->save(); |
178 | 178 | } |
179 | 179 | return TRUE; |
@@ -193,30 +193,30 @@ discard block |
||
193 | 193 | * @return void |
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
196 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
197 | 197 | $existing_reg_status = $registration->status_ID(); |
198 | 198 | // set initial REG_Status |
199 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
199 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
200 | 200 | // is the registration currently incomplete ? |
201 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
201 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
202 | 202 | // grab default reg status for the event, if set |
203 | 203 | $event_default_registration_status = $registration->event()->default_registration_status(); |
204 | 204 | // if no default reg status is set for the event, then use the global value |
205 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
205 | + $STS_ID = ! empty($event_default_registration_status) |
|
206 | 206 | ? $event_default_registration_status |
207 | 207 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
208 | 208 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
209 | 209 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
210 | 210 | // set incoming REG_Status |
211 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
212 | - $registration->set_status( $STS_ID ); |
|
213 | - if ( $save ) { |
|
211 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
212 | + $registration->set_status($STS_ID); |
|
213 | + if ($save) { |
|
214 | 214 | $registration->save(); |
215 | 215 | } |
216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
217 | - if ( ! EE_Processor_Base::$IPN ) { |
|
217 | + if ( ! EE_Processor_Base::$IPN) { |
|
218 | 218 | // otherwise, send out notifications |
219 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
219 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
220 | 220 | } |
221 | 221 | // DEBUG LOG |
222 | 222 | //$this->log( |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * @return boolean |
242 | 242 | * @throws \EE_Error |
243 | 243 | */ |
244 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
244 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
245 | 245 | $reg_status = $registration->status_ID(); |
246 | 246 | // set initial REG_Status |
247 | - $this->set_old_reg_status( $registration->ID(), $reg_status ); |
|
247 | + $this->set_old_reg_status($registration->ID(), $reg_status); |
|
248 | 248 | // if not already, toggle reg status to approved IF the event default reg status is approved |
249 | 249 | // ( as long as the registration wasn't cancelled or declined at some point ) |
250 | 250 | if ( |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | $registration->event()->default_registration_status() === EEM_Registration::status_id_approved |
255 | 255 | ) { |
256 | 256 | // set incoming REG_Status |
257 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
257 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
258 | 258 | // toggle status to approved |
259 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
260 | - if ( $save ) { |
|
259 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
260 | + if ($save) { |
|
261 | 261 | $registration->save(); |
262 | 262 | } |
263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
264 | - if ( ! EE_Processor_Base::$IPN ) { |
|
264 | + if ( ! EE_Processor_Base::$IPN) { |
|
265 | 265 | // otherwise, send out notifications |
266 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
266 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
267 | 267 | } |
268 | 268 | // DEBUG LOG |
269 | 269 | //$this->log( |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | * @throws \EE_Error |
293 | 293 | */ |
294 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
294 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
295 | 295 | // set initial REG_Status |
296 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
296 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
297 | 297 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
298 | 298 | // was a payment just made ? |
299 | 299 | if ( |
300 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
301 | - $additional_details[ 'payment_updates' ] && |
|
302 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
300 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
301 | + $additional_details['payment_updates'] && |
|
302 | + $additional_details['last_payment'] instanceof EE_Payment |
|
303 | 303 | ) { |
304 | - $payment = $additional_details[ 'last_payment' ]; |
|
304 | + $payment = $additional_details['last_payment']; |
|
305 | 305 | $total_paid = 0; |
306 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
306 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
307 | 307 | $total_paid += $amount_paid; |
308 | 308 | } |
309 | 309 | } else { |
@@ -327,30 +327,30 @@ discard block |
||
327 | 327 | $registration->transaction()->is_completed() || |
328 | 328 | $registration->transaction()->is_overpaid() || |
329 | 329 | $registration->transaction()->is_free() || |
330 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
330 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
331 | 331 | ) || ( |
332 | 332 | $payment instanceof EE_Payment && |
333 | 333 | $payment->is_approved() && |
334 | 334 | // this specific registration has not yet been paid for |
335 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
335 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
336 | 336 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
337 | 337 | $payment->amount() - $total_paid >= $registration->final_price() |
338 | 338 | ) |
339 | 339 | ) |
340 | 340 | ) { |
341 | 341 | // mark as paid |
342 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
342 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
343 | 343 | // track new REG_Status |
344 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
344 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
345 | 345 | // toggle status to approved |
346 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
347 | - if ( $save ) { |
|
346 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
347 | + if ($save) { |
|
348 | 348 | $registration->save(); |
349 | 349 | } |
350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
351 | - if ( ! EE_Processor_Base::$IPN ) { |
|
351 | + if ( ! EE_Processor_Base::$IPN) { |
|
352 | 352 | // otherwise, send out notifications |
353 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
353 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
354 | 354 | } |
355 | 355 | // DEBUG LOG |
356 | 356 | //$this->log( |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | * @param array $additional_details |
377 | 377 | * @return void |
378 | 378 | */ |
379 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
379 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
380 | 380 | try { |
381 | - if ( ! $registration instanceof EE_Registration ) { |
|
382 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
381 | + if ( ! $registration instanceof EE_Registration) { |
|
382 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
383 | 383 | } |
384 | 384 | // EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
385 | 385 | // EEH_Debug_Tools::log( |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | $registration, |
399 | 399 | $additional_details |
400 | 400 | ); |
401 | - } catch( Exception $e ) { |
|
402 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
401 | + } catch (Exception $e) { |
|
402 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -413,22 +413,22 @@ discard block |
||
413 | 413 | * @return bool |
414 | 414 | * @throws \EE_Error |
415 | 415 | */ |
416 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
416 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
417 | 417 | // set initial REG_Status |
418 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
418 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
419 | 419 | |
420 | 420 | // if the registration status gets updated, then save the registration |
421 | 421 | if ( |
422 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ) |
|
423 | - || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details ) |
|
422 | + $this->toggle_registration_status_for_default_approved_events($registration, false) |
|
423 | + || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details) |
|
424 | 424 | ) { |
425 | 425 | $registration->save(); |
426 | 426 | } |
427 | 427 | |
428 | 428 | // set new REG_Status |
429 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
430 | - return $this->reg_status_updated( $registration->ID() ) |
|
431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
429 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
430 | + return $this->reg_status_updated($registration->ID()) |
|
431 | + && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved |
|
432 | 432 | ? true |
433 | 433 | : false; |
434 | 434 | } |
@@ -444,20 +444,20 @@ discard block |
||
444 | 444 | * @return void |
445 | 445 | * @throws \EE_Error |
446 | 446 | */ |
447 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
448 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
449 | - foreach( $transaction->registrations() as $registration ) { |
|
447 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
448 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
449 | + foreach ($transaction->registrations() as $registration) { |
|
450 | 450 | /** @var EE_Line_Item $line_item */ |
451 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
452 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
453 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
454 | - if( $save_regs ) { |
|
451 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
452 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
453 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
454 | + if ($save_regs) { |
|
455 | 455 | $registration->save(); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | //and make sure there's no rounding problem |
460 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
460 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return boolean success verifying that there is NO difference after this method is done |
478 | 478 | * @throws \EE_Error |
479 | 479 | */ |
480 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
480 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
481 | 481 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
482 | 482 | array( |
483 | 483 | array( |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | ), |
487 | 487 | 'REG_final_price' |
488 | 488 | ); |
489 | - $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
489 | + $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
490 | 490 | //ok then, just grab one of the registrations |
491 | - if( $diff !== 0 ) { |
|
491 | + if ($diff !== 0) { |
|
492 | 492 | $a_reg = EEM_Registration::instance()->get_one( |
493 | 493 | array( |
494 | 494 | array( |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | )); |
498 | 498 | $success = $a_reg instanceof EE_Registration |
499 | 499 | ? $a_reg->save( |
500 | - array( 'REG_final_price' => $a_reg->final_price() + $diff ) |
|
500 | + array('REG_final_price' => $a_reg->final_price() + $diff) |
|
501 | 501 | ) |
502 | 502 | : false; |
503 | 503 | return $success ? true : false; |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | $update_reg = true |
524 | 524 | ) { |
525 | 525 | // these reg statuses should not be considered in any calculations involving monies owing |
526 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
|
526 | + $closed_reg_statuses = ! empty($closed_reg_statuses) |
|
527 | 527 | ? $closed_reg_statuses |
528 | 528 | : EEM_Registration::closed_reg_statuses(); |
529 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
|
529 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses, true)) { |
|
530 | 530 | return false; |
531 | 531 | } |
532 | 532 | // release a reserved ticket by decrementing ticket and datetime reserved values |
533 | 533 | $registration->release_reserved_ticket(true); |
534 | 534 | $registration->set_final_price(0); |
535 | - if ( $update_reg ) { |
|
535 | + if ($update_reg) { |
|
536 | 536 | $registration->save(); |
537 | 537 | } |
538 | 538 | return true; |
@@ -555,23 +555,23 @@ discard block |
||
555 | 555 | $update_reg = true |
556 | 556 | ) { |
557 | 557 | // these reg statuses should not be considered in any calculations involving monies owing |
558 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
558 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
559 | 559 | : EEM_Registration::closed_reg_statuses(); |
560 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
560 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | $ticket = $registration->ticket(); |
564 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
564 | + if ( ! $ticket instanceof EE_Ticket) { |
|
565 | 565 | throw new EE_Error( |
566 | 566 | sprintf( |
567 | - __( 'The Ticket for Registration %1$d was not found or is invalid.', |
|
568 | - 'event_espresso' ), |
|
567 | + __('The Ticket for Registration %1$d was not found or is invalid.', |
|
568 | + 'event_espresso'), |
|
569 | 569 | $registration->ticket_ID() |
570 | 570 | ) |
571 | 571 | ); |
572 | 572 | } |
573 | - $registration->set_final_price( $ticket->price() ); |
|
574 | - if ( $update_reg ) { |
|
573 | + $registration->set_final_price($ticket->price()); |
|
574 | + if ($update_reg) { |
|
575 | 575 | $registration->save(); |
576 | 576 | } |
577 | 577 | return true; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $total_ticket_count = 1 |
610 | 610 | ) { |
611 | 611 | EE_Error::doing_it_wrong( |
612 | - __CLASS__ . '::' . __FUNCTION__, |
|
612 | + __CLASS__.'::'.__FUNCTION__, |
|
613 | 613 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
614 | 614 | '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'), |
615 | 615 | '4.9.1', |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | public function generate_reg_url_link($att_nmbr, $item) |
653 | 653 | { |
654 | 654 | EE_Error::doing_it_wrong( |
655 | - __CLASS__ . '::' . __FUNCTION__, |
|
655 | + __CLASS__.'::'.__FUNCTION__, |
|
656 | 656 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
657 | 657 | 'EventEspresso\core\domain\entities\RegUrlLink'), |
658 | 658 | '4.9.1', |
@@ -672,11 +672,11 @@ discard block |
||
672 | 672 | * @return string |
673 | 673 | * @throws \EE_Error |
674 | 674 | */ |
675 | - public function generate_reg_code( EE_Registration $registration ) { |
|
675 | + public function generate_reg_code(EE_Registration $registration) { |
|
676 | 676 | EE_Error::doing_it_wrong( |
677 | - __CLASS__ . '::' . __FUNCTION__, |
|
677 | + __CLASS__.'::'.__FUNCTION__, |
|
678 | 678 | sprintf( |
679 | - __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), |
|
679 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
680 | 680 | 'EventEspresso\core\domain\entities\RegCode' |
681 | 681 | ), |
682 | 682 | '4.9.1', |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | return apply_filters( |
686 | 686 | 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', |
687 | 687 | new RegCode( |
688 | - RegUrlLink::fromRegistration( $registration ), |
|
688 | + RegUrlLink::fromRegistration($registration), |
|
689 | 689 | $registration->transaction(), |
690 | 690 | $registration->ticket() |
691 | 691 | ), |
@@ -42,6 +42,8 @@ discard block |
||
42 | 42 | * @param \EE_State | string $state |
43 | 43 | * @param string $zip |
44 | 44 | * @param \EE_Country | string $country |
45 | + * @param integer $state |
|
46 | + * @param string $country |
|
45 | 47 | * @return GenericAddress |
46 | 48 | */ |
47 | 49 | public function __construct( $address, $address2, $city, $state, $zip, $country ) { |
@@ -135,7 +137,7 @@ discard block |
||
135 | 137 | |
136 | 138 | |
137 | 139 | /** |
138 | - * @return \EE_State |
|
140 | + * @return string |
|
139 | 141 | */ |
140 | 142 | public function state_obj() { |
141 | 143 | return $this->_state_obj; |
@@ -188,7 +190,7 @@ discard block |
||
188 | 190 | |
189 | 191 | |
190 | 192 | /** |
191 | - * @return \EE_Country |
|
193 | + * @return string |
|
192 | 194 | */ |
193 | 195 | public function country_obj() { |
194 | 196 | return $this->_country_obj; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\domain\entities; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | * @param \EE_Country | string $country |
45 | 45 | * @return GenericAddress |
46 | 46 | */ |
47 | - public function __construct( $address, $address2, $city, $state, $zip, $country ) { |
|
47 | + public function __construct($address, $address2, $city, $state, $zip, $country) { |
|
48 | 48 | $this->_address = $address; |
49 | 49 | $this->_address2 = $address2; |
50 | 50 | $this->_city = $city; |
51 | - if ( $state instanceof \EE_State ) { |
|
51 | + if ($state instanceof \EE_State) { |
|
52 | 52 | $this->_state_obj = $state; |
53 | 53 | } else { |
54 | 54 | $this->_state_ID = $state; |
55 | 55 | $this->_state_obj = $this->_get_state_obj(); |
56 | 56 | } |
57 | 57 | $this->_zip = $zip; |
58 | - if ( $country instanceof \EE_Country ) { |
|
58 | + if ($country instanceof \EE_Country) { |
|
59 | 59 | $this->_country_obj = $country; |
60 | 60 | } else { |
61 | 61 | $this->_country_ID = $country; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | private function _get_state_obj() { |
99 | 99 | return $this->_state_obj instanceof \EE_State |
100 | 100 | ? $this->_state_obj |
101 | - : \EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID ); |
|
101 | + : \EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return string |
148 | 148 | */ |
149 | 149 | public function state() { |
150 | - if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) { |
|
150 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
151 | 151 | return $this->state_obj()->abbrev(); |
152 | 152 | } else { |
153 | 153 | return $this->state_name(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | private function _get_country_obj() { |
163 | 163 | return $this->_country_obj instanceof \EE_Country |
164 | 164 | ? $this->_country_obj |
165 | - : \EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID ); |
|
165 | + : \EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return string |
201 | 201 | */ |
202 | 202 | public function country() { |
203 | - if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) { |
|
203 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
204 | 204 | return $this->country_ID(); |
205 | 205 | } else { |
206 | 206 | return $this->country_name(); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\EntityNotFoundException; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -25,116 +25,116 @@ discard block |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param \EE_Registration $registration |
|
30 | - * @param int $quantity |
|
31 | - * @return bool|int |
|
32 | - */ |
|
33 | - public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
34 | - return $this->cancel( |
|
35 | - $registration->transaction(), |
|
36 | - $registration->ticket(), |
|
37 | - $quantity, |
|
38 | - $registration->ticket_line_item() |
|
39 | - ); |
|
40 | - } |
|
28 | + /** |
|
29 | + * @param \EE_Registration $registration |
|
30 | + * @param int $quantity |
|
31 | + * @return bool|int |
|
32 | + */ |
|
33 | + public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
34 | + return $this->cancel( |
|
35 | + $registration->transaction(), |
|
36 | + $registration->ticket(), |
|
37 | + $quantity, |
|
38 | + $registration->ticket_line_item() |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param \EE_Transaction $transaction |
|
45 | - * @param \EE_Ticket $ticket |
|
46 | - * @param int $quantity |
|
47 | - * @param \EE_Line_Item $ticket_line_item |
|
48 | - * @return bool|int |
|
49 | - */ |
|
50 | - public function cancel( |
|
51 | - \EE_Transaction $transaction, |
|
52 | - \EE_Ticket $ticket, |
|
53 | - $quantity = 1, |
|
54 | - \EE_Line_Item $ticket_line_item = null |
|
55 | - ) { |
|
56 | - $ticket_line_item = $ticket_line_item instanceof \EE_Line_Item |
|
57 | - ? $ticket_line_item |
|
58 | - : $this->getTicketLineItem($transaction, $ticket); |
|
59 | - // first we need to decrement the ticket quantity |
|
60 | - \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
|
61 | - // no tickets left for this line item ? |
|
62 | - if ((int)$ticket_line_item->quantity() === 0) { |
|
63 | - // then just set this line item as cancelled, save, and get out |
|
64 | - $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
|
65 | - $success = $ticket_line_item->save(); |
|
66 | - } else { |
|
67 | - // otherwise create a new cancelled line item, so that we have a record of the cancellation |
|
68 | - $items_subtotal = \EEH_Line_Item::get_pre_tax_subtotal( |
|
69 | - \EEH_Line_Item::get_event_line_item_for_ticket( |
|
70 | - $transaction->total_line_item(), |
|
71 | - $ticket |
|
72 | - ) |
|
73 | - ); |
|
74 | - $cancelled_line_item = \EE_Line_Item::new_instance( |
|
75 | - array( |
|
76 | - 'LIN_name' => $ticket_line_item->name(), |
|
77 | - 'LIN_desc' => sprintf( |
|
78 | - __('%1$s Cancelled: %2$s', 'event_espresso'), |
|
79 | - $ticket_line_item->desc(), |
|
80 | - date('Y-m-d h:i a') |
|
81 | - ), |
|
82 | - 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
83 | - 'LIN_quantity' => $quantity, |
|
84 | - 'LIN_percent' => null, |
|
85 | - 'LIN_is_taxable' => false, |
|
86 | - 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
|
87 | - ? count($items_subtotal->children()) |
|
88 | - : 0, |
|
89 | - 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
90 | - 'LIN_type' => \EEM_Line_Item::type_cancellation |
|
91 | - ) |
|
92 | - ); |
|
93 | - $success = \EEH_Line_Item::add_item($transaction->total_line_item(), $cancelled_line_item); |
|
94 | - } |
|
95 | - if ( ! $success) { |
|
96 | - throw new \RuntimeException( |
|
97 | - sprintf( |
|
98 | - __('An error occurred while attempting to cancel ticket line item %1$s', 'event_espresso'), |
|
99 | - $ticket_line_item->ID() |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - return $success; |
|
104 | - } |
|
43 | + /** |
|
44 | + * @param \EE_Transaction $transaction |
|
45 | + * @param \EE_Ticket $ticket |
|
46 | + * @param int $quantity |
|
47 | + * @param \EE_Line_Item $ticket_line_item |
|
48 | + * @return bool|int |
|
49 | + */ |
|
50 | + public function cancel( |
|
51 | + \EE_Transaction $transaction, |
|
52 | + \EE_Ticket $ticket, |
|
53 | + $quantity = 1, |
|
54 | + \EE_Line_Item $ticket_line_item = null |
|
55 | + ) { |
|
56 | + $ticket_line_item = $ticket_line_item instanceof \EE_Line_Item |
|
57 | + ? $ticket_line_item |
|
58 | + : $this->getTicketLineItem($transaction, $ticket); |
|
59 | + // first we need to decrement the ticket quantity |
|
60 | + \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
|
61 | + // no tickets left for this line item ? |
|
62 | + if ((int)$ticket_line_item->quantity() === 0) { |
|
63 | + // then just set this line item as cancelled, save, and get out |
|
64 | + $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
|
65 | + $success = $ticket_line_item->save(); |
|
66 | + } else { |
|
67 | + // otherwise create a new cancelled line item, so that we have a record of the cancellation |
|
68 | + $items_subtotal = \EEH_Line_Item::get_pre_tax_subtotal( |
|
69 | + \EEH_Line_Item::get_event_line_item_for_ticket( |
|
70 | + $transaction->total_line_item(), |
|
71 | + $ticket |
|
72 | + ) |
|
73 | + ); |
|
74 | + $cancelled_line_item = \EE_Line_Item::new_instance( |
|
75 | + array( |
|
76 | + 'LIN_name' => $ticket_line_item->name(), |
|
77 | + 'LIN_desc' => sprintf( |
|
78 | + __('%1$s Cancelled: %2$s', 'event_espresso'), |
|
79 | + $ticket_line_item->desc(), |
|
80 | + date('Y-m-d h:i a') |
|
81 | + ), |
|
82 | + 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
83 | + 'LIN_quantity' => $quantity, |
|
84 | + 'LIN_percent' => null, |
|
85 | + 'LIN_is_taxable' => false, |
|
86 | + 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
|
87 | + ? count($items_subtotal->children()) |
|
88 | + : 0, |
|
89 | + 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
90 | + 'LIN_type' => \EEM_Line_Item::type_cancellation |
|
91 | + ) |
|
92 | + ); |
|
93 | + $success = \EEH_Line_Item::add_item($transaction->total_line_item(), $cancelled_line_item); |
|
94 | + } |
|
95 | + if ( ! $success) { |
|
96 | + throw new \RuntimeException( |
|
97 | + sprintf( |
|
98 | + __('An error occurred while attempting to cancel ticket line item %1$s', 'event_espresso'), |
|
99 | + $ticket_line_item->ID() |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + return $success; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * @param \EE_Transaction $transaction |
|
110 | - * @param \EE_Ticket $ticket |
|
111 | - * @return \EE_Line_Item |
|
112 | - * @throws EntityNotFoundException |
|
113 | - * @throws \EE_Error |
|
114 | - */ |
|
115 | - protected static function getTicketLineItem(\EE_Transaction $transaction, \EE_Ticket $ticket) |
|
116 | - { |
|
117 | - $line_item = null; |
|
118 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
119 | - $transaction->total_line_item(), |
|
120 | - 'Ticket', |
|
121 | - array($ticket->ID()) |
|
122 | - ); |
|
123 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
124 | - if ( |
|
125 | - $ticket_line_item instanceof \EE_Line_Item |
|
126 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
127 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
128 | - ) { |
|
129 | - $line_item = $ticket_line_item; |
|
130 | - break; |
|
131 | - } |
|
132 | - } |
|
133 | - if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
134 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
135 | - } |
|
136 | - return $line_item; |
|
137 | - } |
|
108 | + /** |
|
109 | + * @param \EE_Transaction $transaction |
|
110 | + * @param \EE_Ticket $ticket |
|
111 | + * @return \EE_Line_Item |
|
112 | + * @throws EntityNotFoundException |
|
113 | + * @throws \EE_Error |
|
114 | + */ |
|
115 | + protected static function getTicketLineItem(\EE_Transaction $transaction, \EE_Ticket $ticket) |
|
116 | + { |
|
117 | + $line_item = null; |
|
118 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
119 | + $transaction->total_line_item(), |
|
120 | + 'Ticket', |
|
121 | + array($ticket->ID()) |
|
122 | + ); |
|
123 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
124 | + if ( |
|
125 | + $ticket_line_item instanceof \EE_Line_Item |
|
126 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
127 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
128 | + ) { |
|
129 | + $line_item = $ticket_line_item; |
|
130 | + break; |
|
131 | + } |
|
132 | + } |
|
133 | + if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
134 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
135 | + } |
|
136 | + return $line_item; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | 140 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param int $quantity |
31 | 31 | * @return bool|int |
32 | 32 | */ |
33 | - public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
33 | + public function forRegistration(\EE_Registration $registration, $quantity = 1) { |
|
34 | 34 | return $this->cancel( |
35 | 35 | $registration->transaction(), |
36 | 36 | $registration->ticket(), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // first we need to decrement the ticket quantity |
60 | 60 | \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
61 | 61 | // no tickets left for this line item ? |
62 | - if ((int)$ticket_line_item->quantity() === 0) { |
|
62 | + if ((int) $ticket_line_item->quantity() === 0) { |
|
63 | 63 | // then just set this line item as cancelled, save, and get out |
64 | 64 | $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
65 | 65 | $success = $ticket_line_item->save(); |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | $ticket_line_item->desc(), |
80 | 80 | date('Y-m-d h:i a') |
81 | 81 | ), |
82 | - 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
82 | + 'LIN_unit_price' => (float) $ticket_line_item->unit_price(), |
|
83 | 83 | 'LIN_quantity' => $quantity, |
84 | 84 | 'LIN_percent' => null, |
85 | 85 | 'LIN_is_taxable' => false, |
86 | 86 | 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
87 | 87 | ? count($items_subtotal->children()) |
88 | 88 | : 0, |
89 | - 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
89 | + 'LIN_total' => (float) $ticket_line_item->unit_price(), |
|
90 | 90 | 'LIN_type' => \EEM_Line_Item::type_cancellation |
91 | 91 | ) |
92 | 92 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\domain\services\DomainService; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -20,24 +20,24 @@ discard block |
||
20 | 20 | class UpdateRegistrationService extends DomainService |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @param \EE_Registration $registration |
|
25 | - * @return bool |
|
26 | - */ |
|
27 | - public function updateRegistrationAndTransaction(\EE_Registration $registration) |
|
28 | - { |
|
29 | - $transaction = $registration->transaction(); |
|
30 | - // reset transaction status back to incomplete |
|
31 | - $transaction->set_status(\EEM_Transaction::incomplete_status_code); |
|
32 | - // update transaction and all line item totals and subtotals |
|
33 | - $transaction->total_line_item()->recalculate_total_including_taxes(); |
|
34 | - // maybe update status, but don't save transaction just yet |
|
35 | - $transaction->update_status_based_on_total_paid(); |
|
36 | - /** @type \EE_Registration_Processor $registration_processor */ |
|
37 | - $registration_processor = \EE_Registry::instance()->load_class('Registration_Processor'); |
|
38 | - $registration_processor->update_registration_status_and_trigger_notifications($registration); |
|
39 | - return true; |
|
40 | - } |
|
23 | + /** |
|
24 | + * @param \EE_Registration $registration |
|
25 | + * @return bool |
|
26 | + */ |
|
27 | + public function updateRegistrationAndTransaction(\EE_Registration $registration) |
|
28 | + { |
|
29 | + $transaction = $registration->transaction(); |
|
30 | + // reset transaction status back to incomplete |
|
31 | + $transaction->set_status(\EEM_Transaction::incomplete_status_code); |
|
32 | + // update transaction and all line item totals and subtotals |
|
33 | + $transaction->total_line_item()->recalculate_total_including_taxes(); |
|
34 | + // maybe update status, but don't save transaction just yet |
|
35 | + $transaction->update_status_based_on_total_paid(); |
|
36 | + /** @type \EE_Registration_Processor $registration_processor */ |
|
37 | + $registration_processor = \EE_Registry::instance()->load_class('Registration_Processor'); |
|
38 | + $registration_processor->update_registration_status_and_trigger_notifications($registration); |
|
39 | + return true; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | // End of file UpdateRegistrationService.php |
@@ -92,7 +92,7 @@ |
||
92 | 92 | $ticket_line_item |
93 | 93 | ); |
94 | 94 | $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
95 | - return (float)$final_price; |
|
95 | + return (float) $final_price; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 |
@@ -39,8 +39,8 @@ |
||
39 | 39 | * @param EE_Transaction $transaction |
40 | 40 | * @param EE_Ticket $ticket |
41 | 41 | * @param EE_Line_Item $ticket_line_item |
42 | - * @param $reg_count |
|
43 | - * @param $reg_group_size |
|
42 | + * @param integer $reg_count |
|
43 | + * @param integer $reg_group_size |
|
44 | 44 | * @param string $reg_status |
45 | 45 | * @return EE_Registration |
46 | 46 | * @throws OutOfRangeException |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use OutOfRangeException; |
18 | 18 | |
19 | 19 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
20 | - exit('No direct script access allowed'); |
|
20 | + exit('No direct script access allowed'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -41,54 +41,54 @@ discard block |
||
41 | 41 | * @param EE_Line_Item $ticket_line_item |
42 | 42 | * @param $reg_count |
43 | 43 | * @param $reg_group_size |
44 | - * @param string $reg_status |
|
45 | - * @return EE_Registration |
|
44 | + * @param string $reg_status |
|
45 | + * @return EE_Registration |
|
46 | 46 | * @throws OutOfRangeException |
47 | 47 | * @throws EE_Error |
48 | 48 | * @throws UnexpectedEntityException |
49 | 49 | */ |
50 | - public function create( |
|
51 | - EE_Event $event, |
|
52 | - EE_Transaction $transaction, |
|
53 | - EE_Ticket $ticket, |
|
54 | - EE_Line_Item $ticket_line_item, |
|
55 | - $reg_count, |
|
56 | - $reg_group_size, |
|
57 | - $reg_status = EEM_Registration::status_id_incomplete |
|
58 | - ) { |
|
59 | - $registrations = $transaction->registrations(); |
|
60 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
61 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
62 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
63 | - // generate new EE_Registration |
|
64 | - $registration = EE_Registration::new_instance( |
|
65 | - array( |
|
66 | - 'EVT_ID' => $event->ID(), |
|
67 | - 'TXN_ID' => $transaction->ID(), |
|
68 | - 'TKT_ID' => $ticket->ID(), |
|
69 | - 'STS_ID' => $reg_status, |
|
70 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
71 | - 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
72 | - 'REG_count' => $reg_count, |
|
73 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
74 | - 'REG_url_link' => $reg_url_link, |
|
75 | - 'REG_code' => $reg_code, |
|
76 | - ) |
|
77 | - ); |
|
78 | - if ( ! $registration instanceof EE_Registration) { |
|
79 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
80 | - } |
|
81 | - // save registration so that we have an ID |
|
82 | - $registration->save(); |
|
83 | - // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
84 | - // because that is done as soon as the tickets are added/removed from the cart |
|
85 | - $registration->reserve_ticket(); |
|
86 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
87 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
88 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
89 | - $registration->save(); |
|
90 | - return $registration; |
|
91 | - } |
|
50 | + public function create( |
|
51 | + EE_Event $event, |
|
52 | + EE_Transaction $transaction, |
|
53 | + EE_Ticket $ticket, |
|
54 | + EE_Line_Item $ticket_line_item, |
|
55 | + $reg_count, |
|
56 | + $reg_group_size, |
|
57 | + $reg_status = EEM_Registration::status_id_incomplete |
|
58 | + ) { |
|
59 | + $registrations = $transaction->registrations(); |
|
60 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
61 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
62 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
63 | + // generate new EE_Registration |
|
64 | + $registration = EE_Registration::new_instance( |
|
65 | + array( |
|
66 | + 'EVT_ID' => $event->ID(), |
|
67 | + 'TXN_ID' => $transaction->ID(), |
|
68 | + 'TKT_ID' => $ticket->ID(), |
|
69 | + 'STS_ID' => $reg_status, |
|
70 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
71 | + 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
72 | + 'REG_count' => $reg_count, |
|
73 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
74 | + 'REG_url_link' => $reg_url_link, |
|
75 | + 'REG_code' => $reg_code, |
|
76 | + ) |
|
77 | + ); |
|
78 | + if ( ! $registration instanceof EE_Registration) { |
|
79 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
80 | + } |
|
81 | + // save registration so that we have an ID |
|
82 | + $registration->save(); |
|
83 | + // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
84 | + // because that is done as soon as the tickets are added/removed from the cart |
|
85 | + $registration->reserve_ticket(); |
|
86 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
87 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
88 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
89 | + $registration->save(); |
|
90 | + return $registration; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 | |
@@ -100,40 +100,40 @@ discard block |
||
100 | 100 | * @throws EE_Error |
101 | 101 | * @throws OutOfRangeException |
102 | 102 | */ |
103 | - protected function resolveFinalPrice( |
|
104 | - EE_Transaction $transaction, |
|
105 | - EE_Ticket $ticket, |
|
106 | - EE_Line_Item $ticket_line_item |
|
107 | - ) { |
|
108 | - $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
109 | - $transaction->total_line_item(), |
|
110 | - $ticket_line_item |
|
111 | - ); |
|
112 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
113 | - return (float)$final_price; |
|
114 | - } |
|
103 | + protected function resolveFinalPrice( |
|
104 | + EE_Transaction $transaction, |
|
105 | + EE_Ticket $ticket, |
|
106 | + EE_Line_Item $ticket_line_item |
|
107 | + ) { |
|
108 | + $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
109 | + $transaction->total_line_item(), |
|
110 | + $ticket_line_item |
|
111 | + ); |
|
112 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
113 | + return (float)$final_price; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * @param EE_Registration[] $registrations |
|
120 | - * @param boolean $update_existing_registrations |
|
121 | - * @return int |
|
122 | - * @throws EE_Error |
|
123 | - */ |
|
124 | - protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
125 | - { |
|
126 | - $new_reg_count = count($registrations) + 1; |
|
127 | - if ($update_existing_registrations) { |
|
128 | - foreach ($registrations as $registration) { |
|
129 | - if ($registration instanceof EE_Registration) { |
|
130 | - $registration->set_count($new_reg_count); |
|
131 | - $registration->save(); |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - return $new_reg_count; |
|
136 | - } |
|
118 | + /** |
|
119 | + * @param EE_Registration[] $registrations |
|
120 | + * @param boolean $update_existing_registrations |
|
121 | + * @return int |
|
122 | + * @throws EE_Error |
|
123 | + */ |
|
124 | + protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
125 | + { |
|
126 | + $new_reg_count = count($registrations) + 1; |
|
127 | + if ($update_existing_registrations) { |
|
128 | + foreach ($registrations as $registration) { |
|
129 | + if ($registration instanceof EE_Registration) { |
|
130 | + $registration->set_count($new_reg_count); |
|
131 | + $registration->save(); |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + return $new_reg_count; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | 139 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -23,140 +23,140 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param \EE_Registration $target_registration |
|
28 | - * @param \EE_Registration $registration_to_copy |
|
29 | - * @return bool |
|
30 | - * @throws \EE_Error |
|
31 | - */ |
|
32 | - public function copyRegistrationDetails( |
|
33 | - \EE_Registration $target_registration, |
|
34 | - \EE_Registration $registration_to_copy |
|
35 | - ) { |
|
36 | - // copy attendee |
|
37 | - $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
38 | - $target_registration->set_status( $registration_to_copy->status_ID() ); |
|
39 | - $target_registration->save(); |
|
40 | - // get answers to previous reg questions |
|
41 | - $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
42 | - // get questions to new event reg form |
|
43 | - $new_event = $target_registration->event(); |
|
44 | - $question_groups = $new_event->question_groups( |
|
45 | - array( |
|
46 | - array( |
|
47 | - 'Event.EVT_ID' => $new_event->ID(), |
|
48 | - 'Event_Question_Group.EQG_primary' => $registration_to_copy->is_primary_registrant() |
|
49 | - ), |
|
50 | - 'order_by' => array('QSG_order' => 'ASC') |
|
51 | - ) |
|
52 | - ); |
|
53 | - foreach ($question_groups as $question_group) { |
|
54 | - if ($question_group instanceof \EE_Question_Group) { |
|
55 | - foreach ($question_group->questions() as $question) { |
|
56 | - if ($question instanceof \EE_Question) { |
|
57 | - $this->generateNewAnswer( |
|
58 | - $question, |
|
59 | - $target_registration, |
|
60 | - $answers |
|
61 | - ); |
|
62 | - } |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - return true; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param \EE_Answer[] $answers |
|
73 | - * @return array |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
76 | - protected static function reindexAnswersByQuestionId(array $answers) |
|
77 | - { |
|
78 | - $reindexed_answers = array(); |
|
79 | - foreach ($answers as $answer) { |
|
80 | - if ($answer instanceof \EE_Answer) { |
|
81 | - $reindexed_answers[$answer->question_ID()] = $answer->value(); |
|
82 | - } |
|
83 | - } |
|
84 | - return $reindexed_answers; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @param \EE_Question $question |
|
91 | - * @param \EE_Registration $registration |
|
92 | - * @param $previous_answers |
|
93 | - * @return \EE_Answer |
|
94 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
95 | - * @throws \EE_Error |
|
96 | - */ |
|
97 | - protected static function generateNewAnswer( |
|
98 | - \EE_Question $question, |
|
99 | - \EE_Registration $registration, |
|
100 | - $previous_answers |
|
101 | - ) { |
|
102 | - $old_answer_value = isset($previous_answers[$question->ID()]) |
|
103 | - ? $previous_answers[$question->ID()] |
|
104 | - : ''; |
|
105 | - $new_answer = \EE_Answer::new_instance( |
|
106 | - array( |
|
107 | - 'QST_ID' => $question->ID(), |
|
108 | - 'REG_ID' => $registration->ID(), |
|
109 | - 'ANS_value' => $old_answer_value, |
|
110 | - ) |
|
111 | - ); |
|
112 | - if ( ! $new_answer instanceof \EE_Answer) { |
|
113 | - throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
114 | - } |
|
115 | - $new_answer->save(); |
|
116 | - return $new_answer; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @param \EE_Registration $target_registration |
|
123 | - * @param \EE_Registration $registration_to_copy |
|
124 | - * @return bool |
|
125 | - * @throws \EE_Error |
|
126 | - */ |
|
127 | - public function copyPaymentDetails( |
|
128 | - \EE_Registration $target_registration, |
|
129 | - \EE_Registration $registration_to_copy |
|
130 | - ) { |
|
131 | - $previous_payments = $registration_to_copy->registration_payments(); |
|
132 | - foreach ($previous_payments as $previous_payment) { |
|
133 | - if ( |
|
134 | - $previous_payment instanceof \EE_Registration_Payment |
|
135 | - && $previous_payment->payment() instanceof \EE_Payment |
|
136 | - && $previous_payment->payment()->is_approved() |
|
137 | - ) { |
|
138 | - $new_registration_payment = \EE_Registration_Payment::new_instance( |
|
139 | - array( |
|
140 | - 'REG_ID' => $target_registration->ID(), |
|
141 | - 'PAY_ID' => $previous_payment->ID(), |
|
142 | - 'RPY_amount' => $previous_payment->amount(), |
|
143 | - ) |
|
144 | - ); |
|
145 | - if ( ! $new_registration_payment instanceof \EE_Registration_Payment) { |
|
146 | - throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
147 | - } |
|
148 | - $new_registration_payment->save(); |
|
149 | - $target_registration->set_paid($previous_payment->amount()); |
|
150 | - $target_registration->save(); |
|
151 | - // if new reg payment is good, then set old reg payment amount to zero |
|
152 | - $previous_payment->set_amount(0); |
|
153 | - $previous_payment->save(); |
|
154 | - $registration_to_copy->set_paid(0); |
|
155 | - $registration_to_copy->save(); |
|
156 | - } |
|
157 | - } |
|
158 | - return true; |
|
159 | - } |
|
26 | + /** |
|
27 | + * @param \EE_Registration $target_registration |
|
28 | + * @param \EE_Registration $registration_to_copy |
|
29 | + * @return bool |
|
30 | + * @throws \EE_Error |
|
31 | + */ |
|
32 | + public function copyRegistrationDetails( |
|
33 | + \EE_Registration $target_registration, |
|
34 | + \EE_Registration $registration_to_copy |
|
35 | + ) { |
|
36 | + // copy attendee |
|
37 | + $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
38 | + $target_registration->set_status( $registration_to_copy->status_ID() ); |
|
39 | + $target_registration->save(); |
|
40 | + // get answers to previous reg questions |
|
41 | + $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
42 | + // get questions to new event reg form |
|
43 | + $new_event = $target_registration->event(); |
|
44 | + $question_groups = $new_event->question_groups( |
|
45 | + array( |
|
46 | + array( |
|
47 | + 'Event.EVT_ID' => $new_event->ID(), |
|
48 | + 'Event_Question_Group.EQG_primary' => $registration_to_copy->is_primary_registrant() |
|
49 | + ), |
|
50 | + 'order_by' => array('QSG_order' => 'ASC') |
|
51 | + ) |
|
52 | + ); |
|
53 | + foreach ($question_groups as $question_group) { |
|
54 | + if ($question_group instanceof \EE_Question_Group) { |
|
55 | + foreach ($question_group->questions() as $question) { |
|
56 | + if ($question instanceof \EE_Question) { |
|
57 | + $this->generateNewAnswer( |
|
58 | + $question, |
|
59 | + $target_registration, |
|
60 | + $answers |
|
61 | + ); |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + return true; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param \EE_Answer[] $answers |
|
73 | + * @return array |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | + protected static function reindexAnswersByQuestionId(array $answers) |
|
77 | + { |
|
78 | + $reindexed_answers = array(); |
|
79 | + foreach ($answers as $answer) { |
|
80 | + if ($answer instanceof \EE_Answer) { |
|
81 | + $reindexed_answers[$answer->question_ID()] = $answer->value(); |
|
82 | + } |
|
83 | + } |
|
84 | + return $reindexed_answers; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @param \EE_Question $question |
|
91 | + * @param \EE_Registration $registration |
|
92 | + * @param $previous_answers |
|
93 | + * @return \EE_Answer |
|
94 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
95 | + * @throws \EE_Error |
|
96 | + */ |
|
97 | + protected static function generateNewAnswer( |
|
98 | + \EE_Question $question, |
|
99 | + \EE_Registration $registration, |
|
100 | + $previous_answers |
|
101 | + ) { |
|
102 | + $old_answer_value = isset($previous_answers[$question->ID()]) |
|
103 | + ? $previous_answers[$question->ID()] |
|
104 | + : ''; |
|
105 | + $new_answer = \EE_Answer::new_instance( |
|
106 | + array( |
|
107 | + 'QST_ID' => $question->ID(), |
|
108 | + 'REG_ID' => $registration->ID(), |
|
109 | + 'ANS_value' => $old_answer_value, |
|
110 | + ) |
|
111 | + ); |
|
112 | + if ( ! $new_answer instanceof \EE_Answer) { |
|
113 | + throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
114 | + } |
|
115 | + $new_answer->save(); |
|
116 | + return $new_answer; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @param \EE_Registration $target_registration |
|
123 | + * @param \EE_Registration $registration_to_copy |
|
124 | + * @return bool |
|
125 | + * @throws \EE_Error |
|
126 | + */ |
|
127 | + public function copyPaymentDetails( |
|
128 | + \EE_Registration $target_registration, |
|
129 | + \EE_Registration $registration_to_copy |
|
130 | + ) { |
|
131 | + $previous_payments = $registration_to_copy->registration_payments(); |
|
132 | + foreach ($previous_payments as $previous_payment) { |
|
133 | + if ( |
|
134 | + $previous_payment instanceof \EE_Registration_Payment |
|
135 | + && $previous_payment->payment() instanceof \EE_Payment |
|
136 | + && $previous_payment->payment()->is_approved() |
|
137 | + ) { |
|
138 | + $new_registration_payment = \EE_Registration_Payment::new_instance( |
|
139 | + array( |
|
140 | + 'REG_ID' => $target_registration->ID(), |
|
141 | + 'PAY_ID' => $previous_payment->ID(), |
|
142 | + 'RPY_amount' => $previous_payment->amount(), |
|
143 | + ) |
|
144 | + ); |
|
145 | + if ( ! $new_registration_payment instanceof \EE_Registration_Payment) { |
|
146 | + throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
147 | + } |
|
148 | + $new_registration_payment->save(); |
|
149 | + $target_registration->set_paid($previous_payment->amount()); |
|
150 | + $target_registration->save(); |
|
151 | + // if new reg payment is good, then set old reg payment amount to zero |
|
152 | + $previous_payment->set_amount(0); |
|
153 | + $previous_payment->save(); |
|
154 | + $registration_to_copy->set_paid(0); |
|
155 | + $registration_to_copy->save(); |
|
156 | + } |
|
157 | + } |
|
158 | + return true; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | 162 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | ) { |
36 | 36 | // copy attendee |
37 | 37 | $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
38 | - $target_registration->set_status( $registration_to_copy->status_ID() ); |
|
38 | + $target_registration->set_status($registration_to_copy->status_ID()); |
|
39 | 39 | $target_registration->save(); |
40 | 40 | // get answers to previous reg questions |
41 | 41 | $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\domain\entities; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | \EE_Ticket $ticket |
39 | 39 | ) { |
40 | 40 | // figure out where to start parsing the reg code |
41 | - $chars = strpos( $reg_url_link, '-' ) + 5; |
|
41 | + $chars = strpos($reg_url_link, '-') + 5; |
|
42 | 42 | // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link |
43 | 43 | $this->reg_code = array( |
44 | 44 | $transaction->ID(), |
45 | 45 | $ticket->ID(), |
46 | - substr( $reg_url_link, 0, $chars ) |
|
46 | + substr($reg_url_link, 0, $chars) |
|
47 | 47 | ); |
48 | 48 | // now put it all together |
49 | 49 | $this->reg_code = apply_filters( |
50 | 50 | 'FHEE__Create__regCode__new_reg_code', |
51 | - implode( '-', $this->reg_code ), |
|
51 | + implode('-', $this->reg_code), |
|
52 | 52 | $transaction, |
53 | 53 | $ticket |
54 | 54 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @access public |
|
28 | - * @param mixed $command_bus_middleware_object |
|
29 | - * @param string $message |
|
30 | - * @param int $code |
|
31 | - * @param \Exception $previous |
|
32 | - */ |
|
33 | - public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
34 | - { |
|
35 | - $command_bus_middleware = is_object($command_bus_middleware_object) |
|
36 | - ? get_class($command_bus_middleware_object) |
|
37 | - : gettype($command_bus_middleware_object); |
|
38 | - |
|
39 | - if (empty($message)) { |
|
40 | - $message = sprintf( |
|
41 | - __('The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
42 | - 'event_espresso'), |
|
43 | - $command_bus_middleware |
|
44 | - ); |
|
45 | - } |
|
46 | - parent::__construct( |
|
47 | - '$command_bus_middleware', |
|
48 | - $command_bus_middleware, |
|
49 | - 'CommandBusMiddlewareInterface', |
|
50 | - $message, |
|
51 | - $code, |
|
52 | - $previous |
|
53 | - ); |
|
54 | - } |
|
26 | + /** |
|
27 | + * @access public |
|
28 | + * @param mixed $command_bus_middleware_object |
|
29 | + * @param string $message |
|
30 | + * @param int $code |
|
31 | + * @param \Exception $previous |
|
32 | + */ |
|
33 | + public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
34 | + { |
|
35 | + $command_bus_middleware = is_object($command_bus_middleware_object) |
|
36 | + ? get_class($command_bus_middleware_object) |
|
37 | + : gettype($command_bus_middleware_object); |
|
38 | + |
|
39 | + if (empty($message)) { |
|
40 | + $message = sprintf( |
|
41 | + __('The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
42 | + 'event_espresso'), |
|
43 | + $command_bus_middleware |
|
44 | + ); |
|
45 | + } |
|
46 | + parent::__construct( |
|
47 | + '$command_bus_middleware', |
|
48 | + $command_bus_middleware, |
|
49 | + 'CommandBusMiddlewareInterface', |
|
50 | + $message, |
|
51 | + $code, |
|
52 | + $previous |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | 57 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\commands\Command; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,121 +21,121 @@ discard block |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @var \EE_Transaction $transaction |
|
26 | - */ |
|
27 | - private $transaction; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Ticket $ticket |
|
31 | - */ |
|
32 | - private $ticket; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var \EE_Line_Item $ticket_line_item |
|
36 | - */ |
|
37 | - protected $ticket_line_item; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var int $quantity |
|
41 | - */ |
|
42 | - protected $quantity; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @param \EE_Registration $registration |
|
48 | - * @param int $quantity |
|
49 | - */ |
|
50 | - public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
51 | - { |
|
52 | - new self( |
|
53 | - $registration->transaction(), |
|
54 | - $registration->ticket(), |
|
55 | - 1, |
|
56 | - $registration->ticket_line_item() |
|
57 | - ); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param \EE_Line_Item $ticket_line_item |
|
64 | - * @param int $quantity |
|
65 | - */ |
|
66 | - public static function fromTicketLineItem( |
|
67 | - \EE_Line_Item $ticket_line_item, |
|
68 | - $quantity = 1 |
|
69 | - ) { |
|
70 | - new self( |
|
71 | - $ticket_line_item->transaction(), |
|
72 | - $ticket_line_item->ticket(), |
|
73 | - $quantity, |
|
74 | - $ticket_line_item |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * CancelTicketLineItemCommand constructor. |
|
82 | - * |
|
83 | - * @param \EE_Transaction $transaction |
|
84 | - * @param \EE_Ticket $ticket |
|
85 | - * @param int $quantity |
|
86 | - * @param \EE_Line_Item $ticket_line_item |
|
87 | - */ |
|
88 | - public function __construct( |
|
89 | - \EE_Transaction $transaction, |
|
90 | - \EE_Ticket $ticket, |
|
91 | - $quantity = 1, |
|
92 | - \EE_Line_Item $ticket_line_item = null |
|
93 | - ) { |
|
94 | - $this->transaction = $transaction; |
|
95 | - $this->ticket = $ticket; |
|
96 | - $this->quantity = min(1, absint($quantity)); |
|
97 | - $this->ticket_line_item = $ticket_line_item; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \EE_Transaction |
|
104 | - */ |
|
105 | - public function transaction() |
|
106 | - { |
|
107 | - return $this->transaction; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return \EE_Ticket |
|
114 | - */ |
|
115 | - public function ticket() |
|
116 | - { |
|
117 | - return $this->ticket; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return \EE_Line_Item |
|
124 | - */ |
|
125 | - public function ticketLineItem() |
|
126 | - { |
|
127 | - return $this->ticket_line_item; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @return int |
|
134 | - */ |
|
135 | - public function quantity() |
|
136 | - { |
|
137 | - return $this->quantity; |
|
138 | - } |
|
24 | + /** |
|
25 | + * @var \EE_Transaction $transaction |
|
26 | + */ |
|
27 | + private $transaction; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Ticket $ticket |
|
31 | + */ |
|
32 | + private $ticket; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var \EE_Line_Item $ticket_line_item |
|
36 | + */ |
|
37 | + protected $ticket_line_item; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var int $quantity |
|
41 | + */ |
|
42 | + protected $quantity; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @param \EE_Registration $registration |
|
48 | + * @param int $quantity |
|
49 | + */ |
|
50 | + public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
51 | + { |
|
52 | + new self( |
|
53 | + $registration->transaction(), |
|
54 | + $registration->ticket(), |
|
55 | + 1, |
|
56 | + $registration->ticket_line_item() |
|
57 | + ); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param \EE_Line_Item $ticket_line_item |
|
64 | + * @param int $quantity |
|
65 | + */ |
|
66 | + public static function fromTicketLineItem( |
|
67 | + \EE_Line_Item $ticket_line_item, |
|
68 | + $quantity = 1 |
|
69 | + ) { |
|
70 | + new self( |
|
71 | + $ticket_line_item->transaction(), |
|
72 | + $ticket_line_item->ticket(), |
|
73 | + $quantity, |
|
74 | + $ticket_line_item |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * CancelTicketLineItemCommand constructor. |
|
82 | + * |
|
83 | + * @param \EE_Transaction $transaction |
|
84 | + * @param \EE_Ticket $ticket |
|
85 | + * @param int $quantity |
|
86 | + * @param \EE_Line_Item $ticket_line_item |
|
87 | + */ |
|
88 | + public function __construct( |
|
89 | + \EE_Transaction $transaction, |
|
90 | + \EE_Ticket $ticket, |
|
91 | + $quantity = 1, |
|
92 | + \EE_Line_Item $ticket_line_item = null |
|
93 | + ) { |
|
94 | + $this->transaction = $transaction; |
|
95 | + $this->ticket = $ticket; |
|
96 | + $this->quantity = min(1, absint($quantity)); |
|
97 | + $this->ticket_line_item = $ticket_line_item; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \EE_Transaction |
|
104 | + */ |
|
105 | + public function transaction() |
|
106 | + { |
|
107 | + return $this->transaction; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return \EE_Ticket |
|
114 | + */ |
|
115 | + public function ticket() |
|
116 | + { |
|
117 | + return $this->ticket; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return \EE_Line_Item |
|
124 | + */ |
|
125 | + public function ticketLineItem() |
|
126 | + { |
|
127 | + return $this->ticket_line_item; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @return int |
|
134 | + */ |
|
135 | + public function quantity() |
|
136 | + { |
|
137 | + return $this->quantity; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | |
141 | 141 | } |