@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,42 +64,42 @@ discard block |
||
64 | 64 | * @param string $cancel_url URL to return to if off-site payments are cancelled |
65 | 65 | * @return EE_Payment |
66 | 66 | */ |
67 | - public function process_payment( EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '' ) { |
|
68 | - if( $amount < 0 ) { |
|
67 | + public function process_payment(EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '') { |
|
68 | + if ($amount < 0) { |
|
69 | 69 | throw new EE_Error( |
70 | 70 | sprintf( |
71 | - __( 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso' ), |
|
71 | + __('Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso'), |
|
72 | 72 | $amount, |
73 | 73 | $transaction->ID() ) ); |
74 | 74 | } |
75 | 75 | // verify payment method |
76 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
76 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
77 | 77 | // verify transaction |
78 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
79 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
78 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
79 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
80 | 80 | // verify payment method type |
81 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ){ |
|
81 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
82 | 82 | $payment = $payment_method->type_obj()->process_payment( |
83 | 83 | $transaction, |
84 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
84 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
85 | 85 | $billing_form, |
86 | 86 | $return_url, |
87 | - add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
87 | + add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
88 | 88 | $method, |
89 | 89 | $by_admin |
90 | 90 | ); |
91 | 91 | // check if payment method uses an off-site gateway |
92 | - if ( $payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite ) { |
|
92 | + if ($payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite) { |
|
93 | 93 | // don't process payments for off-site gateways yet because no payment has occurred yet |
94 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
94 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
95 | 95 | } |
96 | 96 | return $payment; |
97 | 97 | } else { |
98 | 98 | EE_Error::add_error( |
99 | 99 | sprintf( |
100 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
100 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
101 | 101 | '<br/>', |
102 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
102 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
103 | 103 | ), __FILE__, __FUNCTION__, __LINE__ |
104 | 104 | ); |
105 | 105 | return NULL; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @throws EE_Error |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
118 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
119 | 119 | /** @type EE_Transaction $transaction */ |
120 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
120 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
121 | 121 | $primary_reg = $transaction->primary_registration(); |
122 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
123 | - throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"),$transaction->ID())); |
|
122 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
123 | + throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"), $transaction->ID())); |
|
124 | 124 | } |
125 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
125 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
126 | 126 | $url = add_query_arg( |
127 | 127 | array( |
128 | 128 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -149,81 +149,81 @@ discard block |
||
149 | 149 | * @throws Exception |
150 | 150 | * @return EE_Payment |
151 | 151 | */ |
152 | - public function process_ipn( $_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true ){ |
|
153 | - $_req_data = $this->_remove_unusable_characters( $_req_data ); |
|
154 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
155 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
156 | - if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){ |
|
157 | - $obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) ); |
|
158 | - }elseif( $payment_method instanceof EE_Payment ){ |
|
152 | + public function process_ipn($_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true) { |
|
153 | + $_req_data = $this->_remove_unusable_characters($_req_data); |
|
154 | + EE_Registry::instance()->load_model('Change_Log'); |
|
155 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
156 | + if ($transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method) { |
|
157 | + $obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc'))); |
|
158 | + }elseif ($payment_method instanceof EE_Payment) { |
|
159 | 159 | $obj_for_log = $payment_method; |
160 | - }elseif( $transaction instanceof EE_Transaction ){ |
|
160 | + }elseif ($transaction instanceof EE_Transaction) { |
|
161 | 161 | $obj_for_log = $transaction; |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $obj_for_log = null; |
164 | 164 | } |
165 | 165 | $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log); |
166 | - try{ |
|
166 | + try { |
|
167 | 167 | /** |
168 | 168 | * @var EE_Payment $payment |
169 | 169 | */ |
170 | 170 | $payment = NULL; |
171 | - if($transaction && $payment_method){ |
|
171 | + if ($transaction && $payment_method) { |
|
172 | 172 | /** @type EE_Transaction $transaction */ |
173 | 173 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
174 | 174 | /** @type EE_Payment_Method $payment_method */ |
175 | 175 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
176 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
177 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
176 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
177 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
178 | 178 | $log->set_object($payment); |
179 | 179 | } else { |
180 | 180 | // not a payment |
181 | 181 | EE_Error::add_error( |
182 | 182 | sprintf( |
183 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
183 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
184 | 184 | '<br/>', |
185 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
185 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
186 | 186 | ), |
187 | 187 | __FILE__, __FUNCTION__, __LINE__ |
188 | 188 | ); |
189 | 189 | } |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | //that's actually pretty ok. The IPN just wasn't able |
192 | 192 | //to identify which transaction or payment method this was for |
193 | 193 | // give all active payment methods a chance to claim it |
194 | 194 | $active_pms = EEM_Payment_Method::instance()->get_all_active(); |
195 | - foreach( $active_pms as $payment_method ){ |
|
196 | - try{ |
|
197 | - $payment = $payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
195 | + foreach ($active_pms as $payment_method) { |
|
196 | + try { |
|
197 | + $payment = $payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
198 | 198 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment); |
199 | 199 | break; |
200 | - } catch( EE_Error $e ) { |
|
200 | + } catch (EE_Error $e) { |
|
201 | 201 | //that's fine- it apparently couldn't handle the IPN |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
206 | 206 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
207 | - if( $payment instanceof EE_Payment){ |
|
207 | + if ($payment instanceof EE_Payment) { |
|
208 | 208 | $payment->save(); |
209 | 209 | // update the TXN |
210 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
211 | - }else{ |
|
210 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
211 | + } else { |
|
212 | 212 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
213 | - if($payment_method){ |
|
213 | + if ($payment_method) { |
|
214 | 214 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
215 | - }elseif($transaction){ |
|
215 | + }elseif ($transaction) { |
|
216 | 216 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | return $payment; |
220 | 220 | |
221 | - } catch( EE_Error $e ) { |
|
221 | + } catch (EE_Error $e) { |
|
222 | 222 | do_action( |
223 | 223 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
224 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
225 | - print_r( $transaction, TRUE ), |
|
226 | - print_r( $_req_data, TRUE ), |
|
224 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
225 | + print_r($transaction, TRUE), |
|
226 | + print_r($_req_data, TRUE), |
|
227 | 227 | $e->getMessage() |
228 | 228 | ) |
229 | 229 | ); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * @param array $request_data |
238 | 238 | * @return array|string |
239 | 239 | */ |
240 | - protected function _remove_unusable_characters( $request_data ) { |
|
241 | - if( is_array( $request_data ) ) { |
|
240 | + protected function _remove_unusable_characters($request_data) { |
|
241 | + if (is_array($request_data)) { |
|
242 | 242 | $return_data = array(); |
243 | - foreach( $request_data as $key => $value ) { |
|
244 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
243 | + foreach ($request_data as $key => $value) { |
|
244 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
245 | 245 | } |
246 | - }else{ |
|
247 | - $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
246 | + } else { |
|
247 | + $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
248 | 248 | } |
249 | 249 | return $return_data; |
250 | 250 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | * @return EE_Payment |
267 | 267 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, to call handle_ipn() for offsite gateways that don't receive separate IPNs |
268 | 268 | */ |
269 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
269 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
270 | 270 | /** @var $transaction EE_Transaction */ |
271 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
271 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
272 | 272 | $last_payment_method = $transaction->payment_method(); |
273 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
274 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
275 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
273 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
274 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
275 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
276 | 276 | return $payment; |
277 | 277 | } else { |
278 | 278 | return NULL; |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @internal param float $amount |
290 | 290 | * @return EE_Payment |
291 | 291 | */ |
292 | - public function process_refund( EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array() ){ |
|
293 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
294 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
295 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
292 | + public function process_refund(EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array()) { |
|
293 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
294 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
295 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
296 | 296 | } |
297 | 297 | return $payment_to_refund; |
298 | 298 | } |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | * TXN is locked before updating |
335 | 335 | * @throws \EE_Error |
336 | 336 | */ |
337 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
337 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
338 | 338 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
339 | 339 | /** @type EE_Transaction $transaction */ |
340 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
340 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
341 | 341 | // can we freely update the TXN at this moment? |
342 | - if ( $IPN && $transaction->is_locked() ) { |
|
342 | + if ($IPN && $transaction->is_locked()) { |
|
343 | 343 | // don't update the transaction at this exact moment |
344 | 344 | // because the TXN is active in another request |
345 | 345 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -349,40 +349,40 @@ discard block |
||
349 | 349 | ); |
350 | 350 | } else { |
351 | 351 | // verify payment and that it has been saved |
352 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
353 | - if( $payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base ){ |
|
354 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
352 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
353 | + if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base) { |
|
354 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
355 | 355 | // update TXN registrations with payment info |
356 | - $this->process_registration_payments( $transaction, $payment ); |
|
356 | + $this->process_registration_payments($transaction, $payment); |
|
357 | 357 | } |
358 | 358 | $do_action = $payment->just_approved() ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' : $do_action; |
359 | 359 | } else { |
360 | 360 | // send out notifications |
361 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
361 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
362 | 362 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
363 | 363 | } |
364 | 364 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
365 | 365 | // so that we know whether the status has changed and notifications should be triggered |
366 | - if ( $IPN ) { |
|
366 | + if ($IPN) { |
|
367 | 367 | /** @type EE_Transaction_Processor $transaction_processor */ |
368 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
369 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
368 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
369 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
370 | 370 | } |
371 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
371 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
372 | 372 | /** @type EE_Transaction_Payments $transaction_payments */ |
373 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
373 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
374 | 374 | // set new value for total paid |
375 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
375 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
376 | 376 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
377 | - if ( $update_txn ) { |
|
378 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
377 | + if ($update_txn) { |
|
378 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | // granular hook for others to use. |
382 | - do_action( $do_action, $transaction, $payment ); |
|
383 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
382 | + do_action($do_action, $transaction, $payment); |
|
383 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
384 | 384 | //global hook for others to use. |
385 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
385 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
@@ -396,25 +396,25 @@ discard block |
||
396 | 396 | * @param EE_Registration[] $registrations |
397 | 397 | * @throws \EE_Error |
398 | 398 | */ |
399 | - public function process_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $registrations = array() ) { |
|
399 | + public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array()) { |
|
400 | 400 | // only process if payment was successful |
401 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
401 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
402 | 402 | return; |
403 | 403 | } |
404 | 404 | //EEM_Registration::instance()->show_next_x_db_queries(); |
405 | - if ( empty( $registrations )) { |
|
405 | + if (empty($registrations)) { |
|
406 | 406 | // find registrations with monies owing that can receive a payment |
407 | - $registrations = $transaction->registrations( array( |
|
407 | + $registrations = $transaction->registrations(array( |
|
408 | 408 | array( |
409 | 409 | // only these reg statuses can receive payments |
410 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
411 | - 'REG_final_price' => array( '!=', 0 ), |
|
412 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
410 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
411 | + 'REG_final_price' => array('!=', 0), |
|
412 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
413 | 413 | ) |
414 | - ) ); |
|
414 | + )); |
|
415 | 415 | } |
416 | 416 | // still nothing ??!?? |
417 | - if ( empty( $registrations )) { |
|
417 | + if (empty($registrations)) { |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | // todo: break out the following logic into a separate strategy class |
@@ -426,28 +426,28 @@ discard block |
||
426 | 426 | |
427 | 427 | $refund = $payment->is_a_refund(); |
428 | 428 | // how much is available to apply to registrations? |
429 | - $available_payment_amount = abs( $payment->amount() ); |
|
430 | - foreach ( $registrations as $registration ) { |
|
431 | - if ( $registration instanceof EE_Registration ) { |
|
429 | + $available_payment_amount = abs($payment->amount()); |
|
430 | + foreach ($registrations as $registration) { |
|
431 | + if ($registration instanceof EE_Registration) { |
|
432 | 432 | // nothing left? |
433 | - if ( $available_payment_amount <= 0 ) { |
|
433 | + if ($available_payment_amount <= 0) { |
|
434 | 434 | break; |
435 | 435 | } |
436 | - if ( $refund ) { |
|
437 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
436 | + if ($refund) { |
|
437 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
438 | 438 | } else { |
439 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
439 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | } |
443 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
443 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
444 | 444 | EE_Error::add_attention( |
445 | 445 | sprintf( |
446 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
447 | - EEH_Template::format_currency( $available_payment_amount ), |
|
448 | - implode( ', ', array_keys( $registrations ) ), |
|
446 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
447 | + EEH_Template::format_currency($available_payment_amount), |
|
448 | + implode(', ', array_keys($registrations)), |
|
449 | 449 | '<br/>', |
450 | - EEH_Template::format_currency( $payment->amount() ) |
|
450 | + EEH_Template::format_currency($payment->amount()) |
|
451 | 451 | ), |
452 | 452 | __FILE__, __FUNCTION__, __LINE__ |
453 | 453 | ); |
@@ -464,17 +464,17 @@ discard block |
||
464 | 464 | * @param float $available_payment_amount |
465 | 465 | * @return float |
466 | 466 | */ |
467 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
467 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
468 | 468 | $owing = $registration->final_price() - $registration->paid(); |
469 | - if ( $owing > 0 ) { |
|
469 | + if ($owing > 0) { |
|
470 | 470 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
471 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
471 | + $payment_amount = min($available_payment_amount, $owing); |
|
472 | 472 | // update $available_payment_amount |
473 | 473 | $available_payment_amount = $available_payment_amount - $payment_amount; |
474 | 474 | //calculate and set new REG_paid |
475 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
475 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
476 | 476 | // now save it |
477 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
477 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
478 | 478 | } |
479 | 479 | return $available_payment_amount; |
480 | 480 | } |
@@ -489,19 +489,19 @@ discard block |
||
489 | 489 | * @param float $payment_amount |
490 | 490 | * @return float |
491 | 491 | */ |
492 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
492 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
493 | 493 | // find any existing reg payment records for this registration and payment |
494 | 494 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
495 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
495 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
496 | 496 | ); |
497 | 497 | // if existing registration payment exists |
498 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
498 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
499 | 499 | // then update that record |
500 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
500 | + $existing_reg_payment->set_amount($payment_amount); |
|
501 | 501 | $existing_reg_payment->save(); |
502 | 502 | } else { |
503 | 503 | // or add new relation between registration and payment and set amount |
504 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
504 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
505 | 505 | // make it stick |
506 | 506 | $registration->save(); |
507 | 507 | } |
@@ -517,21 +517,21 @@ discard block |
||
517 | 517 | * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
518 | 518 | * @return float |
519 | 519 | */ |
520 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
520 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
521 | 521 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
522 | - if ( $registration->paid() > 0 ) { |
|
522 | + if ($registration->paid() > 0) { |
|
523 | 523 | // ensure $available_refund_amount is NOT negative |
524 | - $available_refund_amount = abs( $available_refund_amount ); |
|
524 | + $available_refund_amount = abs($available_refund_amount); |
|
525 | 525 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
526 | - $refund_amount = min( $available_refund_amount, $registration->paid() ); |
|
526 | + $refund_amount = min($available_refund_amount, $registration->paid()); |
|
527 | 527 | // update $available_payment_amount |
528 | 528 | $available_refund_amount = $available_refund_amount - $refund_amount; |
529 | 529 | //calculate and set new REG_paid |
530 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
530 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
531 | 531 | // convert payment amount back to a negative value for storage in the db |
532 | - $refund_amount = abs( $refund_amount ) * -1; |
|
532 | + $refund_amount = abs($refund_amount) * -1; |
|
533 | 533 | // now save it |
534 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
534 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
535 | 535 | } |
536 | 536 | return $available_refund_amount; |
537 | 537 | } |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | * @param EE_Payment $payment |
550 | 550 | * @param bool $IPN |
551 | 551 | */ |
552 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
552 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
553 | 553 | |
554 | 554 | /** @type EE_Transaction_Processor $transaction_processor */ |
555 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
555 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
556 | 556 | // is the Payment Options Reg Step completed ? |
557 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
557 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
558 | 558 | // DEBUG LOG |
559 | 559 | //$this->log( |
560 | 560 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | // if the Payment Options Reg Step is completed... |
568 | 568 | $revisit = $payment_options_step_completed === true ? true : false; |
569 | 569 | // then this is kinda sorta a revisit with regards to payments at least |
570 | - $transaction_processor->set_revisit( $revisit ); |
|
570 | + $transaction_processor->set_revisit($revisit); |
|
571 | 571 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
572 | 572 | if ( |
573 | 573 | $IPN && |
574 | 574 | $payment_options_step_completed !== true && |
575 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
575 | + ($payment->is_approved() || $payment->is_pending()) |
|
576 | 576 | ) { |
577 | - $payment_options_step_completed = $transaction_processor->set_reg_step_completed( $transaction, 'payment_options' ); |
|
577 | + $payment_options_step_completed = $transaction_processor->set_reg_step_completed($transaction, 'payment_options'); |
|
578 | 578 | } |
579 | 579 | // DEBUG LOG |
580 | 580 | //$this->log( |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | // ) |
587 | 587 | //); |
588 | 588 | /** @type EE_Transaction_Payments $transaction_payments */ |
589 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
589 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
590 | 590 | // maybe update status, but don't save transaction just yet |
591 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
591 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
592 | 592 | // check if 'finalize_registration' step has been completed... |
593 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
593 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
594 | 594 | // DEBUG LOG |
595 | 595 | //$this->log( |
596 | 596 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | // ) |
602 | 602 | //); |
603 | 603 | // if this is an IPN and the final step has not been initiated |
604 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
604 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
605 | 605 | // and if it hasn't already been set as being started... |
606 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
606 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
607 | 607 | // DEBUG LOG |
608 | 608 | //$this->log( |
609 | 609 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | } |
617 | 617 | $transaction->save(); |
618 | 618 | // because the above will return false if the final step was not fully completed, we need to check again... |
619 | - if ( $IPN && $finalized !== false ) { |
|
619 | + if ($IPN && $finalized !== false) { |
|
620 | 620 | // and if we are all good to go, then send out notifications |
621 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
621 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
622 | 622 | // DEBUG LOG |
623 | 623 | //$this->log( __CLASS__, __FUNCTION__, __LINE__, $transaction ); |
624 | 624 | //ok, now process the transaction according to the payment |
625 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
625 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
626 | 626 | } |
627 | 627 | // DEBUG LOG |
628 | 628 | //$this->log( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
106 | - * @return null |
|
106 | + * @return EE_Line_Item_Display |
|
107 | 107 | */ |
108 | 108 | public function line_item_display() { |
109 | 109 | return $this->line_item_display; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | |
114 | 114 | /** |
115 | - * @param null $line_item_display |
|
115 | + * @param EE_Line_Item_Display $line_item_display |
|
116 | 116 | */ |
117 | 117 | public function set_line_item_display( $line_item_display ) { |
118 | 118 | $this->line_item_display = $line_item_display; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | /** |
183 | - * @return bool |
|
183 | + * @return EE_Form_Section_Proper |
|
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | 186 | EE_Registry::instance()->load_helper( 'HTML' ); |
@@ -537,6 +537,7 @@ discard block |
||
537 | 537 | * _apply_registration_payments_to_amount_owing |
538 | 538 | * |
539 | 539 | * @access protected |
540 | + * @param EE_Base_Class[] $registrations |
|
540 | 541 | * @return void |
541 | 542 | */ |
542 | 543 | protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
@@ -754,7 +755,7 @@ discard block |
||
754 | 755 | * get_billing_form_html_for_payment_method |
755 | 756 | * |
756 | 757 | * @access public |
757 | - * @return string |
|
758 | + * @return boolean |
|
758 | 759 | */ |
759 | 760 | public function get_billing_form_html_for_payment_method() { |
760 | 761 | // how have they chosen to pay? |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | * switch_payment_method |
875 | 876 | * |
876 | 877 | * @access public |
877 | - * @return string |
|
878 | + * @return boolean |
|
878 | 879 | */ |
879 | 880 | public function switch_payment_method() { |
880 | 881 | if ( ! $this->_verify_payment_method_is_set() ) { |
@@ -1041,7 +1042,7 @@ discard block |
||
1041 | 1042 | |
1042 | 1043 | /** |
1043 | 1044 | * process_reg_step |
1044 | - * @return boolean |
|
1045 | + * @return null|boolean |
|
1045 | 1046 | */ |
1046 | 1047 | public function process_reg_step() { |
1047 | 1048 | // how have they chosen to pay? |
@@ -1117,7 +1118,7 @@ discard block |
||
1117 | 1118 | * update_reg_step |
1118 | 1119 | * this is the final step after a user revisits the site to retry a payment |
1119 | 1120 | * |
1120 | - * @return boolean |
|
1121 | + * @return null|boolean |
|
1121 | 1122 | */ |
1122 | 1123 | public function update_reg_step() { |
1123 | 1124 | $success = TRUE; |
@@ -1399,7 +1400,7 @@ discard block |
||
1399 | 1400 | * |
1400 | 1401 | * @access private |
1401 | 1402 | * @type EE_Payment_Method $payment_method |
1402 | - * @return mixed EE_Payment | boolean |
|
1403 | + * @return EE_Payment|null EE_Payment | boolean |
|
1403 | 1404 | */ |
1404 | 1405 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
1405 | 1406 | $payment =NULL; |
@@ -1602,6 +1603,7 @@ discard block |
||
1602 | 1603 | * @access private |
1603 | 1604 | * @type EE_Payment $payment |
1604 | 1605 | * @param string $payment_occurs |
1606 | + * @param EE_Payment|null $payment |
|
1605 | 1607 | * @return bool |
1606 | 1608 | * @throws \EE_Error |
1607 | 1609 | */ |
@@ -1708,7 +1710,7 @@ discard block |
||
1708 | 1710 | * or present the payment options again |
1709 | 1711 | * |
1710 | 1712 | * @access private |
1711 | - * @return EE_Payment | FALSE |
|
1713 | + * @return boolean | FALSE |
|
1712 | 1714 | */ |
1713 | 1715 | public function process_gateway_response() { |
1714 | 1716 | $payment = null; |
@@ -1769,7 +1771,7 @@ discard block |
||
1769 | 1771 | * _validate_return |
1770 | 1772 | * |
1771 | 1773 | * @access private |
1772 | - * @return bool |
|
1774 | + * @return boolean|null |
|
1773 | 1775 | */ |
1774 | 1776 | private function _validate_offsite_return() { |
1775 | 1777 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
@@ -1836,7 +1838,7 @@ discard block |
||
1836 | 1838 | * |
1837 | 1839 | * @access private |
1838 | 1840 | * @param \EE_Registration $primary_registrant |
1839 | - * @return bool |
|
1841 | + * @return false|null |
|
1840 | 1842 | */ |
1841 | 1843 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
1842 | 1844 | if ( ! $primary_registrant instanceof EE_Registration ) { |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) ); |
|
32 | - add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
33 | - add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
34 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
35 | - add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
36 | - add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) ); |
|
37 | - add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
31 | + add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')); |
|
32 | + add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
33 | + add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
34 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
35 | + add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
36 | + add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')); |
|
37 | + add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
38 | 38 | ); |
39 | - add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 ); |
|
39 | + add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * ajax switch_spco_billing_form |
46 | 46 | */ |
47 | 47 | public static function switch_spco_billing_form() { |
48 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
48 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * ajax save_payer_details |
55 | 55 | */ |
56 | 56 | public static function save_payer_details() { |
57 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
57 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * ajax get_transaction_details |
64 | 64 | */ |
65 | 65 | public static function get_transaction_details() { |
66 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
66 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param EE_Checkout $checkout |
92 | 92 | * @return \EE_SPCO_Reg_Step_Payment_Options |
93 | 93 | */ |
94 | - public function __construct( EE_Checkout $checkout ) { |
|
94 | + public function __construct(EE_Checkout $checkout) { |
|
95 | 95 | $this->_slug = 'payment_options'; |
96 | 96 | $this->_name = __('Payment Options', 'event_espresso'); |
97 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
97 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
98 | 98 | $this->checkout = $checkout; |
99 | 99 | $this->_reset_success_message(); |
100 | - $this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
100 | + $this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param null $line_item_display |
116 | 116 | */ |
117 | - public function set_line_item_display( $line_item_display ) { |
|
117 | + public function set_line_item_display($line_item_display) { |
|
118 | 118 | $this->line_item_display = $line_item_display; |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | public function translate_js_strings() { |
128 | - EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' ); |
|
129 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' ); |
|
130 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' ); |
|
128 | + EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso'); |
|
129 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso'); |
|
130 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | // $ 0.00 transactions (no payment required) |
157 | 157 | ! $this->checkout->payment_required() |
158 | 158 | // but do NOT remove if current action being called belongs to this reg step |
159 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
159 | + && ! is_callable(array($this, $this->checkout->action)) |
|
160 | 160 | && ! $this->completed() |
161 | 161 | ) { |
162 | 162 | // and if so, then we no longer need the Payment Options step |
163 | - if ( $this->is_current_step() ) { |
|
163 | + if ($this->is_current_step()) { |
|
164 | 164 | $this->checkout->generate_reg_form = false; |
165 | 165 | } |
166 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
166 | + $this->checkout->remove_reg_step($this->_slug); |
|
167 | 167 | // DEBUG LOG |
168 | 168 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // load EEM_Payment_Method |
172 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
172 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
173 | 173 | // get all active payment methods |
174 | 174 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
175 | 175 | $this->checkout->transaction, EEM_Payment_Method::scope_cart |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return bool |
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
186 | + EE_Registry::instance()->load_helper('HTML'); |
|
187 | 187 | // reset in case someone changes their mind |
188 | 188 | $this->_reset_selected_method_of_payment(); |
189 | 189 | // set some defaults |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | $sold_out_events = array(); |
195 | 195 | $reg_count = 0; |
196 | 196 | // loop thru registrations to gather info |
197 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
198 | - foreach ( $registrations as $registration ) { |
|
197 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
198 | + foreach ($registrations as $registration) { |
|
199 | 199 | /** @var $registration EE_Registration */ |
200 | 200 | $reg_count++; |
201 | 201 | // if returning registrant is Approved then do NOT do this |
202 | - if ( ! ( $this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved )) { |
|
203 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true )) { |
|
202 | + if ( ! ($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) { |
|
203 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
204 | 204 | // add event to list of events that are sold out |
205 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
205 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
206 | 206 | do_action( |
207 | 207 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
208 | 208 | $registration->event(), |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | ); |
211 | 211 | } |
212 | 212 | // event requires admin approval |
213 | - if ( $registration->status_ID() == EEM_Registration::status_id_not_approved ) { |
|
213 | + if ($registration->status_ID() == EEM_Registration::status_id_not_approved) { |
|
214 | 214 | // add event to list of events with pre-approval reg status |
215 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
215 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
216 | 216 | do_action( |
217 | 217 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
218 | 218 | $registration->event(), |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | // are they allowed to pay now and is there monies owing? |
224 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
225 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
224 | + if ($registration->owes_monies_and_can_pay()) { |
|
225 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
226 | 226 | do_action( |
227 | 227 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
228 | 228 | $registration->event(), |
229 | 229 | $this |
230 | 230 | ); |
231 | - } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free() ) { |
|
232 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
231 | + } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) { |
|
232 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | $subsections = array(); |
236 | 236 | // now decide which template to load |
237 | - if ( ! empty( $sold_out_events )) { |
|
238 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
237 | + if ( ! empty($sold_out_events)) { |
|
238 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
239 | 239 | } |
240 | - if ( ! empty( $registrations_requiring_pre_approval )) { |
|
241 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval ); |
|
240 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
241 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval); |
|
242 | 242 | } |
243 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
244 | - $subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events ); |
|
243 | + if ( ! empty($registrations_for_free_events)) { |
|
244 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
245 | 245 | } |
246 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
246 | + if ( ! empty($registrations_requiring_payment)) { |
|
247 | 247 | // autoload Line_Item_Display classes |
248 | 248 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
249 | 249 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | $this->checkout->cart->get_grand_total() |
255 | 255 | ); |
256 | 256 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
257 | - if ( $this->checkout->amount_owing > 0 ) { |
|
257 | + if ($this->checkout->amount_owing > 0) { |
|
258 | 258 | EEH_Autoloader::register_line_item_display_autoloaders(); |
259 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
260 | - $subsections[ 'payment_options' ] = $this->_display_payment_options( |
|
259 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
260 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
261 | 261 | $this->line_item_display->display_line_item( |
262 | 262 | $filtered_line_item_tree, |
263 | - array( 'registrations' => $registrations ) |
|
263 | + array('registrations' => $registrations) |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
267 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
267 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
268 | 268 | } |
269 | 269 | } else { |
270 | 270 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
298 | 298 | * @return \EE_Line_Item_Filter_Collection |
299 | 299 | */ |
300 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
300 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
301 | 301 | $line_item_filter_collection->add( |
302 | 302 | new EE_Billable_Line_Item_Filter( |
303 | 303 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ) |
306 | 306 | ) |
307 | 307 | ); |
308 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
308 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
309 | 309 | return $line_item_filter_collection; |
310 | 310 | } |
311 | 311 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return void |
320 | 320 | */ |
321 | 321 | protected function _hide_reg_step_submit_button_if_revisit() { |
322 | - if ( $this->checkout->revisit ) { |
|
323 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
322 | + if ($this->checkout->revisit) { |
|
323 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param \EE_Event[] $sold_out_events_array |
332 | 332 | * @return \EE_Form_Section_Proper |
333 | 333 | */ |
334 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
334 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
335 | 335 | // set some defaults |
336 | 336 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
337 | 337 | $sold_out_events = ''; |
338 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
339 | - $sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )); |
|
338 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
339 | + $sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')); |
|
340 | 340 | } |
341 | 341 | return new EE_Form_Section_Proper( |
342 | 342 | array( |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | ), |
349 | 349 | 'layout_strategy' => new EE_Template_Layout( |
350 | 350 | array( |
351 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template |
|
351 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template |
|
352 | 352 | 'template_args' => apply_filters( |
353 | 353 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
354 | 354 | array( |
355 | 355 | 'sold_out_events' => $sold_out_events, |
356 | 356 | 'sold_out_events_msg' => apply_filters( |
357 | 357 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
358 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ) |
|
358 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso') |
|
359 | 359 | ) |
360 | 360 | ) |
361 | 361 | ) |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * @param array $registrations_requiring_pre_approval |
373 | 373 | * @return \EE_Form_Section_Proper |
374 | 374 | */ |
375 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) { |
|
375 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
376 | 376 | $events_requiring_pre_approval = ''; |
377 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
378 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
379 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
380 | - EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
377 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
378 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
379 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
380 | + EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
381 | 381 | ) |
382 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
382 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | } |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | ), |
392 | 392 | 'layout_strategy' => new EE_Template_Layout( |
393 | 393 | array( |
394 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template |
|
394 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template |
|
395 | 395 | 'template_args' => apply_filters( |
396 | 396 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
397 | 397 | array( |
398 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
398 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
399 | 399 | 'events_requiring_pre_approval_msg' => apply_filters( |
400 | 400 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
401 | - __( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' ) |
|
401 | + __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ), |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param \EE_Event[] $registrations_for_free_events |
417 | 417 | * @return \EE_Form_Section_Proper |
418 | 418 | */ |
419 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
419 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
420 | 420 | // set some defaults |
421 | 421 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
422 | 422 | // generate no_payment_required form |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | ), |
429 | 429 | 'layout_strategy' => new EE_Template_Layout( |
430 | 430 | array( |
431 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template |
|
431 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template |
|
432 | 432 | 'template_args' => apply_filters( |
433 | 433 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
434 | 434 | array( |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'registrations' => array(), |
437 | 437 | 'ticket_count' => array(), |
438 | 438 | 'registrations_for_free_events' => $registrations_for_free_events, |
439 | - 'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' )) |
|
439 | + 'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso')) |
|
440 | 440 | ) |
441 | 441 | ), |
442 | 442 | ) |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @param string $transaction_details |
454 | 454 | * @return \EE_Form_Section_Proper |
455 | 455 | */ |
456 | - private function _display_payment_options( $transaction_details = '' ) { |
|
456 | + private function _display_payment_options($transaction_details = '') { |
|
457 | 457 | // has method_of_payment been set by no-js user? |
458 | 458 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
459 | 459 | // build payment options form |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | 'before_payment_options' => apply_filters( |
466 | 466 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
467 | 467 | new EE_Form_Section_Proper( |
468 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
468 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
469 | 469 | ) |
470 | 470 | ), |
471 | 471 | 'payment_options' => $this->_setup_payment_options(), |
472 | 472 | 'after_payment_options' => apply_filters( |
473 | 473 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
474 | 474 | new EE_Form_Section_Proper( |
475 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
475 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
479 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( FALSE ) |
|
479 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE) |
|
480 | 480 | ), |
481 | - 'layout_strategy' => new EE_Template_Layout( array( |
|
481 | + 'layout_strategy' => new EE_Template_Layout(array( |
|
482 | 482 | 'layout_template_file' => $this->_template, |
483 | 483 | 'template_args' => apply_filters( |
484 | 484 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param bool $no_payment_required |
503 | 503 | * @return \EE_Form_Section_Proper |
504 | 504 | */ |
505 | - private function _extra_hidden_inputs( $no_payment_required = TRUE ) { |
|
505 | + private function _extra_hidden_inputs($no_payment_required = TRUE) { |
|
506 | 506 | |
507 | 507 | return new EE_Form_Section_Proper( |
508 | 508 | array( |
509 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
509 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
510 | 510 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
511 | 511 | 'subsections' => array( |
512 | 512 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | * @access protected |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
|
542 | + protected function _apply_registration_payments_to_amount_owing($registrations) { |
|
543 | 543 | $payments = array(); |
544 | - foreach ( $registrations as $registration ) { |
|
545 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
544 | + foreach ($registrations as $registration) { |
|
545 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
546 | 546 | $payments = $payments + $registration->registration_payments(); |
547 | 547 | } |
548 | 548 | } |
549 | - if ( ! empty( $payments ) ) { |
|
550 | - foreach ( $payments as $payment ) { |
|
551 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
549 | + if ( ! empty($payments)) { |
|
550 | + foreach ($payments as $payment) { |
|
551 | + if ($payment instanceof EE_Registration_Payment) { |
|
552 | 552 | $this->checkout->amount_owing -= $payment->amount(); |
553 | 553 | } |
554 | 554 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @param bool $force_reset |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function _reset_selected_method_of_payment( $force_reset = FALSE ) { |
|
567 | - $reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE )); |
|
568 | - if ( $reset_payment_method ) { |
|
566 | + private function _reset_selected_method_of_payment($force_reset = FALSE) { |
|
567 | + $reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE)); |
|
568 | + if ($reset_payment_method) { |
|
569 | 569 | $this->checkout->selected_method_of_payment = NULL; |
570 | 570 | $this->checkout->payment_method = NULL; |
571 | 571 | $this->checkout->billing_form = NULL; |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @param string $selected_method_of_payment |
585 | 585 | * @return EE_Billing_Info_Form |
586 | 586 | */ |
587 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
588 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | - EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment )); |
|
587 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
588 | + $selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | + EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment)); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,40 +599,40 @@ discard block |
||
599 | 599 | // load payment method classes |
600 | 600 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
601 | 601 | // switch up header depending on number of available payment methods |
602 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
603 | - ? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' )) |
|
604 | - : apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' )); |
|
602 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
603 | + ? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso')) |
|
604 | + : apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso')); |
|
605 | 605 | $available_payment_methods = array( |
606 | 606 | // display the "Payment Method" header |
607 | 607 | 'payment_method_header' => new EE_Form_Section_HTML( |
608 | - EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' ) |
|
608 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
609 | 609 | ) |
610 | 610 | ); |
611 | 611 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
612 | 612 | $available_payment_method_options = array(); |
613 | 613 | $default_payment_method_option = array(); |
614 | 614 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
615 | - $payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' ))); |
|
615 | + $payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;'))); |
|
616 | 616 | // loop through payment methods |
617 | - foreach( $this->checkout->available_payment_methods as $payment_method ) { |
|
618 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
619 | - $payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' ); |
|
617 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
618 | + if ($payment_method instanceof EE_Payment_Method) { |
|
619 | + $payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img'); |
|
620 | 620 | // check if any payment methods are set as default |
621 | 621 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
622 | - if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) { |
|
622 | + if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) { |
|
623 | 623 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
624 | 624 | $this->_save_selected_method_of_payment(); |
625 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
625 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
626 | 626 | } else { |
627 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
627 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
628 | 628 | } |
629 | - $payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method ); |
|
629 | + $payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method); |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | // prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs |
633 | 633 | $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
634 | 634 | // now generate the actual form inputs |
635 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options ); |
|
635 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options); |
|
636 | 636 | $available_payment_methods = $available_payment_methods + $payment_methods_billing_info; |
637 | 637 | |
638 | 638 | // build the available payment methods form |
@@ -652,19 +652,19 @@ discard block |
||
652 | 652 | * @return EE_Payment_Method[] |
653 | 653 | */ |
654 | 654 | protected function _get_available_payment_methods() { |
655 | - if ( ! empty( $this->checkout->available_payment_methods )) { |
|
655 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
656 | 656 | return $this->checkout->available_payment_methods; |
657 | 657 | } |
658 | 658 | $available_payment_methods = array(); |
659 | 659 | // load EEM_Payment_Method |
660 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
660 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
661 | 661 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
662 | 662 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
663 | 663 | // get all active payment methods |
664 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart ); |
|
665 | - foreach ( $payment_methods as $payment_method ) { |
|
666 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
667 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
664 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart); |
|
665 | + foreach ($payment_methods as $payment_method) { |
|
666 | + if ($payment_method instanceof EE_Payment_Method) { |
|
667 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | return $available_payment_methods; |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | * @param array $available_payment_method_options |
681 | 681 | * @return \EE_Form_Section_Proper |
682 | 682 | */ |
683 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
683 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
684 | 684 | // generate inputs |
685 | 685 | return new EE_Form_Section_Proper( |
686 | 686 | array( |
687 | 687 | 'html_id' => 'ee-available-payment-method-inputs', |
688 | 688 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
689 | 689 | 'subsections' => array( |
690 | - '' => new EE_Radio_Button_Input ( |
|
690 | + '' => new EE_Radio_Button_Input( |
|
691 | 691 | $available_payment_method_options, |
692 | 692 | array( |
693 | 693 | 'html_name' => 'selected_method_of_payment', |
@@ -711,36 +711,36 @@ discard block |
||
711 | 711 | * @param EE_Payment_Method $payment_method |
712 | 712 | * @return \EE_Form_Section_Proper |
713 | 713 | */ |
714 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
714 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
715 | 715 | $currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE; |
716 | 716 | // generate the billing form for payment method |
717 | - $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML(); |
|
717 | + $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML(); |
|
718 | 718 | $this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form; |
719 | 719 | // it's all in the details |
720 | - $info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' ); |
|
720 | + $info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr'); |
|
721 | 721 | // add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not |
722 | - if ( $payment_method->description() ) { |
|
722 | + if ($payment_method->description()) { |
|
723 | 723 | $payment_method_info = $payment_method->description(); |
724 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
725 | - $payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
724 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
725 | + $payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
726 | 726 | } else { |
727 | - $payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
727 | + $payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
728 | 728 | } |
729 | - $info_html .= EEH_HTML::p ( |
|
730 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ), |
|
729 | + $info_html .= EEH_HTML::p( |
|
730 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info), |
|
731 | 731 | '', |
732 | 732 | 'spco-payment-method-desc ee-attention' |
733 | 733 | ); |
734 | 734 | |
735 | 735 | return new EE_Form_Section_Proper( |
736 | 736 | array( |
737 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
737 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
738 | 738 | 'html_class' => 'spco-payment-method-info-dv', |
739 | 739 | // only display the selected or default PM |
740 | 740 | 'html_style' => $currently_selected ? '' : 'display:none;', |
741 | 741 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
742 | 742 | 'subsections' => array( |
743 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
743 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
744 | 744 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
745 | 745 | ) |
746 | 746 | ) |
@@ -758,12 +758,12 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function get_billing_form_html_for_payment_method() { |
760 | 760 | // how have they chosen to pay? |
761 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
761 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
762 | 762 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
763 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
763 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
764 | 764 | return FALSE; |
765 | 765 | } |
766 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
766 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
767 | 767 | EE_Error::add_success( |
768 | 768 | apply_filters( |
769 | 769 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | ); |
773 | 773 | } |
774 | 774 | // now generate billing form for selected method of payment |
775 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
775 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
776 | 776 | // fill form with attendee info if applicable |
777 | - if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
778 | - $payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
777 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
778 | + $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
779 | 779 | } |
780 | 780 | // and debug content |
781 | - if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
782 | - $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form ); |
|
781 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
782 | + $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form); |
|
783 | 783 | } |
784 | 784 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : ''; |
785 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info )); |
|
785 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
786 | 786 | // localize validation rules for main form |
787 | 787 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
788 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
788 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
789 | 789 | return TRUE; |
790 | 790 | } |
791 | 791 | |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | * @param EE_Payment_Method $payment_method |
799 | 799 | * @return \EE_Billing_Info_Form |
800 | 800 | */ |
801 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
802 | - $billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) ); |
|
803 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
804 | - if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) { |
|
805 | - if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) { |
|
801 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
802 | + $billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing)); |
|
803 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
804 | + if (EE_Registry::instance()->REQ->is_set('payment_method')) { |
|
805 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
806 | 806 | EE_Error::add_success( |
807 | 807 | apply_filters( |
808 | 808 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
809 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() ) |
|
809 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name()) |
|
810 | 810 | ) |
811 | 811 | ); |
812 | 812 | } |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | * @param string $request_param |
832 | 832 | * @return NULL|string |
833 | 833 | */ |
834 | - private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) { |
|
834 | + private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') { |
|
835 | 835 | // is selected_method_of_payment set in the request ? |
836 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE ); |
|
837 | - if ( $selected_method_of_payment ) { |
|
836 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE); |
|
837 | + if ($selected_method_of_payment) { |
|
838 | 838 | // sanitize it |
839 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment; |
|
840 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
839 | + $selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment; |
|
840 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
841 | 841 | // store it in the session so that it's available for all subsequent requests including AJAX |
842 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
842 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
843 | 843 | } else { |
844 | 844 | // or is is set in the session ? |
845 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' ); |
|
845 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment'); |
|
846 | 846 | } |
847 | 847 | // do ya really really gotta have it? |
848 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
848 | + if (empty($selected_method_of_payment) && $required) { |
|
849 | 849 | EE_Error::add_error( |
850 | 850 | sprintf( |
851 | - __( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ), |
|
851 | + __('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'), |
|
852 | 852 | '<br/>', |
853 | 853 | '<br/>', |
854 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
854 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
855 | 855 | ), |
856 | 856 | __FILE__, __FUNCTION__, __LINE__ |
857 | 857 | ); |
@@ -877,37 +877,37 @@ discard block |
||
877 | 877 | * @return string |
878 | 878 | */ |
879 | 879 | public function switch_payment_method() { |
880 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
880 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
881 | 881 | return FALSE; |
882 | 882 | } |
883 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
883 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
884 | 884 | EE_Error::add_success( |
885 | 885 | apply_filters( |
886 | 886 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
887 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() ) |
|
887 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name()) |
|
888 | 888 | ) |
889 | 889 | ); |
890 | 890 | } |
891 | 891 | // generate billing form for selected method of payment if it hasn't been done already |
892 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
893 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
892 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
893 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
894 | 894 | } |
895 | 895 | // fill form with attendee info if applicable |
896 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
897 | - $this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
896 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
897 | + $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
898 | 898 | } |
899 | 899 | // and debug content |
900 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
901 | - $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form ); |
|
900 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
901 | + $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form); |
|
902 | 902 | } |
903 | 903 | // get html and validation rules for form |
904 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
905 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() )); |
|
904 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
905 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html())); |
|
906 | 906 | // localize validation rules for main form |
907 | - $this->checkout->billing_form->localize_validation_rules( TRUE ); |
|
908 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
907 | + $this->checkout->billing_form->localize_validation_rules(TRUE); |
|
908 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
909 | 909 | } else { |
910 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' )); |
|
910 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
911 | 911 | } |
912 | 912 | //prevents advancement to next step |
913 | 913 | $this->checkout->continue_reg = FALSE; |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | */ |
923 | 923 | protected function _verify_payment_method_is_set() { |
924 | 924 | // generate billing form for selected method of payment if it hasn't been done already |
925 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
925 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
926 | 926 | // how have they chosen to pay? |
927 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
927 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
928 | 928 | } |
929 | 929 | // verify payment method |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | // get payment method for selected method of payment |
932 | 932 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
933 | 933 | } |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | */ |
949 | 949 | public function save_payer_details_via_ajax() { |
950 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
950 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
951 | 951 | return; |
952 | 952 | } |
953 | 953 | // generate billing form for selected method of payment if it hasn't been done already |
954 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
955 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
954 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
955 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
956 | 956 | } |
957 | 957 | // generate primary attendee from payer info if applicable |
958 | 958 | if ( ! $this->checkout->transaction_has_primary_registrant()) { |
959 | 959 | $attendee = $this->_create_attendee_from_request_data(); |
960 | - if ( $attendee instanceof EE_Attendee ) { |
|
961 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
962 | - if ( $registration->is_primary_registrant() ) { |
|
960 | + if ($attendee instanceof EE_Attendee) { |
|
961 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
962 | + if ($registration->is_primary_registrant()) { |
|
963 | 963 | $this->checkout->primary_attendee_obj = $attendee; |
964 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
965 | - $registration->set_attendee_id( $attendee->ID() ); |
|
966 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
964 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
965 | + $registration->set_attendee_id($attendee->ID()); |
|
966 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | } |
@@ -976,56 +976,56 @@ discard block |
||
976 | 976 | * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
977 | 977 | * @return \EE_Attendee |
978 | 978 | */ |
979 | - protected function _create_attendee_from_request_data(){ |
|
979 | + protected function _create_attendee_from_request_data() { |
|
980 | 980 | // get State ID |
981 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
982 | - if ( ! empty( $STA_ID )) { |
|
981 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
982 | + if ( ! empty($STA_ID)) { |
|
983 | 983 | // can we get state object from name ? |
984 | - EE_Registry::instance()->load_model( 'State' ); |
|
985 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' ); |
|
986 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
984 | + EE_Registry::instance()->load_model('State'); |
|
985 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
986 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
987 | 987 | } |
988 | 988 | // get Country ISO |
989 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
990 | - if ( ! empty( $CNT_ISO )) { |
|
989 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
990 | + if ( ! empty($CNT_ISO)) { |
|
991 | 991 | // can we get country object from name ? |
992 | - EE_Registry::instance()->load_model( 'Country' ); |
|
993 | - $country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' ); |
|
994 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
992 | + EE_Registry::instance()->load_model('Country'); |
|
993 | + $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO'); |
|
994 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
995 | 995 | } |
996 | 996 | // grab attendee data |
997 | 997 | $attendee_data = array( |
998 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
999 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1000 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1001 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1002 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1003 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
998 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
999 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1000 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1001 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1002 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1003 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1004 | 1004 | 'STA_ID' => $STA_ID, |
1005 | 1005 | 'CNT_ISO' => $CNT_ISO, |
1006 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1007 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1006 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1007 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1008 | 1008 | ); |
1009 | 1009 | // validate the email address since it is the most important piece of info |
1010 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) { |
|
1011 | - EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1010 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) { |
|
1011 | + EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1012 | 1012 | } |
1013 | 1013 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1014 | - if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) { |
|
1015 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1014 | + if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) { |
|
1015 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1016 | 1016 | 'ATT_fname' => $attendee_data['ATT_fname'], |
1017 | 1017 | 'ATT_lname' => $attendee_data['ATT_lname'], |
1018 | 1018 | 'ATT_email' => $attendee_data['ATT_email'] |
1019 | 1019 | )); |
1020 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1020 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1021 | 1021 | return $existing_attendee; |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | // no existing attendee? kk let's create a new one |
1025 | 1025 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1026 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1026 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | + return EE_Attendee::new_instance($attendee_data); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | |
@@ -1045,22 +1045,22 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | public function process_reg_step() { |
1047 | 1047 | // how have they chosen to pay? |
1048 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE ); |
|
1048 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE); |
|
1049 | 1049 | // choose your own adventure based on method_of_payment |
1050 | - switch( $this->checkout->selected_method_of_payment ) { |
|
1050 | + switch ($this->checkout->selected_method_of_payment) { |
|
1051 | 1051 | |
1052 | 1052 | case 'events_sold_out' : |
1053 | 1053 | $this->checkout->redirect = TRUE; |
1054 | 1054 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1055 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1055 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1056 | 1056 | // mark this reg step as completed |
1057 | 1057 | $this->set_completed(); |
1058 | 1058 | return FALSE; |
1059 | 1059 | break; |
1060 | 1060 | |
1061 | 1061 | case 'payments_closed' : |
1062 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) { |
|
1063 | - EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1062 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) { |
|
1063 | + EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1064 | 1064 | } |
1065 | 1065 | // mark this reg step as completed |
1066 | 1066 | $this->set_completed(); |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | break; |
1069 | 1069 | |
1070 | 1070 | case 'no_payment_required' : |
1071 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) { |
|
1072 | - EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) { |
|
1072 | + EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | } |
1074 | 1074 | // mark this reg step as completed |
1075 | 1075 | $this->set_completed(); |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | default: |
1080 | 1080 | $payment_successful = $this->_process_payment(); |
1081 | - if ( $payment_successful ) { |
|
1081 | + if ($payment_successful) { |
|
1082 | 1082 | $this->checkout->continue_reg = true; |
1083 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1083 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1084 | 1084 | } else { |
1085 | 1085 | $this->checkout->continue_reg = false; |
1086 | 1086 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param \EE_Payment_Method $payment_method |
1099 | 1099 | * @return void |
1100 | 1100 | */ |
1101 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1102 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1101 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1102 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1103 | 1103 | case EE_PMT_Base::offsite : |
1104 | 1104 | break; |
1105 | 1105 | case EE_PMT_Base::onsite : |
@@ -1122,15 +1122,15 @@ discard block |
||
1122 | 1122 | public function update_reg_step() { |
1123 | 1123 | $success = TRUE; |
1124 | 1124 | // if payment required |
1125 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1126 | - do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction ); |
|
1125 | + if ($this->checkout->transaction->total() > 0) { |
|
1126 | + do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction); |
|
1127 | 1127 | // attempt payment via payment method |
1128 | 1128 | $success = $this->process_reg_step(); |
1129 | 1129 | } |
1130 | - if ( $success && ! $this->checkout->redirect ) { |
|
1131 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
1130 | + if ($success && ! $this->checkout->redirect) { |
|
1131 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
1132 | 1132 | // set return URL |
1133 | - $this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url ); |
|
1133 | + $this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url); |
|
1134 | 1134 | } |
1135 | 1135 | return $success; |
1136 | 1136 | } |
@@ -1150,24 +1150,24 @@ discard block |
||
1150 | 1150 | // clear any previous errors related to not selecting a payment method |
1151 | 1151 | // EE_Error::overwrite_errors(); |
1152 | 1152 | // ya gotta make a choice man |
1153 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
1154 | - $this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' )); |
|
1153 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1154 | + $this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso')); |
|
1155 | 1155 | return FALSE; |
1156 | 1156 | } |
1157 | 1157 | // get EE_Payment_Method object |
1158 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1158 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1159 | 1159 | return FALSE; |
1160 | 1160 | } |
1161 | 1161 | // setup billing form |
1162 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1163 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1162 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1163 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1164 | 1164 | // bad billing form ? |
1165 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1165 | + if ( ! $this->_billing_form_is_valid()) { |
|
1166 | 1166 | return FALSE; |
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | // ensure primary registrant has been fully processed |
1170 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1170 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1171 | 1171 | return FALSE; |
1172 | 1172 | } |
1173 | 1173 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1175,24 +1175,24 @@ discard block |
||
1175 | 1175 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1176 | 1176 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1177 | 1177 | // attempt payment |
1178 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1178 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1179 | 1179 | // process results |
1180 | - $payment = $this->_validate_payment( $payment ); |
|
1181 | - $payment = $this->_post_payment_processing( $payment ); |
|
1180 | + $payment = $this->_validate_payment($payment); |
|
1181 | + $payment = $this->_post_payment_processing($payment); |
|
1182 | 1182 | // verify payment |
1183 | - if ( $payment instanceof EE_Payment ) { |
|
1183 | + if ($payment instanceof EE_Payment) { |
|
1184 | 1184 | // store that for later |
1185 | 1185 | $this->checkout->payment = $payment; |
1186 | 1186 | /** @type EE_Transaction_Processor $transaction_processor */ |
1187 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1187 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1188 | 1188 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1189 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1190 | - if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) { |
|
1189 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1190 | + if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) { |
|
1191 | 1191 | return true; |
1192 | 1192 | } else { |
1193 | 1193 | return false; |
1194 | 1194 | } |
1195 | - } else if ( $payment === true ) { |
|
1195 | + } else if ($payment === true) { |
|
1196 | 1196 | // please note that offline payment methods will NOT make a payment, |
1197 | 1197 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1198 | 1198 | $this->checkout->payment = $payment; |
@@ -1211,10 +1211,10 @@ discard block |
||
1211 | 1211 | * @return bool |
1212 | 1212 | */ |
1213 | 1213 | public function redirect_form() { |
1214 | - $payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() ); |
|
1214 | + $payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment()); |
|
1215 | 1215 | $html = $payment_method_billing_info->get_html_and_js(); |
1216 | 1216 | $html .= $this->checkout->redirect_form; |
1217 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1217 | + EE_Registry::instance()->REQ->add_output($html); |
|
1218 | 1218 | return TRUE; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1227,33 +1227,33 @@ discard block |
||
1227 | 1227 | * @return bool |
1228 | 1228 | */ |
1229 | 1229 | private function _billing_form_is_valid() { |
1230 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1231 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1230 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1231 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1232 | 1232 | $this->checkout->billing_form->receive_form_submission(); |
1233 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1233 | + if ($this->checkout->billing_form->is_valid()) { |
|
1234 | 1234 | return TRUE; |
1235 | 1235 | } |
1236 | 1236 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1237 | 1237 | $error_strings = array(); |
1238 | - foreach( $validation_errors as $validation_error ){ |
|
1239 | - if( $validation_error instanceof EE_Validation_Error ){ |
|
1238 | + foreach ($validation_errors as $validation_error) { |
|
1239 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1240 | 1240 | $form_section = $validation_error->get_form_section(); |
1241 | - if( $form_section instanceof EE_Form_Input_Base ){ |
|
1241 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1242 | 1242 | $label = $form_section->html_label_text(); |
1243 | - }elseif( $form_section instanceof EE_Form_Section_Base ){ |
|
1243 | + }elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1244 | 1244 | $label = $form_section->name(); |
1245 | - }else{ |
|
1246 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1245 | + } else { |
|
1246 | + $label = __('Validation Error', 'event_espresso'); |
|
1247 | 1247 | } |
1248 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1248 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1249 | 1249 | } |
1250 | 1250 | } |
1251 | - EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings ) ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1251 | + EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__); |
|
1252 | 1252 | } else { |
1253 | - EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1253 | + EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1254 | 1254 | } |
1255 | 1255 | } else { |
1256 | - EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1256 | + EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | 1257 | } |
1258 | 1258 | return FALSE; |
1259 | 1259 | } |
@@ -1271,9 +1271,9 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | private function _setup_primary_registrant_prior_to_payment() { |
1273 | 1273 | // check if transaction has a primary registrant and that it has a related Attendee object |
1274 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1274 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1275 | 1275 | // need to at least gather some primary registrant data before attempting payment |
1276 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) { |
|
1276 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) { |
|
1277 | 1277 | return FALSE; |
1278 | 1278 | } |
1279 | 1279 | } |
@@ -1281,13 +1281,13 @@ discard block |
||
1281 | 1281 | // grab the primary_registration object |
1282 | 1282 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1283 | 1283 | /** @type EE_Transaction_Processor $transaction_processor */ |
1284 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1284 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1285 | 1285 | // at this point we'll consider a TXN to not have been failed |
1286 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1286 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1287 | 1287 | // save the TXN ( which clears cached copy of primary_registration) |
1288 | 1288 | $this->checkout->transaction->save(); |
1289 | 1289 | // grab TXN ID and save it to the primary_registration |
1290 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1290 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1291 | 1291 | // save what we have so far |
1292 | 1292 | $primary_registration->save(); |
1293 | 1293 | return TRUE; |
@@ -1304,41 +1304,41 @@ discard block |
||
1304 | 1304 | private function _capture_primary_registration_data_from_billing_form() { |
1305 | 1305 | // convert billing form data into an attendee |
1306 | 1306 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1307 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1307 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1308 | 1308 | EE_Error::add_error( |
1309 | 1309 | sprintf( |
1310 | - __( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1310 | + __('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1311 | 1311 | '<br/>', |
1312 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1312 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1313 | 1313 | ), __FILE__, __FUNCTION__, __LINE__ |
1314 | 1314 | ); |
1315 | 1315 | return FALSE; |
1316 | 1316 | } |
1317 | 1317 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1318 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1318 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1319 | 1319 | EE_Error::add_error( |
1320 | 1320 | sprintf( |
1321 | - __( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1321 | + __('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1322 | 1322 | '<br/>', |
1323 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1323 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1324 | 1324 | ), __FILE__, __FUNCTION__, __LINE__ |
1325 | 1325 | ); |
1326 | 1326 | return FALSE; |
1327 | 1327 | } |
1328 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) { |
|
1328 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) { |
|
1329 | 1329 | EE_Error::add_error( |
1330 | 1330 | sprintf( |
1331 | - __( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1331 | + __('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1332 | 1332 | '<br/>', |
1333 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1333 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1334 | 1334 | ), __FILE__, __FUNCTION__, __LINE__ |
1335 | 1335 | ); |
1336 | 1336 | return FALSE; |
1337 | 1337 | } |
1338 | 1338 | /** @type EE_Registration_Processor $registration_processor */ |
1339 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1339 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1340 | 1340 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1341 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1341 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1342 | 1342 | |
1343 | 1343 | return TRUE; |
1344 | 1344 | } |
@@ -1354,35 +1354,35 @@ discard block |
||
1354 | 1354 | */ |
1355 | 1355 | private function _get_payment_method_for_selected_method_of_payment() { |
1356 | 1356 | // get EE_Payment_Method object |
1357 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) { |
|
1358 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1357 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1358 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1359 | 1359 | } else { |
1360 | 1360 | // load EEM_Payment_Method |
1361 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1361 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1362 | 1362 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1363 | 1363 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1364 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1364 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1365 | 1365 | } |
1366 | 1366 | // verify $payment_method |
1367 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1367 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1368 | 1368 | // not a payment |
1369 | 1369 | EE_Error::add_error( |
1370 | 1370 | sprintf( |
1371 | - __( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1371 | + __('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1372 | 1372 | '<br/>', |
1373 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1373 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1374 | 1374 | ), __FILE__, __FUNCTION__, __LINE__ |
1375 | 1375 | ); |
1376 | 1376 | return NULL; |
1377 | 1377 | } |
1378 | 1378 | // and verify it has a valid Payment_Method Type object |
1379 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1379 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1380 | 1380 | // not a payment |
1381 | 1381 | EE_Error::add_error( |
1382 | 1382 | sprintf( |
1383 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1383 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1384 | 1384 | '<br/>', |
1385 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1385 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1386 | 1386 | ), __FILE__, __FUNCTION__, __LINE__ |
1387 | 1387 | ); |
1388 | 1388 | return NULL; |
@@ -1401,30 +1401,30 @@ discard block |
||
1401 | 1401 | * @type EE_Payment_Method $payment_method |
1402 | 1402 | * @return mixed EE_Payment | boolean |
1403 | 1403 | */ |
1404 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1405 | - $payment =NULL; |
|
1404 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1405 | + $payment = NULL; |
|
1406 | 1406 | $this->checkout->transaction->save(); |
1407 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1408 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1407 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1408 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1409 | 1409 | return FALSE; |
1410 | 1410 | } |
1411 | 1411 | try { |
1412 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1412 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1413 | 1413 | // generate payment object |
1414 | 1414 | $payment = $payment_processor->process_payment( |
1415 | 1415 | $payment_method, |
1416 | 1416 | $this->checkout->transaction, |
1417 | 1417 | $this->checkout->amount_owing, |
1418 | 1418 | $this->checkout->billing_form, |
1419 | - $this->_get_return_url( $payment_method ), |
|
1419 | + $this->_get_return_url($payment_method), |
|
1420 | 1420 | 'CART', |
1421 | 1421 | $this->checkout->admin_request, |
1422 | 1422 | TRUE, |
1423 | 1423 | $this->reg_step_url() |
1424 | 1424 | ); |
1425 | 1425 | |
1426 | - } catch( Exception $e ) { |
|
1427 | - $this->_handle_payment_processor_exception( $e ); |
|
1426 | + } catch (Exception $e) { |
|
1427 | + $this->_handle_payment_processor_exception($e); |
|
1428 | 1428 | } |
1429 | 1429 | return $payment; |
1430 | 1430 | } |
@@ -1438,12 +1438,12 @@ discard block |
||
1438 | 1438 | * @param \Exception $e |
1439 | 1439 | * @return void |
1440 | 1440 | */ |
1441 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1441 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1442 | 1442 | EE_Error::add_error( |
1443 | 1443 | sprintf( |
1444 | - __( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ), |
|
1444 | + __('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'), |
|
1445 | 1445 | '<br/>', |
1446 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1446 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1447 | 1447 | $e->getMessage(), |
1448 | 1448 | $e->getFile(), |
1449 | 1449 | $e->getLine() |
@@ -1460,9 +1460,9 @@ discard block |
||
1460 | 1460 | * @param \EE_Payment_Method $payment_method |
1461 | 1461 | * @return string |
1462 | 1462 | */ |
1463 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1463 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1464 | 1464 | $return_url = ''; |
1465 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1465 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1466 | 1466 | |
1467 | 1467 | case EE_PMT_Base::offsite : |
1468 | 1468 | $return_url = add_query_arg( |
@@ -1493,28 +1493,28 @@ discard block |
||
1493 | 1493 | * @param EE_Payment $payment |
1494 | 1494 | * @return EE_Payment | FALSE |
1495 | 1495 | */ |
1496 | - private function _validate_payment( $payment = NULL ) { |
|
1497 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1496 | + private function _validate_payment($payment = NULL) { |
|
1497 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1498 | 1498 | return TRUE; |
1499 | 1499 | } |
1500 | 1500 | // verify payment object |
1501 | - if ( $payment instanceof EE_Payment ) { |
|
1501 | + if ($payment instanceof EE_Payment) { |
|
1502 | 1502 | if ( |
1503 | 1503 | $payment->status() != EEM_Payment::status_id_approved |
1504 | 1504 | && $payment->status() != EEM_Payment::status_id_pending |
1505 | 1505 | && $payment->status() != EEM_Payment::status_id_cancelled |
1506 | 1506 | && $payment->gateway_response() != '' |
1507 | 1507 | ) { |
1508 | - EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1508 | + EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__); |
|
1509 | 1509 | } |
1510 | 1510 | } else { |
1511 | 1511 | // not a payment |
1512 | 1512 | EE_Error::add_error( |
1513 | 1513 | sprintf( |
1514 | - __( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact |
|
1515 | - %2$s for assistance.', 'event_espresso' ), |
|
1514 | + __('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact |
|
1515 | + %2$s for assistance.', 'event_espresso'), |
|
1516 | 1516 | '<br/>', |
1517 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1517 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1518 | 1518 | ), __FILE__, __FUNCTION__, __LINE__ |
1519 | 1519 | ); |
1520 | 1520 | return FALSE; |
@@ -1531,23 +1531,23 @@ discard block |
||
1531 | 1531 | * @param EE_Payment $payment |
1532 | 1532 | * @return bool |
1533 | 1533 | */ |
1534 | - private function _post_payment_processing( $payment = NULL ) { |
|
1534 | + private function _post_payment_processing($payment = NULL) { |
|
1535 | 1535 | // On-Site payment? |
1536 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1537 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) { |
|
1536 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1537 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1538 | 1538 | //$this->_setup_redirect_for_next_step(); |
1539 | 1539 | $this->checkout->continue_reg = false; |
1540 | 1540 | } |
1541 | 1541 | // Off-Site payment? |
1542 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1542 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1543 | 1543 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1544 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ){ |
|
1545 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1544 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1545 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1546 | 1546 | $this->checkout->redirect = TRUE; |
1547 | 1547 | $this->checkout->redirect_form = $payment->redirect_form(); |
1548 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1548 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1549 | 1549 | // set JSON response |
1550 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1550 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1551 | 1551 | // set cron job for finalizing the TXN |
1552 | 1552 | // in case the user does not return from the off-site gateway |
1553 | 1553 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1555,21 +1555,21 @@ discard block |
||
1555 | 1555 | $this->checkout->transaction->ID() |
1556 | 1556 | ); |
1557 | 1557 | // and lastly, let's bump the payment status to pending |
1558 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1558 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1559 | 1559 | $payment->save(); |
1560 | 1560 | } else { |
1561 | 1561 | // not a payment |
1562 | 1562 | $this->checkout->continue_reg = false; |
1563 | 1563 | EE_Error::add_error( |
1564 | 1564 | sprintf( |
1565 | - __( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1565 | + __('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1566 | 1566 | '<br/>', |
1567 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1567 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1568 | 1568 | ), __FILE__, __FUNCTION__, __LINE__ |
1569 | 1569 | ); |
1570 | 1570 | } |
1571 | 1571 | // Off-Line payment? |
1572 | - } else if ( $payment === TRUE ) { |
|
1572 | + } else if ($payment === TRUE) { |
|
1573 | 1573 | //$this->_setup_redirect_for_next_step(); |
1574 | 1574 | return TRUE; |
1575 | 1575 | } else { |
@@ -1605,65 +1605,65 @@ discard block |
||
1605 | 1605 | * @return bool |
1606 | 1606 | * @throws \EE_Error |
1607 | 1607 | */ |
1608 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1608 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1609 | 1609 | // off-line payment? carry on |
1610 | - if ( $payment_occurs == EE_PMT_Base::offline ) { |
|
1610 | + if ($payment_occurs == EE_PMT_Base::offline) { |
|
1611 | 1611 | return true; |
1612 | 1612 | } |
1613 | 1613 | // verify payment validity |
1614 | - if ( $payment instanceof EE_Payment ) { |
|
1615 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1614 | + if ($payment instanceof EE_Payment) { |
|
1615 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1616 | 1616 | $msg = $payment->gateway_response(); |
1617 | 1617 | // check results |
1618 | - switch ( $payment->status() ) { |
|
1618 | + switch ($payment->status()) { |
|
1619 | 1619 | |
1620 | 1620 | // good payment |
1621 | 1621 | case EEM_Payment::status_id_approved : |
1622 | - EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1622 | + EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1623 | 1623 | return TRUE; |
1624 | 1624 | break; |
1625 | 1625 | |
1626 | 1626 | // slow payment |
1627 | 1627 | case EEM_Payment::status_id_pending : |
1628 | - if ( empty( $msg )) { |
|
1629 | - $msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' ); |
|
1628 | + if (empty($msg)) { |
|
1629 | + $msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso'); |
|
1630 | 1630 | } |
1631 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1631 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1632 | 1632 | return TRUE; |
1633 | 1633 | break; |
1634 | 1634 | |
1635 | 1635 | // don't wanna payment |
1636 | 1636 | case EEM_Payment::status_id_cancelled : |
1637 | - if ( empty( $msg )) { |
|
1637 | + if (empty($msg)) { |
|
1638 | 1638 | $msg = _n( |
1639 | 1639 | 'Payment cancelled. Please try again.', |
1640 | 1640 | 'Payment cancelled. Please try again or select another method of payment.', |
1641 | - count( $this->checkout->available_payment_methods ), |
|
1641 | + count($this->checkout->available_payment_methods), |
|
1642 | 1642 | 'event_espresso' |
1643 | 1643 | ); |
1644 | 1644 | } |
1645 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1645 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1646 | 1646 | return FALSE; |
1647 | 1647 | break; |
1648 | 1648 | |
1649 | 1649 | // not enough payment |
1650 | 1650 | case EEM_Payment::status_id_declined : |
1651 | - if ( empty( $msg )) { |
|
1651 | + if (empty($msg)) { |
|
1652 | 1652 | $msg = _n( |
1653 | 1653 | 'We\'re sorry but your payment was declined. Please try again.', |
1654 | 1654 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
1655 | - count( $this->checkout->available_payment_methods ), |
|
1655 | + count($this->checkout->available_payment_methods), |
|
1656 | 1656 | 'event_espresso' |
1657 | 1657 | ); |
1658 | 1658 | } |
1659 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1659 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1660 | 1660 | return FALSE; |
1661 | 1661 | break; |
1662 | 1662 | |
1663 | 1663 | // bad payment |
1664 | 1664 | case EEM_Payment::status_id_failed : |
1665 | - if ( ! empty( $msg ) ) { |
|
1666 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1665 | + if ( ! empty($msg)) { |
|
1666 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1667 | 1667 | return false; |
1668 | 1668 | } |
1669 | 1669 | // default to error below |
@@ -1673,14 +1673,14 @@ discard block |
||
1673 | 1673 | } |
1674 | 1674 | // off-site payment gateway responses are too unreliable, so let's just assume that |
1675 | 1675 | // the payment processing is just running slower than the registrant's request |
1676 | - if ( $payment_occurs == EE_PMT_Base::offsite ) { |
|
1676 | + if ($payment_occurs == EE_PMT_Base::offsite) { |
|
1677 | 1677 | return true; |
1678 | 1678 | } |
1679 | 1679 | EE_Error::add_error( |
1680 | 1680 | sprintf( |
1681 | - __( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1681 | + __('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1682 | 1682 | '<br/>', |
1683 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1683 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1684 | 1684 | ), |
1685 | 1685 | __FILE__, __FUNCTION__, __LINE__ |
1686 | 1686 | ); |
@@ -1713,13 +1713,13 @@ discard block |
||
1713 | 1713 | public function process_gateway_response() { |
1714 | 1714 | $payment = null; |
1715 | 1715 | // how have they chosen to pay? |
1716 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1716 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1717 | 1717 | // get EE_Payment_Method object |
1718 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1718 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1719 | 1719 | $this->checkout->continue_reg = false; |
1720 | 1720 | return false; |
1721 | 1721 | } |
1722 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
1722 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
1723 | 1723 | return false; |
1724 | 1724 | } |
1725 | 1725 | $this->_validate_offsite_return(); |
@@ -1733,23 +1733,23 @@ discard block |
||
1733 | 1733 | // true |
1734 | 1734 | //); |
1735 | 1735 | // verify TXN |
1736 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1736 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1737 | 1737 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
1738 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
1738 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
1739 | 1739 | $this->checkout->continue_reg = false; |
1740 | 1740 | return false; |
1741 | 1741 | } |
1742 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
1743 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
1744 | - $payment = $this->_validate_payment( $payment ); |
|
1742 | + $payment = $this->_process_off_site_payment($gateway); |
|
1743 | + $payment = $this->_process_cancelled_payments($payment); |
|
1744 | + $payment = $this->_validate_payment($payment); |
|
1745 | 1745 | // if payment was not declined by the payment gateway or cancelled by the registrant |
1746 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
1746 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
1747 | 1747 | //$this->_setup_redirect_for_next_step(); |
1748 | 1748 | // store that for later |
1749 | 1749 | $this->checkout->payment = $payment; |
1750 | 1750 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
1751 | 1751 | // because we will complete this step during the IPN processing then |
1752 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) { |
|
1752 | + if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) { |
|
1753 | 1753 | $this->set_completed(); |
1754 | 1754 | } |
1755 | 1755 | return true; |
@@ -1772,19 +1772,19 @@ discard block |
||
1772 | 1772 | * @return bool |
1773 | 1773 | */ |
1774 | 1774 | private function _validate_offsite_return() { |
1775 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
1776 | - if ( $TXN_ID != $this->checkout->transaction->ID() ) { |
|
1775 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
1776 | + if ($TXN_ID != $this->checkout->transaction->ID()) { |
|
1777 | 1777 | // Houston... we might have a problem |
1778 | 1778 | $invalid_TXN = false; |
1779 | 1779 | // first gather some info |
1780 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1780 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1781 | 1781 | $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; |
1782 | 1782 | // let's start by retrieving the cart for this TXN |
1783 | - $cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction ); |
|
1784 | - if ( $cart instanceof EE_Cart ) { |
|
1783 | + $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); |
|
1784 | + if ($cart instanceof EE_Cart) { |
|
1785 | 1785 | // verify that the current cart has tickets |
1786 | 1786 | $tickets = $cart->get_tickets(); |
1787 | - if ( empty( $tickets ) ) { |
|
1787 | + if (empty($tickets)) { |
|
1788 | 1788 | $invalid_TXN = true; |
1789 | 1789 | } |
1790 | 1790 | } else { |
@@ -1792,39 +1792,39 @@ discard block |
||
1792 | 1792 | } |
1793 | 1793 | $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; |
1794 | 1794 | // validate current Session ID and compare against valid TXN session ID |
1795 | - if ( EE_Session::instance()->id() === null ) { |
|
1795 | + if (EE_Session::instance()->id() === null) { |
|
1796 | 1796 | $invalid_TXN = true; |
1797 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
1797 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
1798 | 1798 | // WARNING !!! |
1799 | 1799 | // this could be PayPal sending back duplicate requests (ya they do that) |
1800 | 1800 | // or it **could** mean someone is simply registering AGAIN after having just done so |
1801 | 1801 | // so now we need to determine if this current TXN looks valid or not |
1802 | 1802 | /** @type EE_Transaction_Processor $transaction_processor */ |
1803 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1803 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1804 | 1804 | // has this step even been started ? |
1805 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
1805 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
1806 | 1806 | ) { |
1807 | 1807 | // really? you're half way through this reg step, but you never started it ? |
1808 | 1808 | $invalid_TXN = true; |
1809 | 1809 | } |
1810 | 1810 | } |
1811 | - if ( $invalid_TXN ) { |
|
1811 | + if ($invalid_TXN) { |
|
1812 | 1812 | // is the valid TXN completed ? |
1813 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
1813 | + if ($valid_TXN instanceof EE_Transaction) { |
|
1814 | 1814 | /** @type EE_Transaction_Processor $transaction_processor */ |
1815 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1815 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1816 | 1816 | // has this step even been started ? |
1817 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
1818 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
1817 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
1818 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
1819 | 1819 | // so it **looks** like this is a double request from PayPal |
1820 | 1820 | // so let's try to pick up where we left off |
1821 | 1821 | $this->checkout->transaction = $valid_TXN; |
1822 | - $this->checkout->refresh_all_entities( true ); |
|
1822 | + $this->checkout->refresh_all_entities(true); |
|
1823 | 1823 | return; |
1824 | 1824 | } |
1825 | 1825 | } |
1826 | 1826 | // you appear to be lost? |
1827 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
1827 | + $this->_redirect_wayward_request($primary_registrant); |
|
1828 | 1828 | } |
1829 | 1829 | } |
1830 | 1830 | } |
@@ -1838,18 +1838,18 @@ discard block |
||
1838 | 1838 | * @param \EE_Registration $primary_registrant |
1839 | 1839 | * @return bool |
1840 | 1840 | */ |
1841 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
1842 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1841 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
1842 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1843 | 1843 | // try redirecting based on the current TXN |
1844 | 1844 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null; |
1845 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1845 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1846 | 1846 | EE_Error::add_error( |
1847 | 1847 | sprintf( |
1848 | - __( 'Invalid information was received from the Off-Site Payment Processor and your |
|
1848 | + __('Invalid information was received from the Off-Site Payment Processor and your |
|
1849 | 1849 | Transaction details could not be retrieved from the database.%1$sPlease try again or contact |
1850 | - %2$s for assistance.', 'event_espresso' ), |
|
1850 | + %2$s for assistance.', 'event_espresso'), |
|
1851 | 1851 | '<br/>', |
1852 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1852 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1853 | 1853 | ), |
1854 | 1854 | __FILE__, __FUNCTION__, __LINE__ |
1855 | 1855 | ); |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | * @param \EE_Offsite_Gateway $gateway |
1878 | 1878 | * @return \EE_Payment |
1879 | 1879 | */ |
1880 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
1880 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
1881 | 1881 | try { |
1882 | 1882 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
1883 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
1883 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
1884 | 1884 | $payment = $this->checkout->transaction->last_payment(); |
1885 | 1885 | //$payment_source = 'last_payment'; |
1886 | 1886 | } else { |
1887 | 1887 | // get payment details and process results |
1888 | 1888 | /** @type EE_Payment_Processor $payment_processor */ |
1889 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1889 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1890 | 1890 | $payment = $payment_processor->process_ipn( |
1891 | 1891 | $_REQUEST, |
1892 | 1892 | $this->checkout->transaction, |
@@ -1896,14 +1896,14 @@ discard block |
||
1896 | 1896 | ); |
1897 | 1897 | //$payment_source = 'process_ipn'; |
1898 | 1898 | } |
1899 | - } catch ( Exception $e ) { |
|
1899 | + } catch (Exception $e) { |
|
1900 | 1900 | // let's just eat the exception and try to move on using any previously set payment info |
1901 | 1901 | $payment = $this->checkout->transaction->last_payment(); |
1902 | 1902 | //$payment_source = 'last_payment after Exception'; |
1903 | 1903 | // but if we STILL don't have a payment object |
1904 | - if ( ! $payment instanceof EE_Payment ) { |
|
1904 | + if ( ! $payment instanceof EE_Payment) { |
|
1905 | 1905 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
1906 | - $this->_handle_payment_processor_exception( $e ); |
|
1906 | + $this->_handle_payment_processor_exception($e); |
|
1907 | 1907 | } |
1908 | 1908 | } |
1909 | 1909 | // DEBUG LOG |
@@ -1927,13 +1927,13 @@ discard block |
||
1927 | 1927 | * @param EE_Payment $payment |
1928 | 1928 | * @return EE_Payment | FALSE |
1929 | 1929 | */ |
1930 | - private function _process_cancelled_payments( $payment = NULL ) { |
|
1930 | + private function _process_cancelled_payments($payment = NULL) { |
|
1931 | 1931 | if ( |
1932 | - isset( $_REQUEST[ 'ee_cancel_payment' ] ) |
|
1932 | + isset($_REQUEST['ee_cancel_payment']) |
|
1933 | 1933 | && $payment instanceof EE_Payment |
1934 | 1934 | && $payment->status() == EEM_Payment::status_id_failed |
1935 | 1935 | ) { |
1936 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
1936 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
1937 | 1937 | } |
1938 | 1938 | return $payment; |
1939 | 1939 | } |
@@ -1950,23 +1950,23 @@ discard block |
||
1950 | 1950 | public function get_transaction_details_for_gateways() { |
1951 | 1951 | $txn_details = array(); |
1952 | 1952 | // ya gotta make a choice man |
1953 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1953 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1954 | 1954 | $txn_details = array( |
1955 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1955 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1956 | 1956 | ); |
1957 | 1957 | } |
1958 | 1958 | // get EE_Payment_Method object |
1959 | 1959 | if ( |
1960 | - empty( $txn_details ) && |
|
1960 | + empty($txn_details) && |
|
1961 | 1961 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
1962 | 1962 | ) { |
1963 | 1963 | $txn_details = array( |
1964 | 1964 | 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
1965 | - 'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' ) |
|
1965 | + 'error' => __('A valid Payment Method could not be determined.', 'event_espresso') |
|
1966 | 1966 | ); |
1967 | 1967 | } |
1968 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
1969 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
1968 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
1969 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
1970 | 1970 | $txn_details = array( |
1971 | 1971 | 'TXN_ID' => $this->checkout->transaction->ID(), |
1972 | 1972 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
1978 | 1978 | 'payment_amount' => $this->checkout->amount_owing, |
1979 | 1979 | 'return_url' => $return_url, |
1980 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
1980 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
1981 | 1981 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
1982 | 1982 | array( |
1983 | 1983 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -1986,7 +1986,7 @@ discard block |
||
1986 | 1986 | ) |
1987 | 1987 | ); |
1988 | 1988 | } |
1989 | - echo json_encode( $txn_details ); |
|
1989 | + echo json_encode($txn_details); |
|
1990 | 1990 | exit(); |
1991 | 1991 | } |
1992 | 1992 |
@@ -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 | * EE_Registration class |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * date_format and the second value is the time format |
42 | 42 | * @return EE_Registration |
43 | 43 | */ |
44 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
45 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
46 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
44 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
45 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
46 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * the website will be used. |
55 | 55 | * @return EE_Registration |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - return new self( $props_n_values, TRUE, $timezone ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + return new self($props_n_values, TRUE, $timezone); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | * @param int $EVT_ID Event ID |
68 | 68 | */ |
69 | - public function set_event( $EVT_ID = 0 ) { |
|
70 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
69 | + public function set_event($EVT_ID = 0) { |
|
70 | + $this->set('EVT_ID', $EVT_ID); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | * @param mixed $field_value |
79 | 79 | * @param bool $use_default |
80 | 80 | */ |
81 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
82 | - switch( $field_name ) { |
|
81 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
82 | + switch ($field_name) { |
|
83 | 83 | case 'REG_code' : |
84 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
85 | - $this->set_reg_code( $field_value, $use_default ); |
|
84 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
85 | + $this->set_reg_code($field_value, $use_default); |
|
86 | 86 | } |
87 | 87 | break; |
88 | 88 | case 'STS_ID' : |
89 | - $this->set_status( $field_value, $use_default ); |
|
89 | + $this->set_status($field_value, $use_default); |
|
90 | 90 | break; |
91 | 91 | default : |
92 | - parent::set( $field_name, $field_value, $use_default ); |
|
92 | + parent::set($field_name, $field_value, $use_default); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @param boolean $use_default |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
109 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
110 | 110 | // get current REG_Status |
111 | 111 | $old_STS_ID = $this->status_ID(); |
112 | 112 | // if status has changed |
113 | - if ( $old_STS_ID != $new_STS_ID ) { |
|
113 | + if ($old_STS_ID != $new_STS_ID) { |
|
114 | 114 | // TO approved |
115 | - if ( $new_STS_ID == EEM_Registration::status_id_approved ) { |
|
115 | + if ($new_STS_ID == EEM_Registration::status_id_approved) { |
|
116 | 116 | // reserve a space by incrementing ticket and datetime sold values |
117 | 117 | $this->_reserve_registration_space(); |
118 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
118 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
119 | 119 | // OR FROM approved |
120 | - } else if ( $old_STS_ID == EEM_Registration::status_id_approved ) { |
|
120 | + } else if ($old_STS_ID == EEM_Registration::status_id_approved) { |
|
121 | 121 | // release a space by decrementing ticket and datetime sold values |
122 | 122 | $this->_release_registration_space(); |
123 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
123 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
124 | 124 | } |
125 | 125 | // update status |
126 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
127 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
126 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
127 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
128 | 128 | return TRUE; |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | //even though the old value matches the new value, it's still good to |
131 | 131 | //allow the parent set method to have a say |
132 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
132 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
133 | 133 | return TRUE; |
134 | 134 | } |
135 | 135 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @access public |
142 | 142 | */ |
143 | 143 | public function status_ID() { |
144 | - return $this->get( 'STS_ID' ); |
|
144 | + return $this->get('STS_ID'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @param boolean $include_archived whether to include archived tickets or not. |
167 | 167 | * @return EE_Ticket |
168 | 168 | */ |
169 | - public function ticket( $include_archived = TRUE ) { |
|
169 | + public function ticket($include_archived = TRUE) { |
|
170 | 170 | $query_params = array(); |
171 | - if ( $include_archived ) { |
|
172 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
171 | + if ($include_archived) { |
|
172 | + $query_params['default_where_conditions'] = 'none'; |
|
173 | 173 | } |
174 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
174 | + return $this->get_first_related('Ticket', $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return EE_Event |
182 | 182 | */ |
183 | 183 | public function event() { |
184 | - return $this->get_first_related( 'Event' ); |
|
184 | + return $this->get_first_related('Event'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function wp_user() { |
197 | 197 | $event = $this->event(); |
198 | - if ( $event instanceof EE_Event ) { |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | 199 | return $event->wp_user(); |
200 | 200 | } |
201 | 201 | return 0; |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @access public |
222 | 222 | * @param int $ATT_ID Attendee ID |
223 | 223 | */ |
224 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
225 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
224 | + public function set_attendee_id($ATT_ID = 0) { |
|
225 | + $this->set('ATT_ID', $ATT_ID); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @access public |
234 | 234 | * @param int $TXN_ID Transaction ID |
235 | 235 | */ |
236 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
237 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
236 | + public function set_transaction_id($TXN_ID = 0) { |
|
237 | + $this->set('TXN_ID', $TXN_ID); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @param string $REG_session PHP Session ID |
247 | 247 | */ |
248 | - public function set_session( $REG_session = '' ) { |
|
249 | - $this->set( 'REG_session', $REG_session ); |
|
248 | + public function set_session($REG_session = '') { |
|
249 | + $this->set('REG_session', $REG_session); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @param string $REG_url_link Registration URL Link |
259 | 259 | */ |
260 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
261 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
260 | + public function set_reg_url_link($REG_url_link = '') { |
|
261 | + $this->set('REG_url_link', $REG_url_link); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @access public |
270 | 270 | * @param int $REG_count Primary Attendee |
271 | 271 | */ |
272 | - public function set_count( $REG_count = 1 ) { |
|
273 | - $this->set( 'REG_count', $REG_count ); |
|
272 | + public function set_count($REG_count = 1) { |
|
273 | + $this->set('REG_count', $REG_count); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @access public |
282 | 282 | * @param boolean $REG_group_size Group Registration |
283 | 283 | */ |
284 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
285 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
284 | + public function set_group_size($REG_group_size = FALSE) { |
|
285 | + $this->set('REG_group_size', $REG_group_size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @access public |
366 | 366 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
367 | 367 | */ |
368 | - public function set_reg_date( $REG_date = FALSE ) { |
|
369 | - $this->set( 'REG_date', $REG_date ); |
|
368 | + public function set_reg_date($REG_date = FALSE) { |
|
369 | + $this->set('REG_date', $REG_date); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @access public |
378 | 378 | * @param float $REG_final_price |
379 | 379 | */ |
380 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
381 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
380 | + public function set_final_price($REG_final_price = 0.00) { |
|
381 | + $this->set('REG_final_price', $REG_final_price); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @access public |
390 | 390 | * @param float $REG_paid |
391 | 391 | */ |
392 | - public function set_paid( $REG_paid = 0.00 ) { |
|
393 | - $this->set( 'REG_paid', $REG_paid ); |
|
392 | + public function set_paid($REG_paid = 0.00) { |
|
393 | + $this->set('REG_paid', $REG_paid); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @access public |
402 | 402 | * @param boolean $REG_att_is_going Attendee Is Going |
403 | 403 | */ |
404 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
405 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
404 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
405 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return EE_Attendee |
413 | 413 | */ |
414 | 414 | public function attendee() { |
415 | - return $this->get_first_related( 'Attendee' ); |
|
415 | + return $this->get_first_related('Attendee'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @access public |
423 | 423 | */ |
424 | 424 | public function event_ID() { |
425 | - return $this->get( 'EVT_ID' ); |
|
425 | + return $this->get('EVT_ID'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function event_name() { |
435 | 435 | $event = $this->event_obj(); |
436 | - if ( $event ) { |
|
436 | + if ($event) { |
|
437 | 437 | return $event->name(); |
438 | 438 | } else { |
439 | 439 | return NULL; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @return EE_Event |
448 | 448 | */ |
449 | 449 | public function event_obj() { |
450 | - return $this->get_first_related( 'Event' ); |
|
450 | + return $this->get_first_related('Event'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @access public |
458 | 458 | */ |
459 | 459 | public function attendee_ID() { |
460 | - return $this->get( 'ATT_ID' ); |
|
460 | + return $this->get('ATT_ID'); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | */ |
469 | 469 | public function session_ID() { |
470 | - return $this->get( 'REG_session' ); |
|
470 | + return $this->get('REG_session'); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function receipt_url( $messenger = 'html' ) { |
|
480 | + public function receipt_url($messenger = 'html') { |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | EE_Registry::instance()->load_helper('Template'); |
488 | 488 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
489 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
489 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
490 | 490 | |
491 | - if ( $has_custom ) { |
|
492 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
491 | + if ($has_custom) { |
|
492 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
493 | 493 | } |
494 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
494 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function invoice_url( $messenger = 'html' ) { |
|
505 | + public function invoice_url($messenger = 'html') { |
|
506 | 506 | /** |
507 | 507 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
508 | 508 | * |
@@ -510,21 +510,21 @@ discard block |
||
510 | 510 | */ |
511 | 511 | EE_Registry::instance()->load_helper('Template'); |
512 | 512 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
513 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
513 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
514 | 514 | |
515 | - if ( $has_custom ) { |
|
516 | - if ( $messenger == 'html' ) { |
|
517 | - return $this->invoice_url( 'launch' ); |
|
515 | + if ($has_custom) { |
|
516 | + if ($messenger == 'html') { |
|
517 | + return $this->invoice_url('launch'); |
|
518 | 518 | } |
519 | 519 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
520 | 520 | |
521 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
522 | - if ( $messenger == 'html' ) { |
|
521 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
522 | + if ($messenger == 'html') { |
|
523 | 523 | $query_args['html'] = TRUE; |
524 | 524 | } |
525 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
525 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
526 | 526 | } |
527 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
527 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @access public |
535 | 535 | */ |
536 | 536 | public function reg_url_link() { |
537 | - return $this->get( 'REG_url_link' ); |
|
537 | + return $this->get('REG_url_link'); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function e_invoice_url( $type = 'launch' ) { |
|
548 | - echo $this->invoice_url( $type ); |
|
547 | + public function e_invoice_url($type = 'launch') { |
|
548 | + echo $this->invoice_url($type); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @return string |
566 | 566 | */ |
567 | 567 | public function payment_overview_url() { |
568 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
568 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return string |
577 | 577 | */ |
578 | 578 | public function edit_attendee_information_url() { |
579 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
579 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -586,8 +586,8 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | */ |
588 | 588 | public function get_admin_edit_url() { |
589 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
590 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
589 | + EE_Registry::instance()->load_helper('URL'); |
|
590 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @access public |
598 | 598 | */ |
599 | 599 | public function is_primary_registrant() { |
600 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
600 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * This returns the primary registration object for this registration group (which may be this object). |
607 | 607 | * @return EE_Registration |
608 | 608 | */ |
609 | - public function get_primary_registration() { |
|
610 | - if ( $this->is_primary_registrant() ) |
|
609 | + public function get_primary_registration() { |
|
610 | + if ($this->is_primary_registrant()) |
|
611 | 611 | return $this; |
612 | 612 | |
613 | 613 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
614 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
614 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
615 | 615 | return $primary_registrant; |
616 | 616 | } |
617 | 617 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @access public |
623 | 623 | */ |
624 | 624 | public function count() { |
625 | - return $this->get( 'REG_count' ); |
|
625 | + return $this->get('REG_count'); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @access public |
633 | 633 | */ |
634 | 634 | public function group_size() { |
635 | - return $this->get( 'REG_group_size' ); |
|
635 | + return $this->get('REG_group_size'); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @access public |
643 | 643 | */ |
644 | 644 | public function date() { |
645 | - return $this->get( 'REG_date' ); |
|
645 | + return $this->get('REG_date'); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $time_format |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
657 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
656 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
657 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @return float |
668 | 668 | */ |
669 | 669 | public function final_price() { |
670 | - return $this->get( 'REG_final_price' ); |
|
670 | + return $this->get('REG_final_price'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | */ |
680 | 680 | public function pretty_final_price() { |
681 | - return $this->get_pretty( 'REG_final_price' ); |
|
681 | + return $this->get_pretty('REG_final_price'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | * @return float |
690 | 690 | */ |
691 | 691 | public function paid() { |
692 | - return $this->get( 'REG_paid' ); |
|
692 | + return $this->get('REG_paid'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @return float |
701 | 701 | */ |
702 | 702 | public function pretty_paid() { |
703 | - return $this->get_pretty( 'REG_paid' ); |
|
703 | + return $this->get_pretty('REG_paid'); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param array $requires_payment |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
715 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
716 | 716 | // these reg statuses require payment (if event is not free) |
717 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
717 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
718 | 718 | if ( |
719 | - in_array( $this->status_ID(), $requires_payment ) && |
|
719 | + in_array($this->status_ID(), $requires_payment) && |
|
720 | 720 | $this->final_price() != 0 && |
721 | 721 | $this->final_price() != $this->paid() |
722 | 722 | ) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | * @param bool $show_icons |
734 | 734 | * @return void |
735 | 735 | */ |
736 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
737 | - echo $this->pretty_status( $show_icons ); |
|
736 | + public function e_pretty_status($show_icons = FALSE) { |
|
737 | + echo $this->pretty_status($show_icons); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | * @param bool $show_icons |
746 | 746 | * @return string |
747 | 747 | */ |
748 | - public function pretty_status( $show_icons = FALSE ) { |
|
749 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
748 | + public function pretty_status($show_icons = FALSE) { |
|
749 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
750 | 750 | $icon = ''; |
751 | - switch ( $this->status_ID() ) { |
|
751 | + switch ($this->status_ID()) { |
|
752 | 752 | case EEM_Registration::status_id_approved: |
753 | 753 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
754 | 754 | break; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
769 | 769 | break; |
770 | 770 | } |
771 | - return $icon . $status[ $this->status_ID() ]; |
|
771 | + return $icon.$status[$this->status_ID()]; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @access public |
779 | 779 | */ |
780 | 780 | public function att_is_going() { |
781 | - return $this->get( 'REG_att_is_going' ); |
|
781 | + return $this->get('REG_att_is_going'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param array $query_params like EEM_Base::get_all |
789 | 789 | * @return EE_Answer[] |
790 | 790 | */ |
791 | - public function answers( $query_params = NULL ) { |
|
792 | - return $this->get_many_related( 'Answer', $query_params ); |
|
791 | + public function answers($query_params = NULL) { |
|
792 | + return $this->get_many_related('Answer', $query_params); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * (because the answer might be an array of answer values, so passing pretty_value=true |
804 | 804 | * will convert it into some kind of string) |
805 | 805 | */ |
806 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
806 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
807 | 807 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
808 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
808 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | */ |
819 | 819 | public function question_groups() { |
820 | 820 | $question_groups = array(); |
821 | - if ( $this->event() instanceof EE_Event ) { |
|
821 | + if ($this->event() instanceof EE_Event) { |
|
822 | 822 | $question_groups = $this->event()->question_groups( |
823 | 823 | array( |
824 | 824 | array( |
825 | 825 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
826 | 826 | ), |
827 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
827 | + 'order_by' => array('QSG_order' => 'ASC') |
|
828 | 828 | ) |
829 | 829 | ); |
830 | 830 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | */ |
842 | 842 | public function count_question_groups() { |
843 | 843 | $qg_count = 0; |
844 | - if ( $this->event() instanceof EE_Event ) { |
|
844 | + if ($this->event() instanceof EE_Event) { |
|
845 | 845 | $qg_count = $this->event()->count_related( |
846 | 846 | 'Question_Group', |
847 | 847 | array( |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @return string |
863 | 863 | */ |
864 | 864 | public function reg_date() { |
865 | - return $this->get_datetime( 'REG_date' ); |
|
865 | + return $this->get_datetime('REG_date'); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @return EE_Datetime_Ticket |
875 | 875 | */ |
876 | 876 | public function datetime_ticket() { |
877 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
877 | + return $this->get_first_related('Datetime_Ticket'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | * @param EE_Datetime_Ticket $datetime_ticket |
885 | 885 | * @return EE_Datetime_Ticket |
886 | 886 | */ |
887 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
888 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
887 | + public function set_datetime_ticket($datetime_ticket) { |
|
888 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
889 | 889 | } |
890 | 890 | /** |
891 | 891 | * Gets deleted |
892 | 892 | * @return boolean |
893 | 893 | */ |
894 | 894 | public function deleted() { |
895 | - return $this->get( 'REG_deleted' ); |
|
895 | + return $this->get('REG_deleted'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * @return boolean |
902 | 902 | */ |
903 | 903 | public function set_deleted($deleted) { |
904 | - $this->set( 'REG_deleted', $deleted ); |
|
904 | + $this->set('REG_deleted', $deleted); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | * @return EE_Status |
912 | 912 | */ |
913 | 913 | public function status_obj() { |
914 | - return $this->get_first_related( 'Status' ); |
|
914 | + return $this->get_first_related('Status'); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @return int |
923 | 923 | */ |
924 | 924 | public function count_checkins() { |
925 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
925 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @return int |
933 | 933 | */ |
934 | 934 | public function count_checkins_not_checkedout() { |
935 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
935 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | |
@@ -945,20 +945,20 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool |
947 | 947 | */ |
948 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
949 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
948 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
949 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
950 | 950 | |
951 | 951 | //first check registration status |
952 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
952 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
953 | 953 | return false; |
954 | 954 | } |
955 | 955 | //is there a datetime ticket that matches this dtt_ID? |
956 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
956 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
957 | 957 | return false; |
958 | 958 | } |
959 | 959 | |
960 | 960 | //final check is against TKT_uses |
961 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
961 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
972 | 972 | * @return bool true means can checkin. false means cannot checkin. |
973 | 973 | */ |
974 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
975 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
974 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
975 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
976 | 976 | |
977 | - if ( ! $DTT_ID ) { |
|
977 | + if ( ! $DTT_ID) { |
|
978 | 978 | return false; |
979 | 979 | } |
980 | 980 | |
@@ -982,23 +982,23 @@ discard block |
||
982 | 982 | |
983 | 983 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
984 | 984 | // or not. |
985 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
985 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
986 | 986 | return true; |
987 | 987 | } |
988 | 988 | |
989 | 989 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
990 | 990 | //go ahead and toggle. |
991 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
991 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
992 | 992 | return true; |
993 | 993 | } |
994 | 994 | |
995 | 995 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
996 | 996 | //disallows further check-ins. |
997 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
997 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
998 | 998 | // checkins have already reached their max number of uses |
999 | 999 | // so registrant can NOT checkin |
1000 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1001 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1000 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1001 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | return true; |
@@ -1019,15 +1019,15 @@ discard block |
||
1019 | 1019 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1020 | 1020 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1021 | 1021 | */ |
1022 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1023 | - if ( empty( $DTT_ID ) ) { |
|
1022 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1023 | + if (empty($DTT_ID)) { |
|
1024 | 1024 | $datetime = $this->get_related_primary_datetime(); |
1025 | 1025 | $DTT_ID = $datetime->ID(); |
1026 | 1026 | // verify the registration can checkin for the given DTT_ID |
1027 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1027 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1028 | 1028 | EE_Error::add_error( |
1029 | 1029 | sprintf( |
1030 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), |
|
1030 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), |
|
1031 | 1031 | because the registration does not have access', 'event_espresso'), |
1032 | 1032 | $this->ID(), |
1033 | 1033 | $DTT_ID |
@@ -1042,8 +1042,8 @@ discard block |
||
1042 | 1042 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1043 | 1043 | ); |
1044 | 1044 | //start by getting the current status so we know what status we'll be changing to. |
1045 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1046 | - $status_to = $status_paths[ $cur_status ]; |
|
1045 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1046 | + $status_to = $status_paths[$cur_status]; |
|
1047 | 1047 | // database only records true for checked IN or false for checked OUT |
1048 | 1048 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1049 | 1049 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1051,24 +1051,24 @@ discard block |
||
1051 | 1051 | // because we are keeping track of Check-ins over time. |
1052 | 1052 | // Eventually we'll probably want to show a list table |
1053 | 1053 | // for the individual Check-ins so that they can be managed. |
1054 | - $checkin = EE_Checkin::new_instance( array( |
|
1054 | + $checkin = EE_Checkin::new_instance(array( |
|
1055 | 1055 | 'REG_ID' => $this->ID(), |
1056 | 1056 | 'DTT_ID' => $DTT_ID, |
1057 | 1057 | 'CHK_in' => $new_status |
1058 | - ) ); |
|
1058 | + )); |
|
1059 | 1059 | // if the record could not be saved then return false |
1060 | - if ( $checkin->save() === 0 ) { |
|
1061 | - if ( WP_DEBUG ) { |
|
1060 | + if ($checkin->save() === 0) { |
|
1061 | + if (WP_DEBUG) { |
|
1062 | 1062 | global $wpdb; |
1063 | 1063 | $error = sprintf( |
1064 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1064 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1065 | 1065 | '<br />', |
1066 | 1066 | $wpdb->last_error |
1067 | 1067 | ); |
1068 | 1068 | } else { |
1069 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1069 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1070 | 1070 | } |
1071 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1072 | 1072 | return false; |
1073 | 1073 | } |
1074 | 1074 | return $status_to; |
@@ -1092,19 +1092,19 @@ discard block |
||
1092 | 1092 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1093 | 1093 | * @return int Integer representing Check-in status. |
1094 | 1094 | */ |
1095 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1096 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1095 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1096 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1097 | 1097 | $datetime = $this->get_related_primary_datetime(); |
1098 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1098 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1099 | 1099 | return 0; |
1100 | 1100 | } |
1101 | 1101 | $DTT_ID = $datetime->ID(); |
1102 | 1102 | //verify the registration can checkin for the given DTT_ID |
1103 | 1103 | } |
1104 | 1104 | //get checkin object (if exists) |
1105 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1106 | - if ( $checkin instanceof EE_Checkin ) { |
|
1107 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1105 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1106 | + if ($checkin instanceof EE_Checkin) { |
|
1107 | + if ($checkin->get('CHK_in')) { |
|
1108 | 1108 | return EE_Registration::checkin_status_in; //checked in |
1109 | 1109 | } else { |
1110 | 1110 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1122,28 +1122,28 @@ discard block |
||
1122 | 1122 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1123 | 1123 | * @return string internationalized message |
1124 | 1124 | */ |
1125 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1125 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1126 | 1126 | //let's get the attendee first so we can include the name of the attendee |
1127 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1128 | - if ( $attendee instanceof EE_Attendee ) { |
|
1129 | - if ( $error ) { |
|
1130 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1127 | + $attendee = $this->get_first_related('Attendee'); |
|
1128 | + if ($attendee instanceof EE_Attendee) { |
|
1129 | + if ($error) { |
|
1130 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1131 | 1131 | } |
1132 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1132 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1133 | 1133 | //what is the status message going to be? |
1134 | - switch ( $cur_status ) { |
|
1134 | + switch ($cur_status) { |
|
1135 | 1135 | case EE_Registration::checkin_status_never : |
1136 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1136 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1137 | 1137 | break; |
1138 | 1138 | case EE_Registration::checkin_status_in : |
1139 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1139 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1140 | 1140 | break; |
1141 | 1141 | case EE_Registration::checkin_status_out : |
1142 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1142 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1143 | 1143 | break; |
1144 | 1144 | } |
1145 | 1145 | } |
1146 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1146 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | * @return EE_Transaction |
1154 | 1154 | */ |
1155 | 1155 | public function transaction() { |
1156 | - return $this->get_first_related( 'Transaction' ); |
|
1156 | + return $this->get_first_related('Transaction'); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | * @access public |
1165 | 1165 | */ |
1166 | 1166 | public function reg_code() { |
1167 | - return $this->get( 'REG_code' ); |
|
1167 | + return $this->get('REG_code'); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * @access public |
1175 | 1175 | */ |
1176 | 1176 | public function transaction_ID() { |
1177 | - return $this->get( 'TXN_ID' ); |
|
1177 | + return $this->get('TXN_ID'); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | * @return int |
1184 | 1184 | */ |
1185 | 1185 | public function ticket_ID() { |
1186 | - return $this->get( 'TKT_ID' ); |
|
1186 | + return $this->get('TKT_ID'); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1195,17 +1195,17 @@ discard block |
||
1195 | 1195 | * @param string $REG_code Registration Code |
1196 | 1196 | * @param boolean $use_default |
1197 | 1197 | */ |
1198 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1199 | - if ( empty( $REG_code )) { |
|
1200 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1198 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1199 | + if (empty($REG_code)) { |
|
1200 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1201 | 1201 | return; |
1202 | 1202 | } |
1203 | - if ( ! $this->reg_code() ) { |
|
1204 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1203 | + if ( ! $this->reg_code()) { |
|
1204 | + parent::set('REG_code', $REG_code, $use_default); |
|
1205 | 1205 | } else { |
1206 | 1206 | EE_Error::doing_it_wrong( |
1207 | - __CLASS__ . '::' . __FUNCTION__, |
|
1208 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1207 | + __CLASS__.'::'.__FUNCTION__, |
|
1208 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1209 | 1209 | '4.6.0' |
1210 | 1210 | ); |
1211 | 1211 | } |
@@ -1225,17 +1225,17 @@ discard block |
||
1225 | 1225 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1226 | 1226 | */ |
1227 | 1227 | public function get_all_other_registrations_in_group() { |
1228 | - if ( $this->group_size() < 2 ) { |
|
1228 | + if ($this->group_size() < 2) { |
|
1229 | 1229 | return array(); |
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | $query[0] = array( |
1233 | 1233 | 'TXN_ID' => $this->transaction_ID(), |
1234 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1234 | + 'REG_ID' => array('!=', $this->ID()), |
|
1235 | 1235 | 'TKT_ID' => $this->ticket_ID() |
1236 | 1236 | ); |
1237 | 1237 | |
1238 | - $registrations = $this->get_model()->get_all( $query ); |
|
1238 | + $registrations = $this->get_model()->get_all($query); |
|
1239 | 1239 | return $registrations; |
1240 | 1240 | } |
1241 | 1241 | |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | * @param array $query_params |
1246 | 1246 | * @return \EE_Registration[] |
1247 | 1247 | */ |
1248 | - public function payments( $query_params = array() ) { |
|
1249 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1248 | + public function payments($query_params = array()) { |
|
1249 | + return $this->get_many_related('Payment', $query_params); |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | |
@@ -1255,8 +1255,8 @@ discard block |
||
1255 | 1255 | * @param array $query_params |
1256 | 1256 | * @return \EE_Registration[] |
1257 | 1257 | */ |
1258 | - public function registration_payments( $query_params = array() ) { |
|
1259 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1258 | + public function registration_payments($query_params = array()) { |
|
1259 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | * @access public |
1268 | 1268 | */ |
1269 | 1269 | public function price_paid() { |
1270 | - EE_Error::doing_it_wrong( 'EE_Registration::price_paid()', __( 'This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1270 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1271 | 1271 | return $this->final_price(); |
1272 | 1272 | } |
1273 | 1273 | |
@@ -1279,9 +1279,9 @@ discard block |
||
1279 | 1279 | * @access public |
1280 | 1280 | * @param float $REG_final_price |
1281 | 1281 | */ |
1282 | - public function set_price_paid( $REG_final_price = 0.00 ) { |
|
1283 | - EE_Error::doing_it_wrong( 'EE_Registration::set_price_paid()', __( 'This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1284 | - $this->set_final_price( $REG_final_price ); |
|
1282 | + public function set_price_paid($REG_final_price = 0.00) { |
|
1283 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1284 | + $this->set_final_price($REG_final_price); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | * @return string |
1293 | 1293 | */ |
1294 | 1294 | public function pretty_price_paid() { |
1295 | - EE_Error::doing_it_wrong( 'EE_Registration::pretty_price_paid()', __( 'This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1295 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1296 | 1296 | return $this->pretty_final_price(); |
1297 | 1297 | } |
1298 | 1298 |
@@ -69,104 +69,104 @@ discard block |
||
69 | 69 | * @param array $options |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
72 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
73 | 73 | |
74 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
75 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
74 | + EE_Registry::instance()->load_helper('Template'); |
|
75 | + EE_Registry::instance()->load_helper('HTML'); |
|
76 | 76 | |
77 | 77 | $html = ''; |
78 | 78 | // set some default options and merge with incoming |
79 | 79 | $default_options = array( |
80 | - 'show_desc' => true, // true false |
|
80 | + 'show_desc' => true, // true false |
|
81 | 81 | 'odd' => false |
82 | 82 | ); |
83 | - $options = array_merge( $default_options, (array)$options ); |
|
83 | + $options = array_merge($default_options, (array) $options); |
|
84 | 84 | |
85 | - switch( $line_item->type() ) { |
|
85 | + switch ($line_item->type()) { |
|
86 | 86 | |
87 | 87 | case EEM_Line_Item::type_line_item: |
88 | 88 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
89 | - if ( $line_item->OBJ_type() == 'Ticket' ) { |
|
89 | + if ($line_item->OBJ_type() == 'Ticket') { |
|
90 | 90 | // item row |
91 | - $html .= $this->_ticket_row( $line_item, $options ); |
|
91 | + $html .= $this->_ticket_row($line_item, $options); |
|
92 | 92 | // got any kids? |
93 | - foreach ( $line_item->children() as $child_line_item ) { |
|
94 | - $this->display_line_item( $child_line_item, $options ); |
|
93 | + foreach ($line_item->children() as $child_line_item) { |
|
94 | + $this->display_line_item($child_line_item, $options); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | 97 | // item row |
98 | - $html .= $this->_item_row( $line_item, $options ); |
|
98 | + $html .= $this->_item_row($line_item, $options); |
|
99 | 99 | // got any kids? |
100 | - foreach ( $line_item->children() as $child_line_item ) { |
|
101 | - $this->display_line_item( $child_line_item, $options ); |
|
100 | + foreach ($line_item->children() as $child_line_item) { |
|
101 | + $this->display_line_item($child_line_item, $options); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | |
106 | 106 | case EEM_Line_Item::type_sub_line_item: |
107 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
107 | + $html .= $this->_sub_item_row($line_item, $options); |
|
108 | 108 | break; |
109 | 109 | |
110 | 110 | case EEM_Line_Item::type_sub_total: |
111 | 111 | static $sub_total = 0; |
112 | 112 | $event_sub_total = 0; |
113 | - $text = __( 'Sub-Total', 'event_espresso' ); |
|
114 | - if ( $line_item->OBJ_type() == 'Event' ) { |
|
115 | - $options[ 'event_id' ] = $event_id = $line_item->OBJ_ID(); |
|
116 | - if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
117 | - $event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] ); |
|
118 | - if ( $event instanceof EE_Event ) { |
|
119 | - if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) { |
|
113 | + $text = __('Sub-Total', 'event_espresso'); |
|
114 | + if ($line_item->OBJ_type() == 'Event') { |
|
115 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
116 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
117 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
118 | + if ($event instanceof EE_Event) { |
|
119 | + if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) { |
|
120 | 120 | return ''; |
121 | 121 | } |
122 | 122 | } |
123 | - $this->_events[ $options[ 'event_id' ] ] = 0; |
|
124 | - $html .= $this->_event_row( $line_item ); |
|
125 | - $text = __( 'Event Sub-Total', 'event_espresso' ); |
|
123 | + $this->_events[$options['event_id']] = 0; |
|
124 | + $html .= $this->_event_row($line_item); |
|
125 | + $text = __('Event Sub-Total', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | $child_line_items = $line_item->children(); |
129 | 129 | // loop thru children |
130 | - foreach( $child_line_items as $child_line_item ) { |
|
130 | + foreach ($child_line_items as $child_line_item) { |
|
131 | 131 | // recursively feed children back into this method |
132 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
132 | + $html .= $this->display_line_item($child_line_item, $options); |
|
133 | 133 | } |
134 | - $event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0; |
|
134 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
135 | 135 | $sub_total += $event_sub_total; |
136 | 136 | if ( |
137 | 137 | ( |
138 | 138 | // event subtotals |
139 | 139 | $line_item->code() != 'pre-tax-subtotal' && |
140 | - count( $child_line_items ) > 1 |
|
140 | + count($child_line_items) > 1 |
|
141 | 141 | ) |
142 | 142 | || |
143 | 143 | ( |
144 | 144 | // pre-tax subtotals |
145 | 145 | $line_item->code() == 'pre-tax-subtotal' && |
146 | - count( $this->_events ) > 1 |
|
146 | + count($this->_events) > 1 |
|
147 | 147 | ) |
148 | 148 | ) { |
149 | 149 | $options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total; |
150 | - $html .= $this->_sub_total_row( $line_item, $text, $options ); |
|
150 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
151 | 151 | } |
152 | 152 | break; |
153 | 153 | |
154 | 154 | case EEM_Line_Item::type_tax: |
155 | - if ( $this->_show_taxes ) { |
|
156 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
155 | + if ($this->_show_taxes) { |
|
156 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
157 | 157 | } |
158 | 158 | break; |
159 | 159 | |
160 | 160 | case EEM_Line_Item::type_tax_sub_total: |
161 | - if ( $this->_show_taxes ) { |
|
161 | + if ($this->_show_taxes) { |
|
162 | 162 | $child_line_items = $line_item->children(); |
163 | 163 | // loop thru children |
164 | - foreach( $child_line_items as $child_line_item ) { |
|
164 | + foreach ($child_line_items as $child_line_item) { |
|
165 | 165 | // recursively feed children back into this method |
166 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
166 | + $html .= $this->display_line_item($child_line_item, $options); |
|
167 | 167 | } |
168 | - if ( count( $child_line_items ) > 1 ) { |
|
169 | - $this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) ); |
|
168 | + if (count($child_line_items) > 1) { |
|
169 | + $this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso')); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | break; |
@@ -175,25 +175,25 @@ discard block |
||
175 | 175 | // get all child line items |
176 | 176 | $children = $line_item->children(); |
177 | 177 | // loop thru all non-tax child line items |
178 | - foreach( $children as $child_line_item ) { |
|
179 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
178 | + foreach ($children as $child_line_item) { |
|
179 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
180 | 180 | // recursively feed children back into this method |
181 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
181 | + $html .= $this->display_line_item($child_line_item, $options); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | 185 | // now loop thru tax child line items |
186 | - foreach( $children as $child_line_item ) { |
|
187 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
186 | + foreach ($children as $child_line_item) { |
|
187 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
188 | 188 | // recursively feed children back into this method |
189 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
189 | + $html .= $this->display_line_item($child_line_item, $options); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | $html .= $this->_taxes_html; |
193 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso') ); |
|
193 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso')); |
|
194 | 194 | |
195 | 195 | |
196 | - $html .= $this->_payments_and_amount_owing_rows( $line_item, $options ); |
|
196 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
197 | 197 | break; |
198 | 198 | |
199 | 199 | } |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @param EE_Line_Item $line_item |
209 | 209 | * @return mixed |
210 | 210 | */ |
211 | - private function _event_row( EE_Line_Item $line_item ) { |
|
211 | + private function _event_row(EE_Line_Item $line_item) { |
|
212 | 212 | // start of row |
213 | - $html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' ); |
|
213 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
214 | 214 | // event name td |
215 | - $html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' ); |
|
215 | + $html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"'); |
|
216 | 216 | // end of row |
217 | 217 | $html .= EEH_HTML::trx(); |
218 | 218 | return $html; |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @param array $options |
228 | 228 | * @return mixed |
229 | 229 | */ |
230 | - private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
|
230 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) { |
|
231 | 231 | // start of row |
232 | 232 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
233 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
233 | + $html = EEH_HTML::tr('', '', $row_class); |
|
234 | 234 | // name && desc |
235 | 235 | $name_and_desc = apply_filters( |
236 | 236 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
@@ -239,23 +239,23 @@ discard block |
||
239 | 239 | ); |
240 | 240 | $name_and_desc .= apply_filters( |
241 | 241 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
242 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
242 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
243 | 243 | $line_item, |
244 | 244 | $options |
245 | 245 | ); |
246 | 246 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
247 | 247 | // name td |
248 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
248 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
249 | 249 | // price td |
250 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
250 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
251 | 251 | // quantity td |
252 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
252 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
253 | 253 | $this->_total_items += $line_item->quantity(); |
254 | 254 | // determine total for line item |
255 | 255 | $total = $line_item->total(); |
256 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
256 | + $this->_events[$options['event_id']] += $total; |
|
257 | 257 | // total td |
258 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
258 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
259 | 259 | // end of row |
260 | 260 | $html .= EEH_HTML::trx(); |
261 | 261 | return $html; |
@@ -270,38 +270,38 @@ discard block |
||
270 | 270 | * @param array $options |
271 | 271 | * @return mixed |
272 | 272 | */ |
273 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
273 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
274 | 274 | // start of row |
275 | 275 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
276 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
276 | + $html = EEH_HTML::tr('', '', $row_class); |
|
277 | 277 | // name && desc |
278 | 278 | $name_and_desc = apply_filters( |
279 | 279 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
280 | - $line_item->OBJ_type() . ': ' . $line_item->name(), |
|
280 | + $line_item->OBJ_type().': '.$line_item->name(), |
|
281 | 281 | $line_item |
282 | 282 | ); |
283 | 283 | $name_and_desc .= apply_filters( |
284 | 284 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
285 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
285 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
286 | 286 | $line_item, |
287 | 287 | $options |
288 | 288 | ); |
289 | 289 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
290 | 290 | // name td |
291 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l' ); |
|
291 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
292 | 292 | // price td |
293 | - if ( $line_item->is_percent() ) { |
|
294 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' ); |
|
293 | + if ($line_item->is_percent()) { |
|
294 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
295 | 295 | } else { |
296 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
296 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
297 | 297 | } |
298 | 298 | // quantity td |
299 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
299 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
300 | 300 | //$total = $line_item->total() * $line_item->quantity(); |
301 | 301 | $total = $line_item->total(); |
302 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
302 | + $this->_events[$options['event_id']] += $total; |
|
303 | 303 | // total td |
304 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
304 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
305 | 305 | // end of row |
306 | 306 | $html .= EEH_HTML::trx(); |
307 | 307 | return $html; |
@@ -316,22 +316,22 @@ discard block |
||
316 | 316 | * @param array $options |
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
319 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
320 | 320 | // start of row |
321 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
321 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
322 | 322 | // name && desc |
323 | 323 | $name_and_desc = $line_item->name(); |
324 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
324 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
325 | 325 | // name td |
326 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
326 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
327 | 327 | // discount/surcharge td |
328 | - if ( $line_item->is_percent() ) { |
|
329 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
328 | + if ($line_item->is_percent()) { |
|
329 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
330 | 330 | } else { |
331 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
331 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
332 | 332 | } |
333 | 333 | // total td |
334 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
334 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
335 | 335 | // end of row |
336 | 336 | $html .= EEH_HTML::trx(); |
337 | 337 | return $html; |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | * @param array $options |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
349 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
350 | 350 | // start of row |
351 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
351 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
352 | 352 | // name && desc |
353 | 353 | $name_and_desc = $line_item->name(); |
354 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>'; |
|
355 | - $name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : ''; |
|
354 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>'; |
|
355 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
356 | 356 | // name td |
357 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
357 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
358 | 358 | // percent td |
359 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', ' jst-rght', '' ); |
|
359 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
360 | 360 | // empty td (price) |
361 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
361 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
362 | 362 | // total td |
363 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
363 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
364 | 364 | // end of row |
365 | 365 | $html .= EEH_HTML::trx(); |
366 | 366 | return $html; |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | * @param string $text |
376 | 376 | * @return mixed |
377 | 377 | */ |
378 | - private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
|
378 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') { |
|
379 | 379 | $html = ''; |
380 | - if ( $line_item->total() ) { |
|
380 | + if ($line_item->total()) { |
|
381 | 381 | // start of row |
382 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
382 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
383 | 383 | // total td |
384 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' ); |
|
384 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"'); |
|
385 | 385 | // empty td (price) |
386 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
386 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
387 | 387 | // total td |
388 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
388 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
389 | 389 | // end of row |
390 | 390 | $html .= EEH_HTML::trx(); |
391 | 391 | } |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | * @param array $options |
403 | 403 | * @return mixed |
404 | 404 | */ |
405 | - private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
405 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
406 | 406 | $html = ''; |
407 | - if ( $line_item->total() ) { |
|
407 | + if ($line_item->total()) { |
|
408 | 408 | // start of row |
409 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
409 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
410 | 410 | // total td |
411 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
411 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
412 | 412 | // total td |
413 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' ); |
|
413 | + $html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght'); |
|
414 | 414 | // end of row |
415 | 415 | $html .= EEH_HTML::trx(); |
416 | 416 | } |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * @param string $text |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
|
430 | + private function _total_row(EE_Line_Item $line_item, $text = '') { |
|
431 | 431 | // start of row |
432 | - $html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' ); |
|
432 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
433 | 433 | // total td |
434 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
434 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
435 | 435 | // total td |
436 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
436 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
437 | 437 | // end of row |
438 | 438 | $html .= EEH_HTML::trx(); |
439 | 439 | return $html; |
@@ -448,30 +448,30 @@ discard block |
||
448 | 448 | * @param array $options |
449 | 449 | * @return mixed |
450 | 450 | */ |
451 | - private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
|
451 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) { |
|
452 | 452 | $html = ''; |
453 | 453 | $owing = $line_item->total(); |
454 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() ); |
|
455 | - if ( $transaction instanceof EE_Transaction ) { |
|
454 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
455 | + if ($transaction instanceof EE_Transaction) { |
|
456 | 456 | $registration_payments = array(); |
457 | - $registrations = ! empty( $options['registrations'] ) |
|
458 | - ? $options[ 'registrations' ] |
|
457 | + $registrations = ! empty($options['registrations']) |
|
458 | + ? $options['registrations'] |
|
459 | 459 | : $transaction->registrations(); |
460 | - foreach ( $registrations as $registration ) { |
|
461 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
460 | + foreach ($registrations as $registration) { |
|
461 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
462 | 462 | $registration_payments = $registration_payments + $registration->registration_payments(); |
463 | 463 | } |
464 | 464 | } |
465 | - if ( ! empty( $registration_payments )) { |
|
466 | - foreach ( $registration_payments as $registration_payment ) { |
|
467 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
465 | + if ( ! empty($registration_payments)) { |
|
466 | + foreach ($registration_payments as $registration_payment) { |
|
467 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
468 | 468 | $owing = $owing - $registration_payment->amount(); |
469 | 469 | $payment = $registration_payment->payment(); |
470 | - if ( $payment instanceof EE_Payment ) { |
|
470 | + if ($payment instanceof EE_Payment) { |
|
471 | 471 | $payment_desc = sprintf( |
472 | - __( 'Payment%1$s Received: %2$s', 'event_espresso' ), |
|
472 | + __('Payment%1$s Received: %2$s', 'event_espresso'), |
|
473 | 473 | $payment->txn_id_chq_nmbr() != '' |
474 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
474 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
475 | 475 | : '', |
476 | 476 | $payment->timestamp() |
477 | 477 | ); |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | $payment_desc = ''; |
480 | 480 | } |
481 | 481 | // start of row |
482 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
482 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
483 | 483 | // payment desc |
484 | - $html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' ); |
|
484 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
485 | 485 | // total td |
486 | 486 | $html .= EEH_HTML::td( |
487 | - EEH_Template::format_currency( $registration_payment->amount(), false, false ), |
|
487 | + EEH_Template::format_currency($registration_payment->amount(), false, false), |
|
488 | 488 | '', |
489 | 489 | 'total jst-rght' |
490 | 490 | ); |
@@ -492,17 +492,17 @@ discard block |
||
492 | 492 | $html .= EEH_HTML::trx(); |
493 | 493 | } |
494 | 494 | } |
495 | - if ( $line_item->total() ) { |
|
495 | + if ($line_item->total()) { |
|
496 | 496 | // start of row |
497 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
497 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
498 | 498 | // total td |
499 | 499 | $html .= EEH_HTML::td( |
500 | 500 | __('Amount Owing', 'event_espresso'), |
501 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
501 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
502 | 502 | ); |
503 | 503 | // total td |
504 | 504 | $html .= EEH_HTML::td( |
505 | - EEH_Template::format_currency( $owing, false, false ), '', 'total jst-rght' |
|
505 | + EEH_Template::format_currency($owing, false, false), '', 'total jst-rght' |
|
506 | 506 | ); |
507 | 507 | // end of row |
508 | 508 | $html .= EEH_HTML::trx(); |