Completed
Branch BUG-9961-paypal-pro-items (52e78c)
by
unknown
49:07 queued 32:43
created

EE_Transaction_Processor   F

Complexity

Total Complexity 76

Size/Duplication

Total Lines 922
Duplicated Lines 3.8 %

Coupling/Cohesion

Components 4
Dependencies 12

Importance

Changes 0
Metric Value
dl 35
loc 922
rs 1.791
c 0
b 0
f 0
wmc 76
lcom 4
cbo 12

30 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 7 2
A __construct() 0 4 1
A _set_registration_query_params() 0 3 2
B manually_update_registration_statuses() 0 25 1
A toggle_registration_statuses_for_default_approved_events() 0 16 1
A toggle_registration_statuses_if_no_monies_owing() 0 16 1
B update_transaction_and_registrations_after_checkout_or_payment() 0 47 5
B update_transaction_after_reinstating_canceled_registration() 0 35 6
B update_transaction_after_canceled_or_declined_registration() 0 31 6
A get_transaction_for_registration() 0 12 2
A get_ticket_line_item_for_transaction_registration() 10 21 2
C toggle_transaction_status_if_all_registrations_canceled_or_declined() 0 28 8
C _call_method_on_registrations_via_Registration_Processor() 0 31 7
C set_transaction_payment_method_based_on_registration_statuses() 0 56 13
A old_txn_status() 0 11 1
A set_old_txn_status() 14 14 2
A new_txn_status() 0 11 1
A set_new_txn_status() 0 11 1
A txn_status_updated() 11 11 3
A all_reg_steps_completed() 0 12 1
A all_reg_steps_completed_except() 0 12 1
A all_reg_steps_completed_except_final_step() 0 12 1
A reg_step_completed() 0 12 1
A final_reg_step_completed() 0 12 1
A set_reg_step_initiated() 0 12 1
A set_reg_step_completed() 0 12 1
A set_reg_step_not_completed() 0 12 1
A remove_reg_step() 0 12 1
A toggle_failed_transaction_status() 0 12 1
A toggle_abandoned_transaction_status() 0 12 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EE_Transaction_Processor often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EE_Transaction_Processor, and based on these observations, apply Extract Interface, too.

1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
EE_Registry::instance()->load_class( 'Processor_Base' );
3
4
/**
5
 * Class EE_Transaction_Processor
6
 * This class contains business logic pertaining specifically to
7
 * the interaction of EE_Transaction and EE_Registration model objects
8
 * Provides methods for manipulating and processing changes to an EE_Transaction
9
 * and it's related EE_Registrations with regards to the checkout/registration process
10
11
*
12
*@package     Event Espresso
13
 * @subpackage 	core
14
 * @author      Brent Christensen
15
 * @since       4.6.0
16
 */
