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 EE_Transaction 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 EE_Transaction, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
17 | class EE_Transaction extends EE_Base_Class implements EEI_Transaction |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * The length of time in seconds that a lock is applied before being considered expired. |
||
22 | * It is not long because a transaction should only be locked for the duration of the request that locked it |
||
23 | */ |
||
24 | const LOCK_EXPIRATION = 2; |
||
25 | |||
26 | /** |
||
27 | * txn status upon initial construction. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $_old_txn_status; |
||
32 | |||
33 | |||
34 | |||
35 | /** |
||
36 | * @param array $props_n_values incoming values |
||
37 | * @param string $timezone incoming timezone |
||
38 | * (if not set the timezone set for the website will be used.) |
||
39 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
40 | * date_format and the second value is the time format |
||
41 | * @return EE_Transaction |
||
42 | * @throws EE_Error |
||
43 | */ |
||
44 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
55 | |||
56 | |||
57 | |||
58 | /** |
||
59 | * @param array $props_n_values incoming values from the database |
||
60 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
61 | * the website will be used. |
||
62 | * @return EE_Transaction |
||
63 | * @throws EE_Error |
||
64 | */ |
||
65 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
71 | |||
72 | |||
73 | |||
74 | /** |
||
75 | * Sets a meta field indicating that this TXN is locked and should not be updated in the db. |
||
76 | * If a lock has already been set, then we will attempt to remove it in case it has expired. |
||
77 | * If that also fails, then an exception is thrown. |
||
78 | * |
||
79 | * @throws EE_Error |
||
80 | */ |
||
81 | public function lock() |
||
103 | |||
104 | |||
105 | |||
106 | /** |
||
107 | * removes transaction lock applied in EE_Transaction::lock() |
||
108 | * |
||
109 | * @return int |
||
110 | * @throws EE_Error |
||
111 | */ |
||
112 | public function unlock() |
||
116 | |||
117 | |||
118 | |||
119 | /** |
||
120 | * Decides whether or not now is the right time to update the transaction. |
||
121 | * This is useful because we don't always know if it is safe to update the transaction |
||
122 | * and its related data. why? |
||
123 | * because it's possible that the transaction is being used in another |
||
124 | * request and could overwrite anything we save. |
||
125 | * So we want to only update the txn once we know that won't happen. |
||
126 | * We also check that the lock isn't expired, and remove it if it is |
||
127 | * |
||
128 | * @return boolean |
||
129 | * @throws EE_Error |
||
130 | */ |
||
131 | public function is_locked() |
||
143 | |||
144 | |||
145 | |||
146 | /** |
||
147 | * Gets the meta field indicating that this TXN is locked |
||
148 | * |
||
149 | * @return int |
||
150 | * @throws EE_Error |
||
151 | */ |
||
152 | protected function _get_lock() |
||
156 | |||
157 | |||
158 | |||
159 | /** |
||
160 | * If the lock on this transaction is expired, then we want to remove it so that the transaction can be updated |
||
161 | * |
||
162 | * @return int |
||
163 | * @throws EE_Error |
||
164 | */ |
||
165 | protected function _remove_expired_lock() |
||
173 | |||
174 | |||
175 | |||
176 | /** |
||
177 | * Set transaction total |
||
178 | * |
||
179 | * @param float $total total value of transaction |
||
180 | * @throws EE_Error |
||
181 | */ |
||
182 | public function set_total($total = 0.00) |
||
186 | |||
187 | |||
188 | |||
189 | /** |
||
190 | * Set Total Amount Paid to Date |
||
191 | * |
||
192 | * @param float $total_paid total amount paid to date (sum of all payments) |
||
193 | * @throws EE_Error |
||
194 | */ |
||
195 | public function set_paid($total_paid = 0.00) |
||
199 | |||
200 | |||
201 | |||
202 | /** |
||
203 | * Set transaction status |
||
204 | * |
||
205 | * @param string $status whether the transaction is open, declined, accepted, |
||
206 | * or any number of custom values that can be set |
||
207 | * @throws EE_Error |
||
208 | */ |
||
209 | public function set_status($status = '') |
||
213 | |||
214 | |||
215 | |||
216 | /** |
||
217 | * Set hash salt |
||
218 | * |
||
219 | * @param string $hash_salt required for some payment gateways |
||
220 | * @throws EE_Error |
||
221 | */ |
||
222 | public function set_hash_salt($hash_salt = '') |
||
226 | |||
227 | |||
228 | |||
229 | /** |
||
230 | * Sets TXN_reg_steps array |
||
231 | * |
||
232 | * @param array $txn_reg_steps |
||
233 | * @throws EE_Error |
||
234 | */ |
||
235 | public function set_reg_steps(array $txn_reg_steps) |
||
239 | |||
240 | |||
241 | |||
242 | /** |
||
243 | * Gets TXN_reg_steps |
||
244 | * |
||
245 | * @return array |
||
246 | * @throws EE_Error |
||
247 | */ |
||
248 | public function reg_steps() |
||
253 | |||
254 | |||
255 | |||
256 | /** |
||
257 | * @return string of transaction's total cost, with currency symbol and decimal |
||
258 | * @throws EE_Error |
||
259 | */ |
||
260 | public function pretty_total() |
||
264 | |||
265 | |||
266 | |||
267 | /** |
||
268 | * Gets the amount paid in a pretty string (formatted and with currency symbol) |
||
269 | * |
||
270 | * @return string |
||
271 | * @throws EE_Error |
||
272 | */ |
||
273 | public function pretty_paid() |
||
277 | |||
278 | |||
279 | |||
280 | /** |
||
281 | * calculate the amount remaining for this transaction and return; |
||
282 | * |
||
283 | * @return float amount remaining |
||
284 | * @throws EE_Error |
||
285 | */ |
||
286 | public function remaining() |
||
290 | |||
291 | |||
292 | |||
293 | /** |
||
294 | * get Transaction Total |
||
295 | * |
||
296 | * @return float |
||
297 | * @throws EE_Error |
||
298 | */ |
||
299 | public function total() |
||
303 | |||
304 | |||
305 | |||
306 | /** |
||
307 | * get Total Amount Paid to Date |
||
308 | * |
||
309 | * @return float |
||
310 | * @throws EE_Error |
||
311 | */ |
||
312 | public function paid() |
||
316 | |||
317 | |||
318 | |||
319 | /** |
||
320 | * @throws EE_Error |
||
321 | */ |
||
322 | public function get_cart_session() |
||
329 | |||
330 | |||
331 | |||
332 | /** |
||
333 | * get Transaction session data |
||
334 | * |
||
335 | * @throws EE_Error |
||
336 | */ |
||
337 | public function session_data() |
||
353 | |||
354 | |||
355 | |||
356 | /** |
||
357 | * Set session data within the TXN object |
||
358 | * |
||
359 | * @param EE_Session|array $session_data |
||
360 | * @throws EE_Error |
||
361 | */ |
||
362 | public function set_txn_session_data($session_data) |
||
370 | |||
371 | |||
372 | |||
373 | /** |
||
374 | * get Transaction hash salt |
||
375 | * |
||
376 | * @throws EE_Error |
||
377 | */ |
||
378 | public function hash_salt_() |
||
382 | |||
383 | |||
384 | |||
385 | /** |
||
386 | * Returns the transaction datetime as either: |
||
387 | * - unix timestamp format ($format = false, $gmt = true) |
||
388 | * - formatted date string including the UTC (timezone) offset ($format = true ($gmt |
||
389 | * has no affect with this option)), this also may include a timezone abbreviation if the |
||
390 | * set timezone in this class differs from what the timezone is on the blog. |
||
391 | * - formatted date string including the UTC (timezone) offset (default). |
||
392 | * |
||
393 | * @param boolean $format - whether to return a unix timestamp (default) or formatted date string |
||
394 | * @param boolean $gmt - whether to return a unix timestamp with UTC offset applied (default) |
||
395 | * or no UTC offset applied |
||
396 | * @return string | int |
||
397 | * @throws EE_Error |
||
398 | */ |
||
399 | public function datetime($format = false, $gmt = false) |
||
409 | |||
410 | |||
411 | |||
412 | /** |
||
413 | * Gets registrations on this transaction |
||
414 | * |
||
415 | * @param array $query_params array of query parameters |
||
416 | * @param boolean $get_cached TRUE to retrieve cached registrations or FALSE to pull from the db |
||
417 | * @return EE_Base_Class[]|EE_Registration[] |
||
418 | * @throws EE_Error |
||
419 | */ |
||
420 | public function registrations($query_params = array(), $get_cached = false) |
||
434 | |||
435 | |||
436 | |||
437 | /** |
||
438 | * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event |
||
439 | * function for getting attendees and how many registrations they each have for an event) |
||
440 | * |
||
441 | * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
||
442 | * @throws EE_Error |
||
443 | */ |
||
444 | public function attendees() |
||
448 | |||
449 | |||
450 | |||
451 | /** |
||
452 | * Gets payments for this transaction. Unlike other such functions, order by 'DESC' by default |
||
453 | * |
||
454 | * @param array $query_params like EEM_Base::get_all |
||
455 | * @return EE_Base_Class[]|EE_Payment[] |
||
456 | * @throws EE_Error |
||
457 | */ |
||
458 | public function payments($query_params = array()) |
||
462 | |||
463 | |||
464 | |||
465 | /** |
||
466 | * gets only approved payments for this transaction |
||
467 | * |
||
468 | * @return EE_Base_Class[]|EE_Payment[] |
||
469 | * @throws EE_Error |
||
470 | * @throws InvalidArgumentException |
||
471 | * @throws ReflectionException |
||
472 | * @throws InvalidDataTypeException |
||
473 | * @throws InvalidInterfaceException |
||
474 | */ |
||
475 | public function approved_payments() |
||
486 | |||
487 | |||
488 | |||
489 | /** |
||
490 | * Gets all payments which have not been approved |
||
491 | * |
||
492 | * @return EE_Base_Class[]|EEI_Payment[] |
||
493 | * @throws EE_Error if a model is misconfigured somehow |
||
494 | */ |
||
495 | public function pending_payments() |
||
509 | |||
510 | |||
511 | |||
512 | /** |
||
513 | * echoes $this->pretty_status() |
||
514 | * |
||
515 | * @param bool $show_icons |
||
516 | * @throws EE_Error |
||
517 | * @throws InvalidArgumentException |
||
518 | * @throws InvalidDataTypeException |
||
519 | * @throws InvalidInterfaceException |
||
520 | */ |
||
521 | public function e_pretty_status($show_icons = false) |
||
525 | |||
526 | |||
527 | |||
528 | /** |
||
529 | * returns a pretty version of the status, good for displaying to users |
||
530 | * |
||
531 | * @param bool $show_icons |
||
532 | * @return string |
||
533 | * @throws EE_Error |
||
534 | * @throws InvalidArgumentException |
||
535 | * @throws InvalidDataTypeException |
||
536 | * @throws InvalidInterfaceException |
||
537 | */ |
||
538 | public function pretty_status($show_icons = false) |
||
566 | |||
567 | |||
568 | |||
569 | /** |
||
570 | * get Transaction Status |
||
571 | * |
||
572 | * @throws EE_Error |
||
573 | */ |
||
574 | public function status_ID() |
||
578 | |||
579 | |||
580 | |||
581 | /** |
||
582 | * Returns TRUE or FALSE for whether or not this transaction cost any money |
||
583 | * |
||
584 | * @return boolean |
||
585 | * @throws EE_Error |
||
586 | */ |
||
587 | public function is_free() |
||
591 | |||
592 | |||
593 | |||
594 | /** |
||
595 | * Returns whether this transaction is complete |
||
596 | * Useful in templates and other logic for deciding if we should ask for another payment... |
||
597 | * |
||
598 | * @return boolean |
||
599 | * @throws EE_Error |
||
600 | */ |
||
601 | public function is_completed() |
||
605 | |||
606 | |||
607 | |||
608 | /** |
||
609 | * Returns whether this transaction is incomplete |
||
610 | * Useful in templates and other logic for deciding if we should ask for another payment... |
||
611 | * |
||
612 | * @return boolean |
||
613 | * @throws EE_Error |
||
614 | */ |
||
615 | public function is_incomplete() |
||
619 | |||
620 | |||
621 | |||
622 | /** |
||
623 | * Returns whether this transaction is overpaid |
||
624 | * Useful in templates and other logic for deciding if monies need to be refunded |
||
625 | * |
||
626 | * @return boolean |
||
627 | * @throws EE_Error |
||
628 | */ |
||
629 | public function is_overpaid() |
||
633 | |||
634 | |||
635 | |||
636 | /** |
||
637 | * Returns whether this transaction was abandoned |
||
638 | * meaning that the transaction/registration process was somehow interrupted and never completed |
||
639 | * but that contact information exists for at least one registrant |
||
640 | * |
||
641 | * @return boolean |
||
642 | * @throws EE_Error |
||
643 | */ |
||
644 | public function is_abandoned() |
||
648 | |||
649 | |||
650 | |||
651 | /** |
||
652 | * Returns whether this transaction failed |
||
653 | * meaning that the transaction/registration process was somehow interrupted and never completed |
||
654 | * and that NO contact information exists for any registrants |
||
655 | * |
||
656 | * @return boolean |
||
657 | * @throws EE_Error |
||
658 | */ |
||
659 | public function failed() |
||
663 | |||
664 | |||
665 | |||
666 | /** |
||
667 | * This returns the url for the invoice of this transaction |
||
668 | * |
||
669 | * @param string $type 'html' or 'pdf' (default is pdf) |
||
670 | * @return string |
||
671 | * @throws EE_Error |
||
672 | */ |
||
673 | public function invoice_url($type = 'html') |
||
681 | |||
682 | |||
683 | |||
684 | /** |
||
685 | * Gets the primary registration only |
||
686 | * |
||
687 | * @return EE_Base_Class|EE_Registration |
||
688 | * @throws EE_Error |
||
689 | */ |
||
690 | public function primary_registration() |
||
708 | |||
709 | |||
710 | |||
711 | /** |
||
712 | * Gets the URL for viewing the receipt |
||
713 | * |
||
714 | * @param string $type 'pdf' or 'html' (default is 'html') |
||
715 | * @return string |
||
716 | * @throws EE_Error |
||
717 | */ |
||
718 | public function receipt_url($type = 'html') |
||
726 | |||
727 | |||
728 | |||
729 | /** |
||
730 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
731 | * a query parameter |
||
732 | * |
||
733 | * @return string |
||
734 | * @throws EE_Error |
||
735 | */ |
||
736 | public function payment_overview_url() |
||
741 | |||
742 | |||
743 | |||
744 | /** |
||
745 | * @return string |
||
746 | * @throws EE_Error |
||
747 | */ |
||
748 | public function gateway_response_on_transaction() |
||
753 | |||
754 | |||
755 | |||
756 | /** |
||
757 | * Get the status object of this object |
||
758 | * |
||
759 | * @return EE_Base_Class|EE_Status |
||
760 | * @throws EE_Error |
||
761 | */ |
||
762 | public function status_obj() |
||
766 | |||
767 | |||
768 | |||
769 | /** |
||
770 | * Gets all the extra meta info on this payment |
||
771 | * |
||
772 | * @param array $query_params like EEM_Base::get_all |
||
773 | * @return EE_Base_Class[]|EE_Extra_Meta |
||
774 | * @throws EE_Error |
||
775 | */ |
||
776 | public function extra_meta($query_params = array()) |
||
780 | |||
781 | |||
782 | |||
783 | /** |
||
784 | * Wrapper for _add_relation_to |
||
785 | * |
||
786 | * @param EE_Registration $registration |
||
787 | * @return EE_Base_Class the relation was added to |
||
788 | * @throws EE_Error |
||
789 | */ |
||
790 | public function add_registration(EE_Registration $registration) |
||
794 | |||
795 | |||
796 | |||
797 | /** |
||
798 | * Removes the given registration from being related (even before saving this transaction). |
||
799 | * If an ID/index is provided and this transaction isn't saved yet, removes it from list of cached relations |
||
800 | * |
||
801 | * @param int $registration_or_id |
||
802 | * @return EE_Base_Class that was removed from being related |
||
803 | * @throws EE_Error |
||
804 | */ |
||
805 | public function remove_registration_with_id($registration_or_id) |
||
809 | |||
810 | |||
811 | |||
812 | /** |
||
813 | * Gets all the line items which are for ACTUAL items |
||
814 | * |
||
815 | * @return EE_Line_Item[] |
||
816 | * @throws EE_Error |
||
817 | */ |
||
818 | public function items_purchased() |
||
822 | |||
823 | |||
824 | |||
825 | /** |
||
826 | * Wrapper for _add_relation_to |
||
827 | * |
||
828 | * @param EE_Line_Item $line_item |
||
829 | * @return EE_Base_Class the relation was added to |
||
830 | * @throws EE_Error |
||
831 | */ |
||
832 | public function add_line_item(EE_Line_Item $line_item) |
||
836 | |||
837 | |||
838 | |||
839 | /** |
||
840 | * Gets ALL the line items related to this transaction (unstructured) |
||
841 | * |
||
842 | * @param array $query_params |
||
843 | * @return EE_Base_Class[]|EE_Line_Item[] |
||
844 | * @throws EE_Error |
||
845 | */ |
||
846 | public function line_items($query_params = array()) |
||
850 | |||
851 | |||
852 | |||
853 | /** |
||
854 | * Gets all the line items which are taxes on the total |
||
855 | * |
||
856 | * @return EE_Line_Item[] |
||
857 | * @throws EE_Error |
||
858 | */ |
||
859 | public function tax_items() |
||
863 | |||
864 | |||
865 | |||
866 | /** |
||
867 | * Gets the total line item (which is a parent of all other related line items, |
||
868 | * meaning it takes them all into account on its total) |
||
869 | * |
||
870 | * @param bool $create_if_not_found |
||
871 | * @return \EE_Line_Item |
||
872 | * @throws EE_Error |
||
873 | */ |
||
874 | public function total_line_item($create_if_not_found = true) |
||
882 | |||
883 | |||
884 | |||
885 | /** |
||
886 | * Returns the total amount of tax on this transaction |
||
887 | * (assumes there's only one tax subtotal line item) |
||
888 | * |
||
889 | * @return float |
||
890 | * @throws EE_Error |
||
891 | */ |
||
892 | public function tax_total() |
||
900 | |||
901 | |||
902 | |||
903 | /** |
||
904 | * Gets the tax subtotal line item (assumes there's only one) |
||
905 | * |
||
906 | * @return EE_Line_Item |
||
907 | * @throws EE_Error |
||
908 | */ |
||
909 | public function tax_total_line_item() |
||
913 | |||
914 | |||
915 | |||
916 | /** |
||
917 | * Gets the array of billing info for the gateway and for this transaction's primary registration's attendee. |
||
918 | * |
||
919 | * @return EE_Form_Section_Proper |
||
920 | * @throws EE_Error |
||
921 | */ |
||
922 | public function billing_info() |
||
965 | |||
966 | |||
967 | |||
968 | /** |
||
969 | * Gets PMD_ID |
||
970 | * |
||
971 | * @return int |
||
972 | * @throws EE_Error |
||
973 | */ |
||
974 | public function payment_method_ID() |
||
978 | |||
979 | |||
980 | |||
981 | /** |
||
982 | * Sets PMD_ID |
||
983 | * |
||
984 | * @param int $PMD_ID |
||
985 | * @throws EE_Error |
||
986 | */ |
||
987 | public function set_payment_method_ID($PMD_ID) |
||
991 | |||
992 | |||
993 | |||
994 | /** |
||
995 | * Gets the last-used payment method on this transaction |
||
996 | * (we COULD just use the last-made payment, but some payment methods, namely |
||
997 | * offline ones, dont' create payments) |
||
998 | * |
||
999 | * @return EE_Payment_Method |
||
1000 | * @throws EE_Error |
||
1001 | */ |
||
1002 | public function payment_method() |
||
1014 | |||
1015 | |||
1016 | |||
1017 | /** |
||
1018 | * Gets the last payment made |
||
1019 | * |
||
1020 | * @return EE_Base_Class|EE_Payment |
||
1021 | * @throws EE_Error |
||
1022 | */ |
||
1023 | public function last_payment() |
||
1027 | |||
1028 | |||
1029 | |||
1030 | /** |
||
1031 | * Gets all the line items which are unrelated to tickets on this transaction |
||
1032 | * |
||
1033 | * @return EE_Line_Item[] |
||
1034 | * @throws EE_Error |
||
1035 | * @throws InvalidArgumentException |
||
1036 | * @throws InvalidDataTypeException |
||
1037 | * @throws InvalidInterfaceException |
||
1038 | */ |
||
1039 | public function non_ticket_line_items() |
||
1043 | |||
1044 | |||
1045 | |||
1046 | /** |
||
1047 | * possibly toggles TXN status |
||
1048 | * |
||
1049 | * @param boolean $update whether to save the TXN |
||
1050 | * @return bool whether the TXN was saved |
||
1051 | * @throws EE_Error |
||
1052 | * @throws RuntimeException |
||
1053 | */ |
||
1054 | public function update_status_based_on_total_paid($update = true) |
||
1076 | |||
1077 | |||
1078 | |||
1079 | /** |
||
1080 | * Updates the transaction's status and total_paid based on all the payments |
||
1081 | * that apply to it |
||
1082 | * |
||
1083 | * @deprecated |
||
1084 | * @return array|bool |
||
1085 | * @throws EE_Error |
||
1086 | * @throws InvalidArgumentException |
||
1087 | * @throws ReflectionException |
||
1088 | * @throws InvalidDataTypeException |
||
1089 | * @throws InvalidInterfaceException |
||
1090 | */ |
||
1091 | View Code Duplication | public function update_based_on_payments() |
|
1105 | |||
1106 | |||
1107 | |||
1108 | /** |
||
1109 | * @return string |
||
1110 | */ |
||
1111 | public function old_txn_status() |
||
1115 | |||
1116 | |||
1117 | |||
1118 | /** |
||
1119 | * @param string $old_txn_status |
||
1120 | */ |
||
1121 | public function set_old_txn_status($old_txn_status) |
||
1128 | |||
1129 | |||
1130 | |||
1131 | /** |
||
1132 | * reg_status_updated |
||
1133 | * |
||
1134 | * @return bool |
||
1135 | * @throws EE_Error |
||
1136 | */ |
||
1137 | public function txn_status_updated() |
||
1141 | |||
1142 | |||
1143 | |||
1144 | /** |
||
1145 | * _reg_steps_completed |
||
1146 | * if $check_all is TRUE, then returns TRUE if ALL reg steps have been marked as completed, |
||
1147 | * if a $reg_step_slug is provided, then this step will be skipped when testing for completion |
||
1148 | * if $check_all is FALSE and a $reg_step_slug is provided, then ONLY that reg step will be tested for completion |
||
1149 | * |
||
1150 | * @param string $reg_step_slug |
||
1151 | * @param bool $check_all |
||
1152 | * @return bool|int |
||
1153 | * @throws EE_Error |
||
1154 | */ |
||
1155 | private function _reg_steps_completed($reg_step_slug = '', $check_all = true) |
||
1190 | |||
1191 | |||
1192 | |||
1193 | /** |
||
1194 | * all_reg_steps_completed |
||
1195 | * returns: |
||
1196 | * true if ALL reg steps have been marked as completed |
||
1197 | * or false if any step is not completed |
||
1198 | * |
||
1199 | * @return bool |
||
1200 | * @throws EE_Error |
||
1201 | */ |
||
1202 | public function all_reg_steps_completed() |
||
1206 | |||
1207 | |||
1208 | |||
1209 | /** |
||
1210 | * all_reg_steps_completed_except |
||
1211 | * returns: |
||
1212 | * true if ALL reg steps, except a particular step that you wish to skip over, have been marked as completed |
||
1213 | * or false if any other step is not completed |
||
1214 | * or false if ALL steps are completed including the exception you are testing !!! |
||
1215 | * |
||
1216 | * @param string $exception |
||
1217 | * @return bool |
||
1218 | * @throws EE_Error |
||
1219 | */ |
||
1220 | public function all_reg_steps_completed_except($exception = '') |
||
1224 | |||
1225 | |||
1226 | |||
1227 | /** |
||
1228 | * all_reg_steps_completed_except |
||
1229 | * returns: |
||
1230 | * true if ALL reg steps, except the final step, have been marked as completed |
||
1231 | * or false if any step is not completed |
||
1232 | * or false if ALL steps are completed including the final step !!! |
||
1233 | * |
||
1234 | * @return bool |
||
1235 | * @throws EE_Error |
||
1236 | */ |
||
1237 | public function all_reg_steps_completed_except_final_step() |
||
1241 | |||
1242 | |||
1243 | |||
1244 | /** |
||
1245 | * reg_step_completed |
||
1246 | * returns: |
||
1247 | * true if a specific reg step has been marked as completed |
||
1248 | * a Unix timestamp if it has been initialized but not yet completed, |
||
1249 | * or false if it has not yet been initialized |
||
1250 | * |
||
1251 | * @param string $reg_step_slug |
||
1252 | * @return bool|int |
||
1253 | * @throws EE_Error |
||
1254 | */ |
||
1255 | public function reg_step_completed($reg_step_slug) |
||
1259 | |||
1260 | |||
1261 | |||
1262 | /** |
||
1263 | * completed_final_reg_step |
||
1264 | * returns: |
||
1265 | * true if the finalize_registration reg step has been marked as completed |
||
1266 | * a Unix timestamp if it has been initialized but not yet completed, |
||
1267 | * or false if it has not yet been initialized |
||
1268 | * |
||
1269 | * @return bool|int |
||
1270 | * @throws EE_Error |
||
1271 | */ |
||
1272 | public function final_reg_step_completed() |
||
1276 | |||
1277 | |||
1278 | |||
1279 | /** |
||
1280 | * set_reg_step_initiated |
||
1281 | * given a valid TXN_reg_step, this sets it's value to a unix timestamp |
||
1282 | * |
||
1283 | * @param string $reg_step_slug |
||
1284 | * @return boolean |
||
1285 | * @throws EE_Error |
||
1286 | */ |
||
1287 | public function set_reg_step_initiated($reg_step_slug) |
||
1291 | |||
1292 | |||
1293 | |||
1294 | /** |
||
1295 | * set_reg_step_completed |
||
1296 | * given a valid TXN_reg_step, this sets the step as completed |
||
1297 | * |
||
1298 | * @param string $reg_step_slug |
||
1299 | * @return boolean |
||
1300 | * @throws EE_Error |
||
1301 | */ |
||
1302 | public function set_reg_step_completed($reg_step_slug) |
||
1306 | |||
1307 | |||
1308 | |||
1309 | /** |
||
1310 | * set_reg_step_completed |
||
1311 | * given a valid TXN_reg_step slug, this sets the step as NOT completed |
||
1312 | * |
||
1313 | * @param string $reg_step_slug |
||
1314 | * @return boolean |
||
1315 | * @throws EE_Error |
||
1316 | */ |
||
1317 | public function set_reg_step_not_completed($reg_step_slug) |
||
1321 | |||
1322 | |||
1323 | |||
1324 | /** |
||
1325 | * set_reg_step_completed |
||
1326 | * given a valid reg step slug, this sets the TXN_reg_step completed status which is either: |
||
1327 | * |
||
1328 | * @param string $reg_step_slug |
||
1329 | * @param boolean|int $status |
||
1330 | * @return boolean |
||
1331 | * @throws EE_Error |
||
1332 | */ |
||
1333 | private function _set_reg_step_completed_status($reg_step_slug, $status) |
||
1368 | |||
1369 | |||
1370 | |||
1371 | /** |
||
1372 | * remove_reg_step |
||
1373 | * given a valid TXN_reg_step slug, this will remove (unset) |
||
1374 | * the reg step from the TXN reg step array |
||
1375 | * |
||
1376 | * @param string $reg_step_slug |
||
1377 | * @return void |
||
1378 | * @throws EE_Error |
||
1379 | */ |
||
1380 | public function remove_reg_step($reg_step_slug) |
||
1387 | |||
1388 | |||
1389 | |||
1390 | /** |
||
1391 | * toggle_failed_transaction_status |
||
1392 | * upgrades a TXNs status from failed to abandoned, |
||
1393 | * meaning that contact information has been captured for at least one registrant |
||
1394 | * |
||
1395 | * @param bool $save |
||
1396 | * @return bool |
||
1397 | * @throws EE_Error |
||
1398 | */ |
||
1399 | public function toggle_failed_transaction_status($save = true) |
||
1411 | |||
1412 | |||
1413 | |||
1414 | /** |
||
1415 | * toggle_abandoned_transaction_status |
||
1416 | * upgrades a TXNs status from failed or abandoned to incomplete |
||
1417 | * |
||
1418 | * @return bool |
||
1419 | * @throws EE_Error |
||
1420 | */ |
||
1421 | public function toggle_abandoned_transaction_status() |
||
1443 | |||
1444 | |||
1445 | |||
1446 | /** |
||
1447 | * checks if an Abandoned TXN has any related payments, and if so, |
||
1448 | * updates the TXN status based on the amount paid |
||
1449 | * |
||
1450 | * @throws EE_Error |
||
1451 | * @throws InvalidDataTypeException |
||
1452 | * @throws InvalidInterfaceException |
||
1453 | * @throws InvalidArgumentException |
||
1454 | * @throws RuntimeException |
||
1455 | */ |
||
1456 | public function verify_abandoned_transaction_status() |
||
1491 | |||
1492 | }/* End of file EE_Transaction.class.php */ |
||
1493 | /* Location: includes/classes/EE_Transaction.class.php */ |
||
1494 |