Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EED_Single_Page_Checkout often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EED_Single_Page_Checkout, and based on these observations, apply Extract Interface, too.
1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
10 | class EED_Single_Page_Checkout extends EED_Module { |
||
11 | |||
12 | |||
13 | /** |
||
14 | * $_initialized - has the SPCO controller already been initialized ? |
||
15 | * @access private |
||
16 | * @var bool $_initialized |
||
17 | */ |
||
18 | private static $_initialized = FALSE; |
||
19 | |||
20 | /** |
||
21 | * $_reg_steps_array - holds initial array of reg steps |
||
22 | * @access private |
||
23 | * @var array $_reg_steps_array |
||
24 | */ |
||
25 | private static $_reg_steps_array = array(); |
||
26 | |||
27 | /** |
||
28 | * $checkout - EE_Checkout object for handling the properties of the current checkout process |
||
29 | * @access public |
||
30 | * @var EE_Checkout $checkout |
||
31 | */ |
||
32 | public $checkout = NULL; |
||
33 | |||
34 | |||
35 | |||
36 | |||
37 | /** |
||
38 | * @return EED_Single_Page_Checkout |
||
39 | */ |
||
40 | public static function instance() { |
||
44 | |||
45 | |||
46 | |||
47 | /** |
||
48 | * @return EE_CART |
||
49 | */ |
||
50 | public function cart() { |
||
53 | |||
54 | |||
55 | |||
56 | /** |
||
57 | * @return EE_Transaction |
||
58 | */ |
||
59 | public function transaction() { |
||
62 | |||
63 | |||
64 | |||
65 | |||
66 | |||
67 | /** |
||
68 | * set_hooks - for hooking into EE Core, other modules, etc |
||
69 | * |
||
70 | * @access public |
||
71 | * @return void |
||
72 | */ |
||
73 | public static function set_hooks() { |
||
76 | |||
77 | |||
78 | |||
79 | /** |
||
80 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
||
81 | * |
||
82 | * @access public |
||
83 | * @return void |
||
84 | */ |
||
85 | public static function set_hooks_admin() { |
||
86 | EED_Single_Page_Checkout::set_definitions(); |
||
87 | if ( defined( 'DOING_AJAX' )) { |
||
88 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
||
89 | ob_start(); |
||
90 | EED_Single_Page_Checkout::load_request_handler(); |
||
91 | EED_Single_Page_Checkout::load_reg_steps(); |
||
92 | } else { |
||
93 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
||
94 | add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
||
95 | } |
||
96 | // set ajax hooks |
||
97 | add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
||
98 | add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
||
99 | add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
||
100 | add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
||
101 | add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
||
102 | add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
||
103 | } |
||
104 | |||
105 | |||
106 | |||
107 | /** |
||
108 | * process ajax request |
||
109 | * @param string $ajax_action |
||
110 | */ |
||
111 | public static function process_ajax_request( $ajax_action ) { |
||
115 | |||
116 | |||
117 | |||
118 | /** |
||
119 | * ajax display registration step |
||
120 | */ |
||
121 | public static function display_reg_step() { |
||
124 | |||
125 | |||
126 | |||
127 | /** |
||
128 | * ajax process registration step |
||
129 | */ |
||
130 | public static function process_reg_step() { |
||
133 | |||
134 | |||
135 | |||
136 | /** |
||
137 | * ajax process registration step |
||
138 | */ |
||
139 | public static function update_reg_step() { |
||
142 | |||
143 | |||
144 | |||
145 | /** |
||
146 | * update_checkout |
||
147 | * |
||
148 | * @access public |
||
149 | * @return void |
||
150 | */ |
||
151 | public static function update_checkout() { |
||
154 | |||
155 | |||
156 | |||
157 | /** |
||
158 | * load_request_handler |
||
159 | * |
||
160 | * @access public |
||
161 | * @return void |
||
162 | */ |
||
163 | public static function load_request_handler() { |
||
169 | |||
170 | |||
171 | |||
172 | /** |
||
173 | * set_definitions |
||
174 | * |
||
175 | * @access public |
||
176 | * @return void |
||
177 | */ |
||
178 | public static function set_definitions() { |
||
188 | |||
189 | |||
190 | |||
191 | /** |
||
192 | * load_reg_steps |
||
193 | * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
||
194 | * |
||
195 | * @access private |
||
196 | * @throws EE_Error |
||
197 | * @return array |
||
198 | */ |
||
199 | public static function load_reg_steps() { |
||
200 | static $reg_steps_loaded = FALSE; |
||
201 | if ( $reg_steps_loaded ) { |
||
202 | return; |
||
203 | } |
||
204 | // filter list of reg_steps |
||
205 | $reg_steps_to_load = apply_filters( |
||
206 | 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
||
207 | EED_Single_Page_Checkout::get_reg_steps() |
||
208 | ); |
||
209 | // sort by key (order) |
||
210 | ksort( $reg_steps_to_load ); |
||
211 | // loop through folders |
||
212 | foreach ( $reg_steps_to_load as $order => $reg_step ) { |
||
213 | // we need a |
||
214 | if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
||
215 | // copy over to the reg_steps_array |
||
216 | EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
||
217 | // register custom key route for each reg step |
||
218 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
||
219 | EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
||
220 | // add AJAX or other hooks |
||
221 | if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
||
222 | // setup autoloaders if necessary |
||
223 | if ( ! class_exists( $reg_step['class_name'] )) { |
||
224 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
||
225 | } |
||
226 | if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
||
227 | call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
||
228 | } |
||
229 | } |
||
230 | } |
||
231 | } |
||
232 | |||
233 | $reg_steps_loaded = TRUE; |
||
234 | } |
||
235 | |||
236 | |||
237 | |||
238 | /** |
||
239 | * get_reg_steps |
||
240 | * |
||
241 | * @access public |
||
242 | * @return array |
||
243 | */ |
||
244 | public static function get_reg_steps() { |
||
276 | |||
277 | |||
278 | |||
279 | /** |
||
280 | * registration_checkout_for_admin |
||
281 | * |
||
282 | * @access public |
||
283 | * @return string |
||
284 | */ |
||
285 | public static function registration_checkout_for_admin() { |
||
294 | |||
295 | |||
296 | |||
297 | /** |
||
298 | * process_registration_from_admin |
||
299 | * |
||
300 | * @access public |
||
301 | * @return int |
||
302 | */ |
||
303 | public static function process_registration_from_admin() { |
||
322 | |||
323 | |||
324 | |||
325 | /** |
||
326 | * run |
||
327 | * |
||
328 | * @access public |
||
329 | * @param WP_Query $WP_Query |
||
330 | * @return void |
||
331 | */ |
||
332 | public function run( $WP_Query ) { |
||
333 | if ( |
||
334 | $WP_Query instanceof WP_Query |
||
335 | && $WP_Query->is_main_query() |
||
336 | && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
||
337 | ) { |
||
338 | $this->_initialize(); |
||
339 | } |
||
340 | } |
||
341 | |||
342 | |||
343 | |||
344 | |||
345 | /** |
||
346 | * run |
||
347 | * |
||
348 | * @access public |
||
349 | * @param WP_Query $WP_Query |
||
350 | * @return void |
||
351 | */ |
||
352 | public static function init( $WP_Query ) { |
||
355 | |||
356 | |||
357 | |||
358 | /** |
||
359 | * _initialize - initial module setup |
||
360 | * |
||
361 | * @access private |
||
362 | * @throws EE_Error |
||
363 | * @return void |
||
364 | */ |
||
365 | private function _initialize() { |
||
366 | // ensure SPCO doesn't run twice |
||
367 | if ( EED_Single_Page_Checkout::$_initialized ) { |
||
368 | return; |
||
369 | } |
||
370 | // setup the EE_Checkout object |
||
371 | $this->checkout = $this->_initialize_checkout(); |
||
372 | // filter checkout |
||
373 | $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
||
374 | // get the $_GET |
||
375 | $this->_get_request_vars(); |
||
376 | // filter continue_reg |
||
377 | $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
||
378 | // load the reg steps array |
||
379 | if ( ! $this->_load_and_instantiate_reg_steps() ) { |
||
380 | EED_Single_Page_Checkout::$_initialized = true; |
||
381 | return; |
||
382 | } |
||
383 | // set the current step |
||
384 | $this->checkout->set_current_step( $this->checkout->step ); |
||
385 | // and the next step |
||
386 | $this->checkout->set_next_step(); |
||
387 | // was there already a valid transaction in the checkout from the session ? |
||
388 | if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
||
389 | // get transaction from db or session |
||
390 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
||
391 | ? $this->_get_transaction_and_cart_for_previous_visit() |
||
392 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
||
393 | if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
||
394 | EE_Error::add_error( |
||
395 | __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
||
396 | __FILE__, __FUNCTION__, __LINE__ |
||
397 | ); |
||
398 | // add some style and make it dance |
||
399 | $this->checkout->transaction = EE_Transaction::new_instance(); |
||
400 | $this->add_styles_and_scripts(); |
||
401 | EED_Single_Page_Checkout::$_initialized = true; |
||
402 | return; |
||
403 | } |
||
404 | // and the registrations for the transaction |
||
405 | $this->_get_registrations( $this->checkout->transaction ); |
||
406 | } |
||
407 | // verify that everything has been setup correctly |
||
408 | if ( ! $this->_final_verifications() ) { |
||
409 | EED_Single_Page_Checkout::$_initialized = true; |
||
410 | return; |
||
411 | } |
||
412 | // lock the transaction |
||
413 | $this->checkout->transaction->lock(); |
||
414 | // make sure all of our cached objects are added to their respective model entity mappers |
||
415 | $this->checkout->refresh_all_entities(); |
||
416 | // set amount owing |
||
417 | $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
||
418 | // initialize each reg step, which gives them the chance to potentially alter the process |
||
419 | $this->_initialize_reg_steps(); |
||
420 | // DEBUG LOG |
||
421 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
||
422 | // get reg form |
||
423 | $this->_check_form_submission(); |
||
424 | // checkout the action!!! |
||
425 | $this->_process_form_action(); |
||
426 | // add some style and make it dance |
||
427 | $this->add_styles_and_scripts(); |
||
428 | // kk... SPCO has successfully run |
||
429 | EED_Single_Page_Checkout::$_initialized = TRUE; |
||
430 | // set no cache headers and constants |
||
431 | EE_System::do_not_cache(); |
||
432 | // add anchor |
||
433 | add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
||
434 | // remove transaction lock |
||
435 | add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
||
436 | } |
||
437 | |||
438 | |||
439 | |||
440 | /** |
||
441 | * _initialize_checkout |
||
442 | * loads and instantiates EE_Checkout |
||
443 | * |
||
444 | * @access private |
||
445 | * @throws EE_Error |
||
446 | * @return EE_Checkout |
||
447 | */ |
||
448 | private function _initialize_checkout() { |
||
470 | |||
471 | |||
472 | |||
473 | /** |
||
474 | * _get_request_vars |
||
475 | * |
||
476 | * @access private |
||
477 | * @return void |
||
478 | */ |
||
479 | private function _get_request_vars() { |
||
480 | // load classes |
||
481 | EED_Single_Page_Checkout::load_request_handler(); |
||
482 | //make sure this request is marked as belonging to EE |
||
483 | EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
||
484 | // which step is being requested ? |
||
485 | $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
||
486 | // which step is being edited ? |
||
487 | $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
||
488 | // and what we're doing on the current step |
||
489 | $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
||
490 | // returning to edit ? |
||
491 | $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
||
492 | // or some other kind of revisit ? |
||
493 | $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
||
494 | // and whether or not to generate a reg form for this request |
||
495 | $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
||
496 | // and whether or not to process a reg form submission for this request |
||
497 | $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
||
498 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
||
499 | ? $this->checkout->process_form_submission |
||
500 | : FALSE; // TRUE FALSE |
||
501 | //$this->_display_request_vars(); |
||
502 | } |
||
503 | |||
504 | |||
505 | |||
506 | /** |
||
507 | * _display_request_vars |
||
508 | * |
||
509 | * @access protected |
||
510 | * @return void |
||
511 | */ |
||
512 | protected function _display_request_vars() { |
||
525 | |||
526 | |||
527 | |||
528 | /** |
||
529 | * _get_first_step |
||
530 | * gets slug for first step in $_reg_steps_array |
||
531 | * |
||
532 | * @access private |
||
533 | * @throws EE_Error |
||
534 | * @return array |
||
535 | */ |
||
536 | private function _get_first_step() { |
||
540 | |||
541 | |||
542 | |||
543 | /** |
||
544 | * _load_and_instantiate_reg_steps |
||
545 | * instantiates each reg step based on the loaded reg_steps array |
||
546 | * |
||
547 | * @access private |
||
548 | * @throws EE_Error |
||
549 | * @return bool |
||
550 | */ |
||
551 | private function _load_and_instantiate_reg_steps() { |
||
552 | // have reg_steps already been instantiated ? |
||
553 | if ( |
||
554 | empty( $this->checkout->reg_steps ) || |
||
555 | apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
||
556 | ) { |
||
557 | // if not, then loop through raw reg steps array |
||
558 | foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
||
559 | if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
||
560 | return false; |
||
561 | } |
||
562 | } |
||
563 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
||
564 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
||
565 | // skip the registration_confirmation page ? |
||
566 | if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
||
567 | // just remove it from the reg steps array |
||
568 | $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
||
569 | } else if ( |
||
570 | EE_Registry::instance()->CFG->registration->reg_confirmation_last |
||
571 | && isset( $this->checkout->reg_steps['registration_confirmation'] ) |
||
572 | ) { |
||
573 | // set the order to something big like 100 |
||
574 | $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
||
575 | } |
||
576 | // filter the array for good luck |
||
577 | $this->checkout->reg_steps = apply_filters( |
||
578 | 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
||
579 | $this->checkout->reg_steps |
||
580 | ); |
||
581 | // finally re-sort based on the reg step class order properties |
||
582 | $this->checkout->sort_reg_steps(); |
||
583 | } else { |
||
584 | foreach ( $this->checkout->reg_steps as $reg_step ) { |
||
585 | // set all current step stati to FALSE |
||
586 | $reg_step->set_is_current_step( FALSE ); |
||
587 | } |
||
588 | } |
||
589 | if ( empty( $this->checkout->reg_steps )) { |
||
590 | EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
||
591 | return false; |
||
592 | } |
||
593 | // make reg step details available to JS |
||
594 | $this->checkout->set_reg_step_JSON_info(); |
||
595 | return true; |
||
596 | } |
||
597 | |||
598 | |||
599 | |||
600 | /** |
||
601 | * _load_and_instantiate_reg_step |
||
602 | * |
||
603 | * @access private |
||
604 | * @param array $reg_step |
||
605 | * @param int $order |
||
606 | * @return bool |
||
607 | */ |
||
608 | private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
||
609 | |||
610 | // we need a file_path, class_name, and slug to add a reg step |
||
611 | if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
||
612 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
||
613 | if ( |
||
614 | $this->checkout->reg_url_link |
||
615 | && $this->checkout->step !== $reg_step['slug'] |
||
616 | && $reg_step['slug'] !== 'finalize_registration' |
||
617 | ) { |
||
618 | return true; |
||
619 | } |
||
620 | // instantiate step class using file path and class name |
||
621 | $reg_step_obj = EE_Registry::instance()->load_file( |
||
622 | $reg_step['file_path'], |
||
623 | $reg_step['class_name'], |
||
624 | 'class', |
||
625 | $this->checkout, |
||
626 | FALSE |
||
627 | ); |
||
628 | // did we gets the goods ? |
||
629 | View Code Duplication | if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
630 | // set reg step order based on config |
||
631 | $reg_step_obj->set_order( $order ); |
||
632 | // add instantiated reg step object to the master reg steps array |
||
633 | $this->checkout->add_reg_step( $reg_step_obj ); |
||
634 | } else { |
||
635 | EE_Error::add_error( |
||
636 | __( 'The current step could not be set.', 'event_espresso' ), |
||
637 | __FILE__, __FUNCTION__, __LINE__ |
||
638 | ); |
||
639 | return false; |
||
640 | } |
||
641 | } else { |
||
642 | if ( WP_DEBUG ) { |
||
643 | EE_Error::add_error( |
||
644 | sprintf( |
||
645 | __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
||
646 | isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
||
647 | isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
||
648 | isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
||
649 | '<ul>', |
||
650 | '<li>', |
||
651 | '</li>', |
||
652 | '</ul>' |
||
653 | ), |
||
654 | __FILE__, __FUNCTION__, __LINE__ |
||
655 | ); |
||
656 | } |
||
657 | return false; |
||
658 | } |
||
659 | return true; |
||
660 | } |
||
661 | |||
662 | |||
663 | |||
664 | /** |
||
665 | * _get_transaction_and_cart_for_previous_visit |
||
666 | * |
||
667 | * @access private |
||
668 | * @return mixed EE_Transaction|NULL |
||
669 | */ |
||
670 | private function _get_transaction_and_cart_for_previous_visit() { |
||
685 | |||
686 | |||
687 | |||
688 | /** |
||
689 | * _get_cart_for_transaction |
||
690 | * |
||
691 | * @access private |
||
692 | * @param EE_Transaction $transaction |
||
693 | * @return EE_Cart |
||
694 | */ |
||
695 | private function _get_cart_for_transaction( $transaction ) { |
||
703 | |||
704 | |||
705 | |||
706 | /** |
||
707 | * _get_cart_for_current_session_and_setup_new_transaction |
||
708 | * generates a new EE_Transaction object and adds it to the $_transaction property. |
||
709 | * |
||
710 | * @access public |
||
711 | * @param EE_Transaction $transaction |
||
712 | * @return EE_Cart |
||
713 | */ |
||
714 | public function get_cart_for_transaction( EE_Transaction $transaction ) { |
||
717 | |||
718 | |||
719 | |||
720 | /** |
||
721 | * _get_transaction_and_cart_for_current_session |
||
722 | * generates a new EE_Transaction object and adds it to the $_transaction property. |
||
723 | * |
||
724 | * @access private |
||
725 | * @return EE_Transaction |
||
726 | */ |
||
727 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
||
744 | |||
745 | |||
746 | |||
747 | /** |
||
748 | * generates a new EE_Transaction object and adds it to the $_transaction property. |
||
749 | * |
||
750 | * @access private |
||
751 | * @return mixed EE_Transaction|NULL |
||
752 | */ |
||
753 | private function _initialize_transaction() { |
||
772 | |||
773 | |||
774 | |||
775 | /** |
||
776 | * _get_registrations |
||
777 | * |
||
778 | * @access private |
||
779 | * @param EE_Transaction $transaction |
||
780 | * @return EE_Cart |
||
781 | */ |
||
782 | private function _get_registrations( EE_Transaction $transaction ) { |
||
813 | |||
814 | |||
815 | |||
816 | /** |
||
817 | * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
||
818 | * |
||
819 | * @access private |
||
820 | * @param EE_Transaction $transaction |
||
821 | * @return array |
||
822 | */ |
||
823 | private function _initialize_registrations( EE_Transaction $transaction ) { |
||
850 | |||
851 | |||
852 | |||
853 | /** |
||
854 | * sorts registrations by REG_count |
||
855 | * |
||
856 | * @access public |
||
857 | * @param EE_Registration $reg_A |
||
858 | * @param EE_Registration $reg_B |
||
859 | * @return array() |
||
860 | */ |
||
861 | public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
||
868 | |||
869 | |||
870 | |||
871 | /** |
||
872 | * _final_verifications |
||
873 | * |
||
874 | * just makes sure that everything is set up correctly before proceeding |
||
875 | * |
||
876 | * @access private |
||
877 | * @return bool |
||
878 | */ |
||
879 | private function _final_verifications() { |
||
912 | |||
913 | |||
914 | |||
915 | |||
916 | /** |
||
917 | * _initialize_reg_steps |
||
918 | * |
||
919 | * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
||
920 | * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
||
921 | * |
||
922 | * @access private |
||
923 | * @param bool $reinitializing |
||
924 | */ |
||
925 | private function _initialize_reg_steps( $reinitializing = false ) { |
||
948 | |||
949 | |||
950 | |||
951 | /** |
||
952 | * _check_form_submission |
||
953 | * |
||
954 | * @access private |
||
955 | * @return void |
||
956 | */ |
||
957 | private function _check_form_submission() { |
||
996 | |||
997 | |||
998 | |||
999 | /** |
||
1000 | * _process_action |
||
1001 | * |
||
1002 | * @access private |
||
1003 | * @return void |
||
1004 | */ |
||
1005 | private function _process_form_action() { |
||
1052 | |||
1053 | |||
1054 | |||
1055 | /** |
||
1056 | * add_styles_and_scripts |
||
1057 | * |
||
1058 | * @access public |
||
1059 | * @return void |
||
1060 | */ |
||
1061 | public function add_styles_and_scripts() { |
||
1070 | |||
1071 | |||
1072 | |||
1073 | /** |
||
1074 | * translate_js_strings |
||
1075 | * |
||
1076 | * @access public |
||
1077 | * @return void |
||
1078 | */ |
||
1079 | public function translate_js_strings() { |
||
1120 | |||
1121 | |||
1122 | |||
1123 | /** |
||
1124 | * enqueue_styles_and_scripts |
||
1125 | * |
||
1126 | * @access public |
||
1127 | * @return void |
||
1128 | */ |
||
1129 | public function enqueue_styles_and_scripts() { |
||
1154 | |||
1155 | |||
1156 | |||
1157 | /** |
||
1158 | * display the Registration Single Page Checkout Form |
||
1159 | * |
||
1160 | * @access private |
||
1161 | * @return void |
||
1162 | */ |
||
1163 | private function _display_spco_reg_form() { |
||
1227 | |||
1228 | |||
1229 | |||
1230 | /** |
||
1231 | * add_extra_finalize_registration_inputs |
||
1232 | * |
||
1233 | * @access public |
||
1234 | * @param $next_step |
||
1235 | * @internal param string $label |
||
1236 | * @return string |
||
1237 | */ |
||
1238 | public function add_extra_finalize_registration_inputs( $next_step ) { |
||
1243 | |||
1244 | |||
1245 | |||
1246 | /** |
||
1247 | * display_registration_footer |
||
1248 | * |
||
1249 | * @access public |
||
1250 | * @return string |
||
1251 | */ |
||
1252 | public static function display_registration_footer() { |
||
1271 | |||
1272 | |||
1273 | |||
1274 | |||
1275 | /** |
||
1276 | * unlock_transaction |
||
1277 | * |
||
1278 | * @access public |
||
1279 | * @return void |
||
1280 | */ |
||
1281 | public function unlock_transaction() { |
||
1284 | |||
1285 | |||
1286 | |||
1287 | |||
1288 | /** |
||
1289 | * _setup_redirect |
||
1290 | * |
||
1291 | * @access private |
||
1292 | * @return array |
||
1293 | */ |
||
1294 | private function _setup_redirect() { |
||
1303 | |||
1304 | |||
1305 | |||
1306 | /** |
||
1307 | * handle ajax message responses and redirects |
||
1308 | * |
||
1309 | * @access public |
||
1310 | * @return void |
||
1311 | */ |
||
1312 | public function go_to_next_step() { |
||
1328 | |||
1329 | |||
1330 | |||
1331 | /** |
||
1332 | * _handle_json_response |
||
1333 | * |
||
1334 | * @access protected |
||
1335 | * @return void |
||
1336 | */ |
||
1337 | protected function _handle_json_response() { |
||
1358 | |||
1359 | |||
1360 | |||
1361 | /** |
||
1362 | * _handle_redirects |
||
1363 | * |
||
1364 | * @access protected |
||
1365 | * @return void |
||
1366 | */ |
||
1367 | protected function _handle_html_redirects() { |
||
1386 | |||
1387 | |||
1388 | |||
1389 | /** |
||
1390 | * set_checkout_anchor |
||
1391 | * |
||
1392 | * @access public |
||
1393 | * @return string |
||
1394 | */ |
||
1395 | public function set_checkout_anchor() { |
||
1398 | |||
1399 | |||
1400 | |||
1401 | } |
||
1402 | // End of file EED_Single_Page_Checkout.module.php |
||
1403 | // Location: /modules/single_page_checkout/EED_Single_Page_Checkout.module.php |
||
1404 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.