17
class EE_Transaction_Processor extends EE_Processor_Base {
18
19
	/**
20
	 * 	@var EE_Registration_Processor $_instance
21
	 * 	@access 	private
22
	 */
23
	private static $_instance;
24
25
	/**
26
	 * array of query WHERE params to use when retrieving cached registrations from a transaction
27
	 *
28
	 * @var array $registration_query_params
29
	 * @access private
30
	 */
31
	private $_registration_query_params = array();
32
33
	/**
34
	 * @deprecated
35
	 * @var string
36
	 */
37
	protected $_old_txn_status;
38
39
	/**
40
	 * @deprecated
41
	 * @var string
42
	 */
43
	protected $_new_txn_status;
44
45
46
47
	/**
48
	 *@singleton method used to instantiate class object
49
	 *@access public
50
	 * @param array $registration_query_params
51
	 *@return EE_Transaction_Processor instance
52
	 */
53
	public static function instance( $registration_query_params = array() ) {
54
		// check if class object is instantiated
55
		if ( ! self::$_instance instanceof EE_Transaction_Processor ) {
56
			self::$_instance = new self( $registration_query_params );
0 ignored issues
show
Documentation Bug introduced by
It seems like new self($registration_query_params) of type object<EE_Transaction_Processor> is incompatible with the declared type object<EE_Registration_Processor> of property $_instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
57
		}
58
		return self::$_instance;
59
	}
60
61
62
63
	/**
64
	 * @param array $registration_query_params
65
	 */
66
	private function __construct( $registration_query_params = array() ) {
67
		// make sure some query params are set for retrieving registrations
68
		$this->_set_registration_query_params( $registration_query_params );
69
	}
70
71
72
73
	/**
74
	 * @access private
75
	 * @param array $registration_query_params
76
	 */
77
	private function _set_registration_query_params( $registration_query_params ) {
78
		$this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' ));
79
	}
80
81
82
83
	/**
84
	 * manually_update_registration_statuses
85
	 *
86
	 * @access public
87
	 * @param EE_Transaction $transaction
88
	 * @param string         $new_reg_status
89
	 * @param array          $registration_query_params array of query WHERE params to use
90
	 *                                                  when retrieving cached registrations from a transaction
91
	 * @return    boolean
92
	 * @throws \EE_Error
93
	 */
94
	public function manually_update_registration_statuses(
95
		EE_Transaction $transaction,
96
		$new_reg_status = '',
97
		$registration_query_params = array()
98
	) {
99
		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor(
100
			'manually_update_registration_status',
101
			$transaction,
102
			$registration_query_params,
103
			$new_reg_status
104
		);
105
		// send messages
106
		/** @type EE_Registration_Processor $registration_processor */
107
		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
108
		$registration_processor->trigger_registration_update_notifications(
109
			$transaction->primary_registration(),
110
			array( 'manually_updated' 	=> true )
111
		);
112
		do_action(
113
			'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
114
			$transaction,
115
			$status_updates
116
		);
117
		return $status_updates;
118
	}
119
120
121
122
	/**
123
	 * toggle_registration_statuses_for_default_approved_events
124
	 *
125
	 * @access public
126
	 * @param EE_Transaction $transaction
127
	 * @param array          $registration_query_params array of query WHERE params to use
128
	 *                                                  when retrieving cached registrations from a transaction
129
	 * @return    boolean
130
	 * @throws \EE_Error
131
	 */
132
	public function toggle_registration_statuses_for_default_approved_events(
133
		EE_Transaction $transaction,
134
		$registration_query_params = array()
135
	) {
136
		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor(
137
			'toggle_registration_status_for_default_approved_events',
138
			$transaction,
139
			$registration_query_params
140
		);
141
		do_action(
142
			'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
143
			$transaction,
144
			$status_updates
145
		);
146
		return $status_updates;
147
	}
148
149
150
151
	/**
152
	 * toggle_registration_statuses_if_no_monies_owing
153
	 *
154
	 * @access public
155
	 * @param EE_Transaction $transaction
156
	 * @param array          $registration_query_params array of query WHERE params to use
157
	 *                                                  when retrieving cached registrations from a transaction
158
	 * @return    boolean
159
	 * @throws \EE_Error
160
	 */
161
	public function toggle_registration_statuses_if_no_monies_owing(
162
		EE_Transaction $transaction,
163
		$registration_query_params = array()
164
	) {
165
		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor(
166
			'toggle_registration_status_if_no_monies_owing',
167
			$transaction,
168
			$registration_query_params
169
		);
170
		do_action(
171
			'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing',
172
			$transaction,
173
			$status_updates
174
		);
175
		return $status_updates;
176
	}
177
178
179
180
	/**
181
	 * update_transaction_and_registrations_after_checkout_or_payment
182
	 * cycles thru related registrations and calls update_registration_after_checkout_or_payment() on each
183
	 *
184
	 * @param EE_Transaction     $transaction
185
	 * @param \EE_Payment | NULL $payment
186
	 * @param array              $registration_query_params    array of query WHERE params to use
187
	 *                                                         when retrieving cached registrations from a transaction
188
	 * @throws \EE_Error
189
	 * @return array
190
	 */
191
	public function update_transaction_and_registrations_after_checkout_or_payment(
192
		EE_Transaction $transaction,
193
		$payment = null,
194
		$registration_query_params = array()
195
	) {
196
		// make sure some query params are set for retrieving registrations
197
		$this->_set_registration_query_params( $registration_query_params );
198
		// get final reg step status
199
		$finalized = $transaction->final_reg_step_completed();
200
		// if the 'finalize_registration' step has been initiated (has a timestamp)
201
		// but has not yet been fully completed (TRUE)
202
		if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) {
203
			$transaction->set_reg_step_completed( 'finalize_registration' );
204
			$finalized = true;
205
		}
206
		$transaction->save();
207
		// array of details to aid in decision making by systems
208
		$update_params = array(
209
			'old_txn_status'  => $transaction->old_txn_status(),
210
			'new_txn_status'  => $transaction->status_ID(),
211
			'finalized'       => $finalized,
212
			'revisit'         => $this->_revisit,
213
			'payment_updates' => $payment instanceof EE_Payment ? true : false,
214
			'last_payment'    => $payment
215
		);
216
		// now update the registrations and add the results to our $update_params
217
		$update_params['status_updates'] = $this->_call_method_on_registrations_via_Registration_Processor(
218
			'update_registration_after_checkout_or_payment',
219
			$transaction,
220
			$this->_registration_query_params,
221
			$update_params
0 ignored issues
show
Documentation introduced by
$update_params is of type array<string,*,{"old_txn...n","last_payment":"?"}>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
222
		);
223
224
		// send messages
225
		/** @type EE_Registration_Processor $registration_processor */
226
		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
227
		$registration_processor->trigger_registration_update_notifications(
228
			$transaction->primary_registration(),
229
			$update_params
230
		);
231
		do_action(
232
			'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment',
233
			$transaction,
234
			$update_params
235
		);
236
		return $update_params;
237
	}
