@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -116,42 +116,42 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | protected function _start() { |
119 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
120 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>'; |
|
119 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
120 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>'; |
|
121 | 121 | |
122 | 122 | return $content; |
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function _display_text_stop() { |
126 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
126 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function _admin_label_stop() { |
130 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _type_stop() { |
134 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _values_stop() { |
138 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _required_stop() { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | protected function _bulk_actions_stop() { |
146 | - return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
|
146 | + return '<p>'.__('Perform bulk actions to multiple questions.', 'event_espresso').'</p>'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function _search_stop() { |
150 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso') . '</p>'; |
|
150 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso').'</p>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function _add_new_question_stop() { |
154 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
154 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | } |
158 | 158 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -18,64 +18,64 @@ discard block |
||
18 | 18 | class Registration_Form_Questions_Overview_Help_Tour extends EE_Help_Tour |
19 | 19 | { |
20 | 20 | |
21 | - protected function _set_tour_properties() |
|
22 | - { |
|
23 | - $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | - $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | - } |
|
21 | + protected function _set_tour_properties() |
|
22 | + { |
|
23 | + $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | + $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | + } |
|
26 | 26 | |
27 | - protected function _set_tour_stops() |
|
28 | - { |
|
29 | - $this->_stops = array( |
|
30 | - 10 => array( |
|
31 | - 'content' => $this->_start(), |
|
32 | - ), |
|
33 | - 30 => array( |
|
34 | - 'id' => 'display_text', |
|
35 | - 'content' => $this->_display_text_stop(), |
|
36 | - 'options' => array( |
|
37 | - 'tipLocation' => 'top', |
|
38 | - 'tipAdjustmentX' => -5, |
|
39 | - 'tipAdjustmentY' => -25 |
|
40 | - ) |
|
41 | - ), |
|
42 | - 40 => array( |
|
43 | - 'id' => 'admin_label', |
|
44 | - 'content' => $this->_admin_label_stop(), |
|
45 | - 'options' => array( |
|
46 | - 'tipLocation' => 'top', |
|
47 | - 'tipAdjustmentX' => 20, |
|
48 | - 'tipAdjustmentY' => -25 |
|
49 | - ) |
|
50 | - ), |
|
51 | - 50 => array( |
|
52 | - 'id' => 'type', |
|
53 | - 'content' => $this->_type_stop(), |
|
54 | - 'options' => array( |
|
55 | - 'tipLocation' => 'top', |
|
56 | - 'tipAdjustmentX' => -5, |
|
57 | - 'tipAdjustmentY' => -25 |
|
58 | - ) |
|
59 | - ), |
|
60 | - 60 => array( |
|
61 | - 'id' => 'values', |
|
62 | - 'content' => $this->_values_stop(), |
|
63 | - 'options' => array( |
|
64 | - 'tipLocation' => 'top', |
|
65 | - 'tipAdjustmentX' => -5, |
|
66 | - 'tipAdjustmentY' => -25 |
|
67 | - ) |
|
68 | - ), |
|
69 | - 70 => array( |
|
70 | - 'id' => 'required', |
|
71 | - 'content' => $this->_required_stop(), |
|
72 | - 'options' => array( |
|
73 | - 'tipLocation' => 'top', |
|
74 | - 'tipAdjustmentY' => -20, |
|
75 | - 'tipAdjustmentX' => -15 |
|
76 | - ) |
|
77 | - ), |
|
78 | - /*80 => array( |
|
27 | + protected function _set_tour_stops() |
|
28 | + { |
|
29 | + $this->_stops = array( |
|
30 | + 10 => array( |
|
31 | + 'content' => $this->_start(), |
|
32 | + ), |
|
33 | + 30 => array( |
|
34 | + 'id' => 'display_text', |
|
35 | + 'content' => $this->_display_text_stop(), |
|
36 | + 'options' => array( |
|
37 | + 'tipLocation' => 'top', |
|
38 | + 'tipAdjustmentX' => -5, |
|
39 | + 'tipAdjustmentY' => -25 |
|
40 | + ) |
|
41 | + ), |
|
42 | + 40 => array( |
|
43 | + 'id' => 'admin_label', |
|
44 | + 'content' => $this->_admin_label_stop(), |
|
45 | + 'options' => array( |
|
46 | + 'tipLocation' => 'top', |
|
47 | + 'tipAdjustmentX' => 20, |
|
48 | + 'tipAdjustmentY' => -25 |
|
49 | + ) |
|
50 | + ), |
|
51 | + 50 => array( |
|
52 | + 'id' => 'type', |
|
53 | + 'content' => $this->_type_stop(), |
|
54 | + 'options' => array( |
|
55 | + 'tipLocation' => 'top', |
|
56 | + 'tipAdjustmentX' => -5, |
|
57 | + 'tipAdjustmentY' => -25 |
|
58 | + ) |
|
59 | + ), |
|
60 | + 60 => array( |
|
61 | + 'id' => 'values', |
|
62 | + 'content' => $this->_values_stop(), |
|
63 | + 'options' => array( |
|
64 | + 'tipLocation' => 'top', |
|
65 | + 'tipAdjustmentX' => -5, |
|
66 | + 'tipAdjustmentY' => -25 |
|
67 | + ) |
|
68 | + ), |
|
69 | + 70 => array( |
|
70 | + 'id' => 'required', |
|
71 | + 'content' => $this->_required_stop(), |
|
72 | + 'options' => array( |
|
73 | + 'tipLocation' => 'top', |
|
74 | + 'tipAdjustmentY' => -20, |
|
75 | + 'tipAdjustmentX' => -15 |
|
76 | + ) |
|
77 | + ), |
|
78 | + /*80 => array( |
|
79 | 79 | 'class' => 'bulkactions', |
80 | 80 | 'content' => $this->_bulk_actions_stop(), |
81 | 81 | 'options' => array( |
@@ -84,77 +84,77 @@ discard block |
||
84 | 84 | 'tipAdjustmentX' => -15 |
85 | 85 | ) |
86 | 86 | ),*/ |
87 | - 90 => array( |
|
88 | - 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | - 'content' => $this->_search_stop(), |
|
90 | - 'options' => array( |
|
91 | - 'tipLocation' => 'left', |
|
92 | - 'tipAdjustmentY' => -50, |
|
93 | - 'tipAdjustmentX' => -15 |
|
94 | - ) |
|
95 | - ), |
|
96 | - 100 => array( |
|
97 | - 'id' => 'add-new-question', |
|
98 | - 'content' => $this->_add_new_question_stop(), |
|
99 | - 'options' => array( |
|
100 | - 'tipLocation' => 'right', |
|
101 | - 'tipAdjustmentY' => -50, |
|
102 | - 'tipAdjustmentX' => 15 |
|
103 | - ) |
|
104 | - ), |
|
105 | - ); |
|
106 | - } |
|
87 | + 90 => array( |
|
88 | + 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | + 'content' => $this->_search_stop(), |
|
90 | + 'options' => array( |
|
91 | + 'tipLocation' => 'left', |
|
92 | + 'tipAdjustmentY' => -50, |
|
93 | + 'tipAdjustmentX' => -15 |
|
94 | + ) |
|
95 | + ), |
|
96 | + 100 => array( |
|
97 | + 'id' => 'add-new-question', |
|
98 | + 'content' => $this->_add_new_question_stop(), |
|
99 | + 'options' => array( |
|
100 | + 'tipLocation' => 'right', |
|
101 | + 'tipAdjustmentY' => -50, |
|
102 | + 'tipAdjustmentX' => 15 |
|
103 | + ) |
|
104 | + ), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - protected function _start() |
|
110 | - { |
|
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
109 | + protected function _start() |
|
110 | + { |
|
111 | + $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | + $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso') . '</p>'; |
|
114 | 114 | |
115 | - return $content; |
|
116 | - } |
|
115 | + return $content; |
|
116 | + } |
|
117 | 117 | |
118 | - protected function _display_text_stop() |
|
119 | - { |
|
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | - } |
|
118 | + protected function _display_text_stop() |
|
119 | + { |
|
120 | + return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | + } |
|
122 | 122 | |
123 | - protected function _admin_label_stop() |
|
124 | - { |
|
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | - } |
|
123 | + protected function _admin_label_stop() |
|
124 | + { |
|
125 | + return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | + } |
|
127 | 127 | |
128 | - protected function _type_stop() |
|
129 | - { |
|
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
132 | - } |
|
128 | + protected function _type_stop() |
|
129 | + { |
|
130 | + return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso') . '</p>'; |
|
132 | + } |
|
133 | 133 | |
134 | - protected function _values_stop() |
|
135 | - { |
|
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
138 | - } |
|
134 | + protected function _values_stop() |
|
135 | + { |
|
136 | + return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso') . '</p>'; |
|
138 | + } |
|
139 | 139 | |
140 | - protected function _required_stop() |
|
141 | - { |
|
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | - } |
|
140 | + protected function _required_stop() |
|
141 | + { |
|
142 | + return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | + } |
|
144 | 144 | |
145 | - /* protected function _bulk_actions_stop() { |
|
145 | + /* protected function _bulk_actions_stop() { |
|
146 | 146 | return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
147 | 147 | } */ |
148 | 148 | |
149 | - protected function _search_stop() |
|
150 | - { |
|
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
153 | - } |
|
149 | + protected function _search_stop() |
|
150 | + { |
|
151 | + return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso') . '</p>'; |
|
153 | + } |
|
154 | 154 | |
155 | - protected function _add_new_question_stop() |
|
156 | - { |
|
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | - } |
|
155 | + protected function _add_new_question_stop() |
|
156 | + { |
|
157 | + return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | + } |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -108,38 +108,38 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function _start() |
110 | 110 | { |
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
111 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
112 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso').'</p>'; |
|
114 | 114 | |
115 | 115 | return $content; |
116 | 116 | } |
117 | 117 | |
118 | 118 | protected function _display_text_stop() |
119 | 119 | { |
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
120 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function _admin_label_stop() |
124 | 124 | { |
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
125 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | protected function _type_stop() |
129 | 129 | { |
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso').'</p>'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | protected function _values_stop() |
135 | 135 | { |
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
136 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso').'</p>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | protected function _required_stop() |
141 | 141 | { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /* protected function _bulk_actions_stop() { |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | |
149 | 149 | protected function _search_stop() |
150 | 150 | { |
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
151 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso').'</p>'; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function _add_new_question_stop() |
156 | 156 | { |
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
157 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | __('Registration Steps', 'event_espresso'), false, array()), |
106 | 106 | ) |
107 | 107 | ); |
108 | - $this->_model_relations = array( |
|
108 | + $this->_model_relations = array( |
|
109 | 109 | 'Registration' => new EE_Has_Many_Relation(), |
110 | 110 | 'Payment' => new EE_Has_Many_Relation(), |
111 | 111 | 'Status' => new EE_Belongs_To_Relation(), |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ), |
168 | 168 | OBJECT, |
169 | 169 | array( |
170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
170 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
171 | 171 | 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
172 | 172 | ) |
173 | 173 | ); |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | public function get_revenue_per_event_report($period = '-1 month') |
188 | 188 | { |
189 | 189 | global $wpdb; |
190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
190 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
191 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
192 | + $registration_payment_table = $wpdb->prefix.'esp_registration_payment'; |
|
193 | 193 | $event_table = $wpdb->posts; |
194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
194 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
195 | 195 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
196 | 196 | $approved_payment_status = EEM_Payment::status_id_approved; |
197 | 197 | $extra_event_on_join = ''; |
198 | 198 | //exclude events not authored by user if permissions in effect |
199 | 199 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
200 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $wpdb->get_results( |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
269 | 269 | { |
270 | 270 | EE_Error::doing_it_wrong( |
271 | - __CLASS__ . '::' . __FUNCTION__, |
|
271 | + __CLASS__.'::'.__FUNCTION__, |
|
272 | 272 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
273 | 273 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
274 | 274 | '4.6.0' |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | array( |
317 | 317 | 0 => array( |
318 | 318 | 'STS_ID' => EEM_Transaction::failed_status_code, |
319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
319 | + 'Payment.PAY_ID' => array('IS NULL'), |
|
320 | 320 | 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
321 | 321 | ) |
322 | 322 | ), |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | $time_to_leave_alone |
335 | 335 | ); |
336 | 336 | //now that we have the ids to delete |
337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
337 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | 338 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
339 | 339 | EEM_Transaction::unset_locked_transactions($txn_ids); |
340 | 340 | // let's get deletin'... |
341 | 341 | // Why no wpdb->prepare? Because the data is trusted. |
342 | 342 | // We got the ids from the original query to get them FROM |
343 | 343 | // the db (which is sanitized) so no need to prepare them again. |
344 | - $query = ' |
|
344 | + $query = ' |
|
345 | 345 | DELETE |
346 | - FROM ' . $this->table() . ' |
|
346 | + FROM ' . $this->table().' |
|
347 | 347 | WHERE |
348 | - TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
|
348 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
349 | 349 | $deleted = $wpdb->query($query); |
350 | 350 | } |
351 | 351 | if ($deleted) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -15,193 +15,193 @@ discard block |
||
15 | 15 | class EEM_Transaction extends EEM_Base |
16 | 16 | { |
17 | 17 | |
18 | - // private instance of the Transaction object |
|
19 | - protected static $_instance; |
|
20 | - |
|
21 | - /** |
|
22 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
23 | - * but payment is pending. This is the state for transactions where payment is promised |
|
24 | - * from an offline gateway. |
|
25 | - */ |
|
26 | - // const open_status_code = 'TPN'; |
|
27 | - |
|
28 | - /** |
|
29 | - * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
30 | - * either due to a technical reason (server or computer crash during registration), |
|
31 | - * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
32 | - */ |
|
33 | - const failed_status_code = 'TFL'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
37 | - * either due to a technical reason (server or computer crash during registration), |
|
38 | - * or due to an abandoned cart after registrant chose not to complete the registration process |
|
39 | - * HOWEVER... |
|
40 | - * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
41 | - * registrant |
|
42 | - */ |
|
43 | - const abandoned_status_code = 'TAB'; |
|
44 | - |
|
45 | - /** |
|
46 | - * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
47 | - * meaning that monies are still owing: TXN_paid < TXN_total |
|
48 | - */ |
|
49 | - const incomplete_status_code = 'TIN'; |
|
50 | - |
|
51 | - /** |
|
52 | - * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
53 | - * meaning that NO monies are owing: TXN_paid == TXN_total |
|
54 | - */ |
|
55 | - const complete_status_code = 'TCM'; |
|
56 | - |
|
57 | - /** |
|
58 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
59 | - * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
60 | - */ |
|
61 | - const overpaid_status_code = 'TOP'; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * private constructor to prevent direct creation |
|
66 | - * |
|
67 | - * @Constructor |
|
68 | - * @access protected |
|
69 | - * |
|
70 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
71 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
72 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
73 | - * timezone in the 'timezone_string' wp option) |
|
74 | - * |
|
75 | - * @return EEM_Transaction |
|
76 | - * @throws \EE_Error |
|
77 | - */ |
|
78 | - protected function __construct($timezone) |
|
79 | - { |
|
80 | - $this->singular_item = __('Transaction', 'event_espresso'); |
|
81 | - $this->plural_item = __('Transactions', 'event_espresso'); |
|
82 | - |
|
83 | - $this->_tables = array( |
|
84 | - 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
85 | - ); |
|
86 | - $this->_fields = array( |
|
87 | - 'TransactionTable' => array( |
|
88 | - 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
89 | - 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
90 | - __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
91 | - $timezone), |
|
92 | - 'TXN_total' => new EE_Money_Field('TXN_total', |
|
93 | - __('Total value of Transaction', 'event_espresso'), false, 0), |
|
94 | - 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
95 | - __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
96 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
97 | - false, EEM_Transaction::failed_status_code, 'Status'), |
|
98 | - 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
99 | - __('Serialized session data', 'event_espresso'), true, ''), |
|
100 | - 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
101 | - __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
102 | - 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
103 | - __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
104 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
105 | - __('Registration Steps', 'event_espresso'), false, array()), |
|
106 | - ) |
|
107 | - ); |
|
108 | - $this->_model_relations = array( |
|
109 | - 'Registration' => new EE_Has_Many_Relation(), |
|
110 | - 'Payment' => new EE_Has_Many_Relation(), |
|
111 | - 'Status' => new EE_Belongs_To_Relation(), |
|
112 | - 'Line_Item' => new EE_Has_Many_Relation(false), |
|
113 | - //you can delete a transaction without needing to delete its line items |
|
114 | - 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
115 | - 'Message' => new EE_Has_Many_Relation() |
|
116 | - ); |
|
117 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
118 | - parent::__construct($timezone); |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * txn_status_array |
|
125 | - * get list of transaction statuses |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - public static function txn_status_array() |
|
131 | - { |
|
132 | - return apply_filters( |
|
133 | - 'FHEE__EEM_Transaction__txn_status_array', |
|
134 | - array( |
|
135 | - EEM_Transaction::overpaid_status_code, |
|
136 | - EEM_Transaction::complete_status_code, |
|
137 | - EEM_Transaction::incomplete_status_code, |
|
138 | - EEM_Transaction::abandoned_status_code, |
|
139 | - EEM_Transaction::failed_status_code, |
|
140 | - ) |
|
141 | - ); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * get the revenue per day for the Transaction Admin page Reports Tab |
|
146 | - * |
|
147 | - * @access public |
|
148 | - * |
|
149 | - * @param string $period |
|
150 | - * |
|
151 | - * @return \stdClass[] |
|
152 | - */ |
|
153 | - public function get_revenue_per_day_report($period = '-1 month') |
|
154 | - { |
|
155 | - $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
156 | - 'Y-m-d H:i:s', 'UTC'); |
|
157 | - |
|
158 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
159 | - |
|
160 | - return $this->_get_all_wpdb_results( |
|
161 | - array( |
|
162 | - array( |
|
163 | - 'TXN_timestamp' => array('>=', $sql_date) |
|
164 | - ), |
|
165 | - 'group_by' => 'txnDate', |
|
166 | - 'order_by' => array('TXN_timestamp' => 'ASC') |
|
167 | - ), |
|
168 | - OBJECT, |
|
169 | - array( |
|
170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
171 | - 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
172 | - ) |
|
173 | - ); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * get the revenue per event for the Transaction Admin page Reports Tab |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * |
|
182 | - * @param string $period |
|
183 | - * |
|
184 | - * @throws \EE_Error |
|
185 | - * @return mixed |
|
186 | - */ |
|
187 | - public function get_revenue_per_event_report($period = '-1 month') |
|
188 | - { |
|
189 | - global $wpdb; |
|
190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
193 | - $event_table = $wpdb->posts; |
|
194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
195 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
196 | - $approved_payment_status = EEM_Payment::status_id_approved; |
|
197 | - $extra_event_on_join = ''; |
|
198 | - //exclude events not authored by user if permissions in effect |
|
199 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
201 | - } |
|
202 | - |
|
203 | - return $wpdb->get_results( |
|
204 | - "SELECT |
|
18 | + // private instance of the Transaction object |
|
19 | + protected static $_instance; |
|
20 | + |
|
21 | + /** |
|
22 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
23 | + * but payment is pending. This is the state for transactions where payment is promised |
|
24 | + * from an offline gateway. |
|
25 | + */ |
|
26 | + // const open_status_code = 'TPN'; |
|
27 | + |
|
28 | + /** |
|
29 | + * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
30 | + * either due to a technical reason (server or computer crash during registration), |
|
31 | + * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
32 | + */ |
|
33 | + const failed_status_code = 'TFL'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
37 | + * either due to a technical reason (server or computer crash during registration), |
|
38 | + * or due to an abandoned cart after registrant chose not to complete the registration process |
|
39 | + * HOWEVER... |
|
40 | + * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
41 | + * registrant |
|
42 | + */ |
|
43 | + const abandoned_status_code = 'TAB'; |
|
44 | + |
|
45 | + /** |
|
46 | + * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
47 | + * meaning that monies are still owing: TXN_paid < TXN_total |
|
48 | + */ |
|
49 | + const incomplete_status_code = 'TIN'; |
|
50 | + |
|
51 | + /** |
|
52 | + * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
53 | + * meaning that NO monies are owing: TXN_paid == TXN_total |
|
54 | + */ |
|
55 | + const complete_status_code = 'TCM'; |
|
56 | + |
|
57 | + /** |
|
58 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
59 | + * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
60 | + */ |
|
61 | + const overpaid_status_code = 'TOP'; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * private constructor to prevent direct creation |
|
66 | + * |
|
67 | + * @Constructor |
|
68 | + * @access protected |
|
69 | + * |
|
70 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
71 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
72 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
73 | + * timezone in the 'timezone_string' wp option) |
|
74 | + * |
|
75 | + * @return EEM_Transaction |
|
76 | + * @throws \EE_Error |
|
77 | + */ |
|
78 | + protected function __construct($timezone) |
|
79 | + { |
|
80 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
81 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
82 | + |
|
83 | + $this->_tables = array( |
|
84 | + 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
85 | + ); |
|
86 | + $this->_fields = array( |
|
87 | + 'TransactionTable' => array( |
|
88 | + 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
89 | + 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
90 | + __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
91 | + $timezone), |
|
92 | + 'TXN_total' => new EE_Money_Field('TXN_total', |
|
93 | + __('Total value of Transaction', 'event_espresso'), false, 0), |
|
94 | + 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
95 | + __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
96 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
97 | + false, EEM_Transaction::failed_status_code, 'Status'), |
|
98 | + 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
99 | + __('Serialized session data', 'event_espresso'), true, ''), |
|
100 | + 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
101 | + __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
102 | + 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
103 | + __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
104 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
105 | + __('Registration Steps', 'event_espresso'), false, array()), |
|
106 | + ) |
|
107 | + ); |
|
108 | + $this->_model_relations = array( |
|
109 | + 'Registration' => new EE_Has_Many_Relation(), |
|
110 | + 'Payment' => new EE_Has_Many_Relation(), |
|
111 | + 'Status' => new EE_Belongs_To_Relation(), |
|
112 | + 'Line_Item' => new EE_Has_Many_Relation(false), |
|
113 | + //you can delete a transaction without needing to delete its line items |
|
114 | + 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
115 | + 'Message' => new EE_Has_Many_Relation() |
|
116 | + ); |
|
117 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
118 | + parent::__construct($timezone); |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * txn_status_array |
|
125 | + * get list of transaction statuses |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + public static function txn_status_array() |
|
131 | + { |
|
132 | + return apply_filters( |
|
133 | + 'FHEE__EEM_Transaction__txn_status_array', |
|
134 | + array( |
|
135 | + EEM_Transaction::overpaid_status_code, |
|
136 | + EEM_Transaction::complete_status_code, |
|
137 | + EEM_Transaction::incomplete_status_code, |
|
138 | + EEM_Transaction::abandoned_status_code, |
|
139 | + EEM_Transaction::failed_status_code, |
|
140 | + ) |
|
141 | + ); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * get the revenue per day for the Transaction Admin page Reports Tab |
|
146 | + * |
|
147 | + * @access public |
|
148 | + * |
|
149 | + * @param string $period |
|
150 | + * |
|
151 | + * @return \stdClass[] |
|
152 | + */ |
|
153 | + public function get_revenue_per_day_report($period = '-1 month') |
|
154 | + { |
|
155 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
156 | + 'Y-m-d H:i:s', 'UTC'); |
|
157 | + |
|
158 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
159 | + |
|
160 | + return $this->_get_all_wpdb_results( |
|
161 | + array( |
|
162 | + array( |
|
163 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
164 | + ), |
|
165 | + 'group_by' => 'txnDate', |
|
166 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
167 | + ), |
|
168 | + OBJECT, |
|
169 | + array( |
|
170 | + 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
171 | + 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
172 | + ) |
|
173 | + ); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * get the revenue per event for the Transaction Admin page Reports Tab |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * |
|
182 | + * @param string $period |
|
183 | + * |
|
184 | + * @throws \EE_Error |
|
185 | + * @return mixed |
|
186 | + */ |
|
187 | + public function get_revenue_per_event_report($period = '-1 month') |
|
188 | + { |
|
189 | + global $wpdb; |
|
190 | + $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | + $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
193 | + $event_table = $wpdb->posts; |
|
194 | + $payment_table = $wpdb->prefix . 'esp_payment'; |
|
195 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
196 | + $approved_payment_status = EEM_Payment::status_id_approved; |
|
197 | + $extra_event_on_join = ''; |
|
198 | + //exclude events not authored by user if permissions in effect |
|
199 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
200 | + $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
201 | + } |
|
202 | + |
|
203 | + return $wpdb->get_results( |
|
204 | + "SELECT |
|
205 | 205 | Transaction_Event.event_name AS event_name, |
206 | 206 | SUM(Transaction_Event.paid) AS revenue |
207 | 207 | FROM |
@@ -228,185 +228,185 @@ discard block |
||
228 | 228 | $extra_event_on_join |
229 | 229 | ) AS Transaction_Event |
230 | 230 | GROUP BY event_name", |
231 | - OBJECT |
|
232 | - ); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
238 | - * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
239 | - * the registration pointed to by reg_url_link), if not returns null |
|
240 | - * |
|
241 | - * @param string $reg_url_link |
|
242 | - * |
|
243 | - * @return EE_Transaction |
|
244 | - */ |
|
245 | - public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
246 | - { |
|
247 | - return $this->get_one(array( |
|
248 | - array( |
|
249 | - 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
250 | - '') |
|
251 | - ) |
|
252 | - )); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Updates the provided EE_Transaction with all the applicable payments |
|
258 | - * (or fetch the EE_Transaction from its ID) |
|
259 | - * |
|
260 | - * @deprecated |
|
261 | - * |
|
262 | - * @param EE_Transaction|int $transaction_obj_or_id |
|
263 | - * @param boolean $save_txn whether or not to save the transaction during this function call |
|
264 | - * |
|
265 | - * @return boolean |
|
266 | - * @throws \EE_Error |
|
267 | - */ |
|
268 | - public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
269 | - { |
|
270 | - EE_Error::doing_it_wrong( |
|
271 | - __CLASS__ . '::' . __FUNCTION__, |
|
272 | - sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
273 | - 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
274 | - '4.6.0' |
|
275 | - ); |
|
276 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
277 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
278 | - |
|
279 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
280 | - $this->ensure_is_obj($transaction_obj_or_id) |
|
281 | - ); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
286 | - * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
287 | - * and so we only use wpdb directly and only do minimal joins. |
|
288 | - * Transactions are considered "junk" if they're failed for longer than a week. |
|
289 | - * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
290 | - * it, it's probably not junk (regardless of what status it has). |
|
291 | - * The downside to this approach is that is addons are listening for object deletions |
|
292 | - * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
293 | - * to catch these types of deletions. |
|
294 | - * |
|
295 | - * @global WPDB $wpdb |
|
296 | - * @return mixed |
|
297 | - */ |
|
298 | - public function delete_junk_transactions() |
|
299 | - { |
|
300 | - /** @type WPDB $wpdb */ |
|
301 | - global $wpdb; |
|
302 | - $deleted = false; |
|
303 | - $time_to_leave_alone = apply_filters( |
|
304 | - 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
305 | - , WEEK_IN_SECONDS |
|
306 | - ); |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
311 | - * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
312 | - * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
313 | - */ |
|
314 | - $ids_query = apply_filters( |
|
315 | - 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
316 | - array( |
|
317 | - 0 => array( |
|
318 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
320 | - 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
321 | - ) |
|
322 | - ), |
|
323 | - $time_to_leave_alone |
|
324 | - ); |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
329 | - * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
330 | - */ |
|
331 | - $txn_ids = apply_filters( |
|
332 | - 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
333 | - EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
334 | - $time_to_leave_alone |
|
335 | - ); |
|
336 | - //now that we have the ids to delete |
|
337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | - // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
339 | - EEM_Transaction::unset_locked_transactions($txn_ids); |
|
340 | - // let's get deletin'... |
|
341 | - // Why no wpdb->prepare? Because the data is trusted. |
|
342 | - // We got the ids from the original query to get them FROM |
|
343 | - // the db (which is sanitized) so no need to prepare them again. |
|
344 | - $query = ' |
|
231 | + OBJECT |
|
232 | + ); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
238 | + * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
239 | + * the registration pointed to by reg_url_link), if not returns null |
|
240 | + * |
|
241 | + * @param string $reg_url_link |
|
242 | + * |
|
243 | + * @return EE_Transaction |
|
244 | + */ |
|
245 | + public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
246 | + { |
|
247 | + return $this->get_one(array( |
|
248 | + array( |
|
249 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
250 | + '') |
|
251 | + ) |
|
252 | + )); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Updates the provided EE_Transaction with all the applicable payments |
|
258 | + * (or fetch the EE_Transaction from its ID) |
|
259 | + * |
|
260 | + * @deprecated |
|
261 | + * |
|
262 | + * @param EE_Transaction|int $transaction_obj_or_id |
|
263 | + * @param boolean $save_txn whether or not to save the transaction during this function call |
|
264 | + * |
|
265 | + * @return boolean |
|
266 | + * @throws \EE_Error |
|
267 | + */ |
|
268 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
269 | + { |
|
270 | + EE_Error::doing_it_wrong( |
|
271 | + __CLASS__ . '::' . __FUNCTION__, |
|
272 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
273 | + 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
274 | + '4.6.0' |
|
275 | + ); |
|
276 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
277 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
278 | + |
|
279 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
280 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
281 | + ); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
286 | + * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
287 | + * and so we only use wpdb directly and only do minimal joins. |
|
288 | + * Transactions are considered "junk" if they're failed for longer than a week. |
|
289 | + * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
290 | + * it, it's probably not junk (regardless of what status it has). |
|
291 | + * The downside to this approach is that is addons are listening for object deletions |
|
292 | + * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
293 | + * to catch these types of deletions. |
|
294 | + * |
|
295 | + * @global WPDB $wpdb |
|
296 | + * @return mixed |
|
297 | + */ |
|
298 | + public function delete_junk_transactions() |
|
299 | + { |
|
300 | + /** @type WPDB $wpdb */ |
|
301 | + global $wpdb; |
|
302 | + $deleted = false; |
|
303 | + $time_to_leave_alone = apply_filters( |
|
304 | + 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
305 | + , WEEK_IN_SECONDS |
|
306 | + ); |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
311 | + * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
312 | + * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
313 | + */ |
|
314 | + $ids_query = apply_filters( |
|
315 | + 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
316 | + array( |
|
317 | + 0 => array( |
|
318 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
319 | + 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
320 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
321 | + ) |
|
322 | + ), |
|
323 | + $time_to_leave_alone |
|
324 | + ); |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
329 | + * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
330 | + */ |
|
331 | + $txn_ids = apply_filters( |
|
332 | + 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
333 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
334 | + $time_to_leave_alone |
|
335 | + ); |
|
336 | + //now that we have the ids to delete |
|
337 | + if (! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | + // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
339 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
340 | + // let's get deletin'... |
|
341 | + // Why no wpdb->prepare? Because the data is trusted. |
|
342 | + // We got the ids from the original query to get them FROM |
|
343 | + // the db (which is sanitized) so no need to prepare them again. |
|
344 | + $query = ' |
|
345 | 345 | DELETE |
346 | 346 | FROM ' . $this->table() . ' |
347 | 347 | WHERE |
348 | 348 | TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
349 | - $deleted = $wpdb->query($query); |
|
350 | - } |
|
351 | - if ($deleted) { |
|
352 | - /** |
|
353 | - * Allows code to do something after the transactions have been deleted. |
|
354 | - */ |
|
355 | - do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
356 | - } |
|
357 | - |
|
358 | - return $deleted; |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param array $transaction_IDs |
|
364 | - * |
|
365 | - * @return bool |
|
366 | - */ |
|
367 | - public static function unset_locked_transactions(array $transaction_IDs) |
|
368 | - { |
|
369 | - $locked_transactions = get_option('ee_locked_transactions', array()); |
|
370 | - $update = false; |
|
371 | - foreach ($transaction_IDs as $TXN_ID) { |
|
372 | - if (isset($locked_transactions[$TXN_ID])) { |
|
373 | - unset($locked_transactions[$TXN_ID]); |
|
374 | - $update = true; |
|
375 | - } |
|
376 | - } |
|
377 | - if ($update) { |
|
378 | - update_option('ee_locked_transactions', $locked_transactions); |
|
379 | - } |
|
380 | - |
|
381 | - return $update; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * returns an array of EE_Transaction objects whose timestamp is less than |
|
388 | - * the current time minus the session lifespan, which defaults to 60 minutes |
|
389 | - * |
|
390 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
391 | - * @throws \EE_Error |
|
392 | - */ |
|
393 | - public function get_transactions_in_progress() |
|
394 | - { |
|
395 | - return $this->get_all( |
|
396 | - array( |
|
397 | - array( |
|
398 | - 'TXN_timestamp' => array( |
|
399 | - '>', |
|
400 | - time() - EE_Registry::instance()->SSN->lifespan() |
|
401 | - ), |
|
402 | - 'STS_ID' => array( |
|
403 | - '!=', |
|
404 | - EEM_Transaction::complete_status_code |
|
405 | - ), |
|
406 | - ) |
|
407 | - ) |
|
408 | - ); |
|
409 | - } |
|
349 | + $deleted = $wpdb->query($query); |
|
350 | + } |
|
351 | + if ($deleted) { |
|
352 | + /** |
|
353 | + * Allows code to do something after the transactions have been deleted. |
|
354 | + */ |
|
355 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
356 | + } |
|
357 | + |
|
358 | + return $deleted; |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param array $transaction_IDs |
|
364 | + * |
|
365 | + * @return bool |
|
366 | + */ |
|
367 | + public static function unset_locked_transactions(array $transaction_IDs) |
|
368 | + { |
|
369 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
370 | + $update = false; |
|
371 | + foreach ($transaction_IDs as $TXN_ID) { |
|
372 | + if (isset($locked_transactions[$TXN_ID])) { |
|
373 | + unset($locked_transactions[$TXN_ID]); |
|
374 | + $update = true; |
|
375 | + } |
|
376 | + } |
|
377 | + if ($update) { |
|
378 | + update_option('ee_locked_transactions', $locked_transactions); |
|
379 | + } |
|
380 | + |
|
381 | + return $update; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * returns an array of EE_Transaction objects whose timestamp is less than |
|
388 | + * the current time minus the session lifespan, which defaults to 60 minutes |
|
389 | + * |
|
390 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
391 | + * @throws \EE_Error |
|
392 | + */ |
|
393 | + public function get_transactions_in_progress() |
|
394 | + { |
|
395 | + return $this->get_all( |
|
396 | + array( |
|
397 | + array( |
|
398 | + 'TXN_timestamp' => array( |
|
399 | + '>', |
|
400 | + time() - EE_Registry::instance()->SSN->lifespan() |
|
401 | + ), |
|
402 | + 'STS_ID' => array( |
|
403 | + '!=', |
|
404 | + EEM_Transaction::complete_status_code |
|
405 | + ), |
|
406 | + ) |
|
407 | + ) |
|
408 | + ); |
|
409 | + } |
|
410 | 410 | |
411 | 411 | |
412 | 412 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | *@param array $settings_array |
98 | 98 | */ |
99 | - public function set_settings( $settings_array ) { |
|
99 | + public function set_settings($settings_array) { |
|
100 | 100 | parent::set_settings($settings_array); |
101 | 101 | // Redirect URL. |
102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | * @return \EE_Payment|\EEI_Payment |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
119 | + if ( ! $payment instanceof EEI_Payment) { |
|
120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
122 | 122 | return $payment; |
123 | 123 | } |
124 | 124 | $transaction = $payment->transaction(); |
125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
128 | 128 | return $payment; |
129 | 129 | } |
130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
131 | 131 | $primary_registration = $transaction->primary_registration(); |
132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | 'RETURNURL' => $return_url, |
142 | 142 | 'CANCELURL' => $cancel_url, |
143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Show itemized list. |
150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
151 | 151 | $item_num = 0; |
152 | 152 | $itemized_sum = 0; |
153 | 153 | $total_line_items = $transaction->total_line_item(); |
154 | 154 | // Go through each item in the list. |
155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
156 | + if ($line_item instanceof EE_Line_Item) { |
|
157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_price = $line_item->unit_price(); |
163 | 163 | $line_item_quantity = $line_item->quantity(); |
164 | 164 | // This is a discount. |
165 | - if ( $line_item->is_percent() ) { |
|
165 | + if ($line_item->is_percent()) { |
|
166 | 166 | $unit_price = $line_item->total(); |
167 | 167 | $line_item_quantity = 1; |
168 | 168 | } |
169 | 169 | // Item Name. |
170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
171 | 171 | // Item description. |
172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
173 | 173 | // Cost of individual item. |
174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
175 | 175 | // Item Number. |
176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
190 | 190 | |
191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
193 | 193 | // add the difference as an extra line item. |
194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
195 | 195 | // Item Name. |
196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
197 | 197 | // Item description. |
198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
199 | 199 | // Cost of individual item. |
200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
201 | 201 | // Item Number. |
202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | // Just one Item. |
211 | 211 | // Item Name. |
212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
213 | 213 | // Item description. |
214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
215 | 215 | // Cost of individual item. |
216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
217 | 217 | // Item Number. |
218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | // Digital item is sold. |
222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
223 | 223 | // Item's sales S/H and tax amount. |
224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
228 | 228 | } |
229 | 229 | // Automatically filling out shipping and contact information. |
230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
241 | 241 | // Do not request shipping details on the PP Checkout page. |
242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
244 | 244 | |
245 | 245 | } |
246 | 246 | // Used a business/personal logo on the PayPal page. |
247 | - if ( ! empty($this->_image_url) ) { |
|
247 | + if ( ! empty($this->_image_url)) { |
|
248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
249 | 249 | } |
250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $this |
254 | 254 | ); |
255 | 255 | // Request PayPal token. |
256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
259 | - if ( $token_rstatus['status'] ) { |
|
256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
259 | + if ($token_rstatus['status']) { |
|
260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
261 | - $payment->set_details( $response_args ); |
|
261 | + $payment->set_details($response_args); |
|
262 | 262 | |
263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
265 | 265 | } else { |
266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
268 | 268 | } else { |
269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
270 | 270 | } |
271 | - $payment->set_details( $response_args ); |
|
272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
271 | + $payment->set_details($response_args); |
|
272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | * @param EEI_Transaction $transaction |
286 | 286 | * @return EEI_Payment |
287 | 287 | */ |
288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
288 | + public function handle_payment_update($update_info, $transaction) { |
|
289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
290 | 290 | |
291 | - if ( $payment instanceof EEI_Payment ) { |
|
292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
291 | + if ($payment instanceof EEI_Payment) { |
|
292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
293 | 293 | $transaction = $payment->transaction(); |
294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
297 | 297 | return $payment; |
298 | 298 | } |
299 | 299 | $primary_registrant = $transaction->primary_registration(); |
300 | 300 | $payment_details = $payment->details(); |
301 | 301 | // Check if we still have the token. |
302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
304 | 304 | return $payment; |
305 | 305 | } |
306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
310 | 310 | ); |
311 | 311 | // Request Customer Details. |
312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
315 | - if ( $cdetails_rstatus['status'] ) { |
|
312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
315 | + if ($cdetails_rstatus['status']) { |
|
316 | 316 | // We got the PayerID so now we can Complete the transaction. |
317 | 317 | $docheckout_request_dtls = array( |
318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
324 | 324 | ); |
325 | 325 | // Payment Checkout/Capture. |
326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
329 | - if ( $docheckout_rstatus['status'] ) { |
|
326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
329 | + if ($docheckout_rstatus['status']) { |
|
330 | 330 | // All is well, payment approved. |
331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
335 | - $payment->set_details( $cdata_response_args ); |
|
336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
332 | + $payment->set_extra_accntng($primary_registration_code); |
|
333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
335 | + $payment->set_details($cdata_response_args); |
|
336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
338 | 338 | } else { |
339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
341 | 341 | } else { |
342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
343 | 343 | } |
344 | - $payment->set_details( $docheckout_response_args ); |
|
345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
344 | + $payment->set_details($docheckout_response_args); |
|
345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
346 | 346 | } |
347 | 347 | } else { |
348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
350 | 350 | } else { |
351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
352 | 352 | } |
353 | - $payment->set_details( $cdata_response_args ); |
|
354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
353 | + $payment->set_details($cdata_response_args); |
|
354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
355 | 355 | } |
356 | 356 | } else { |
357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param EEI_Payment $payment |
371 | 371 | * @return mixed |
372 | 372 | */ |
373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
374 | 374 | $request_dtls = array( |
375 | 375 | 'VERSION' => '204.0', |
376 | - 'USER' => urlencode( $this->_api_username ), |
|
377 | - 'PWD' => urlencode( $this->_api_password ), |
|
378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
376 | + 'USER' => urlencode($this->_api_username), |
|
377 | + 'PWD' => urlencode($this->_api_password), |
|
378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
379 | 379 | ); |
380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
380 | + $dtls = array_merge($request_dtls, $request_params); |
|
381 | 381 | |
382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
383 | 383 | // Request Customer Details. |
384 | 384 | $request_response = wp_remote_post( |
385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | 'httpversion' => '1.1', |
390 | 390 | 'cookies' => array(), |
391 | 391 | 'headers' => array(), |
392 | - 'body' => http_build_query( $dtls ) |
|
392 | + 'body' => http_build_query($dtls) |
|
393 | 393 | ) |
394 | 394 | ); |
395 | 395 | // Log the response. |
396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
397 | 397 | |
398 | 398 | return $request_response; |
399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param mixed $request_response |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function _ppExpress_check_response( $request_response ) { |
|
409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
408 | + public function _ppExpress_check_response($request_response) { |
|
409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
410 | 410 | // If we got here then there was an error in this request. |
411 | 411 | return array('status' => false, 'args' => $request_response); |
412 | 412 | } |
413 | 413 | $response_args = array(); |
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
415 | 415 | if ( ! isset($response_args['ACK'])) { |
416 | 416 | return array('status' => false, 'args' => $request_response); |
417 | 417 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | * @param string $info |
442 | 442 | * @return void |
443 | 443 | */ |
444 | - private function _log_clean_request($request, $payment, $info ) { |
|
444 | + private function _log_clean_request($request, $payment, $info) { |
|
445 | 445 | $cleaned_request_data = $request; |
446 | 446 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
447 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
447 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * @param array $data_array |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - private function _get_errors( $data_array ) { |
|
457 | + private function _get_errors($data_array) { |
|
458 | 458 | $errors = array(); |
459 | 459 | $n = 0; |
460 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
460 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
461 | 461 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
462 | 462 | ? $data_array["L_ERRORCODE{$n}"] |
463 | 463 | : ''; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | ? $data_array["L_LONGMESSAGE{$n}"] |
472 | 472 | : ''; |
473 | 473 | |
474 | - if ( $n === 0 ) { |
|
474 | + if ($n === 0) { |
|
475 | 475 | $errors = array( |
476 | 476 | 'L_ERRORCODE' => $l_error_code, |
477 | 477 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | 'L_SEVERITYCODE' => $l_severity_code |
480 | 480 | ); |
481 | 481 | } else { |
482 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
483 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
484 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
485 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
482 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
483 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
484 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
485 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $n++; |
@@ -44,77 +44,76 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $_image_url; |
46 | 46 | |
47 | - /** |
|
48 | - * gateway URL variable |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_base_gateway_url = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * EEG_Paypal_Express constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->_currencies_supported = array( |
|
62 | - 'USD', |
|
63 | - 'AUD', |
|
64 | - 'BRL', |
|
65 | - 'CAD', |
|
66 | - 'CZK', |
|
67 | - 'DKK', |
|
68 | - 'EUR', |
|
69 | - 'HKD', |
|
70 | - 'HUF', |
|
71 | - 'ILS', |
|
72 | - 'JPY', |
|
73 | - 'MYR', |
|
74 | - 'MXN', |
|
75 | - 'NOK', |
|
76 | - 'NZD', |
|
77 | - 'PHP', |
|
78 | - 'PLN', |
|
79 | - 'GBP', |
|
80 | - 'RUB', |
|
81 | - 'SGD', |
|
82 | - 'SEK', |
|
83 | - 'CHF', |
|
84 | - 'TWD', |
|
85 | - 'THB', |
|
86 | - 'TRY' |
|
87 | - ); |
|
88 | - parent::__construct(); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
47 | + /** |
|
48 | + * gateway URL variable |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_base_gateway_url = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * EEG_Paypal_Express constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->_currencies_supported = array( |
|
62 | + 'USD', |
|
63 | + 'AUD', |
|
64 | + 'BRL', |
|
65 | + 'CAD', |
|
66 | + 'CZK', |
|
67 | + 'DKK', |
|
68 | + 'EUR', |
|
69 | + 'HKD', |
|
70 | + 'HUF', |
|
71 | + 'ILS', |
|
72 | + 'JPY', |
|
73 | + 'MYR', |
|
74 | + 'MXN', |
|
75 | + 'NOK', |
|
76 | + 'NZD', |
|
77 | + 'PHP', |
|
78 | + 'PLN', |
|
79 | + 'GBP', |
|
80 | + 'RUB', |
|
81 | + 'SGD', |
|
82 | + 'SEK', |
|
83 | + 'CHF', |
|
84 | + 'TWD', |
|
85 | + 'THB', |
|
86 | + 'TRY' |
|
87 | + ); |
|
88 | + parent::__construct(); |
|
89 | + } |
|
90 | + |
|
95 | 91 | |
92 | + |
|
93 | + /** |
|
94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
96 | 95 | * |
97 | 96 | *@param array $settings_array |
98 | 97 | */ |
99 | 98 | public function set_settings( $settings_array ) { |
100 | 99 | parent::set_settings($settings_array); |
101 | 100 | // Redirect URL. |
102 | - $this->_base_gateway_url = $this->_debug_mode |
|
103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
104 | - : 'https://api-3t.paypal.com/nvp'; |
|
101 | + $this->_base_gateway_url = $this->_debug_mode |
|
102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
103 | + : 'https://api-3t.paypal.com/nvp'; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | |
108 | 107 | |
109 | - /** |
|
110 | - * @param EEI_Payment $payment |
|
111 | - * @param array $billing_info |
|
112 | - * @param string $return_url |
|
113 | - * @param string $notify_url |
|
114 | - * @param string $cancel_url |
|
115 | - * @return \EE_Payment|\EEI_Payment |
|
116 | - * @throws \EE_Error |
|
117 | - */ |
|
108 | + /** |
|
109 | + * @param EEI_Payment $payment |
|
110 | + * @param array $billing_info |
|
111 | + * @param string $return_url |
|
112 | + * @param string $notify_url |
|
113 | + * @param string $cancel_url |
|
114 | + * @return \EE_Payment|\EEI_Payment |
|
115 | + * @throws \EE_Error |
|
116 | + */ |
|
118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 202 | // Item quantity. |
204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
205 | - // Digital item is sold. |
|
206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
207 | - $item_num++; |
|
204 | + // Digital item is sold. |
|
205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
206 | + $item_num++; |
|
208 | 207 | } |
209 | 208 | } else { |
210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
277 | 276 | |
278 | 277 | |
279 | 278 | /** |
280 | - |
|
281 | 279 | * @param array $update_info { |
282 | 280 | * @type string $gateway_txn_id |
283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
297 | 295 | return $payment; |
298 | 296 | } |
299 | 297 | $primary_registrant = $transaction->primary_registration(); |
300 | - $payment_details = $payment->details(); |
|
301 | - // Check if we still have the token. |
|
298 | + $payment_details = $payment->details(); |
|
299 | + // Check if we still have the token. |
|
302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
304 | 302 | return $payment; |
@@ -407,36 +405,36 @@ discard block |
||
407 | 405 | */ |
408 | 406 | public function _ppExpress_check_response( $request_response ) { |
409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
410 | - // If we got here then there was an error in this request. |
|
411 | - return array('status' => false, 'args' => $request_response); |
|
412 | - } |
|
413 | - $response_args = array(); |
|
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
415 | - if ( ! isset($response_args['ACK'])) { |
|
416 | - return array('status' => false, 'args' => $request_response); |
|
417 | - } |
|
418 | - if ( |
|
419 | - $response_args['ACK'] === 'Success' |
|
420 | - && ( |
|
421 | - isset($response_args['PAYERID']) |
|
422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
424 | - || isset($response_args['TOKEN']) |
|
425 | - ) |
|
426 | - ) { |
|
427 | - // Response status OK, return response parameters for further processing. |
|
428 | - return array('status' => true, 'args' => $response_args); |
|
429 | - } else { |
|
430 | - $errors = $this->_get_errors($response_args); |
|
431 | - return array('status' => false, 'args' => $errors); |
|
432 | - } |
|
408 | + // If we got here then there was an error in this request. |
|
409 | + return array('status' => false, 'args' => $request_response); |
|
410 | + } |
|
411 | + $response_args = array(); |
|
412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
413 | + if ( ! isset($response_args['ACK'])) { |
|
414 | + return array('status' => false, 'args' => $request_response); |
|
415 | + } |
|
416 | + if ( |
|
417 | + $response_args['ACK'] === 'Success' |
|
418 | + && ( |
|
419 | + isset($response_args['PAYERID']) |
|
420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
422 | + || isset($response_args['TOKEN']) |
|
423 | + ) |
|
424 | + ) { |
|
425 | + // Response status OK, return response parameters for further processing. |
|
426 | + return array('status' => true, 'args' => $response_args); |
|
427 | + } else { |
|
428 | + $errors = $this->_get_errors($response_args); |
|
429 | + return array('status' => false, 'args' => $errors); |
|
430 | + } |
|
433 | 431 | } |
434 | 432 | |
435 | 433 | |
436 | 434 | /** |
437 | - * Log a "Cleared" request. |
|
438 | - * |
|
439 | - * @param array $request |
|
435 | + * Log a "Cleared" request. |
|
436 | + * |
|
437 | + * @param array $request |
|
440 | 438 | * @param EEI_Payment $payment |
441 | 439 | * @param string $info |
442 | 440 | * @return void |
@@ -459,17 +457,17 @@ discard block |
||
459 | 457 | $n = 0; |
460 | 458 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
461 | 459 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
462 | - ? $data_array["L_ERRORCODE{$n}"] |
|
463 | - : ''; |
|
460 | + ? $data_array["L_ERRORCODE{$n}"] |
|
461 | + : ''; |
|
464 | 462 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
465 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
466 | - : ''; |
|
463 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
464 | + : ''; |
|
467 | 465 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
468 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
469 | - : ''; |
|
466 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
467 | + : ''; |
|
470 | 468 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
471 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
472 | - : ''; |
|
469 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
470 | + : ''; |
|
473 | 471 | |
474 | 472 | if ( $n === 0 ) { |
475 | 473 | $errors = array( |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_SPCO_Reg_Step_Attendee_Information |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_SPCO_Reg_Step_Attendee_Information |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step { |
15 | 15 | |
16 | 16 | /** |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | $registration instanceof EE_Registration |
136 | 136 | && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
137 | 137 | ) { |
138 | - $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
139 | - if ( ! $this->checkout->admin_request) { |
|
140 | - $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
141 | - $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
142 | - $template_args['ticket_count'][$registration->ticket()->ID()] |
|
143 | - ) |
|
144 | - ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
145 | - : 1; |
|
146 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
147 | - $this->checkout->cart->get_grand_total(), |
|
148 | - 'Ticket', |
|
149 | - array($registration->ticket()->ID()) |
|
150 | - ); |
|
151 | - $ticket_line_item = is_array($ticket_line_item) |
|
152 | - ? reset($ticket_line_item) |
|
153 | - : $ticket_line_item; |
|
154 | - $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
155 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
156 | - } |
|
157 | - if ($registration->is_primary_registrant()) { |
|
158 | - $primary_registrant = $registration->reg_url_link(); |
|
159 | - } |
|
138 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
139 | + if ( ! $this->checkout->admin_request) { |
|
140 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
141 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
142 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
143 | + ) |
|
144 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
145 | + : 1; |
|
146 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
147 | + $this->checkout->cart->get_grand_total(), |
|
148 | + 'Ticket', |
|
149 | + array($registration->ticket()->ID()) |
|
150 | + ); |
|
151 | + $ticket_line_item = is_array($ticket_line_item) |
|
152 | + ? reset($ticket_line_item) |
|
153 | + : $ticket_line_item; |
|
154 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
155 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
156 | + } |
|
157 | + if ($registration->is_primary_registrant()) { |
|
158 | + $primary_registrant = $registration->reg_url_link(); |
|
159 | + } |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | // print_copy_info ? |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | // generate hidden input |
169 | 169 | if ( |
170 | 170 | isset( $subsections[ $primary_registrant ] ) |
171 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
171 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
172 | 172 | ) { |
173 | 173 | $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
174 | 174 | } |
@@ -196,42 +196,42 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | |
199 | - /** |
|
199 | + /** |
|
200 | 200 | * @param EE_Registration $registration |
201 | 201 | * @return EE_Form_Section_Base |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | 204 | private function _registrations_reg_form( EE_Registration $registration ) { |
205 | 205 | static $attendee_nmbr = 1; |
206 | - $form_args = array(); |
|
206 | + $form_args = array(); |
|
207 | 207 | // verify that registration has valid event |
208 | 208 | if ( $registration->event() instanceof EE_Event ) { |
209 | 209 | $question_groups = $registration->event()->question_groups( |
210 | - array( |
|
211 | - array( |
|
212 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
213 | - 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
214 | - ), |
|
215 | - 'order_by' => array('QSG_order' => 'ASC') |
|
216 | - ) |
|
217 | - ); |
|
210 | + array( |
|
211 | + array( |
|
212 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
213 | + 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
214 | + ), |
|
215 | + 'order_by' => array('QSG_order' => 'ASC') |
|
216 | + ) |
|
217 | + ); |
|
218 | 218 | if ( $question_groups ) { |
219 | - // array of params to pass to parent constructor |
|
220 | - $form_args = array( |
|
221 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
222 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
223 | - 'html_style' => $this->checkout->admin_request |
|
224 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
225 | - : '', |
|
226 | - 'subsections' => array(), |
|
227 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
228 | - array( |
|
229 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
230 | - 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
231 | - ) |
|
232 | - ) |
|
233 | - ); |
|
234 | - foreach ( $question_groups as $question_group ) { |
|
219 | + // array of params to pass to parent constructor |
|
220 | + $form_args = array( |
|
221 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
222 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
223 | + 'html_style' => $this->checkout->admin_request |
|
224 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
225 | + : '', |
|
226 | + 'subsections' => array(), |
|
227 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
228 | + array( |
|
229 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
230 | + 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
231 | + ) |
|
232 | + ) |
|
233 | + ); |
|
234 | + foreach ( $question_groups as $question_group ) { |
|
235 | 235 | if ( $question_group instanceof EE_Question_Group ) { |
236 | 236 | $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
237 | 237 | $registration, |
@@ -239,19 +239,19 @@ discard block |
||
239 | 239 | ); |
240 | 240 | } |
241 | 241 | } |
242 | - // add hidden input |
|
243 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
244 | - $registration |
|
245 | - ); |
|
246 | - // if we have question groups for additional attendees, then display the copy options |
|
242 | + // add hidden input |
|
243 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
244 | + $registration |
|
245 | + ); |
|
246 | + // if we have question groups for additional attendees, then display the copy options |
|
247 | 247 | $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
248 | - if ($registration->is_primary_registrant()) { |
|
249 | - // generate hidden input |
|
250 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
251 | - } |
|
252 | - } |
|
248 | + if ($registration->is_primary_registrant()) { |
|
249 | + // generate hidden input |
|
250 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
251 | + } |
|
252 | + } |
|
253 | 253 | } |
254 | - $attendee_nmbr++; |
|
254 | + $attendee_nmbr++; |
|
255 | 255 | return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
256 | 256 | } |
257 | 257 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | if ( isset( $valid_data[ $reg_url_link ] ) ) { |
885 | 885 | // do we need to copy basic info from primary attendee ? |
886 | 886 | $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
887 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
887 | + && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
888 | 888 | ? true |
889 | 889 | : false; |
890 | 890 | // filter form input data for this registration |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | ) ) { |
1055 | 1055 | return true; |
1056 | 1056 | } |
1057 | - /* |
|
1057 | + /* |
|
1058 | 1058 | * $answer_cache_id is the key used to find the EE_Answer we want |
1059 | 1059 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1060 | 1060 | */ |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | ? $form_input . '-' . $registration->reg_url_link() |
1063 | 1063 | : $form_input; |
1064 | 1064 | $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
1065 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1065 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1066 | 1066 | ? true |
1067 | 1067 | : false; |
1068 | 1068 | //rename form_inputs if they are EE_Attendee properties |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | // then attempt to copy them from the primary attendee |
1183 | 1183 | if ( |
1184 | 1184 | $this->checkout->primary_attendee_obj instanceof EE_Attendee |
1185 | - && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] ) |
|
1185 | + && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] ) |
|
1186 | 1186 | ) { |
1187 | 1187 | return $this->checkout->primary_attendee_obj; |
1188 | 1188 | } |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | } |
1301 | 1301 | foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
1302 | 1302 | if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
1303 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1303 | + || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1304 | 1304 | ) { |
1305 | 1305 | $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
1306 | 1306 | $critical_attendee_detail |
@@ -41,21 +41,21 @@ discard block |
||
41 | 41 | * @access public |
42 | 42 | * @param EE_Checkout $checkout |
43 | 43 | */ |
44 | - public function __construct( EE_Checkout $checkout ) { |
|
44 | + public function __construct(EE_Checkout $checkout) { |
|
45 | 45 | $this->_slug = 'attendee_information'; |
46 | 46 | $this->_name = __('Attendee Information', 'event_espresso'); |
47 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
47 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
48 | 48 | $this->checkout = $checkout; |
49 | 49 | $this->_reset_success_message(); |
50 | 50 | $this->set_instructions( |
51 | - __( 'Please answer the following registration questions before proceeding.', 'event_espresso' ) |
|
51 | + __('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | 57 | public function translate_js_strings() { |
58 | - EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' ); |
|
58 | + EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso'); |
|
59 | 59 | EE_Registry::$i18n_js_strings['required_multi_field'] = __( |
60 | 60 | ' is a required question. Please enter a value for at least one of the options.', |
61 | 61 | 'event_espresso' |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | // calculate taxes |
116 | 116 | $Line_Item_Display->display_line_item( |
117 | 117 | $this->checkout->cart->get_grand_total(), |
118 | - array( 'set_tax_rate' => true ) |
|
118 | + array('set_tax_rate' => true) |
|
119 | 119 | ); |
120 | 120 | /** @var $subsections EE_Form_Section_Proper[] */ |
121 | 121 | $subsections = array( |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | 'ticket_count' => array() |
128 | 128 | ); |
129 | 129 | // grab the saved registrations from the transaction |
130 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
131 | - if ( $registrations ) { |
|
132 | - foreach ( $registrations as $registration ) { |
|
130 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
131 | + if ($registrations) { |
|
132 | + foreach ($registrations as $registration) { |
|
133 | 133 | // can this registration be processed during this visit ? |
134 | 134 | if ( |
135 | 135 | $registration instanceof EE_Registration |
136 | - && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
|
136 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
137 | 137 | ) { |
138 | 138 | $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
139 | 139 | if ( ! $this->checkout->admin_request) { |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | } |
161 | 161 | } |
162 | 162 | // print_copy_info ? |
163 | - if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) { |
|
163 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
164 | 164 | // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info |
165 | 165 | $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
166 | 166 | ? $this->_copy_attendee_info_form() |
167 | 167 | : $this->_auto_copy_attendee_info(); |
168 | 168 | // generate hidden input |
169 | 169 | if ( |
170 | - isset( $subsections[ $primary_registrant ] ) |
|
171 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
170 | + isset($subsections[$primary_registrant]) |
|
171 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
172 | 172 | ) { |
173 | - $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
|
173 | + $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | 'html_id' => $this->reg_form_name(), |
183 | 183 | 'subsections' => $subsections, |
184 | 184 | 'layout_strategy' => $this->checkout->admin_request ? |
185 | - new EE_Div_Per_Section_Layout() : |
|
186 | - new EE_Template_Layout( |
|
185 | + new EE_Div_Per_Section_Layout() : new EE_Template_Layout( |
|
187 | 186 | array( |
188 | 187 | 'layout_template_file' => $this->_template, // layout_template |
189 | 188 | 'template_args' => $template_args |
@@ -201,11 +200,11 @@ discard block |
||
201 | 200 | * @return EE_Form_Section_Base |
202 | 201 | * @throws \EE_Error |
203 | 202 | */ |
204 | - private function _registrations_reg_form( EE_Registration $registration ) { |
|
203 | + private function _registrations_reg_form(EE_Registration $registration) { |
|
205 | 204 | static $attendee_nmbr = 1; |
206 | 205 | $form_args = array(); |
207 | 206 | // verify that registration has valid event |
208 | - if ( $registration->event() instanceof EE_Event ) { |
|
207 | + if ($registration->event() instanceof EE_Event) { |
|
209 | 208 | $question_groups = $registration->event()->question_groups( |
210 | 209 | array( |
211 | 210 | array( |
@@ -215,10 +214,10 @@ discard block |
||
215 | 214 | 'order_by' => array('QSG_order' => 'ASC') |
216 | 215 | ) |
217 | 216 | ); |
218 | - if ( $question_groups ) { |
|
217 | + if ($question_groups) { |
|
219 | 218 | // array of params to pass to parent constructor |
220 | 219 | $form_args = array( |
221 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
220 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
222 | 221 | 'html_class' => 'ee-reg-form-attendee-dv', |
223 | 222 | 'html_style' => $this->checkout->admin_request |
224 | 223 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -231,9 +230,9 @@ discard block |
||
231 | 230 | ) |
232 | 231 | ) |
233 | 232 | ); |
234 | - foreach ( $question_groups as $question_group ) { |
|
235 | - if ( $question_group instanceof EE_Question_Group ) { |
|
236 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
233 | + foreach ($question_groups as $question_group) { |
|
234 | + if ($question_group instanceof EE_Question_Group) { |
|
235 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
237 | 236 | $registration, |
238 | 237 | $question_group |
239 | 238 | ); |
@@ -252,7 +251,7 @@ discard block |
||
252 | 251 | } |
253 | 252 | } |
254 | 253 | $attendee_nmbr++; |
255 | - return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
|
254 | + return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML(); |
|
256 | 255 | } |
257 | 256 | |
258 | 257 | |
@@ -273,7 +272,7 @@ discard block |
||
273 | 272 | // generate hidden input |
274 | 273 | return new EE_Hidden_Input( |
275 | 274 | array( |
276 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
275 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
277 | 276 | 'default' => $additional_attendee_reg_info |
278 | 277 | ) |
279 | 278 | ); |
@@ -287,26 +286,26 @@ discard block |
||
287 | 286 | * @return EE_Form_Section_Proper |
288 | 287 | * @throws \EE_Error |
289 | 288 | */ |
290 | - private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){ |
|
289 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) { |
|
291 | 290 | // array of params to pass to parent constructor |
292 | 291 | $form_args = array( |
293 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier(), |
|
292 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier(), |
|
294 | 293 | 'html_class' => $this->checkout->admin_request |
295 | 294 | ? 'form-table ee-reg-form-qstn-grp-dv' |
296 | 295 | : 'ee-reg-form-qstn-grp-dv', |
297 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl', |
|
296 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl', |
|
298 | 297 | 'subsections' => array( |
299 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group ) |
|
298 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group) |
|
300 | 299 | ), |
301 | 300 | 'layout_strategy' => $this->checkout->admin_request |
302 | 301 | ? new EE_Admin_Two_Column_Layout() |
303 | 302 | : new EE_Div_Per_Section_Layout() |
304 | 303 | ); |
305 | 304 | // where params |
306 | - $query_params = array( 'QST_deleted' => 0 ); |
|
305 | + $query_params = array('QST_deleted' => 0); |
|
307 | 306 | // don't load admin only questions on the frontend |
308 | - if ( ! $this->checkout->admin_request ) { |
|
309 | - $query_params['QST_admin_only'] = array( '!=', true ); |
|
307 | + if ( ! $this->checkout->admin_request) { |
|
308 | + $query_params['QST_admin_only'] = array('!=', true); |
|
310 | 309 | } |
311 | 310 | $questions = $question_group->get_many_related( |
312 | 311 | 'Question', |
@@ -328,10 +327,10 @@ discard block |
||
328 | 327 | ) |
329 | 328 | ); |
330 | 329 | // loop thru questions |
331 | - foreach ( $questions as $question ) { |
|
332 | - if( $question instanceof EE_Question ){ |
|
330 | + foreach ($questions as $question) { |
|
331 | + if ($question instanceof EE_Question) { |
|
333 | 332 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
334 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question ); |
|
333 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
335 | 334 | } |
336 | 335 | } |
337 | 336 | $form_args['subsections'] = apply_filters( |
@@ -352,7 +351,7 @@ discard block |
||
352 | 351 | ) |
353 | 352 | ); |
354 | 353 | // d( $form_args ); |
355 | - $question_group_reg_form = new EE_Form_Section_Proper( $form_args ); |
|
354 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
356 | 355 | return apply_filters( |
357 | 356 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
358 | 357 | $question_group_reg_form, |
@@ -369,11 +368,11 @@ discard block |
||
369 | 368 | * @param EE_Question_Group $question_group |
370 | 369 | * @return EE_Form_Section_HTML |
371 | 370 | */ |
372 | - private function _question_group_header( EE_Question_Group $question_group ){ |
|
371 | + private function _question_group_header(EE_Question_Group $question_group) { |
|
373 | 372 | $html = ''; |
374 | 373 | // group_name |
375 | - if ( $question_group->show_group_name() && $question_group->name() !== '' ) { |
|
376 | - if ( $this->checkout->admin_request ) { |
|
374 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
375 | + if ($this->checkout->admin_request) { |
|
377 | 376 | $html .= EEH_HTML::br(); |
378 | 377 | $html .= EEH_HTML::h3( |
379 | 378 | $question_group->name(), |
@@ -387,7 +386,7 @@ discard block |
||
387 | 386 | } |
388 | 387 | } |
389 | 388 | // group_desc |
390 | - if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) { |
|
389 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
391 | 390 | $html .= EEH_HTML::p( |
392 | 391 | $question_group->desc(), |
393 | 392 | '', |
@@ -397,7 +396,7 @@ discard block |
||
397 | 396 | ); |
398 | 397 | |
399 | 398 | } |
400 | - return new EE_Form_Section_HTML( $html ); |
|
399 | + return new EE_Form_Section_HTML($html); |
|
401 | 400 | } |
402 | 401 | |
403 | 402 | |
@@ -407,7 +406,7 @@ discard block |
||
407 | 406 | * @return EE_Form_Section_Proper |
408 | 407 | * @throws \EE_Error |
409 | 408 | */ |
410 | - private function _copy_attendee_info_form(){ |
|
409 | + private function _copy_attendee_info_form() { |
|
411 | 410 | // array of params to pass to parent constructor |
412 | 411 | return new EE_Form_Section_Proper( |
413 | 412 | array( |
@@ -436,7 +435,7 @@ discard block |
||
436 | 435 | private function _auto_copy_attendee_info() { |
437 | 436 | return new EE_Form_Section_HTML( |
438 | 437 | EEH_Template::locate_template( |
439 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
438 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
440 | 439 | apply_filters( |
441 | 440 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
442 | 441 | array() |
@@ -460,32 +459,32 @@ discard block |
||
460 | 459 | $copy_attendee_info_inputs = array(); |
461 | 460 | $prev_ticket = NULL; |
462 | 461 | // grab the saved registrations from the transaction |
463 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
464 | - foreach ( $registrations as $registration ) { |
|
462 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
463 | + foreach ($registrations as $registration) { |
|
465 | 464 | // for all attendees other than the primary attendee |
466 | - if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) { |
|
465 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
467 | 466 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
468 | - if ( $registration->ticket()->ID() !== $prev_ticket ) { |
|
467 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
469 | 468 | $item_name = $registration->ticket()->name(); |
470 | 469 | $item_name .= $registration->ticket()->description() !== '' |
471 | - ? ' - ' . $registration->ticket()->description() |
|
470 | + ? ' - '.$registration->ticket()->description() |
|
472 | 471 | : ''; |
473 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML( |
|
474 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
472 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML( |
|
473 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
475 | 474 | ); |
476 | 475 | $prev_ticket = $registration->ticket()->ID(); |
477 | 476 | } |
478 | 477 | |
479 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new |
|
478 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new |
|
480 | 479 | EE_Checkbox_Multi_Input( |
481 | 480 | array( |
482 | 481 | $registration->ID() => sprintf( |
483 | - __( 'Attendee #%s', 'event_espresso' ), |
|
482 | + __('Attendee #%s', 'event_espresso'), |
|
484 | 483 | $registration->count() |
485 | 484 | ) |
486 | 485 | ), |
487 | 486 | array( |
488 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
487 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
489 | 488 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
490 | 489 | 'display_html_label_text' => false |
491 | 490 | ) |
@@ -505,7 +504,7 @@ discard block |
||
505 | 504 | * @return EE_Form_Input_Base |
506 | 505 | * @throws \EE_Error |
507 | 506 | */ |
508 | - private function _additional_primary_registrant_inputs( EE_Registration $registration ){ |
|
507 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) { |
|
509 | 508 | // generate hidden input |
510 | 509 | return new EE_Hidden_Input( |
511 | 510 | array( |
@@ -524,7 +523,7 @@ discard block |
||
524 | 523 | * @return EE_Form_Input_Base |
525 | 524 | * @throws \EE_Error |
526 | 525 | */ |
527 | - public function reg_form_question( EE_Registration $registration, EE_Question $question ){ |
|
526 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) { |
|
528 | 527 | |
529 | 528 | // if this question was for an attendee detail, then check for that answer |
530 | 529 | $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
@@ -533,32 +532,32 @@ discard block |
||
533 | 532 | ); |
534 | 533 | $answer = $answer_value === null |
535 | 534 | ? EEM_Answer::instance()->get_one( |
536 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
535 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
537 | 536 | ) |
538 | 537 | : null; |
539 | 538 | // if NOT returning to edit an existing registration |
540 | 539 | // OR if this question is for an attendee property |
541 | 540 | // OR we still don't have an EE_Answer object |
542 | - if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) { |
|
541 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
543 | 542 | // create an EE_Answer object for storing everything in |
544 | - $answer = EE_Answer::new_instance ( array( |
|
543 | + $answer = EE_Answer::new_instance(array( |
|
545 | 544 | 'QST_ID'=> $question->ID(), |
546 | 545 | 'REG_ID'=> $registration->ID() |
547 | 546 | )); |
548 | 547 | } |
549 | 548 | // verify instance |
550 | - if( $answer instanceof EE_Answer ){ |
|
551 | - if ( ! empty( $answer_value )) { |
|
552 | - $answer->set( 'ANS_value', $answer_value ); |
|
549 | + if ($answer instanceof EE_Answer) { |
|
550 | + if ( ! empty($answer_value)) { |
|
551 | + $answer->set('ANS_value', $answer_value); |
|
553 | 552 | } |
554 | - $answer->cache( 'Question', $question ); |
|
553 | + $answer->cache('Question', $question); |
|
555 | 554 | //remember system ID had a bug where sometimes it could be null |
556 | - $answer_cache_id =$question->is_system_question() |
|
557 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
558 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
559 | - $registration->cache( 'Answer', $answer, $answer_cache_id ); |
|
555 | + $answer_cache_id = $question->is_system_question() |
|
556 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
557 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
558 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
560 | 559 | } |
561 | - return $this->_generate_question_input( $registration, $question, $answer ); |
|
560 | + return $this->_generate_question_input($registration, $question, $answer); |
|
562 | 561 | |
563 | 562 | } |
564 | 563 | |
@@ -571,46 +570,46 @@ discard block |
||
571 | 570 | * @return EE_Form_Input_Base |
572 | 571 | * @throws \EE_Error |
573 | 572 | */ |
574 | - private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){ |
|
573 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { |
|
575 | 574 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
576 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
575 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
577 | 576 | add_filter( |
578 | 577 | 'FHEE__EE_Question__generate_form_input__country_options', |
579 | - array( $this, 'use_cached_countries_for_form_input' ), |
|
578 | + array($this, 'use_cached_countries_for_form_input'), |
|
580 | 579 | 10, |
581 | 580 | 4 |
582 | 581 | ); |
583 | 582 | add_filter( |
584 | 583 | 'FHEE__EE_Question__generate_form_input__state_options', |
585 | - array( $this, 'use_cached_states_for_form_input' ), |
|
584 | + array($this, 'use_cached_states_for_form_input'), |
|
586 | 585 | 10, |
587 | 586 | 4 |
588 | 587 | ); |
589 | 588 | $input_constructor_args = array( |
590 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
591 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
592 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
593 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
589 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
590 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
591 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
592 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
594 | 593 | 'html_label_class' => 'ee-reg-qstn', |
595 | 594 | ); |
596 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
597 | - if ( $answer instanceof EE_Answer && $answer->ID() ) { |
|
598 | - $input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']'; |
|
599 | - $input_constructor_args[ 'html_id' ] .= '-' . $answer->ID(); |
|
600 | - $input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID(); |
|
595 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
596 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
597 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
598 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
599 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
601 | 600 | } |
602 | - $form_input = $question->generate_form_input( |
|
601 | + $form_input = $question->generate_form_input( |
|
603 | 602 | $registration, |
604 | 603 | $answer, |
605 | 604 | $input_constructor_args |
606 | 605 | ); |
607 | 606 | remove_filter( |
608 | 607 | 'FHEE__EE_Question__generate_form_input__country_options', |
609 | - array( $this, 'use_cached_countries_for_form_input' ) |
|
608 | + array($this, 'use_cached_countries_for_form_input') |
|
610 | 609 | ); |
611 | 610 | remove_filter( |
612 | 611 | 'FHEE__EE_Question__generate_form_input__state_options', |
613 | - array( $this, 'use_cached_states_for_form_input' ) |
|
612 | + array($this, 'use_cached_states_for_form_input') |
|
614 | 613 | ); |
615 | 614 | return $form_input; |
616 | 615 | } |
@@ -632,22 +631,22 @@ discard block |
||
632 | 631 | \EE_Registration $registration = null, |
633 | 632 | \EE_Answer $answer = null |
634 | 633 | ) { |
635 | - $country_options = array( '' => '' ); |
|
634 | + $country_options = array('' => ''); |
|
636 | 635 | // get possibly cached list of countries |
637 | 636 | $countries = $this->checkout->action === 'process_reg_step' |
638 | 637 | ? EEM_Country::instance()->get_all_countries() |
639 | 638 | : EEM_Country::instance()->get_all_active_countries(); |
640 | - if ( ! empty( $countries )) { |
|
641 | - foreach( $countries as $country ){ |
|
642 | - if ( $country instanceof EE_Country ) { |
|
643 | - $country_options[ $country->ID() ] = $country->name(); |
|
639 | + if ( ! empty($countries)) { |
|
640 | + foreach ($countries as $country) { |
|
641 | + if ($country instanceof EE_Country) { |
|
642 | + $country_options[$country->ID()] = $country->name(); |
|
644 | 643 | } |
645 | 644 | } |
646 | 645 | } |
647 | - if( $question instanceof EE_Question |
|
648 | - && $registration instanceof EE_Registration ) { |
|
646 | + if ($question instanceof EE_Question |
|
647 | + && $registration instanceof EE_Registration) { |
|
649 | 648 | $answer = EEM_Answer::instance()->get_one( |
650 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
649 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
651 | 650 | ); |
652 | 651 | } else { |
653 | 652 | $answer = EE_Answer::new_instance(); |
@@ -680,14 +679,14 @@ discard block |
||
680 | 679 | \EE_Registration $registration = null, |
681 | 680 | \EE_Answer $answer = null |
682 | 681 | ) { |
683 | - $state_options = array( '' => array( '' => '')); |
|
682 | + $state_options = array('' => array('' => '')); |
|
684 | 683 | $states = $this->checkout->action === 'process_reg_step' |
685 | 684 | ? EEM_State::instance()->get_all_states() |
686 | 685 | : EEM_State::instance()->get_all_active_states(); |
687 | - if ( ! empty( $states )) { |
|
688 | - foreach( $states as $state ){ |
|
689 | - if ( $state instanceof EE_State ) { |
|
690 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
686 | + if ( ! empty($states)) { |
|
687 | + foreach ($states as $state) { |
|
688 | + if ($state instanceof EE_State) { |
|
689 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
691 | 690 | } |
692 | 691 | } |
693 | 692 | } |
@@ -715,24 +714,24 @@ discard block |
||
715 | 714 | * @throws \EE_Error |
716 | 715 | */ |
717 | 716 | public function process_reg_step() { |
718 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
717 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
719 | 718 | // grab validated data from form |
720 | 719 | $valid_data = $this->checkout->current_step->valid_data(); |
721 | 720 | // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
722 | 721 | // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
723 | 722 | // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
724 | - if ( empty( $valid_data )) { |
|
723 | + if (empty($valid_data)) { |
|
725 | 724 | EE_Error::add_error( |
726 | - __( 'No valid question responses were received.', 'event_espresso' ), |
|
725 | + __('No valid question responses were received.', 'event_espresso'), |
|
727 | 726 | __FILE__, |
728 | 727 | __FUNCTION__, |
729 | 728 | __LINE__ |
730 | 729 | ); |
731 | 730 | return false; |
732 | 731 | } |
733 | - if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) { |
|
732 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
734 | 733 | EE_Error::add_error( |
735 | - __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), |
|
734 | + __('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), |
|
736 | 735 | __FILE__, |
737 | 736 | __FUNCTION__, |
738 | 737 | __LINE__ |
@@ -740,11 +739,11 @@ discard block |
||
740 | 739 | return false; |
741 | 740 | } |
742 | 741 | // get cached registrations |
743 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
742 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
744 | 743 | // verify we got the goods |
745 | - if ( empty( $registrations )) { |
|
744 | + if (empty($registrations)) { |
|
746 | 745 | EE_Error::add_error( |
747 | - __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), |
|
746 | + __('Your form data could not be applied to any valid registrations.', 'event_espresso'), |
|
748 | 747 | __FILE__, |
749 | 748 | __FUNCTION__, |
750 | 749 | __LINE__ |
@@ -752,15 +751,15 @@ discard block |
||
752 | 751 | return false; |
753 | 752 | } |
754 | 753 | // extract attendee info from form data and save to model objects |
755 | - $registrations_processed = $this->_process_registrations( $registrations, $valid_data ); |
|
754 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
756 | 755 | // if first pass thru SPCO, |
757 | 756 | // then let's check processed registrations against the total number of tickets in the cart |
758 | - if ( $registrations_processed === false ) { |
|
757 | + if ($registrations_processed === false) { |
|
759 | 758 | // but return immediately if the previous step exited early due to errors |
760 | 759 | return false; |
761 | - } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) { |
|
760 | + } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
762 | 761 | // generate a correctly translated string for all possible singular/plural combinations |
763 | - if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) { |
|
762 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
764 | 763 | $error_msg = sprintf( |
765 | 764 | __( |
766 | 765 | 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | $this->checkout->total_ticket_count, |
770 | 769 | $registrations_processed |
771 | 770 | ); |
772 | - } else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) { |
|
771 | + } else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
773 | 772 | $error_msg = sprintf( |
774 | 773 | __( |
775 | 774 | 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
@@ -788,17 +787,17 @@ discard block |
||
788 | 787 | $registrations_processed |
789 | 788 | ); |
790 | 789 | } |
791 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
790 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
792 | 791 | return false; |
793 | 792 | } |
794 | 793 | // mark this reg step as completed |
795 | 794 | $this->set_completed(); |
796 | 795 | $this->_set_success_message( |
797 | - __( 'The Attendee Information Step has been successfully completed.', 'event_espresso' ) |
|
796 | + __('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
798 | 797 | ); |
799 | 798 | //do action in case a plugin wants to do something with the data submitted in step 1. |
800 | 799 | //passes EE_Single_Page_Checkout, and it's posted data |
801 | - do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data ); |
|
800 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
802 | 801 | return true; |
803 | 802 | } |
804 | 803 | |
@@ -812,9 +811,9 @@ discard block |
||
812 | 811 | * @return boolean | int |
813 | 812 | * @throws \EE_Error |
814 | 813 | */ |
815 | - private function _process_registrations( $registrations = array(), $valid_data = array() ) { |
|
814 | + private function _process_registrations($registrations = array(), $valid_data = array()) { |
|
816 | 815 | // load resources and set some defaults |
817 | - EE_Registry::instance()->load_model( 'Attendee' ); |
|
816 | + EE_Registry::instance()->load_model('Attendee'); |
|
818 | 817 | // holder for primary registrant attendee object |
819 | 818 | $this->checkout->primary_attendee_obj = NULL; |
820 | 819 | // array for tracking reg form data for the primary registrant |
@@ -831,9 +830,9 @@ discard block |
||
831 | 830 | // attendee counter |
832 | 831 | $att_nmbr = 0; |
833 | 832 | // grab the saved registrations from the transaction |
834 | - foreach ( $registrations as $registration ) { |
|
833 | + foreach ($registrations as $registration) { |
|
835 | 834 | // verify EE_Registration object |
836 | - if ( ! $registration instanceof EE_Registration ) { |
|
835 | + if ( ! $registration instanceof EE_Registration) { |
|
837 | 836 | EE_Error::add_error( |
838 | 837 | __( |
839 | 838 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -848,12 +847,12 @@ discard block |
||
848 | 847 | /** @var string $reg_url_link */ |
849 | 848 | $reg_url_link = $registration->reg_url_link(); |
850 | 849 | // reg_url_link exists ? |
851 | - if ( ! empty( $reg_url_link ) ) { |
|
850 | + if ( ! empty($reg_url_link)) { |
|
852 | 851 | // should this registration be processed during this visit ? |
853 | - if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) { |
|
852 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
854 | 853 | // if NOT revisiting, then let's save the registration now, |
855 | 854 | // so that we have a REG_ID to use when generating other objects |
856 | - if ( ! $this->checkout->revisit ) { |
|
855 | + if ( ! $this->checkout->revisit) { |
|
857 | 856 | $registration->save(); |
858 | 857 | } |
859 | 858 | /** |
@@ -863,7 +862,7 @@ discard block |
||
863 | 862 | * @var bool if true is returned by the plugin then the |
864 | 863 | * registration processing is halted. |
865 | 864 | */ |
866 | - if ( apply_filters( |
|
865 | + if (apply_filters( |
|
867 | 866 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
868 | 867 | false, |
869 | 868 | $att_nmbr, |
@@ -871,38 +870,38 @@ discard block |
||
871 | 870 | $registrations, |
872 | 871 | $valid_data, |
873 | 872 | $this |
874 | - ) ) { |
|
873 | + )) { |
|
875 | 874 | return false; |
876 | 875 | } |
877 | 876 | |
878 | 877 | // Houston, we have a registration! |
879 | 878 | $att_nmbr++; |
880 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
879 | + $this->_attendee_data[$reg_url_link] = array(); |
|
881 | 880 | // grab any existing related answer objects |
882 | 881 | $this->_registration_answers = $registration->answers(); |
883 | 882 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
884 | - if ( isset( $valid_data[ $reg_url_link ] ) ) { |
|
883 | + if (isset($valid_data[$reg_url_link])) { |
|
885 | 884 | // do we need to copy basic info from primary attendee ? |
886 | - $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
|
887 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
885 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
886 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 |
|
888 | 887 | ? true |
889 | 888 | : false; |
890 | 889 | // filter form input data for this registration |
891 | - $valid_data[ $reg_url_link ] = (array)apply_filters( |
|
890 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
892 | 891 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
893 | - $valid_data[ $reg_url_link ] |
|
892 | + $valid_data[$reg_url_link] |
|
894 | 893 | ); |
895 | 894 | // EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ ); |
896 | - if ( isset( $valid_data['primary_attendee'] )) { |
|
897 | - $primary_registrant['line_item_id'] = ! empty( $valid_data['primary_attendee'] ) |
|
895 | + if (isset($valid_data['primary_attendee'])) { |
|
896 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
898 | 897 | ? $valid_data['primary_attendee'] |
899 | 898 | : false; |
900 | - unset( $valid_data['primary_attendee'] ); |
|
899 | + unset($valid_data['primary_attendee']); |
|
901 | 900 | } |
902 | 901 | // now loop through our array of valid post data && process attendee reg forms |
903 | - foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) { |
|
904 | - if ( ! in_array( $form_section, $non_input_form_sections )) { |
|
905 | - foreach ( $form_inputs as $form_input => $input_value ) { |
|
902 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
903 | + if ( ! in_array($form_section, $non_input_form_sections)) { |
|
904 | + foreach ($form_inputs as $form_input => $input_value) { |
|
906 | 905 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
907 | 906 | // check for critical inputs |
908 | 907 | if ( |
@@ -916,16 +915,16 @@ discard block |
||
916 | 915 | // store a bit of data about the primary attendee |
917 | 916 | if ( |
918 | 917 | $att_nmbr === 1 |
919 | - && ! empty( $input_value ) |
|
918 | + && ! empty($input_value) |
|
920 | 919 | && $reg_url_link === $primary_registrant['line_item_id'] |
921 | 920 | ) { |
922 | - $primary_registrant[ $form_input ] = $input_value; |
|
921 | + $primary_registrant[$form_input] = $input_value; |
|
923 | 922 | } else if ( |
924 | 923 | $copy_primary |
925 | 924 | && $input_value === null |
926 | - && isset( $primary_registrant[ $form_input ] ) |
|
925 | + && isset($primary_registrant[$form_input]) |
|
927 | 926 | ) { |
928 | - $input_value = $primary_registrant[ $form_input ]; |
|
927 | + $input_value = $primary_registrant[$form_input]; |
|
929 | 928 | } |
930 | 929 | // now attempt to save the input data |
931 | 930 | if ( |
@@ -967,55 +966,55 @@ discard block |
||
967 | 966 | // have we met before? |
968 | 967 | $attendee = $this->_find_existing_attendee( |
969 | 968 | $registration, |
970 | - $this->_attendee_data[ $reg_url_link ] |
|
969 | + $this->_attendee_data[$reg_url_link] |
|
971 | 970 | ); |
972 | 971 | // did we find an already existing record for this attendee ? |
973 | - if ( $attendee instanceof EE_Attendee ) { |
|
972 | + if ($attendee instanceof EE_Attendee) { |
|
974 | 973 | $attendee = $this->_update_existing_attendee_data( |
975 | 974 | $attendee, |
976 | - $this->_attendee_data[ $reg_url_link ] |
|
975 | + $this->_attendee_data[$reg_url_link] |
|
977 | 976 | ); |
978 | 977 | } else { |
979 | 978 | // ensure critical details are set for additional attendees |
980 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
979 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
981 | 980 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
982 | - $this->_attendee_data[ $reg_url_link ] |
|
981 | + $this->_attendee_data[$reg_url_link] |
|
983 | 982 | ) |
984 | - : $this->_attendee_data[ $reg_url_link ]; |
|
983 | + : $this->_attendee_data[$reg_url_link]; |
|
985 | 984 | $attendee = $this->_create_new_attendee( |
986 | 985 | $registration, |
987 | - $this->_attendee_data[ $reg_url_link ] |
|
986 | + $this->_attendee_data[$reg_url_link] |
|
988 | 987 | ); |
989 | 988 | } |
990 | 989 | // who's #1 ? |
991 | - if ( $att_nmbr === 1 ) { |
|
990 | + if ($att_nmbr === 1) { |
|
992 | 991 | $this->checkout->primary_attendee_obj = $attendee; |
993 | 992 | } |
994 | 993 | } |
995 | 994 | // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
996 | 995 | // add relation to registration, set attendee ID, and cache attendee |
997 | - $this->_associate_attendee_with_registration( $registration, $attendee ); |
|
996 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
998 | 997 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
999 | - if ( ! $registration->attendee() instanceof EE_Attendee ) { |
|
1000 | - EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ ); |
|
998 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
999 | + EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__); |
|
1001 | 1000 | return false; |
1002 | 1001 | } |
1003 | 1002 | /** @type EE_Registration_Processor $registration_processor */ |
1004 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1003 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1005 | 1004 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1006 | - $registration_processor->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
1005 | + $registration_processor->toggle_incomplete_registration_status_to_default($registration, false); |
|
1007 | 1006 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1008 | 1007 | $this->checkout->transaction->toggle_failed_transaction_status(); |
1009 | 1008 | // if we've gotten this far, then let's save what we have |
1010 | 1009 | $registration->save(); |
1011 | 1010 | // add relation between TXN and registration |
1012 | - $this->_associate_registration_with_transaction( $registration ); |
|
1011 | + $this->_associate_registration_with_transaction($registration); |
|
1013 | 1012 | } // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) { |
1014 | 1013 | |
1015 | - } else { |
|
1016 | - EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1014 | + } else { |
|
1015 | + EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1017 | 1016 | // remove malformed data |
1018 | - unset( $valid_data[ $reg_url_link ] ); |
|
1017 | + unset($valid_data[$reg_url_link]); |
|
1019 | 1018 | return false; |
1020 | 1019 | } |
1021 | 1020 | |
@@ -1044,14 +1043,14 @@ discard block |
||
1044 | 1043 | // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
1045 | 1044 | // allow for plugins to hook in and do their own processing of the form input. |
1046 | 1045 | // For plugins to bypass normal processing here, they just need to return a boolean value. |
1047 | - if ( apply_filters( |
|
1046 | + if (apply_filters( |
|
1048 | 1047 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
1049 | 1048 | false, |
1050 | 1049 | $registration, |
1051 | 1050 | $form_input, |
1052 | 1051 | $input_value, |
1053 | 1052 | $this |
1054 | - ) ) { |
|
1053 | + )) { |
|
1055 | 1054 | return true; |
1056 | 1055 | } |
1057 | 1056 | /* |
@@ -1059,14 +1058,14 @@ discard block |
||
1059 | 1058 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1060 | 1059 | */ |
1061 | 1060 | $answer_cache_id = $this->checkout->reg_url_link |
1062 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1061 | + ? $form_input.'-'.$registration->reg_url_link() |
|
1063 | 1062 | : $form_input; |
1064 | - $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
|
1065 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1063 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1064 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer |
|
1066 | 1065 | ? true |
1067 | 1066 | : false; |
1068 | 1067 | //rename form_inputs if they are EE_Attendee properties |
1069 | - switch( (string)$form_input ) { |
|
1068 | + switch ((string) $form_input) { |
|
1070 | 1069 | |
1071 | 1070 | case 'state' : |
1072 | 1071 | case 'STA_ID' : |
@@ -1081,32 +1080,32 @@ discard block |
||
1081 | 1080 | break; |
1082 | 1081 | |
1083 | 1082 | default : |
1084 | - $ATT_input = 'ATT_' . $form_input; |
|
1083 | + $ATT_input = 'ATT_'.$form_input; |
|
1085 | 1084 | //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1086 | - $attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false; |
|
1087 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1085 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1086 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1088 | 1087 | } |
1089 | 1088 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1090 | 1089 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1091 | 1090 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1092 | 1091 | // if this form input has a corresponding attendee property |
1093 | - if ( $attendee_property ) { |
|
1094 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1095 | - if ( $answer_is_obj ) { |
|
1092 | + if ($attendee_property) { |
|
1093 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1094 | + if ($answer_is_obj) { |
|
1096 | 1095 | // and delete the corresponding answer since we won't be storing this data in that object |
1097 | - $registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' ); |
|
1098 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1096 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1097 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1099 | 1098 | } |
1100 | 1099 | return true; |
1101 | - } elseif ( $answer_is_obj ) { |
|
1100 | + } elseif ($answer_is_obj) { |
|
1102 | 1101 | // save this data to the answer object |
1103 | - $this->_registration_answers[ $answer_cache_id ]->set_value( $input_value ); |
|
1104 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1102 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1103 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1105 | 1104 | return $result !== false ? true : false; |
1106 | 1105 | } else { |
1107 | - foreach ( $this->_registration_answers as $answer ) { |
|
1108 | - if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) { |
|
1109 | - $answer->set_value( $input_value ); |
|
1106 | + foreach ($this->_registration_answers as $answer) { |
|
1107 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1108 | + $answer->set_value($input_value); |
|
1110 | 1109 | $result = $answer->save(); |
1111 | 1110 | return $result !== false ? true : false; |
1112 | 1111 | } |
@@ -1128,15 +1127,15 @@ discard block |
||
1128 | 1127 | $form_input = '', |
1129 | 1128 | $input_value = '' |
1130 | 1129 | ) { |
1131 | - if ( empty( $input_value ) ) { |
|
1130 | + if (empty($input_value)) { |
|
1132 | 1131 | // if the form input isn't marked as being required, then just return |
1133 | - if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) { |
|
1132 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1134 | 1133 | return true; |
1135 | 1134 | } |
1136 | - switch ( $form_input ) { |
|
1135 | + switch ($form_input) { |
|
1137 | 1136 | case 'fname' : |
1138 | 1137 | EE_Error::add_error( |
1139 | - __( 'First Name is a required value.', 'event_espresso' ), |
|
1138 | + __('First Name is a required value.', 'event_espresso'), |
|
1140 | 1139 | __FILE__, |
1141 | 1140 | __FUNCTION__, |
1142 | 1141 | __LINE__ |
@@ -1145,7 +1144,7 @@ discard block |
||
1145 | 1144 | break; |
1146 | 1145 | case 'lname' : |
1147 | 1146 | EE_Error::add_error( |
1148 | - __( 'Last Name is a required value.', 'event_espresso' ), |
|
1147 | + __('Last Name is a required value.', 'event_espresso'), |
|
1149 | 1148 | __FILE__, |
1150 | 1149 | __FUNCTION__, |
1151 | 1150 | __LINE__ |
@@ -1154,7 +1153,7 @@ discard block |
||
1154 | 1153 | break; |
1155 | 1154 | case 'email' : |
1156 | 1155 | EE_Error::add_error( |
1157 | - __( 'Please enter a valid email address.', 'event_espresso' ), |
|
1156 | + __('Please enter a valid email address.', 'event_espresso'), |
|
1158 | 1157 | __FILE__, |
1159 | 1158 | __FUNCTION__, |
1160 | 1159 | __LINE__ |
@@ -1176,30 +1175,30 @@ discard block |
||
1176 | 1175 | * @return boolean|EE_Attendee |
1177 | 1176 | * @throws \EE_Error |
1178 | 1177 | */ |
1179 | - private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1178 | + private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1180 | 1179 | $existing_attendee = null; |
1181 | 1180 | // if none of the critical properties are set in the incoming attendee data... |
1182 | 1181 | // then attempt to copy them from the primary attendee |
1183 | 1182 | if ( |
1184 | 1183 | $this->checkout->primary_attendee_obj instanceof EE_Attendee |
1185 | - && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] ) |
|
1184 | + && ! isset($attendee_data['ATT_fname'], $attendee_data['ATT_email']) |
|
1186 | 1185 | ) { |
1187 | 1186 | return $this->checkout->primary_attendee_obj; |
1188 | 1187 | } |
1189 | 1188 | // does this attendee already exist in the db ? |
1190 | 1189 | // we're searching using a combination of first name, last name, AND email address |
1191 | - $ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] ) |
|
1190 | + $ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname']) |
|
1192 | 1191 | ? $attendee_data['ATT_fname'] |
1193 | 1192 | : ''; |
1194 | - $ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] ) |
|
1193 | + $ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname']) |
|
1195 | 1194 | ? $attendee_data['ATT_lname'] |
1196 | 1195 | : ''; |
1197 | - $ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] ) |
|
1196 | + $ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email']) |
|
1198 | 1197 | ? $attendee_data['ATT_email'] |
1199 | 1198 | : ''; |
1200 | 1199 | // but only if those have values |
1201 | - if ( $ATT_fname && $ATT_lname && $ATT_email ) { |
|
1202 | - $existing_attendee = EEM_Attendee::instance()->find_existing_attendee( array( |
|
1200 | + if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
1201 | + $existing_attendee = EEM_Attendee::instance()->find_existing_attendee(array( |
|
1203 | 1202 | 'ATT_fname' => $ATT_fname, |
1204 | 1203 | 'ATT_lname' => $ATT_lname, |
1205 | 1204 | 'ATT_email' => $ATT_email |
@@ -1223,13 +1222,13 @@ discard block |
||
1223 | 1222 | * @return \EE_Attendee |
1224 | 1223 | * @throws \EE_Error |
1225 | 1224 | */ |
1226 | - private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) { |
|
1225 | + private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) { |
|
1227 | 1226 | // first remove fname, lname, and email from attendee data |
1228 | - $dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1227 | + $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1229 | 1228 | // now loop thru what's left and add to attendee CPT |
1230 | - foreach ( $attendee_data as $property_name => $property_value ) { |
|
1231 | - if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) { |
|
1232 | - $existing_attendee->set( $property_name, $property_value ); |
|
1229 | + foreach ($attendee_data as $property_name => $property_value) { |
|
1230 | + if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) { |
|
1231 | + $existing_attendee->set($property_name, $property_value); |
|
1233 | 1232 | } |
1234 | 1233 | } |
1235 | 1234 | // better save that now |
@@ -1247,11 +1246,11 @@ discard block |
||
1247 | 1246 | * @return void |
1248 | 1247 | * @throws \EE_Error |
1249 | 1248 | */ |
1250 | - private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) { |
|
1249 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) { |
|
1251 | 1250 | // add relation to attendee |
1252 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1253 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1254 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1251 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1252 | + $registration->set_attendee_id($attendee->ID()); |
|
1253 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1255 | 1254 | } |
1256 | 1255 | |
1257 | 1256 | |
@@ -1263,10 +1262,10 @@ discard block |
||
1263 | 1262 | * @return void |
1264 | 1263 | * @throws \EE_Error |
1265 | 1264 | */ |
1266 | - private function _associate_registration_with_transaction( EE_Registration $registration ) { |
|
1265 | + private function _associate_registration_with_transaction(EE_Registration $registration) { |
|
1267 | 1266 | // add relation to attendee |
1268 | - $this->checkout->transaction->_add_relation_to( $registration, 'Registration' ); |
|
1269 | - $this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration ); |
|
1267 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1268 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1270 | 1269 | } |
1271 | 1270 | |
1272 | 1271 | |
@@ -1279,14 +1278,14 @@ discard block |
||
1279 | 1278 | * @return array |
1280 | 1279 | * @throws \EE_Error |
1281 | 1280 | */ |
1282 | - private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) { |
|
1281 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) { |
|
1283 | 1282 | // bare minimum critical details include first name, last name, email address |
1284 | - $critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1283 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1285 | 1284 | // add address info to critical details? |
1286 | - if ( apply_filters( |
|
1285 | + if (apply_filters( |
|
1287 | 1286 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
1288 | 1287 | false |
1289 | - ) ) { |
|
1288 | + )) { |
|
1290 | 1289 | $address_details = array( |
1291 | 1290 | 'ATT_address', |
1292 | 1291 | 'ATT_address2', |
@@ -1296,13 +1295,13 @@ discard block |
||
1296 | 1295 | 'ATT_zip', |
1297 | 1296 | 'ATT_phone' |
1298 | 1297 | ); |
1299 | - $critical_attendee_details = array_merge( $critical_attendee_details, $address_details ); |
|
1298 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1300 | 1299 | } |
1301 | - foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
|
1302 | - if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
|
1303 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1300 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1301 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1302 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1304 | 1303 | ) { |
1305 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1304 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1306 | 1305 | $critical_attendee_detail |
1307 | 1306 | ); |
1308 | 1307 | } |
@@ -1320,11 +1319,11 @@ discard block |
||
1320 | 1319 | * @return \EE_Attendee |
1321 | 1320 | * @throws \EE_Error |
1322 | 1321 | */ |
1323 | - private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1322 | + private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1324 | 1323 | // create new attendee object |
1325 | - $new_attendee = EE_Attendee::new_instance( $attendee_data ); |
|
1324 | + $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
1326 | 1325 | // set author to event creator |
1327 | - $new_attendee->set( 'ATT_author', $registration->event()->wp_user() ); |
|
1326 | + $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
1328 | 1327 | $new_attendee->save(); |
1329 | 1328 | return $new_attendee; |
1330 | 1329 | } |
@@ -1341,7 +1340,7 @@ discard block |
||
1341 | 1340 | */ |
1342 | 1341 | public function update_reg_step() { |
1343 | 1342 | // save everything |
1344 | - if ( $this->process_reg_step() ) { |
|
1343 | + if ($this->process_reg_step()) { |
|
1345 | 1344 | $this->checkout->redirect = true; |
1346 | 1345 | $this->checkout->redirect_url = add_query_arg( |
1347 | 1346 | array( |
@@ -1350,7 +1349,7 @@ discard block |
||
1350 | 1349 | ), |
1351 | 1350 | $this->checkout->thank_you_page_url |
1352 | 1351 | ); |
1353 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1352 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1354 | 1353 | return true; |
1355 | 1354 | } |
1356 | 1355 | return false; |
@@ -30,6 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * |
32 | 32 | * @param string $status |
33 | + * @return void |
|
33 | 34 | */ |
34 | 35 | public function set_status($status); |
35 | 36 | |
@@ -37,6 +38,7 @@ discard block |
||
37 | 38 | * Sets the response from the gateway, which is displayable to the user. |
38 | 39 | * Eg, 'payment was approved', 'payment failed because invalid date', etc. |
39 | 40 | * @param string $response |
41 | + * @return void |
|
40 | 42 | */ |
41 | 43 | public function set_gateway_response($response); |
42 | 44 | |
@@ -44,6 +46,7 @@ discard block |
||
44 | 46 | * Sets the response details, usually the entire contents of an IPN request, |
45 | 47 | * or data about the direct payment data sent |
46 | 48 | * @param mixed $response_details |
49 | + * @return void |
|
47 | 50 | */ |
48 | 51 | public function set_details($response_details); |
49 | 52 | |
@@ -56,12 +59,14 @@ discard block |
||
56 | 59 | /** |
57 | 60 | * Sets the URl to redirect to, to process payment |
58 | 61 | * @param string $url |
62 | + * @return void |
|
59 | 63 | */ |
60 | 64 | public function set_redirect_url($url); |
61 | 65 | |
62 | 66 | /** |
63 | 67 | * Sets the argument which should be passed to the redirect url (ie, usually POST variables) |
64 | 68 | * @param array $args |
69 | + * @return void |
|
65 | 70 | */ |
66 | 71 | public function set_redirect_args($args); |
67 | 72 | |
@@ -80,25 +85,27 @@ discard block |
||
80 | 85 | /** |
81 | 86 | * Sets the amount for this payment |
82 | 87 | * @param float $amount |
88 | + * @return void |
|
83 | 89 | */ |
84 | 90 | public function set_amount($amount); |
85 | 91 | |
86 | 92 | /** |
87 | 93 | * Sets the ID of the gateway transaction |
88 | 94 | * @param string $txn_id |
95 | + * @return void |
|
89 | 96 | */ |
90 | 97 | public function set_txn_id_chq_nmbr($txn_id); |
91 | 98 | |
92 | 99 | /** |
93 | 100 | * Sets a string for some extra accounting info |
94 | 101 | * @param string $extra_accounting_info |
102 | + * @return void |
|
95 | 103 | */ |
96 | 104 | public function set_extra_accntng($extra_accounting_info); |
97 | 105 | |
98 | 106 | /** |
99 | 107 | * Gets the first event for this payment (it's possible that it could be for multiple) |
100 | 108 | * |
101 | - * @param EE_Payment $payment |
|
102 | 109 | * @return EE_Event|null |
103 | 110 | */ |
104 | 111 | public function get_first_event(); |
@@ -106,7 +113,6 @@ discard block |
||
106 | 113 | /** |
107 | 114 | * Gets the name of the first event for which is being paid |
108 | 115 | * |
109 | - * @param EE_Payment $payment |
|
110 | 116 | * @return string |
111 | 117 | */ |
112 | 118 | public function get_first_event_name(); |
@@ -139,22 +145,27 @@ discard block |
||
139 | 145 | interface EEMI_Payment { |
140 | 146 | /** |
141 | 147 | * returns a string for the approved status |
148 | + * @return string |
|
142 | 149 | */ |
143 | 150 | public function approved_status(); |
144 | 151 | /** |
145 | 152 | * returns a string for the pending status |
153 | + * @return string |
|
146 | 154 | */ |
147 | 155 | public function pending_status(); |
148 | 156 | /** |
149 | 157 | * returns a string for the cancelled status |
158 | + * @return string |
|
150 | 159 | */ |
151 | 160 | public function cancelled_status(); |
152 | 161 | /** |
153 | 162 | * returns a string for the failed status |
163 | + * @return string |
|
154 | 164 | */ |
155 | 165 | public function failed_status(); |
156 | 166 | /** |
157 | 167 | * returns a string for the declined status |
168 | + * @return string |
|
158 | 169 | */ |
159 | 170 | public function declined_status(); |
160 | 171 | |
@@ -208,6 +219,10 @@ discard block |
||
208 | 219 | * Interface for an event being registered for |
209 | 220 | */ |
210 | 221 | interface EEI_Event { |
222 | + |
|
223 | + /** |
|
224 | + * @return boolean |
|
225 | + */ |
|
211 | 226 | public function name(); |
212 | 227 | } |
213 | 228 |
@@ -95,34 +95,34 @@ |
||
95 | 95 | */ |
96 | 96 | public function set_extra_accntng($extra_accounting_info); |
97 | 97 | |
98 | - /** |
|
99 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
100 | - * |
|
101 | - * @param EE_Payment $payment |
|
102 | - * @return EE_Event|null |
|
103 | - */ |
|
104 | - public function get_first_event(); |
|
105 | - |
|
106 | - /** |
|
107 | - * Gets the name of the first event for which is being paid |
|
108 | - * |
|
109 | - * @param EE_Payment $payment |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function get_first_event_name(); |
|
113 | - |
|
114 | - /** |
|
115 | - * Returns the payment's transaction's primary registration |
|
116 | - * |
|
117 | - * @return EE_Registration|null |
|
118 | - */ |
|
119 | - public function get_primary_registration(); |
|
120 | - |
|
121 | - /** |
|
122 | - * Gets the payment's transaction's primary registration's attendee, or null |
|
123 | - * @return EE_Attendee|null |
|
124 | - */ |
|
125 | - public function get_primary_attendee(); |
|
98 | + /** |
|
99 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
100 | + * |
|
101 | + * @param EE_Payment $payment |
|
102 | + * @return EE_Event|null |
|
103 | + */ |
|
104 | + public function get_first_event(); |
|
105 | + |
|
106 | + /** |
|
107 | + * Gets the name of the first event for which is being paid |
|
108 | + * |
|
109 | + * @param EE_Payment $payment |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function get_first_event_name(); |
|
113 | + |
|
114 | + /** |
|
115 | + * Returns the payment's transaction's primary registration |
|
116 | + * |
|
117 | + * @return EE_Registration|null |
|
118 | + */ |
|
119 | + public function get_primary_registration(); |
|
120 | + |
|
121 | + /** |
|
122 | + * Gets the payment's transaction's primary registration's attendee, or null |
|
123 | + * @return EE_Attendee|null |
|
124 | + */ |
|
125 | + public function get_primary_attendee(); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
22 | 22 | */ |
23 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
24 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
25 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @return EE_Payment |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
38 | - return new self( $props_n_values, true, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $TXN_ID |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
51 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
50 | + public function set_transaction_id($TXN_ID = 0) { |
|
51 | + $this->set('TXN_ID', $TXN_ID); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | 62 | public function transaction() { |
63 | - return $this->get_first_related( 'Transaction' ); |
|
63 | + return $this->get_first_related('Transaction'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $STS_ID |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function set_status( $STS_ID = '' ) { |
|
76 | - $this->set( 'STS_ID', $STS_ID ); |
|
75 | + public function set_status($STS_ID = '') { |
|
76 | + $this->set('STS_ID', $STS_ID); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $timestamp |
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | - public function set_timestamp( $timestamp = 0 ) { |
|
89 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
88 | + public function set_timestamp($timestamp = 0) { |
|
89 | + $this->set('PAY_timestamp', $timestamp); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $PAY_source |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - public function set_source( $PAY_source = '' ) { |
|
102 | - $this->set( 'PAY_source', $PAY_source ); |
|
101 | + public function set_source($PAY_source = '') { |
|
102 | + $this->set('PAY_source', $PAY_source); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function set_amount( $amount = 0.00 ) { |
|
115 | - $this->set( 'PAY_amount', (float)$amount ); |
|
114 | + public function set_amount($amount = 0.00) { |
|
115 | + $this->set('PAY_amount', (float) $amount); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $gateway_response |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function set_gateway_response( $gateway_response = '' ) { |
|
128 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
127 | + public function set_gateway_response($gateway_response = '') { |
|
128 | + $this->set('PAY_gateway_response', $gateway_response); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ), |
149 | 149 | '4.6.0' |
150 | 150 | ); |
151 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
151 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string $txn_id_chq_nmbr |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
164 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
163 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
164 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $po_number |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_po_number( $po_number = '' ) { |
|
177 | - $this->set( 'PAY_po_number', $po_number ); |
|
176 | + public function set_po_number($po_number = '') { |
|
177 | + $this->set('PAY_po_number', $po_number); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string $extra_accntng |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
190 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
189 | + public function set_extra_accntng($extra_accntng = '') { |
|
190 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param bool $via_admin |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_payment_made_via_admin( $via_admin = false ) { |
|
203 | - if ( $via_admin ) { |
|
204 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_admin ); |
|
202 | + public function set_payment_made_via_admin($via_admin = false) { |
|
203 | + if ($via_admin) { |
|
204 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
205 | 205 | } else { |
206 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_cart ); |
|
206 | + $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string|array $details |
217 | 217 | * @throws \EE_Error |
218 | 218 | */ |
219 | - public function set_details( $details = '' ) { |
|
220 | - if ( is_array( $details ) ) { |
|
221 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' ) ); |
|
219 | + public function set_details($details = '') { |
|
220 | + if (is_array($details)) { |
|
221 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
222 | 222 | } else { |
223 | - $details = wp_strip_all_tags( $details ); |
|
223 | + $details = wp_strip_all_tags($details); |
|
224 | 224 | } |
225 | - $this->set( 'PAY_details', $details ); |
|
225 | + $this->set('PAY_details', $details); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $redirect_url |
234 | 234 | * @throws \EE_Error |
235 | 235 | */ |
236 | - public function set_redirect_url( $redirect_url ) { |
|
237 | - $this->set( 'PAY_redirect_url', $redirect_url ); |
|
236 | + public function set_redirect_url($redirect_url) { |
|
237 | + $this->set('PAY_redirect_url', $redirect_url); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array $redirect_args |
246 | 246 | * @throws \EE_Error |
247 | 247 | */ |
248 | - public function set_redirect_args( $redirect_args ) { |
|
249 | - $this->set( 'PAY_redirect_args', $redirect_args ); |
|
248 | + public function set_redirect_args($redirect_args) { |
|
249 | + $this->set('PAY_redirect_args', $redirect_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function TXN_ID() { |
261 | - return $this->get( 'TXN_ID' ); |
|
261 | + return $this->get('TXN_ID'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @throws \EE_Error |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - return $this->get( 'STS_ID' ); |
|
273 | + return $this->get('STS_ID'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | 284 | public function STS_ID() { |
285 | - return $this->get( 'STS_ID' ); |
|
285 | + return $this->get('STS_ID'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @return string |
297 | 297 | * @throws \EE_Error |
298 | 298 | */ |
299 | - public function timestamp( $dt_frmt = '', $tm_frmt = '' ) { |
|
300 | - return $this->get_i18n_datetime( 'PAY_timestamp', trim( $dt_frmt . ' ' . $tm_frmt) ); |
|
299 | + public function timestamp($dt_frmt = '', $tm_frmt = '') { |
|
300 | + return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt.' '.$tm_frmt)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | 311 | public function source() { |
312 | - return $this->get( 'PAY_source' ); |
|
312 | + return $this->get('PAY_source'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | 324 | public function amount() { |
325 | - return (float)$this->get( 'PAY_amount' ); |
|
325 | + return (float) $this->get('PAY_amount'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @throws \EE_Error |
333 | 333 | */ |
334 | 334 | public function amount_no_code() { |
335 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
335 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws \EE_Error |
345 | 345 | */ |
346 | 346 | public function gateway_response() { |
347 | - return $this->get( 'PAY_gateway_response' ); |
|
347 | + return $this->get('PAY_gateway_response'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @throws \EE_Error |
357 | 357 | */ |
358 | 358 | public function txn_id_chq_nmbr() { |
359 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
359 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | 370 | public function po_number() { |
371 | - return $this->get( 'PAY_po_number' ); |
|
371 | + return $this->get('PAY_po_number'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @throws \EE_Error |
381 | 381 | */ |
382 | 382 | public function extra_accntng() { |
383 | - return $this->get( 'PAY_extra_accntng' ); |
|
383 | + return $this->get('PAY_extra_accntng'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | 394 | public function payment_made_via_admin() { |
395 | - return ( $this->get( 'PAY_source' ) === EEM_Payment_Method::scope_admin ); |
|
395 | + return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @throws \EE_Error |
405 | 405 | */ |
406 | 406 | public function details() { |
407 | - return $this->get( 'PAY_details' ); |
|
407 | + return $this->get('PAY_details'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function redirect_url() { |
419 | - return $this->get( 'PAY_redirect_url' ); |
|
419 | + return $this->get('PAY_redirect_url'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | 430 | public function redirect_args() { |
431 | - return $this->get( 'PAY_redirect_args' ); |
|
431 | + return $this->get('PAY_redirect_args'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | - public function e_pretty_status( $show_icons = false ) { |
|
444 | - echo $this->pretty_status( $show_icons ); |
|
443 | + public function e_pretty_status($show_icons = false) { |
|
444 | + echo $this->pretty_status($show_icons); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return string |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - public function pretty_status( $show_icons = false ) { |
|
456 | + public function pretty_status($show_icons = false) { |
|
457 | 457 | $status = EEM_Status::instance()->localized_status( |
458 | - array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), |
|
458 | + array($this->STS_ID() => __('unknown', 'event_espresso')), |
|
459 | 459 | false, |
460 | 460 | 'sentence' |
461 | 461 | ); |
462 | 462 | $icon = ''; |
463 | - switch ( $this->STS_ID() ) { |
|
463 | + switch ($this->STS_ID()) { |
|
464 | 464 | case EEM_Payment::status_id_approved: |
465 | 465 | $icon = $show_icons |
466 | 466 | ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | : ''; |
483 | 483 | break; |
484 | 484 | } |
485 | - return $icon . $status[ $this->STS_ID() ]; |
|
485 | + return $icon.$status[$this->STS_ID()]; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | 496 | public function is_approved() { |
497 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
497 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return boolean whether the status of this payment equals the status id |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function status_is( $STS_ID ) { |
|
511 | + protected function status_is($STS_ID) { |
|
512 | 512 | return $STS_ID === $this->STS_ID() ? true : false; |
513 | 513 | } |
514 | 514 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function is_pending() { |
524 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
524 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | 535 | public function is_cancelled() { |
536 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
536 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \EE_Error |
546 | 546 | */ |
547 | 547 | public function is_declined() { |
548 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
548 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | 559 | public function is_failed() { |
560 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
560 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | 583 | public function status_obj() { |
584 | - return $this->get_first_related( 'Status' ); |
|
584 | + return $this->get_first_related('Status'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * @return EE_Extra_Meta |
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | - public function extra_meta( $query_params = array() ) { |
|
597 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
596 | + public function extra_meta($query_params = array()) { |
|
597 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function payment_method() { |
611 | - return $this->get_first_related( 'Payment_Method' ); |
|
611 | + return $this->get_first_related('Payment_Method'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @return string html |
627 | 627 | * @throws \EE_Error |
628 | 628 | */ |
629 | - public function redirect_form( $inside_form_html = null ) { |
|
629 | + public function redirect_form($inside_form_html = null) { |
|
630 | 630 | $redirect_url = $this->redirect_url(); |
631 | - if ( ! empty( $redirect_url ) ) { |
|
631 | + if ( ! empty($redirect_url)) { |
|
632 | 632 | // what ? no inner form content? |
633 | - if ( $inside_form_html === null ) { |
|
633 | + if ($inside_form_html === null) { |
|
634 | 634 | $inside_form_html = EEH_HTML::p( |
635 | 635 | sprintf( |
636 | 636 | __( |
637 | 637 | 'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', |
638 | 638 | 'event_espresso' |
639 | 639 | ), |
640 | - EEH_HTML::br( 2 ), |
|
640 | + EEH_HTML::br(2), |
|
641 | 641 | '<input type="submit" value="', |
642 | 642 | '">' |
643 | 643 | ), |
@@ -653,22 +653,22 @@ discard block |
||
653 | 653 | ); |
654 | 654 | //if it's a GET request, we need to remove all the GET params in the querystring |
655 | 655 | //and put them into the form instead |
656 | - if ( $method === 'GET' ) { |
|
657 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
656 | + if ($method === 'GET') { |
|
657 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
658 | 658 | $get_params = null; |
659 | - parse_str( $querystring, $get_params ); |
|
660 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
661 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
659 | + parse_str($querystring, $get_params); |
|
660 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
661 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
662 | 662 | } |
663 | - $form = EEH_HTML::nl( 1 ) |
|
663 | + $form = EEH_HTML::nl(1) |
|
664 | 664 | . '<form method="' |
665 | 665 | . $method |
666 | 666 | . '" name="gateway_form" action="' |
667 | 667 | . $redirect_url |
668 | 668 | . '">'; |
669 | - $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
|
669 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
670 | 670 | $form .= $inside_form_html; |
671 | - $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
|
671 | + $form .= EEH_HTML::nl( -1 ).'</form>'.EEH_HTML::nl( -1 ); |
|
672 | 672 | return $form; |
673 | 673 | } else { |
674 | 674 | return null; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function redirect_args_as_inputs() { |
688 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
688 | + return $this->_args_as_inputs($this->redirect_args()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param array $args key-value pairs |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - protected function _args_as_inputs( $args ) { |
|
700 | + protected function _args_as_inputs($args) { |
|
701 | 701 | $html = ''; |
702 | - if ( $args !== null && is_array( $args ) ) { |
|
703 | - foreach ( $args as $name => $value ) { |
|
704 | - $html .= EEH_HTML::nl( 0 ) |
|
702 | + if ($args !== null && is_array($args)) { |
|
703 | + foreach ($args as $name => $value) { |
|
704 | + $html .= EEH_HTML::nl(0) |
|
705 | 705 | . '<input type="hidden" name="' |
706 | 706 | . $name |
707 | 707 | . '" value="' |
708 | - . esc_attr( $value ) |
|
708 | + . esc_attr($value) |
|
709 | 709 | . '"/>'; |
710 | 710 | } |
711 | 711 | } |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @access private |
735 | 735 | * @param mixed $item |
736 | 736 | */ |
737 | - private function _strip_all_tags_within_array( &$item ) { |
|
738 | - if ( is_object( $item ) ) { |
|
739 | - $item = (array)$item; |
|
737 | + private function _strip_all_tags_within_array(&$item) { |
|
738 | + if (is_object($item)) { |
|
739 | + $item = (array) $item; |
|
740 | 740 | } |
741 | - if ( is_array( $item ) ) { |
|
742 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
741 | + if (is_array($item)) { |
|
742 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
743 | 743 | } else { |
744 | - $item = wp_strip_all_tags( $item ); |
|
744 | + $item = wp_strip_all_tags($item); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $original_status = EEH_Array::is_set( |
759 | 759 | $this->_props_n_values_provided_in_constructor, |
760 | 760 | 'STS_ID', |
761 | - $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() |
|
761 | + $this->get_model()->field_settings_for('STS_ID')->get_default_value() |
|
762 | 762 | ); |
763 | 763 | $current_status = $this->status(); |
764 | 764 | if ( |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | * @return mixed |
785 | 785 | * @throws \EE_Error |
786 | 786 | */ |
787 | - public function get_pretty( $field_name, $extra_cache_ref = null ) { |
|
788 | - if ( $field_name === 'PAY_gateway' ) { |
|
789 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
787 | + public function get_pretty($field_name, $extra_cache_ref = null) { |
|
788 | + if ($field_name === 'PAY_gateway') { |
|
789 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
790 | 790 | } |
791 | - return $this->_get_cached_property( $field_name, true, $extra_cache_ref ); |
|
791 | + return $this->_get_cached_property($field_name, true, $extra_cache_ref); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @return EE_Registration_Payment[] |
801 | 801 | * @throws \EE_Error |
802 | 802 | */ |
803 | - public function registration_payments( $query_params = array() ) { |
|
804 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
803 | + public function registration_payments($query_params = array()) { |
|
804 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | public function get_primary_attendee() |
863 | 863 | { |
864 | 864 | $primary_reg = $this->get_primary_registration(); |
865 | - if( $primary_reg instanceof EE_Registration) { |
|
865 | + if ($primary_reg instanceof EE_Registration) { |
|
866 | 866 | return $primary_reg->attendee(); |
867 | 867 | } |
868 | 868 | return null; |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
662 | 662 | } |
663 | 663 | $form = EEH_HTML::nl( 1 ) |
664 | - . '<form method="' |
|
665 | - . $method |
|
666 | - . '" name="gateway_form" action="' |
|
667 | - . $redirect_url |
|
668 | - . '">'; |
|
664 | + . '<form method="' |
|
665 | + . $method |
|
666 | + . '" name="gateway_form" action="' |
|
667 | + . $redirect_url |
|
668 | + . '">'; |
|
669 | 669 | $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
670 | 670 | $form .= $inside_form_html; |
671 | 671 | $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
@@ -702,11 +702,11 @@ discard block |
||
702 | 702 | if ( $args !== null && is_array( $args ) ) { |
703 | 703 | foreach ( $args as $name => $value ) { |
704 | 704 | $html .= EEH_HTML::nl( 0 ) |
705 | - . '<input type="hidden" name="' |
|
706 | - . $name |
|
707 | - . '" value="' |
|
708 | - . esc_attr( $value ) |
|
709 | - . '"/>'; |
|
705 | + . '<input type="hidden" name="' |
|
706 | + . $name |
|
707 | + . '" value="' |
|
708 | + . esc_attr( $value ) |
|
709 | + . '"/>'; |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | return $html; |
@@ -806,64 +806,64 @@ discard block |
||
806 | 806 | |
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | - * |
|
812 | - * @return EE_Event|null |
|
813 | - */ |
|
814 | - public function get_first_event() |
|
815 | - { |
|
816 | - $transaction = $this->transaction(); |
|
817 | - if ($transaction instanceof EE_Transaction) { |
|
818 | - $primary_registrant = $transaction->primary_registration(); |
|
819 | - if ($primary_registrant instanceof EE_Registration) { |
|
820 | - return $primary_registrant->event_obj(); |
|
821 | - } |
|
822 | - } |
|
823 | - return null; |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - |
|
828 | - /** |
|
829 | - * Gets the name of the first event for which is being paid |
|
830 | - * |
|
831 | - * @return string |
|
832 | - */ |
|
833 | - public function get_first_event_name() |
|
834 | - { |
|
835 | - $event = $this->get_first_event(); |
|
836 | - return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * Returns the payment's transaction's primary registration |
|
843 | - * @return EE_Registration|null |
|
844 | - */ |
|
845 | - public function get_primary_registration() |
|
846 | - { |
|
847 | - if ($this->transaction() instanceof EE_Transaction) { |
|
848 | - return $this->transaction()->primary_registration(); |
|
849 | - } |
|
850 | - return null; |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - |
|
855 | - /** |
|
856 | - * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | - * @return EE_Attendee|null |
|
858 | - */ |
|
859 | - public function get_primary_attendee() |
|
860 | - { |
|
861 | - $primary_reg = $this->get_primary_registration(); |
|
862 | - if( $primary_reg instanceof EE_Registration) { |
|
863 | - return $primary_reg->attendee(); |
|
864 | - } |
|
865 | - return null; |
|
866 | - } |
|
809 | + /** |
|
810 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | + * |
|
812 | + * @return EE_Event|null |
|
813 | + */ |
|
814 | + public function get_first_event() |
|
815 | + { |
|
816 | + $transaction = $this->transaction(); |
|
817 | + if ($transaction instanceof EE_Transaction) { |
|
818 | + $primary_registrant = $transaction->primary_registration(); |
|
819 | + if ($primary_registrant instanceof EE_Registration) { |
|
820 | + return $primary_registrant->event_obj(); |
|
821 | + } |
|
822 | + } |
|
823 | + return null; |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + |
|
828 | + /** |
|
829 | + * Gets the name of the first event for which is being paid |
|
830 | + * |
|
831 | + * @return string |
|
832 | + */ |
|
833 | + public function get_first_event_name() |
|
834 | + { |
|
835 | + $event = $this->get_first_event(); |
|
836 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * Returns the payment's transaction's primary registration |
|
843 | + * @return EE_Registration|null |
|
844 | + */ |
|
845 | + public function get_primary_registration() |
|
846 | + { |
|
847 | + if ($this->transaction() instanceof EE_Transaction) { |
|
848 | + return $this->transaction()->primary_registration(); |
|
849 | + } |
|
850 | + return null; |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + |
|
855 | + /** |
|
856 | + * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | + * @return EE_Attendee|null |
|
858 | + */ |
|
859 | + public function get_primary_attendee() |
|
860 | + { |
|
861 | + $primary_reg = $this->get_primary_registration(); |
|
862 | + if( $primary_reg instanceof EE_Registration) { |
|
863 | + return $primary_reg->attendee(); |
|
864 | + } |
|
865 | + return null; |
|
866 | + } |
|
867 | 867 | } |
868 | 868 | /* End of file EE_Payment.class.php */ |
869 | 869 | /* Location: /includes/classes/EE_Payment.class.php */ |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $props_n_values incoming values |
16 | 16 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
17 | 17 | * used.) |
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
18 | + * @param string[] $date_formats incoming date_formats in an array where the first value is the |
|
19 | 19 | * date_format and the second value is the time format |
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Gets all the extra meta info on this payment |
591 | 591 | * |
592 | 592 | * @param array $query_params like EEM_Base::get_all |
593 | - * @return EE_Extra_Meta |
|
593 | + * @return EE_Base_Class[] |
|
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | 596 | public function extra_meta( $query_params = array() ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Returns the payment's transaction's primary registration |
843 | - * @return EE_Registration|null |
|
843 | + * @return EE_Base_Class|null |
|
844 | 844 | */ |
845 | 845 | public function get_primary_registration() |
846 | 846 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * You can specify $default is case you haven't found the extra meta |
61 | 61 | * @param string $meta_key |
62 | 62 | * @param boolean $single |
63 | - * @param mixed $default if we don't find anything, what should we return? |
|
63 | + * @param boolean $default if we don't find anything, what should we return? |
|
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | 66 | public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
@@ -72,9 +72,7 @@ discard block |
||
72 | 72 | * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
73 | 73 | * to see what options are available. |
74 | 74 | * @param string $field_name |
75 | - * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | - * (in cases where the same property may be used for different outputs |
|
77 | - * - i.e. datetime, money etc.) |
|
75 | + * @param string|null $extra_cache_ref |
|
78 | 76 | * @return mixed |
79 | 77 | * @throws \EE_Error |
80 | 78 | */ |
@@ -120,6 +118,7 @@ discard block |
||
120 | 118 | * |
121 | 119 | * @param EE_Request $request |
122 | 120 | * @param EE_Response $response |
121 | + * @return void |
|
123 | 122 | */ |
124 | 123 | public function handle_response( EE_Request $request, EE_Response $response ); |
125 | 124 | } |
@@ -203,26 +202,78 @@ discard block |
||
203 | 202 | * Interface EEI_Attendee |
204 | 203 | */ |
205 | 204 | interface EEI_Attendee { |
205 | + |
|
206 | + /** |
|
207 | + * @return string |
|
208 | + */ |
|
206 | 209 | public function fname(); |
210 | + |
|
211 | + /** |
|
212 | + * @return string |
|
213 | + */ |
|
207 | 214 | public function lname(); |
215 | + |
|
216 | + /** |
|
217 | + * @return string |
|
218 | + */ |
|
208 | 219 | public function full_name(); |
220 | + |
|
221 | + /** |
|
222 | + * @return string |
|
223 | + */ |
|
209 | 224 | public function email(); |
225 | + |
|
226 | + /** |
|
227 | + * @return string |
|
228 | + */ |
|
210 | 229 | public function phone(); |
230 | + |
|
231 | + /** |
|
232 | + * @return string |
|
233 | + */ |
|
211 | 234 | public function address(); |
235 | + |
|
236 | + /** |
|
237 | + * @return string |
|
238 | + */ |
|
212 | 239 | public function address2(); |
240 | + |
|
241 | + /** |
|
242 | + * @return string |
|
243 | + */ |
|
213 | 244 | public function city(); |
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
214 | 249 | public function state_ID(); |
250 | + |
|
251 | + /** |
|
252 | + * @return string |
|
253 | + */ |
|
215 | 254 | public function state_name(); |
216 | 255 | /** |
217 | 256 | * @return EE_State |
218 | 257 | */ |
219 | 258 | public function state_obj(); |
259 | + |
|
260 | + /** |
|
261 | + * @return string |
|
262 | + */ |
|
220 | 263 | public function country_ID(); |
264 | + |
|
265 | + /** |
|
266 | + * @return string |
|
267 | + */ |
|
221 | 268 | public function country_name(); |
222 | 269 | /** |
223 | 270 | * @return EE_Country |
224 | 271 | */ |
225 | 272 | public function country_obj(); |
273 | + |
|
274 | + /** |
|
275 | + * @return string |
|
276 | + */ |
|
226 | 277 | public function zip(); |
227 | 278 | } |
228 | 279 | |
@@ -234,9 +285,25 @@ discard block |
||
234 | 285 | * Interface EEI_Contact |
235 | 286 | */ |
236 | 287 | interface EEI_Contact { |
288 | + |
|
289 | + /** |
|
290 | + * @return string |
|
291 | + */ |
|
237 | 292 | public function fname(); |
293 | + |
|
294 | + /** |
|
295 | + * @return string |
|
296 | + */ |
|
238 | 297 | public function lname(); |
298 | + |
|
299 | + /** |
|
300 | + * @return string |
|
301 | + */ |
|
239 | 302 | public function email(); |
303 | + |
|
304 | + /** |
|
305 | + * @return string |
|
306 | + */ |
|
240 | 307 | public function phone(); |
241 | 308 | } |
242 | 309 | |
@@ -263,24 +330,64 @@ discard block |
||
263 | 330 | * Interface EEI_Address |
264 | 331 | */ |
265 | 332 | interface EEI_Address { |
333 | + |
|
334 | + /** |
|
335 | + * @return string |
|
336 | + */ |
|
266 | 337 | public function address(); |
338 | + |
|
339 | + /** |
|
340 | + * @return string |
|
341 | + */ |
|
267 | 342 | public function address2(); |
343 | + |
|
344 | + /** |
|
345 | + * @return string |
|
346 | + */ |
|
268 | 347 | public function city(); |
269 | 348 | /** |
270 | 349 | * @return EE_State |
271 | 350 | */ |
272 | 351 | public function state_obj(); |
273 | 352 | public function state_ID(); |
353 | + |
|
354 | + /** |
|
355 | + * @return string |
|
356 | + */ |
|
274 | 357 | public function state_name(); |
358 | + |
|
359 | + /** |
|
360 | + * @return string |
|
361 | + */ |
|
275 | 362 | public function state_abbrev(); |
363 | + |
|
364 | + /** |
|
365 | + * @return string |
|
366 | + */ |
|
276 | 367 | public function state(); |
277 | 368 | /** |
278 | 369 | * @return EE_Country |
279 | 370 | */ |
280 | 371 | public function country_obj(); |
372 | + |
|
373 | + /** |
|
374 | + * @return string |
|
375 | + */ |
|
281 | 376 | public function country_ID(); |
377 | + |
|
378 | + /** |
|
379 | + * @return string |
|
380 | + */ |
|
282 | 381 | public function country_name(); |
382 | + |
|
383 | + /** |
|
384 | + * @return string |
|
385 | + */ |
|
283 | 386 | public function country(); |
387 | + |
|
388 | + /** |
|
389 | + * @return string |
|
390 | + */ |
|
284 | 391 | public function zip(); |
285 | 392 | } |
286 | 393 | |
@@ -301,6 +408,7 @@ discard block |
||
301 | 408 | * @param string $zip |
302 | 409 | * @param string $country |
303 | 410 | * @param string $CNT_ISO |
411 | + * @return string|null |
|
304 | 412 | */ |
305 | 413 | public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
306 | 414 | } |
@@ -413,7 +521,7 @@ discard block |
||
413 | 521 | /** |
414 | 522 | * @param EE_Line_Item $line_item |
415 | 523 | * @param array $options |
416 | - * @return mixed |
|
524 | + * @return string |
|
417 | 525 | */ |
418 | 526 | public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
419 | 527 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param EE_Response $response |
106 | 106 | * @return EE_Response |
107 | 107 | */ |
108 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
108 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param EE_Request $request |
122 | 122 | * @param EE_Response $response |
123 | 123 | */ |
124 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
124 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $country |
303 | 303 | * @param string $CNT_ISO |
304 | 304 | */ |
305 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
305 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | /** |
313 | 313 | * Interface EEHI_Line_Item |
314 | 314 | */ |
315 | -interface EEHI_Line_Item{ |
|
315 | +interface EEHI_Line_Item { |
|
316 | 316 | /** |
317 | 317 | * Adds an item to the purchase in the right spot |
318 | 318 | * @param EE_Line_Item $total_line_item |
319 | 319 | * @param EE_Line_Item $line_item |
320 | 320 | */ |
321 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
321 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
322 | 322 | /** |
323 | 323 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
324 | 324 | * tax and updates the total line item accordingly |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * set the taxes to match $amount |
333 | 333 | * @return EE_Line_Item the new tax created |
334 | 334 | */ |
335 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
335 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
343 | 343 | * it will be whitelisted (ie, except from becoming taxable) |
344 | 344 | */ |
345 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
345 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,21 +356,21 @@ discard block |
||
356 | 356 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
357 | 357 | * @return boolean success |
358 | 358 | */ |
359 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
359 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Gets the line item for the taxes subtotal |
363 | 363 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
364 | 364 | * @return \EE_Line_Item |
365 | 365 | */ |
366 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
366 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Money-related helper |
372 | 372 | */ |
373 | -interface EEHI_Money{ |
|
373 | +interface EEHI_Money { |
|
374 | 374 | /** |
375 | 375 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
376 | 376 | * This should be used to compare floats instead of normal '==' because floats |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
382 | 382 | * @return boolean whether the equation is true or false |
383 | 383 | */ |
384 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
384 | + public function compare_floats($float1, $float2, $operator = '='); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Interface EEHI_Template |
389 | 389 | */ |
390 | -interface EEHI_Template{ |
|
390 | +interface EEHI_Template { |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * EEH_Template::format_currency |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param string $cur_code_span_class |
401 | 401 | * @return string the html output for the formatted money value |
402 | 402 | */ |
403 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
403 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @param array $options |
416 | 416 | * @return mixed |
417 | 417 | */ |
418 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
418 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @throws EE_Error |
433 | 433 | * @return bool |
434 | 434 | */ |
435 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
435 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * ensure_folder_exists_and_is_writable |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @throws EE_Error |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
444 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // End of file EEI_Interfaces.php |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Gets a pretty view of the field's value. $extra_cache_ref can specify different formats for this. |
|
72 | - * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
|
73 | - * to see what options are available. |
|
74 | - * @param string $field_name |
|
75 | - * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | - * (in cases where the same property may be used for different outputs |
|
77 | - * - i.e. datetime, money etc.) |
|
78 | - * @return mixed |
|
79 | - * @throws \EE_Error |
|
80 | - */ |
|
81 | - public function get_pretty($field_name, $extra_cache_ref); |
|
70 | + /** |
|
71 | + * Gets a pretty view of the field's value. $extra_cache_ref can specify different formats for this. |
|
72 | + * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
|
73 | + * to see what options are available. |
|
74 | + * @param string $field_name |
|
75 | + * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | + * (in cases where the same property may be used for different outputs |
|
77 | + * - i.e. datetime, money etc.) |
|
78 | + * @return mixed |
|
79 | + * @throws \EE_Error |
|
80 | + */ |
|
81 | + public function get_pretty($field_name, $extra_cache_ref); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * Retrieves all the pending payments on this transaction |
|
173 | - * @return EEI_Payment[] |
|
174 | - */ |
|
175 | - public function pending_payments(); |
|
171 | + /** |
|
172 | + * Retrieves all the pending payments on this transaction |
|
173 | + * @return EEI_Payment[] |
|
174 | + */ |
|
175 | + public function pending_payments(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | interface EEI_Attendee { |
214 | 214 | public function fname(); |
215 | 215 | public function lname(); |
216 | - public function full_name(); |
|
216 | + public function full_name(); |
|
217 | 217 | public function email(); |
218 | 218 | public function phone(); |
219 | 219 | public function address(); |
@@ -334,23 +334,23 @@ discard block |
||
334 | 334 | * @param float $amount |
335 | 335 | * @param string $name |
336 | 336 | * @param string $description |
337 | - * @param string $code |
|
338 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
339 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
340 | - * set the taxes to match $amount |
|
337 | + * @param string $code |
|
338 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
339 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
340 | + * set the taxes to match $amount |
|
341 | 341 | * @return EE_Line_Item the new tax created |
342 | 342 | */ |
343 | 343 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
344 | 344 | |
345 | - /** |
|
346 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
347 | - * Does NOT save the line items |
|
348 | - * @param EE_Line_Item $line_item |
|
349 | - * @param boolean $taxable |
|
350 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
351 | - * it will be whitelisted (ie, except from becoming taxable) |
|
352 | - */ |
|
353 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
345 | + /** |
|
346 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
347 | + * Does NOT save the line items |
|
348 | + * @param EE_Line_Item $line_item |
|
349 | + * @param boolean $taxable |
|
350 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
351 | + * it will be whitelisted (ie, except from becoming taxable) |
|
352 | + */ |
|
353 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | */ |
381 | 381 | interface EEHI_Money{ |
382 | 382 | /** |
383 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
384 | - * This should be used to compare floats instead of normal '==' because floats |
|
385 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
386 | - * but actually differ by 0.00000001. |
|
387 | - * @param float $float1 |
|
388 | - * @param float $float2 |
|
389 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
390 | - * @return boolean whether the equation is true or false |
|
391 | - */ |
|
383 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
384 | + * This should be used to compare floats instead of normal '==' because floats |
|
385 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
386 | + * but actually differ by 0.00000001. |
|
387 | + * @param float $float1 |
|
388 | + * @param float $float2 |
|
389 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
390 | + * @return boolean whether the equation is true or false |
|
391 | + */ |
|
392 | 392 | public function compare_floats( $float1, $float2, $operator='=' ); |
393 | 393 | } |
394 | 394 |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * Gets the first event for this payment (it's possible that it could be for multiple) |
371 | 371 | * @param EEI_Payment $payment |
372 | - * @return EEI_Event|null |
|
372 | + * @return EE_Event|null |
|
373 | 373 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
374 | 374 | */ |
375 | 375 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | 431 | * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
432 | 432 | * @param EEI_Payment $payment |
433 | - * @return type |
|
433 | + * @return string |
|
434 | 434 | */ |
435 | 435 | protected function _format_order_description( EEI_Payment $payment ) { |
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected $_line_item; |
76 | 76 | |
77 | - /** |
|
78 | - * @var GatewayDataFormatterInterface |
|
79 | - */ |
|
80 | - protected $_gateway_data_formatter; |
|
77 | + /** |
|
78 | + * @var GatewayDataFormatterInterface |
|
79 | + */ |
|
80 | + protected $_gateway_data_formatter; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var FormatterInterface |
|
84 | - */ |
|
85 | - protected $_unsupported_character_remover; |
|
82 | + /** |
|
83 | + * @var FormatterInterface |
|
84 | + */ |
|
85 | + protected $_unsupported_character_remover; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The ID of the payment method using this gateway |
@@ -211,75 +211,75 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Sets the gateway data formatter helper |
|
216 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | - * @throws InvalidEntityException if it's not set properly |
|
218 | - */ |
|
214 | + /** |
|
215 | + * Sets the gateway data formatter helper |
|
216 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | + * @throws InvalidEntityException if it's not set properly |
|
218 | + */ |
|
219 | 219 | public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | - throw new InvalidEntityException( |
|
222 | - is_object($gateway_data_formatter) |
|
223 | - ? get_class($gateway_data_formatter) |
|
224 | - : esc_html__('Not an object','event_espresso'), |
|
225 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | - ); |
|
227 | - } |
|
228 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Gets the gateway data formatter |
|
233 | - * @return GatewayDataFormatterInterface |
|
234 | - * @throws InvalidEntityException if it's not set properly |
|
235 | - */ |
|
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | - throw new InvalidEntityException( |
|
239 | - is_object($this->_gateway_data_formatter) |
|
240 | - ? get_class($this->_gateway_data_formatter) |
|
241 | - : esc_html__('Not an object','event_espresso'), |
|
242 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | - ); |
|
244 | - } |
|
245 | - return $this->_gateway_data_formatter; |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * Sets the helper which will remove unsupported characters for most gateways |
|
252 | - * @param FormatterInterface $formatter |
|
253 | - * @return FormatterInterface |
|
254 | - * @throws InvalidEntityException |
|
255 | - */ |
|
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
258 | - throw new InvalidEntityException( |
|
259 | - is_object($formatter) |
|
260 | - ? get_class($formatter) |
|
261 | - : esc_html__('Not an object','event_espresso'), |
|
262 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | - ); |
|
264 | - } |
|
265 | - $this->_unsupported_character_remover = $formatter; |
|
266 | - } |
|
267 | - /** |
|
268 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | - * @return FormatterInterface |
|
270 | - * @throws InvalidEntityException |
|
271 | - */ |
|
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | - throw new InvalidEntityException( |
|
275 | - is_object($this->_unsupported_character_remover) |
|
276 | - ? get_class($this->_unsupported_character_remover) |
|
277 | - : esc_html__('Not an object','event_espresso'), |
|
278 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | - ); |
|
280 | - } |
|
281 | - return $this->_unsupported_character_remover; |
|
282 | - } |
|
220 | + if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | + throw new InvalidEntityException( |
|
222 | + is_object($gateway_data_formatter) |
|
223 | + ? get_class($gateway_data_formatter) |
|
224 | + : esc_html__('Not an object','event_espresso'), |
|
225 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | + ); |
|
227 | + } |
|
228 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Gets the gateway data formatter |
|
233 | + * @return GatewayDataFormatterInterface |
|
234 | + * @throws InvalidEntityException if it's not set properly |
|
235 | + */ |
|
236 | + protected function _get_gateway_formatter(){ |
|
237 | + if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | + throw new InvalidEntityException( |
|
239 | + is_object($this->_gateway_data_formatter) |
|
240 | + ? get_class($this->_gateway_data_formatter) |
|
241 | + : esc_html__('Not an object','event_espresso'), |
|
242 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | + ); |
|
244 | + } |
|
245 | + return $this->_gateway_data_formatter; |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * Sets the helper which will remove unsupported characters for most gateways |
|
252 | + * @param FormatterInterface $formatter |
|
253 | + * @return FormatterInterface |
|
254 | + * @throws InvalidEntityException |
|
255 | + */ |
|
256 | + public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | + if( ! $formatter instanceof FormatterInterface){ |
|
258 | + throw new InvalidEntityException( |
|
259 | + is_object($formatter) |
|
260 | + ? get_class($formatter) |
|
261 | + : esc_html__('Not an object','event_espresso'), |
|
262 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | + ); |
|
264 | + } |
|
265 | + $this->_unsupported_character_remover = $formatter; |
|
266 | + } |
|
267 | + /** |
|
268 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | + * @return FormatterInterface |
|
270 | + * @throws InvalidEntityException |
|
271 | + */ |
|
272 | + protected function _get_unsupported_character_remover(){ |
|
273 | + if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | + throw new InvalidEntityException( |
|
275 | + is_object($this->_unsupported_character_remover) |
|
276 | + ? get_class($this->_unsupported_character_remover) |
|
277 | + : esc_html__('Not an object','event_espresso'), |
|
278 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | + ); |
|
280 | + } |
|
281 | + return $this->_unsupported_character_remover; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * Formats the amount so it can generally be sent to gateways |
301 | 301 | * @param float $amount |
302 | 302 | * @return string |
303 | - * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
303 | + * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
304 | 304 | */ |
305 | 305 | public function format_currency($amount){ |
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * Gets the first event for this payment (it's possible that it could be for multiple) |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | * @return EEI_Event|null |
373 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
373 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
374 | 374 | */ |
375 | 375 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
376 | 376 | return $payment->get_first_event(); |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | * Gets the name of the first event for which is being paid |
381 | 381 | * @param EEI_Payment $payment |
382 | 382 | * @return string |
383 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
383 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
384 | 384 | */ |
385 | 385 | protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
389 | 389 | * Gets the text to use for a gateway's line item name when this is a partial payment |
390 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
390 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | /** |
398 | 398 | * Gets the text to use for a gateway's line item description when this is a partial payment |
399 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
399 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Gets the name to use for a line item when sending line items to the gateway |
|
409 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | - * @param EEI_Line_Item $line_item |
|
408 | + * Gets the name to use for a line item when sending line items to the gateway |
|
409 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | + * @param EEI_Line_Item $line_item |
|
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Gets the description to use for a line item when sending line items to the gateway |
420 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
420 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
421 | 421 | * @param EEI_Line_Item $line_item |
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
431 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @subpackage core/libraries/payment_methods |
21 | 21 | * @author Mike Nelson |
22 | 22 | */ |
23 | -abstract class EE_Gateway{ |
|
23 | +abstract class EE_Gateway { |
|
24 | 24 | /** |
25 | 25 | * a constant used as a possible value for $_currencies_supported to indicate |
26 | 26 | * that ALL currencies are supported by this gateway |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return EE_Gateway |
110 | 110 | */ |
111 | - public function __construct(){ |
|
111 | + public function __construct() { |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * beginning again) |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function __sleep(){ |
|
123 | + public function __sleep() { |
|
124 | 124 | $properties = get_object_vars($this); |
125 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
125 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
126 | 126 | return array_keys($properties); |
127 | 127 | } |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * see $_supports_sending_refunds |
131 | 131 | * @return boolean |
132 | 132 | */ |
133 | - public function supports_sending_refunds(){ |
|
133 | + public function supports_sending_refunds() { |
|
134 | 134 | return $this->_supports_sending_refunds; |
135 | 135 | } |
136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * see $_supports_receiving_refunds |
139 | 139 | * @return boolean |
140 | 140 | */ |
141 | - public function supports_receiving_refunds(){ |
|
141 | + public function supports_receiving_refunds() { |
|
142 | 142 | return $this->_supports_receiving_refunds; |
143 | 143 | } |
144 | 144 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return EE_Payment for the refund |
154 | 154 | * @throws EE_Error |
155 | 155 | */ |
156 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
156 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
157 | 157 | return NULL; |
158 | 158 | } |
159 | 159 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * etc |
165 | 165 | * @param array $settings_array |
166 | 166 | */ |
167 | - public function set_settings($settings_array){ |
|
168 | - foreach($settings_array as $name => $value){ |
|
167 | + public function set_settings($settings_array) { |
|
168 | + foreach ($settings_array as $name => $value) { |
|
169 | 169 | $property_name = "_".$name; |
170 | 170 | $this->{$property_name} = $value; |
171 | 171 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEMI_Payment $payment_model |
176 | 176 | */ |
177 | - public function set_payment_model($payment_model){ |
|
177 | + public function set_payment_model($payment_model) { |
|
178 | 178 | $this->_pay_model = $payment_model; |
179 | 179 | } |
180 | 180 | /** |
181 | 181 | * See this class description |
182 | 182 | * @param EEMI_Payment_Log $payment_log_model |
183 | 183 | */ |
184 | - public function set_payment_log($payment_log_model){ |
|
184 | + public function set_payment_log($payment_log_model) { |
|
185 | 185 | $this->_pay_log = $payment_log_model; |
186 | 186 | } |
187 | 187 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * See this class description |
190 | 190 | * @param EEHI_Template $template_helper |
191 | 191 | */ |
192 | - public function set_template_helper($template_helper){ |
|
192 | + public function set_template_helper($template_helper) { |
|
193 | 193 | $this->_template = $template_helper; |
194 | 194 | } |
195 | 195 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * See this class description |
198 | 198 | * @param EEHI_Line_Item $line_item_helper |
199 | 199 | */ |
200 | - public function set_line_item_helper( $line_item_helper ){ |
|
200 | + public function set_line_item_helper($line_item_helper) { |
|
201 | 201 | $this->_line_item = $line_item_helper; |
202 | 202 | } |
203 | 203 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * See this class description |
206 | 206 | * @param EEHI_Money $money_helper |
207 | 207 | */ |
208 | - public function set_money_helper( $money_helper ){ |
|
208 | + public function set_money_helper($money_helper) { |
|
209 | 209 | $this->_money = $money_helper; |
210 | 210 | } |
211 | 211 | |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @param GatewayDataFormatterInterface $gateway_data_formatter |
217 | 217 | * @throws InvalidEntityException if it's not set properly |
218 | 218 | */ |
219 | - public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
|
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
219 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) { |
|
220 | + if ( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
221 | 221 | throw new InvalidEntityException( |
222 | 222 | is_object($gateway_data_formatter) |
223 | 223 | ? get_class($gateway_data_formatter) |
224 | - : esc_html__('Not an object','event_espresso'), |
|
224 | + : esc_html__('Not an object', 'event_espresso'), |
|
225 | 225 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
226 | 226 | ); |
227 | 227 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | * @return GatewayDataFormatterInterface |
234 | 234 | * @throws InvalidEntityException if it's not set properly |
235 | 235 | */ |
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
236 | + protected function _get_gateway_formatter() { |
|
237 | + if ( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
238 | 238 | throw new InvalidEntityException( |
239 | 239 | is_object($this->_gateway_data_formatter) |
240 | 240 | ? get_class($this->_gateway_data_formatter) |
241 | - : esc_html__('Not an object','event_espresso'), |
|
241 | + : esc_html__('Not an object', 'event_espresso'), |
|
242 | 242 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
243 | 243 | ); |
244 | 244 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return FormatterInterface |
254 | 254 | * @throws InvalidEntityException |
255 | 255 | */ |
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
256 | + public function set_unsupported_character_remover(FormatterInterface $formatter) { |
|
257 | + if ( ! $formatter instanceof FormatterInterface) { |
|
258 | 258 | throw new InvalidEntityException( |
259 | 259 | is_object($formatter) |
260 | 260 | ? get_class($formatter) |
261 | - : esc_html__('Not an object','event_espresso'), |
|
261 | + : esc_html__('Not an object', 'event_espresso'), |
|
262 | 262 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
263 | 263 | ); |
264 | 264 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @return FormatterInterface |
270 | 270 | * @throws InvalidEntityException |
271 | 271 | */ |
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
272 | + protected function _get_unsupported_character_remover() { |
|
273 | + if ( ! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
274 | 274 | throw new InvalidEntityException( |
275 | 275 | is_object($this->_unsupported_character_remover) |
276 | 276 | ? get_class($this->_unsupported_character_remover) |
277 | - : esc_html__('Not an object','event_espresso'), |
|
277 | + : esc_html__('Not an object', 'event_espresso'), |
|
278 | 278 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
279 | 279 | ); |
280 | 280 | } |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | * @param $message |
287 | 287 | * @param $payment |
288 | 288 | */ |
289 | - public function log($message,$payment){ |
|
290 | - if($payment instanceof EEI_Payment){ |
|
291 | - $type='Payment'; |
|
289 | + public function log($message, $payment) { |
|
290 | + if ($payment instanceof EEI_Payment) { |
|
291 | + $type = 'Payment'; |
|
292 | 292 | $id = $payment->ID(); |
293 | - }else{ |
|
293 | + } else { |
|
294 | 294 | $type = 'Payment_Method'; |
295 | 295 | $id = $this->_ID; |
296 | 296 | } |
297 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
297 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
298 | 298 | } |
299 | 299 | /** |
300 | 300 | * Formats the amount so it can generally be sent to gateways |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string |
303 | 303 | * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
304 | 304 | */ |
305 | - public function format_currency($amount){ |
|
305 | + public function format_currency($amount) { |
|
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
307 | 307 | } |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
312 | 312 | * @return mixed array or string |
313 | 313 | */ |
314 | - public function currencies_supported(){ |
|
314 | + public function currencies_supported() { |
|
315 | 315 | return $this->_currencies_supported; |
316 | 316 | } |
317 | 317 | |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | * @param EE_Transaction $transaction |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
326 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
327 | 327 | $total_line_item = $transaction->total_line_item(); |
328 | 328 | $total = 0; |
329 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
330 | - $total += max( $item_line_item->total(), 0 ); |
|
329 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
330 | + $total += max($item_line_item->total(), 0); |
|
331 | 331 | } |
332 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
333 | - $total += max( $tax_line_item->total(), 0 ); |
|
332 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
333 | + $total += max($tax_line_item->total(), 0); |
|
334 | 334 | } |
335 | 335 | return $total; |
336 | 336 | } |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | * @param EEI_Payment $payment |
342 | 342 | * @return boolean |
343 | 343 | */ |
344 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
344 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
345 | 345 | return $this->_money->compare_floats( |
346 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
346 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
347 | 347 | $payment->transaction()->total() ) && |
348 | 348 | $this->_money->compare_floats( |
349 | 349 | $payment->amount(), |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param EE_Payment $payment |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - public function update_txn_based_on_payment( $payment ){ |
|
364 | + public function update_txn_based_on_payment($payment) { |
|
365 | 365 | //maybe update the transaction or line items or registrations |
366 | 366 | //but most gateways don't need to do this, because they only update the payment |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return EEI_Event|null |
373 | 373 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
374 | 374 | */ |
375 | - protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
|
375 | + protected function _get_first_event_for_payment(EEI_Payment $payment) { |
|
376 | 376 | return $payment->get_first_event(); |
377 | 377 | } |
378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return string |
383 | 383 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
384 | 384 | */ |
385 | - protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
|
385 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) { |
|
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){ |
|
394 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) { |
|
395 | 395 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
396 | 396 | } |
397 | 397 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) { |
|
403 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) { |
|
404 | 404 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
405 | 405 | } |
406 | 406 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
415 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment); |
|
414 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
415 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
425 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
426 | 426 | return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
427 | 427 | } |
428 | 428 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
435 | - protected function _format_order_description( EEI_Payment $payment ) { |
|
435 | + protected function _format_order_description(EEI_Payment $payment) { |
|
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
437 | 437 | } |
438 | 438 | } |
439 | 439 | \ No newline at end of file |