238
239
240
241
	/**
242
	 * update_transaction_after_registration_reopened
243
	 * readjusts TXN and Line Item totals after a registration is changed from
244
	 * cancelled or declined to another reg status such as pending payment or approved
245
	 *
246
	 * @param \EE_Registration $registration
247
	 * @param array            $closed_reg_statuses
248
	 * @param bool             $update_txn
249
	 * @return bool
250
	 */
251
	public function update_transaction_after_reinstating_canceled_registration(
252
		EE_Registration $registration,
253
		$closed_reg_statuses = array(),
254
		$update_txn = true
255
	) {
256
		// these reg statuses should not be considered in any calculations involving monies owing
257
		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses();
258
		if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
259
			return false;
260
		}
261
		try {
262
			$transaction = $this->get_transaction_for_registration( $registration );
263
			$ticket_line_item = $this->get_ticket_line_item_for_transaction_registration(
264
				$transaction,
265
				$registration
266
			);
267
			// un-cancel the ticket
268
			$success = EEH_Line_Item::reinstate_canceled_ticket_line_item( $ticket_line_item );
269
		} catch ( EE_Error $e ) {
270
			EE_Error::add_error(
271
				sprintf(
272
					__( 'The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso' ),
273
					$registration->ID(),
274
					'<br />',
275
					$e->getMessage()
276
				),
277
				__FILE__, __FUNCTION__, __LINE__
278
			);
279
			return false;
280
		}
281
		if ( $update_txn ) {
282
			return $transaction->save() ? $success : false;
283
		}
284
		return $success;
285
	}
286
287
288
289
	/**
290
	 * update_transaction_after_canceled_or_declined_registration
291
	 * readjusts TXN and Line Item totals after a registration is cancelled or declined
292
	 *
293
	 * @param \EE_Registration $registration
294
	 * @param array            $closed_reg_statuses
295
	 * @param bool             $update_txn
296
	 * @return bool
297
	 * @throws \EE_Error
298
	 */
299
	public function update_transaction_after_canceled_or_declined_registration(
300
		EE_Registration $registration,
301
		$closed_reg_statuses = array(),
302
		$update_txn = true
303
	) {
304
		// these reg statuses should not be considered in any calculations involving monies owing
305
		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses();
306
		if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
307
			return false;
308
		}
309
		try {
310
			$transaction = $this->get_transaction_for_registration( $registration );
311
			$ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration );
312
			EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item );
313
		} catch ( EE_Error $e ) {
314
			EE_Error::add_error(
315
				sprintf(
316
					__( 'The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso' ),
317
					$registration->ID(),
318
					'<br />',
319
					$e->getMessage()
320
				),
321
				__FILE__, __FUNCTION__, __LINE__
322
			);
323
			return false;
324
		}
325
		if ( $update_txn ) {
326
			return $transaction->save() ? true : false;
327
		}
328
		return true;
329
	}
330
331
332
333
	/**
334
	 * get_transaction_for_registration
335
	 *
336
	 * @access 	public
337
	 * @param 	EE_Registration $registration
338
	 * @return 	EE_Transaction
339
	 * @throws 	EE_Error
340
	 */
341
	public function get_transaction_for_registration( EE_Registration $registration ) {
342
		$transaction = $registration->transaction();
343
		if ( ! $transaction instanceof EE_Transaction ) {
344
			throw new EE_Error(
345
				sprintf(
346
					__( 'The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso' ),
347
					$registration->ID()
348
				)
349
			);
350
		}
351
		return $transaction;
352
	}
353
354
355
356
	/**
357
	 * get_ticket_line_item_for_transaction_registration
358
	 *
359
	 * @access 	public
360
	 * @param 	EE_Transaction  $transaction
361
	 * @param 	EE_Registration $registration
362
	 * @return 	EE_Line_Item
363
	 * @throws 	EE_Error
364
	 */
365
	public function get_ticket_line_item_for_transaction_registration(
366
		EE_Transaction $transaction,
367
		EE_Registration $registration
368
	) {
369
		EE_Registry::instance()->load_helper( 'Line_Item' );
370
		$ticket_line_item = EEM_Line_Item::instance()->get_ticket_line_item_for_transaction(
371
			$transaction->ID(),
372
			$registration->ticket_ID()
373
		);
374 View Code Duplication
		if ( ! $ticket_line_item instanceof EE_Line_Item ) {
375
			throw new EE_Error(
376
				sprintf(
377
					__( 'The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.',
378
						'event_espresso' ),
379
					$transaction->ID(),
380
					$registration->ticket_ID()
381
				)
382
			);
383
		}
384
		return $ticket_line_item;
385
	}
386
387
388
389
	/**
390
	 * cancel_transaction_if_all_registrations_canceled
391
	 * cycles thru related registrations and checks their statuses
392
	 * if ALL registrations are Cancelled or Declined, then this sets the TXN status to
393
	 *
394
	 * @access 	public
395
	 * @param 	EE_Transaction 	$transaction
396
	 * @param 	string 			$new_TXN_status
397
	 * @param 	array          	$registration_query_params - array of query WHERE params to use when
398
	 *                                                     retrieving cached registrations from a transaction
399
	 * @param 	array          	$closed_reg_statuses
400
	 * @param 	bool 			$update_txn
401
	 * @return 	bool 			true if TXN status was updated, false if not
402
	 */
403
	public function toggle_transaction_status_if_all_registrations_canceled_or_declined(
404
		EE_Transaction $transaction,
405
		$new_TXN_status = '',
406
		$registration_query_params = array(),
407
		$closed_reg_statuses = array(),
408
		$update_txn = true
409
	) {
410
		// make sure some query params are set for retrieving registrations
411
		$this->_set_registration_query_params( $registration_query_params );
412
		// these reg statuses should not be considered in any calculations involving monies owing
413
		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses();
414
		// loop through cached registrations
415
		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
416
			if (
417
				$registration instanceof EE_Registration
418
				&& ! in_array( $registration->status_ID(), $closed_reg_statuses )
419
			) {
420
				return false;
421
			}
422
		}
423
		if ( in_array( $new_TXN_status, EEM_Transaction::txn_status_array() ) ) {
424
			$transaction->set_status( $new_TXN_status );
425
		}
426
		if ( $update_txn ) {
427
			return $transaction->save() ? true : false;
428
		}
429
		return true;
430
	}
431
432
433
434
	/**
435
	 * _call_method_on_registrations_via_Registration_Processor
436
	 * cycles thru related registrations and calls the requested method on each
437
	 *
438
	 * @access private
439
	 * @param string 		$method_name
440
	 * @param EE_Transaction $transaction
441
	 * @param array          $registration_query_params array of query WHERE params to use
442
	 *                                                  when retrieving cached registrations from a transaction
443
	 * @param string 	$additional_param
444
	 * @throws \EE_Error
445
	 * @return boolean
446
	 */
447
	private function _call_method_on_registrations_via_Registration_Processor(
448
		$method_name,
449
		EE_Transaction $transaction,
450
		$registration_query_params = array(),
451
		$additional_param = null
452
	) {
453
		$response = false;
454
		/** @type EE_Registration_Processor $registration_processor */
455
		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
456
		// check that method exists
457
		if ( ! method_exists( $registration_processor, $method_name )) {
458
			throw new EE_Error( __( 'Method does not exist.', 'event_espresso' ));
459
		}
460
		// make sure some query params are set for retrieving registrations
461
		$this->_set_registration_query_params( $registration_query_params );
462
		// loop through cached registrations
463
		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
464
			if ( $registration instanceof EE_Registration ) {
465
				if ( $additional_param ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $additional_param of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
466
					$response = $registration_processor->{$method_name}( $registration, $additional_param )
467
						? true
468
						: $response;
469
				} else {
470
					$response = $registration_processor->{$method_name}( $registration )
471
						? true
472
						: $response;
473
				}
474
			}
475
		}
476
		return $response;
477
	}
478
479
480
481
	/**
482
	 * set_transaction_payment_method_based_on_registration_statuses
483
	 * sets or unsets the PMD_ID field on the TXN based on the related REG statuses
484
	 * basically if ALL Registrations are "Not Approved", then the EE_Transaction.PMD_ID is set to null,
485
	 * but if any Registration has a different status, then EE_Transaction.PMD_ID is set to either:
486
	 *        the first "default" Payment Method
487
	 *        the first active Payment Method
488
	 *    whichever is found first.
489
	 *
490
	 * @param  EE_Registration $edited_registration
491
	 * @return void
492
	 * @throws \EE_Error
493
	 */
494
	public function set_transaction_payment_method_based_on_registration_statuses(
495
		EE_Registration $edited_registration
496
	) {
497
		if ( $edited_registration instanceof EE_Registration ) {
498
			$transaction = $edited_registration->transaction();
499
			if ( $transaction instanceof EE_Transaction ) {
500
				$all_not_approved = true;
501
				foreach ( $transaction->registrations() as $registration ) {
502
					if ( $registration instanceof EE_Registration ) {
503
						// if any REG != "Not Approved" then toggle to false
504
						$all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
505
					}
506
				}
507
				// if ALL Registrations are "Not Approved"
508
				if ( $all_not_approved ) {
509
					$transaction->set_payment_method_ID( null );
510
					$transaction->save();
511
				} else {
512
					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
513
						$transaction,
514
						EEM_Payment_Method::scope_cart
515
					);
516
					if ( ! empty( $available_payment_methods ) ) {
517
						$PMD_ID = 0;
518
						foreach ( $available_payment_methods as $available_payment_method ) {
519
							if (
520
								$available_payment_method instanceof EE_Payment_Method
521
							    && $available_payment_method->open_by_default()
522
							) {
523
								$PMD_ID = $available_payment_method->ID();
524
								break;
525
							}
526
						}
527
						if ( ! $PMD_ID ) {
528
							$first_payment_method = reset( $available_payment_methods );
529
							if ( $first_payment_method instanceof EE_Payment_Method ) {
530
								$PMD_ID = $first_payment_method->ID();
531
							} else {
532
								EE_Error::add_error(
533
									__( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ),
534
									__FILE__, __LINE__, __FUNCTION__
535
								);
536
							}
537
						}
538
						$transaction->set_payment_method_ID( $PMD_ID );
539
						$transaction->save();
540
					} else {
541
						EE_Error::add_error(
542
							__( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ),
543
							__FILE__, __LINE__, __FUNCTION__
544
						);
545
					}
546
				}
547
			}
548
		}
549
	}
550
551
552
553
	/********************************** DEPRECATED METHODS **********************************/
554
555
556
557
	/**
558
	 * @deprecated 4.9.12
559
	 * @return string
560
	 */
561
	public function old_txn_status() {
562
		EE_Error::doing_it_wrong(
563
			__METHOD__,
564
			esc_html__(
565
				'This logic has been moved into \EE_Transaction::old_txn_status(), please use that method instead.',
566
				'event_espresso'
567
			),
568
			'4.9.12'
569
		);
570
		return $this->_old_txn_status;
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_old_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
571
	}
572
573
574
575
	/**
576
	 * @deprecated 4.9.12
577
	 * @param string $old_txn_status
578
	 */
579 View Code Duplication
	public function set_old_txn_status( $old_txn_status ) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
580
		EE_Error::doing_it_wrong(
581
			__METHOD__,
582
			esc_html__(
583
				'This logic has been moved into \EE_Transaction::set_old_txn_status(), please use that method instead.',
584
				'event_espresso'
585
			),
586
			'4.9.12'
587
		);
588
		// only set the first time
589
		if ( $this->_old_txn_status === null ) {
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_old_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
590
			$this->_old_txn_status = $old_txn_status;
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_old_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
591
		}
592
	}
593
594
595
596
	/**
597
	 * @deprecated 4.9.12
598
	 * @return string
599
	 */
600
	public function new_txn_status() {
601
		EE_Error::doing_it_wrong(
602
			__METHOD__,
603
			esc_html__(
604
				'This logic has been removed. Please just use \EE_Transaction::status_ID() instead.',
605
				'event_espresso'
606
			),
607
			'4.9.12'
608
		);
609
		return $this->_new_txn_status;
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_new_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
610
	}
611
612
613
614
	/**
615
	 * @deprecated 4.9.12
616
	 * @param string $new_txn_status
617
	 */
618
	public function set_new_txn_status( $new_txn_status ) {
619
		EE_Error::doing_it_wrong(
620
			__METHOD__,
621
			esc_html__(
622
				'This logic has been removed. Please just use \EE_Transaction::set_status() instead.',
623
				'event_espresso'
624
			),
625
			'4.9.12'
626
		);
627
		$this->_new_txn_status = $new_txn_status;
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_new_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
628
	}
629
630
631
632
	/**
633
	 * reg_status_updated
634
	 *
635
	 * @deprecated 4.9.12
636
	 * @return bool
637
	 */
638 View Code Duplication
	public function txn_status_updated() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
639
		EE_Error::doing_it_wrong(
640
			__METHOD__,
641
			esc_html__(
642
				'This logic has been moved into \EE_Transaction::txn_status_updated(), please use that method instead.',
643
				'event_espresso'
644
			),
645
			'4.9.12'
646
		);
647
		return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false;
0 ignored issues
show
Deprecated Code introduced by
The property EE_Transaction_Processor::$_new_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The property EE_Transaction_Processor::$_old_txn_status has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
648
	}
649
650
651
652
	/**
653
	 * all_reg_steps_completed
654
	 * returns:
655
	 *    true if ALL reg steps have been marked as completed
656
	 *        or false if any step is not completed
657
	 *
658
	 * @deprecated 4.9.12
659
	 * @param EE_Transaction $transaction
660
	 * @return boolean
661
	 */
662
	public function all_reg_steps_completed( EE_Transaction $transaction ) {
663
		EE_Error::doing_it_wrong(
664
			__METHOD__,
665
			esc_html__(
666
				'This logic has been moved into \EE_Transaction::all_reg_steps_completed(), please use that method instead.',
667
				'event_espresso'
668
			),
669
			'4.9.12',
670
			'5.0.0'
671
		);
672
		return $transaction->all_reg_steps_completed();
673
	}
674
675
676
677
	/**
678
	 * all_reg_steps_completed_except
679
	 * returns:
680
	 *        true if ALL reg steps, except a particular step that you wish to skip over, have been marked as completed
681
	 *        or false if any other step is not completed
682
	 *        or false if ALL steps are completed including the exception you are testing !!!
683
	 *
684
	 * @deprecated 4.9.12
685
	 * @param EE_Transaction $transaction
686
	 * @param string         $exception
687
	 * @return boolean
688
	 */
689
	public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) {
690
		EE_Error::doing_it_wrong(
691
			__METHOD__,
692
			esc_html__(
693
				'This logic has been moved into \EE_Transaction::all_reg_steps_completed_except(), please use that method instead.',
694
				'event_espresso'
695
			),
696
			'4.9.12',
697
			'5.0.0'
698
		);
699
		return $transaction->all_reg_steps_completed_except( $exception );
700
	}
701
702
703
704
	/**
705
	 * all_reg_steps_completed_except
706
	 * returns:
707
	 *        true if ALL reg steps, except the final step, have been marked as completed
708
	 *        or false if any step is not completed
709
	 *    or false if ALL steps are completed including the final step !!!
710
	 *
711
	 * @deprecated 4.9.12
712
	 * @param EE_Transaction $transaction
713
	 * @return boolean
714
	 */
715
	public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) {
716
		EE_Error::doing_it_wrong(
717
			__METHOD__,
718
			esc_html__(
719
				'This logic has been moved into \EE_Transaction::all_reg_steps_completed_except_final_step(), please use that method instead.',
720
				'event_espresso'
721
			),
722
			'4.9.12',
723
			'5.0.0'
724
		);
725
		return $transaction->all_reg_steps_completed_except_final_step();
726
	}
727
728
729
730
	/**
731
	 * reg_step_completed
732
	 * returns:
733
	 *    true if a specific reg step has been marked as completed
734
	 *    a Unix timestamp if it has been initialized but not yet completed,
735
	 *    or false if it has not yet been initialized
736
	 *
737
	 * @deprecated 4.9.12
738
	 * @param EE_Transaction $transaction
739
	 * @param string         $reg_step_slug
740
	 * @return boolean | int
741
	 */
742
	public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
743
		EE_Error::doing_it_wrong(
744
			__METHOD__,
745
			esc_html__(
746
				'This logic has been moved into \EE_Transaction::reg_step_completed(), please use that method instead.',
747
				'event_espresso'
748
			),
749
			'4.9.12',
750
			'5.0.0'
751
		);
752
		return $transaction->reg_step_completed( $reg_step_slug );
753
	}
754
755
756
757
	/**
758
	 * completed_final_reg_step
759
	 * returns:
760
	 *    true if the finalize_registration reg step has been marked as completed
761
	 *    a Unix timestamp if it has been initialized but not yet completed,
762
	 *    or false if it has not yet been initialized
763
	 *
764
	 * @deprecated 4.9.12
765
	 * @param EE_Transaction $transaction
766
	 * @return boolean | int
767
	 */
768
	public function final_reg_step_completed( EE_Transaction $transaction ) {
769
		EE_Error::doing_it_wrong(
770
			__METHOD__,
771
			esc_html__(
772
				'This logic has been moved into \EE_Transaction::final_reg_step_completed(), please use that method instead.',
773
				'event_espresso'
774
			),
775
			'4.9.12',
776
			'5.0.0'
777
		);
778
		return $transaction->final_reg_step_completed();
779
	}
780
781
782
783
	/**
784
	 * set_reg_step_initiated
785
	 * given a valid TXN_reg_step, this sets it's value to a unix timestamp
786
	 *
787
	 * @deprecated 4.9.12
788
	 * @access public
789
	 * @param \EE_Transaction $transaction
790
	 * @param string          $reg_step_slug
791
	 * @return boolean
792
	 * @throws \EE_Error
793
	 */
794
	public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) {
795
		EE_Error::doing_it_wrong(
796
			__METHOD__,
797
			esc_html__(
798
				'This logic has been moved into \EE_Transaction::set_reg_step_initiated(), please use that method instead.',
799
				'event_espresso'
800
			),
801
			'4.9.12',
802
			'5.0.0'
803
		);
804
		return $transaction->set_reg_step_initiated( $reg_step_slug );
805
	}
806
807
808
809
	/**
810
	 * set_reg_step_completed
811
	 * given a valid TXN_reg_step, this sets the step as completed
812
	 *
813
	 * @deprecated 4.9.12
814
	 * @access public
815
	 * @param \EE_Transaction $transaction
816
	 * @param string          $reg_step_slug
817
	 * @return boolean
818
	 * @throws \EE_Error
819
	 */
820
	public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
821
		EE_Error::doing_it_wrong(
822
			__METHOD__,
823
			esc_html__(
824
				'This logic has been moved into \EE_Transaction::set_reg_step_completed(), please use that method instead.',
825
				'event_espresso'
826
			),
827
			'4.9.12',
828
			'5.0.0'
829
		);
830
		return $transaction->set_reg_step_completed( $reg_step_slug );
831
	}
832
833
834
835
	/**
836
	 * set_reg_step_completed
837
	 * given a valid TXN_reg_step slug, this sets the step as NOT completed
838
	 *
839
	 * @deprecated 4.9.12
840
	 * @access public
841
	 * @param \EE_Transaction $transaction
842
	 * @param string          $reg_step_slug
843
	 * @return boolean
844
	 * @throws \EE_Error
845
	 */
846
	public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) {
847
		EE_Error::doing_it_wrong(
848
			__METHOD__,
849
			esc_html__(
850
				'This logic has been moved into \EE_Transaction::set_reg_step_not_completed(), please use that method instead.',
851
				'event_espresso'
852
			),
853
			'4.9.12',
854
			'5.0.0'
855
		);
856
		return $transaction->set_reg_step_not_completed( $reg_step_slug );
857
	}
858
859
860
861
862
	/**
863
	 * remove_reg_step
864
	 * given a valid TXN_reg_step slug, this will remove (unset)
865
	 * the reg step from the TXN reg step array
866
	 *
867
	 * @deprecated 4.9.12
868
	 * @access public
869
	 * @param \EE_Transaction $transaction
870
	 * @param string          $reg_step_slug
871
	 * @return void
872
	 */
873
	public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) {
874
		EE_Error::doing_it_wrong(
875
			__METHOD__,
876
			esc_html__(
877
				'This logic has been moved into \EE_Transaction::remove_reg_step(), please use that method instead.',
878
				'event_espresso'
879
			),
880
			'4.9.12',
881
			'5.0.0'
882
		);
883
		$transaction->remove_reg_step( $reg_step_slug );
884
	}
885
886
887
888
	/**
889
	 *    toggle_failed_transaction_status
890
	 * upgrades a TXNs status from failed to abandoned,
891
	 * meaning that contact information has been captured for at least one registrant
892
	 *
893
	 * @deprecated 4.9.12
894
	 * @access public
895
	 * @param EE_Transaction $transaction
896
	 * @return    boolean
897
	 * @throws \EE_Error
898
	 */
899
	public function toggle_failed_transaction_status( EE_Transaction $transaction ) {
900
		EE_Error::doing_it_wrong(
901
			__METHOD__,
902
			esc_html__(
903
				'This logic has been moved into \EE_Transaction::toggle_failed_transaction_status(), please use that method instead.',
904
				'event_espresso'
905
			),
906
			'4.9.12',
907
			'5.0.0'
908
		);
909
		return $transaction->toggle_failed_transaction_status();
910
	}
911
912
913
914
	/**
915
	 * toggle_abandoned_transaction_status
916
	 * upgrades a TXNs status from failed or abandoned to incomplete
917
	 *
918
	 * @deprecated 4.9.12
919
	 * @access public
920
	 * @param  EE_Transaction $transaction
921
	 * @return boolean
922
	 */
923
	public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) {
924
		EE_Error::doing_it_wrong(
925
			__METHOD__,
926
			esc_html__(
927
				'This logic has been moved into \EE_Transaction::toggle_abandoned_transaction_status(), please use that method instead.',
928
				'event_espresso'
929
			),
930
			'4.9.12',
931
			'5.0.0'
932
		);
933
		return $transaction->toggle_abandoned_transaction_status();
934
	}
935
936
937
938
}
939
// End of file EE_Transaction_Processor.class.php
940
// Location: /EE_Transaction_Processor.class.php
941