Completed
Branch BUG-10489-non-trashed-regs-onl... (b37a8e)
by
unknown
37:13 queued 23:24
created
thank_you_page/templates/thank-you-page-payment-details.template.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <h2 class="section-heading display-box-heading">
2 2
 	<?php _e('Payment Overview', 'event_espresso'); ?>
3 3
 </h2>
4
-<?php  do_action( 'AHEE__thank_you_page_payment_details_template__after_heading' ); ?>
4
+<?php  do_action('AHEE__thank_you_page_payment_details_template__after_heading'); ?>
5 5
 
6 6
 <div id="espresso-thank-you-page-payment-details-dv">
7
-<?php if ( ! empty( $payments )){	 ?>
7
+<?php if ( ! empty($payments)) {	 ?>
8 8
 	<table class="ee-table">
9 9
 		<thead>
10 10
 			<tr>
11 11
 				<th width="35%" class="jst-left">
12
-					<?php _e('Payment Date','event_espresso')?>
12
+					<?php _e('Payment Date', 'event_espresso')?>
13 13
 				</th>
14 14
 				<th width="17.5%" class="jst-left">
15
-					<?php _e('Type','event_espresso');?>
15
+					<?php _e('Type', 'event_espresso'); ?>
16 16
 				</th>
17 17
 				<th width="17.5%" class="jst-rght">
18
-					<?php _e('Amount','event_espresso');?>
18
+					<?php _e('Amount', 'event_espresso'); ?>
19 19
 				</th>
20 20
 				<th width="30%" class="jst-rght">
21
-					<?php _e('Status','event_espresso');?>
21
+					<?php _e('Status', 'event_espresso'); ?>
22 22
 				</th>
23 23
 			</tr>
24 24
 		</thead>
25 25
 		<tbody>
26 26
 		<?php
27
-			foreach ( $payments as $payment ) {
27
+			foreach ($payments as $payment) {
28 28
 				echo $payment;
29 29
 			}
30 30
 		?>
@@ -33,38 +33,38 @@  discard block
 block discarded – undo
33 33
 <?php
34 34
 	} else {
35 35
 
36
-		if ( $transaction->total() ){
36
+		if ($transaction->total()) {
37 37
 
38 38
 			echo apply_filters(
39 39
 				'FHEE__payment_overview_template__no_payments_made',
40
-				sprintf (
41
-					__('%sNo payments towards this transaction have been received.%s', 'event_espresso' ),
40
+				sprintf(
41
+					__('%sNo payments towards this transaction have been received.%s', 'event_espresso'),
42 42
 					'<p class="important-notice">',
43 43
 					'</p>'
44 44
 				)
45 45
 			);
46
-			do_action( 'AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction );
46
+			do_action('AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction);
47 47
 
48 48
 		} else {
49 49
 
50 50
 			echo apply_filters(
51 51
 				'FHEE__payment_overview_template__no_payment_required',
52
-				sprintf (
53
-					__('%sNo payment is required for this transaction.%s', 'event_espresso' ),
52
+				sprintf(
53
+					__('%sNo payment is required for this transaction.%s', 'event_espresso'),
54 54
 					'<p>',
55 55
 					'</p>'
56 56
 				)
57 57
 			);
58
-			do_action( 'AHEE__thank_you_page_payment_details_template__no_payment_required' );
58
+			do_action('AHEE__thank_you_page_payment_details_template__no_payment_required');
59 59
 
60 60
 		 }
61 61
 
62 62
 	}
63 63
 	echo $gateway_content;
64
-	do_action( 'AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content );
64
+	do_action('AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content);
65 65
 
66 66
 ?>
67 67
 
68 68
 	<br/>
69
-	<?php  do_action( 'AHEE__thank_you_page_payment_details_template__after_payment_details' ); ?>
69
+	<?php  do_action('AHEE__thank_you_page_payment_details_template__after_payment_details'); ?>
70 70
 
Please login to merge, or discard this patch.
modules/thank_you_page/templates/thank-you-page-overview.template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 /** @var boolean $revisit */
4 4
 /** @var string $order_conf_desc */
5 5
 
6
-do_action( 'AHEE__thank_you_page_overview_template__top', $transaction );
6
+do_action('AHEE__thank_you_page_overview_template__top', $transaction);
7 7
 
8 8
 ?>
9 9
 
10 10
 <div id="espresso-thank-you-page-overview-dv" class="width-100" >
11 11
 
12
-	<?php if ( ! $revisit ) : ?>
12
+	<?php if ( ! $revisit) : ?>
13 13
 	<div class="ee-attention">
14 14
 		<div class="extra-padding-sides">
15 15
 			<?php echo apply_filters(
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 					'<br />'
22 22
 				)
23 23
 			);
24
-			if ( ! empty( $TXN_receipt_url )) : ?>
24
+			if ( ! empty($TXN_receipt_url)) : ?>
25 25
 			<br/>
26 26
 			<div class="jst-rght">
27
-				<a class="ee-button ee-roundish indented-text big-text" href="<?php echo $TXN_receipt_url;?>"><span class="ee-icon ee-icon-PDF-file-type"></span><?php echo apply_filters( 'FHEE__thank_you_page_overview_template__order_conf_button_text', __( 'View Full Order Confirmation Receipt', 'event_espresso' )); ?></a>
27
+				<a class="ee-button ee-roundish indented-text big-text" href="<?php echo $TXN_receipt_url; ?>"><span class="ee-icon ee-icon-PDF-file-type"></span><?php echo apply_filters('FHEE__thank_you_page_overview_template__order_conf_button_text', __('View Full Order Confirmation Receipt', 'event_espresso')); ?></a>
28 28
 			</div>
29 29
 			<?php endif; ?>
30 30
 		</div>
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	<?php endif; ?>
34 34
 	<br/>
35 35
 
36
-	<?php  do_action( 'AHEE__thank_you_page_overview_template__content', $transaction ); ?>
36
+	<?php  do_action('AHEE__thank_you_page_overview_template__content', $transaction); ?>
37 37
 
38 38
 </div>
39 39
 <!-- end of espresso-thank-you-page-overview-dv -->
40 40
 
41
-<?php  do_action( 'AHEE__thank_you_page_overview_template__bottom', $transaction ); ?>
41
+<?php  do_action('AHEE__thank_you_page_overview_template__bottom', $transaction); ?>
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-transaction-details.template.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <h3><?php _e('Transaction Details', 'event_espresso'); ?></h3>
2
-<?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_heading' ); ?>
2
+<?php  do_action('AHEE__thank_you_page_transaction_details_template__after_heading'); ?>
3 3
 
4 4
 <div id="espresso-thank-you-page-transaction-details-dv">
5 5
 	<table class='ee-table'>
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 					<label><?php _e('Total Cost: ', 'event_espresso'); ?></label>
10 10
 				</td>
11 11
 				<td>
12
-					<?php echo EEH_Template::format_currency( $transaction->total() ); ?>
12
+					<?php echo EEH_Template::format_currency($transaction->total()); ?>
13 13
 				</td>
14 14
 			</tr>
15 15
 			<tr>
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 					<label><?php _e('Amount Owing: ', 'event_espresso'); ?></label>
18 18
 				</td>
19 19
 				<td class="<?php echo ($transaction->paid() == $transaction->total()) ? 'ee-transaction-paid' : 'ee-transaction-unpaid' ?>">
20
-					<?php echo EEH_Template::format_currency( $transaction->remaining() ); ?>
20
+					<?php echo EEH_Template::format_currency($transaction->remaining()); ?>
21 21
 				</td>
22 22
 			</tr>
23 23
 			<tr>
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 					<label><?php _e('Transaction Status: ', 'event_espresso'); ?></label>
26 26
 				</td>
27 27
 				<td>
28
-					<?php $transaction->e_pretty_status( TRUE );
29
-					if ( $show_try_pay_again_link && ! $transaction->is_completed() ) { ?>
28
+					<?php $transaction->e_pretty_status(TRUE);
29
+					if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?>
30 30
 					 &nbsp; <span class="small-text"><a href='<?php echo $SPCO_payment_options_url?>'><?php _e('View Payment Options', 'event_espresso'); ?></a></span>
31 31
 					<?php } ?>
32 32
 				</td>
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 					<?php  echo $primary_registrant_name; ?>
40 40
 				</td>
41 41
 			</tr>
42
-            <?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', $transaction ); ?>
42
+            <?php  do_action('AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', $transaction); ?>
43 43
 		</tbody>
44 44
 	</table>
45 45
 
46
-<?php if ( $show_try_pay_again_link && ! $transaction->is_completed() ) { ?>
46
+<?php if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?>
47 47
 	<p class="small-text jst-rght">
48 48
 		<a href='<?php echo $SPCO_payment_options_url?>'><?php _e("Click here to view Payment Options", 'event_espresso'); ?></a>
49 49
 	</p>
@@ -52,6 +52,6 @@  discard block
 block discarded – undo
52 52
 
53 53
 <?php }?>
54 54
 
55
-    <?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_transaction_details' ); ?>
55
+    <?php  do_action('AHEE__thank_you_page_transaction_details_template__after_transaction_details'); ?>
56 56
 
57 57
 </div>
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-registration-details.template.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,81 +5,81 @@  discard block
 block discarded – undo
5 5
 /** @type string $SPCO_attendee_information_url */
6 6
 ?>
7 7
 <h3 class="ee-registration-details-h3"><?php _e('Registration Details', 'event_espresso'); ?></h3>
8
-<?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_heading' ); ?>
8
+<?php  do_action('AHEE__thank_you_page_registration_details_template__after_heading'); ?>
9 9
 
10 10
 <div class="ee-registration-details-dv">
11 11
 <?php
12 12
 $registrations = $transaction->registrations();
13
-$registrations = is_array( $registrations ) ? $registrations : array();
14
-$reg_count = count( $registrations );
13
+$registrations = is_array($registrations) ? $registrations : array();
14
+$reg_count = count($registrations);
15 15
 $reg_cntr = 0;
16 16
 $event_name = '';
17 17
 $wait_list = false;
18
-foreach ( $registrations as $registration ) {
19
-	if ( $registration instanceof EE_Registration ) {
20
-		if ( $event_name != $registration->event_name() && ! empty( $event_name )) { ?>
18
+foreach ($registrations as $registration) {
19
+	if ($registration instanceof EE_Registration) {
20
+		if ($event_name != $registration->event_name() && ! empty($event_name)) { ?>
21 21
 		</tbody>
22 22
 	</table>
23 23
 		<?php
24 24
 		}
25 25
 		$reg_cntr++;
26
-		if ( $event_name != $registration->event_name() ) {
26
+		if ($event_name != $registration->event_name()) {
27 27
 	?>
28 28
 	<h5>
29
-		<span class="smaller-text grey-text"><?php _e('for','event_espresso');?>: </span> <?php echo htmlentities( $registration->event_name(), ENT_QUOTES, 'UTF-8' );?>
29
+		<span class="smaller-text grey-text"><?php _e('for', 'event_espresso'); ?>: </span> <?php echo htmlentities($registration->event_name(), ENT_QUOTES, 'UTF-8'); ?>
30 30
 	</h5>
31 31
 	<table class='ee-table ee-registrations-list'>
32 32
 		<thead>
33 33
 			<tr>
34 34
 				<th width="40%">
35
-					<?php _e("Registrant Name",'event_espresso')?>
35
+					<?php _e("Registrant Name", 'event_espresso')?>
36 36
 				</th>
37 37
 				<th width="25%" class="jst-left">
38
-					<?php _e("REG Code",'event_espresso');?>
38
+					<?php _e("REG Code", 'event_espresso'); ?>
39 39
 				</th>
40 40
 				<th width="35%" class="jst-left">
41
-					<?php _e("REG Status",'event_espresso');?>
41
+					<?php _e("REG Status", 'event_espresso'); ?>
42 42
 				</th>
43 43
 			</tr>
44 44
 		</thead>
45 45
 		<tbody>
46 46
 	<?php
47 47
 		}
48
-		if ( $is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link() )) { ?>
48
+		if ($is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
49 49
 			<tr>
50 50
 				<td width="40%">
51 51
 				<?php
52
-					if ( $registration->attendee() instanceof EE_Attendee ) {
53
-						echo $registration->attendee()->full_name( TRUE );
52
+					if ($registration->attendee() instanceof EE_Attendee) {
53
+						echo $registration->attendee()->full_name(TRUE);
54 54
 					}
55 55
 				?>
56 56
 					<p class="tiny-text" style="margin: .75em 0 0;">
57 57
 					<?php
58
-					if ( $registration->count_question_groups() ) {
58
+					if ($registration->count_question_groups()) {
59 59
 					?>
60
-						<a class="ee-icon-only-lnk" href="<?php echo $registration->edit_attendee_information_url();?>" title="<?php esc_attr_e('Click here to edit Attendee Information', 'event_espresso');?>"><span class="ee-icon ee-icon-user-edit"></span><?php _e('edit info', 'event_espresso');?></a>
60
+						<a class="ee-icon-only-lnk" href="<?php echo $registration->edit_attendee_information_url(); ?>" title="<?php esc_attr_e('Click here to edit Attendee Information', 'event_espresso'); ?>"><span class="ee-icon ee-icon-user-edit"></span><?php _e('edit info', 'event_espresso'); ?></a>
61 61
 					<?php } ?>
62
-						<a class="ee-resend-reg-confirmation-email ee-icon-only-lnk" href="<?php echo add_query_arg( array( 'token'=>$registration->reg_url_link(), 'resend_reg_confirmation' => 'true' ), EE_Registry::instance()->CFG->core->thank_you_page_url() );?>" title="<?php esc_attr_e('Click here to resend the Registration Confirmation email', 'event_espresso');?>" rel="<?php echo $registration->reg_url_link();?>"><span class="dashicons dashicons-email-alt"></span><?php _e('resend email', 'event_espresso');?></a>
62
+						<a class="ee-resend-reg-confirmation-email ee-icon-only-lnk" href="<?php echo add_query_arg(array('token'=>$registration->reg_url_link(), 'resend_reg_confirmation' => 'true'), EE_Registry::instance()->CFG->core->thank_you_page_url()); ?>" title="<?php esc_attr_e('Click here to resend the Registration Confirmation email', 'event_espresso'); ?>" rel="<?php echo $registration->reg_url_link(); ?>"><span class="dashicons dashicons-email-alt"></span><?php _e('resend email', 'event_espresso'); ?></a>
63 63
 					</p>
64 64
 				</td>
65 65
 				<td width="25%" class="jst-left">
66 66
 					<?php $registration->e('REG_code') ?>
67 67
 				</td>
68 68
 				<td width="35%" class="jst-left">
69
-					<?php $registration->e_pretty_status( TRUE )?>
69
+					<?php $registration->e_pretty_status(TRUE)?>
70 70
 					<?php
71
-						if ( $registration->status_ID() === EEM_Registration::status_id_wait_list ) {
71
+						if ($registration->status_ID() === EEM_Registration::status_id_wait_list) {
72 72
 							$wait_list = true;
73 73
 						}
74 74
 					?>
75 75
 				</td>
76 76
 			</tr>
77
-            <?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_registration_table_row', $registration ); ?>
77
+            <?php  do_action('AHEE__thank_you_page_registration_details_template__after_registration_table_row', $registration); ?>
78 78
         <?php
79 79
 			$event_name = $registration->event_name();
80 80
 
81 81
 		}
82
-		if ( $reg_cntr >= $reg_count ) {
82
+		if ($reg_cntr >= $reg_count) {
83 83
 			?>
84 84
 			</tbody>
85 85
 			</table>
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 }
90 90
 ?>
91
-<?php if ( $is_primary && $SPCO_attendee_information_url ) { ?>
91
+<?php if ($is_primary && $SPCO_attendee_information_url) { ?>
92 92
 	<p class="small-text jst-rght">
93 93
 		<a href='<?php echo $SPCO_attendee_information_url?>'><?php _e("Click here to edit All Attendee Information", 'event_espresso'); ?></a>
94 94
 	</p>
95 95
 <?php } ?>
96
-	<?php if ( $wait_list ) { ?>
96
+	<?php if ($wait_list) { ?>
97 97
 
98 98
 			<?php
99 99
 			echo apply_filters(
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	<?php } ?>
114 114
 
115 115
 
116
-	<?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_registration_details' ); ?>
116
+	<?php  do_action('AHEE__thank_you_page_registration_details_template__after_registration_details'); ?>
117 117
 
118 118
 </div>
119 119
 <!-- end of .registration-details -->
Please login to merge, or discard this patch.
modules/thank_you_page/EED_Thank_You_Page.module.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public static function set_definitions()
143 143
     {
144
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
144
+        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
145
+        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
146 146
     }
147 147
 
148 148
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     {
334 334
         wp_register_script(
335 335
             'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
336
+            THANK_YOU_ASSETS_URL.'thank_you_page.js',
337 337
             array('espresso_core', 'heartbeat'),
338 338
             EVENT_ESPRESSO_VERSION,
339 339
             true
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         $this->_get_reg_url_link();
355 355
         if ( ! $this->get_txn()) {
356 356
             echo EEH_HTML::div(
357
-                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
357
+                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '').
358 358
                 sprintf(
359 359
                     __(
360 360
                         'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
             add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
470 470
         }
471 471
         return EEH_Template::locate_template(
472
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
472
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php',
473 473
             $template_args,
474 474
             true,
475 475
             true
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
             '$SPCO_attendee_information_url'
637 637
         );
638 638
         echo EEH_Template::locate_template(
639
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
639
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php',
640 640
             $template_args,
641 641
             true,
642 642
             true
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
             '$SPCO_payment_options_url'
845 845
         );
846 846
         return EEH_Template::locate_template(
847
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
847
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php',
848 848
             $template_args,
849 849
             true,
850 850
             true
@@ -875,25 +875,25 @@  discard block
 block discarded – undo
875 875
                 $payment->set_status(EEM_Payment::status_id_pending);
876 876
             }
877 877
             $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
878
-                ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
878
+                ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>'
879 879
                 : '';
880 880
             $html .= '
881 881
 				<tr>
882 882
 					<td>
883
-						' . $payment->timestamp() . '
883
+						' . $payment->timestamp().'
884 884
 					</td>
885 885
 					<td>
886 886
 						' . (
887 887
                 $payment->payment_method() instanceof EE_Payment_Method
888 888
                     ? $payment->payment_method()->name()
889 889
                     : __('Unknown', 'event_espresso')
890
-                ) . '
890
+                ).'
891 891
 					</td>
892 892
 					<td class="jst-rght">
893
-						' . EEH_Template::format_currency($payment->amount()) . '
893
+						' . EEH_Template::format_currency($payment->amount()).'
894 894
 					</td>
895 895
 					<td class="jst-rght" style="line-height:1;">
896
-						' . $payment->pretty_status(true) . $payment_declined_msg . '
896
+						' . $payment->pretty_status(true).$payment_declined_msg.'
897 897
 					</td>
898 898
 				</tr>';
899 899
             do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
             '$SPCO_payment_options_url'
953 953
         );
954 954
         return EEH_Template::locate_template(
955
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
955
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php',
956 956
             $template_args,
957 957
             true,
958 958
             true
Please login to merge, or discard this patch.
Indentation   +916 added lines, -916 removed lines patch added patch discarded remove patch
@@ -14,757 +14,757 @@  discard block
 block discarded – undo
14 14
 class EED_Thank_You_Page extends EED_Module
15 15
 {
16 16
 
17
-    /**
18
-     * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
-     */
20
-    const IPN_wait_time = 1200;
21
-
22
-    /**
23
-     * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
-     *
25
-     * @var EE_Transaction $_current_txn
26
-     */
27
-    private $_current_txn;
28
-
29
-    /**
30
-     * @var EE_Registration $_primary_registrant
31
-     */
32
-    private $_primary_registrant;
33
-
34
-    /**
35
-     * The reg_url_link passed from the Request, or from the Session
36
-     *
37
-     * @var string $_reg_url_link
38
-     */
39
-    private $_reg_url_link;
40
-
41
-    /**
42
-     * whether the incoming reg_url_link is for the primary registrant or not
43
-     *
44
-     * @var boolean $_is_primary
45
-     */
46
-    private $_is_primary;
47
-
48
-    /**
49
-     * The URL for revisiting the SPCO attendee information step
50
-     *
51
-     * @var string $_SPCO_attendee_information_url
52
-     */
53
-    private $_SPCO_attendee_information_url;
54
-
55
-    /**
56
-     * The URL for revisiting the SPCO payment options step
57
-     *
58
-     * @var string $_SPCO_payment_options_url
59
-     */
60
-    private $_SPCO_payment_options_url;
61
-
62
-    /**
63
-     * whether to display the Payment Options link
64
-     *
65
-     * @var boolean $_show_try_pay_again_link
66
-     */
67
-    private $_show_try_pay_again_link = false;
68
-
69
-    /**
70
-     * whether payments are allowed at this time
71
-     *
72
-     * @var boolean $_payments_closed
73
-     */
74
-    private $_payments_closed = false;
75
-
76
-    /**
77
-     * whether the selected payment method is Bank, Check , Invoice, etc
78
-     *
79
-     * @var boolean $_is_offline_payment_method
80
-     */
81
-    private $_is_offline_payment_method = true;
82
-
83
-
84
-
85
-    /**
86
-     * @return EED_Module|EED_Thank_You_Page
87
-     */
88
-    public static function instance()
89
-    {
90
-        return parent::get_instance(__CLASS__);
91
-    }
92
-
93
-
94
-    /**
95
-     * set_hooks - for hooking into EE Core, modules, etc
96
-     *
97
-     * @return void
98
-     */
99
-    public static function set_hooks()
100
-    {
101
-        add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
-    }
103
-
104
-
105
-
106
-    /**
107
-     * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
-     *
109
-     * @return void
110
-     */
111
-    public static function set_hooks_admin()
112
-    {
113
-        // AJAX for IPN monitoring
114
-        add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
-        add_filter(
116
-            'heartbeat_nopriv_received',
117
-            array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
-            10,
119
-            3
120
-        );
121
-        add_action(
122
-            'wp_ajax_espresso_resend_reg_confirmation_email',
123
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
-            10,
125
-            2
126
-        );
127
-        add_action(
128
-            'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
-            10,
131
-            2
132
-        );
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * set_definitions
139
-     *
140
-     * @return void
141
-     */
142
-    public static function set_definitions()
143
-    {
144
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * get_txn
152
-     *
153
-     * @return EE_Transaction
154
-     */
155
-    public function get_txn()
156
-    {
157
-        if ($this->_current_txn instanceof EE_Transaction) {
158
-            return $this->_current_txn;
159
-        }
160
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
161
-        if ( ! $TXN_model instanceof EEM_Transaction) {
162
-            EE_Error::add_error(
163
-                __('The transaction model could not be established.', 'event_espresso'),
164
-                __FILE__,
165
-                __FUNCTION__,
166
-                __LINE__
167
-            );
168
-            return null;
169
-        }
170
-        //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
-        $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
-        // verify TXN
173
-        if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
-            EE_Error::add_error(
175
-                __(
176
-                    'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
-                    'event_espresso'
178
-                ),
179
-                __FILE__,
180
-                __FUNCTION__,
181
-                __LINE__
182
-            );
183
-            return null;
184
-        }
185
-        return $this->_current_txn;
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * get_txn_payments
192
-     *
193
-     * @param int $since
194
-     * @return mixed array of EE_Payment || FALSE
195
-     * @throws \EE_Error
196
-     */
197
-    public function get_txn_payments($since = 0)
198
-    {
199
-        if ( ! $this->get_txn()) {
200
-            return false;
201
-        }
202
-        $args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
-        if ($since > 0) {
204
-            $args[0] = array('PAY_timestamp' => array('>', $since));
205
-        }
206
-        // get array of payments with most recent first
207
-        return $this->_current_txn->payments($args);
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * get_reg_url_link
214
-     *
215
-     * @return void
216
-     */
217
-    private function _get_reg_url_link()
218
-    {
219
-        if ( ! empty($this->_reg_url_link)) {
220
-            return;
221
-        }
222
-        // only do thank you page stuff if we have a REG_url_link in the url
223
-        if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
-            EE_Error::add_error(
225
-                __(
226
-                    'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
-                    'event_espresso'
228
-                ),
229
-                __FILE__,
230
-                __FUNCTION__,
231
-                __LINE__
232
-            );
233
-            return;
234
-        }
235
-        // check for reg_url_link
236
-        $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * set_reg_url_link
243
-     *
244
-     * @param string $reg_url_link
245
-     */
246
-    public function set_reg_url_link($reg_url_link = null)
247
-    {
248
-        $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * run - initial module setup
255
-     * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
-     *
257
-     * @param WP $WP
258
-     * @return void
259
-     * @throws \EE_Error
260
-     */
261
-    public function run($WP)
262
-    {
263
-
264
-    }
265
-
266
-
267
-
268
-    /**
269
-     * load_resources
270
-     *
271
-     * @return void
272
-     * @throws \EE_Error
273
-     */
274
-    public function load_resources() {
275
-        $this->_get_reg_url_link();
276
-        // resend_reg_confirmation_email ?
277
-        if (EE_Registry::instance()->REQ->is_set('resend')) {
278
-            EED_Thank_You_Page::resend_reg_confirmation_email();
279
-        }
280
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
-        $this->_translate_strings();
282
-        // load assets
283
-        add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * load_js
290
-     *
291
-     * @return void
292
-     */
293
-    protected function _translate_strings()
294
-    {
295
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
-        EE_Registry::$i18n_js_strings['initial_access'] = time();
297
-        EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
-        EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
-        EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
-        EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
-            'checking for new payments...',
302
-            'event_espresso'
303
-        );
304
-        EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
-            'loading payment information...',
306
-            'event_espresso'
307
-        );
308
-        EE_Registry::$i18n_js_strings['server_error'] = __(
309
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
-            'event_espresso'
311
-        );
312
-        EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
-            'EED_Thank_You_Page__load_js__slow_IPN',
314
-            sprintf(
315
-                __(
316
-                    '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
-                    'event_espresso'
318
-                ),
319
-                '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
-                '</div>'
321
-            )
322
-        );
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * load_js
329
-     *
330
-     * @return void
331
-     */
332
-    public function load_js()
333
-    {
334
-        wp_register_script(
335
-            'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
-            array('espresso_core', 'heartbeat'),
338
-            EVENT_ESPRESSO_VERSION,
339
-            true
340
-        );
341
-        wp_enqueue_script('thank_you_page');
342
-        wp_enqueue_style('espresso_default');
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * init
349
-     *
350
-     * @return void
351
-     * @throws \EE_Error
352
-     */
353
-    public function init()
354
-    {
355
-        $this->_get_reg_url_link();
356
-        if ( ! $this->get_txn()) {
357
-            echo EEH_HTML::div(
358
-                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
359
-                sprintf(
360
-                    __(
361
-                        'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
362
-                        'event_espresso'
363
-                    ),
364
-                    '<br/>'
365
-                ),
366
-                '',
367
-                'ee-attention'
368
-            );
369
-            return null;
370
-        }
371
-        // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
372
-        if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
373
-            $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
374
-            $this->_current_txn->save();
375
-        }
376
-        $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
377
-            ? $this->_current_txn->primary_registration()
378
-            : null;
379
-        $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
380
-        $show_try_pay_again_link_default = apply_filters(
381
-            'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
382
-            true
383
-        );
384
-        $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
385
-        // txn status ?
386
-        if ($this->_current_txn->is_completed()) {
387
-            $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
388
-        } else if (
389
-            $this->_current_txn->is_incomplete()
390
-            && ($this->_primary_registrant->is_approved()
391
-                || $this->_primary_registrant->is_pending_payment())
392
-        ) {
393
-            $this->_show_try_pay_again_link = true;
394
-        } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
395
-            // its pending
396
-            $this->_show_try_pay_again_link = isset(
397
-                                                  EE_Registry::instance()->CFG->registration->show_pending_payment_options
398
-                                              )
399
-                                              && EE_Registry::instance()->CFG->registration->show_pending_payment_options
400
-                ? true
401
-                : $show_try_pay_again_link_default;
402
-        }
403
-        $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
404
-            ? true
405
-            : false;
406
-        $this->_is_offline_payment_method = false;
407
-        if (
408
-            // if payment method is unknown
409
-            ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
410
-            || (
411
-                // or is an offline payment method
412
-                $this->_current_txn->payment_method() instanceof EE_Payment_Method
413
-                && $this->_current_txn->payment_method()->is_off_line()
414
-            )
415
-        ) {
416
-            $this->_is_offline_payment_method = true;
417
-        }
418
-        // link to SPCO
419
-        $revisit_spco_url = add_query_arg(
420
-            array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
421
-            EE_Registry::instance()->CFG->core->reg_page_url()
422
-        );
423
-        // link to SPCO payment_options
424
-        $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
425
-            ? $this->_primary_registrant->payment_overview_url()
426
-            : add_query_arg(
427
-                array('step' => 'payment_options'),
428
-                $revisit_spco_url
429
-            );
430
-        // link to SPCO attendee_information
431
-        $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
432
-            ? $this->_primary_registrant->edit_attendee_information_url()
433
-            : false;
434
-        do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
435
-        // set no cache headers and constants
436
-        EE_System::do_not_cache();
437
-    }
438
-
439
-
440
-
441
-    /**
442
-     * display_thank_you_page_results
443
-     *
444
-     * @return string
445
-     * @throws \EE_Error
446
-     */
447
-    public function thank_you_page_results()
448
-    {
449
-        $this->init();
450
-        if ( ! $this->_current_txn instanceof EE_Transaction) {
451
-            return EE_Error::get_notices();
452
-        }
453
-        // link to receipt
454
-        $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
455
-        if ( ! empty($template_args['TXN_receipt_url'])) {
456
-            $template_args['order_conf_desc'] = __(
457
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
458
-                'event_espresso'
459
-            );
460
-        } else {
461
-            $template_args['order_conf_desc'] = __(
462
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
463
-                'event_espresso'
464
-            );
465
-        }
466
-        $template_args['transaction'] = $this->_current_txn;
467
-        $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
468
-        add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
469
-        if ($this->_is_primary && ! $this->_current_txn->is_free()) {
470
-            add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
471
-        }
472
-        return EEH_Template::locate_template(
473
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
474
-            $template_args,
475
-            true,
476
-            true
477
-        );
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * thank_you_page_IPN_monitor
484
-     * this basically just pulls the TXN based on the reg_url_link sent from the server,
485
-     * then checks that the TXN status is not failed, and that no other errors have been generated.
486
-     * it also calculates the IPN wait time since the Thank You page was first loaded
487
-     *
488
-     * @param array $response
489
-     * @param array $data
490
-     * @return array
491
-     * @throws \EE_Error
492
-     */
493
-    public static function thank_you_page_IPN_monitor($response = array(), $data = array())
494
-    {
495
-        // does this heartbeat contain our data ?
496
-        if ( ! isset($data['espresso_thank_you_page'])) {
497
-            return $response;
498
-        }
499
-        // check for reg_url_link in the incoming heartbeat data
500
-        if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
501
-            $response['espresso_thank_you_page'] = array(
502
-                'errors' => ! empty($notices['errors'])
503
-                    ? $notices['errors']
504
-                    : __(
505
-                        'No transaction information could be retrieved because the registration URL link is missing or invalid.',
506
-                        'event_espresso'
507
-                    )
508
-            );
509
-            return $response;
510
-        }
511
-        // kk heartbeat has our data
512
-        $response['espresso_thank_you_page'] = array();
513
-        // set_definitions, instantiate the thank you page class, and get the ball rolling
514
-        EED_Thank_You_Page::set_definitions();
515
-        /** @var $espresso_thank_you_page EED_Thank_You_Page */
516
-        $espresso_thank_you_page = EED_Thank_You_Page::instance();
517
-        $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
518
-        $espresso_thank_you_page->init();
519
-        //get TXN
520
-        $TXN = $espresso_thank_you_page->get_txn();
521
-        // no TXN? then get out
522
-        if ( ! $TXN instanceof EE_Transaction) {
523
-            $notices = EE_Error::get_notices();
524
-            $response['espresso_thank_you_page'] = array(
525
-                'errors' => ! empty($notices['errors'])
526
-                    ? $notices['errors']
527
-                    : sprintf(
528
-                        __(
529
-                            'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
530
-                            'event_espresso'
531
-                        ),
532
-                        __LINE__
533
-                    )
534
-            );
535
-            return $response;
536
-        }
537
-        // grab transient of TXN's status
538
-        $txn_status = isset($data['espresso_thank_you_page']['txn_status'])
539
-            ? $data['espresso_thank_you_page']['txn_status']
540
-            : null;
541
-        // has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
542
-        if ($txn_status !== $TXN->status_ID()) {
543
-            // switch between two possible basic outcomes
544
-            switch ($TXN->status_ID()) {
545
-                // TXN has been updated in some way
546
-                case EEM_Transaction::overpaid_status_code:
547
-                case EEM_Transaction::complete_status_code:
548
-                case EEM_Transaction::incomplete_status_code:
549
-                    // send updated TXN results back to client,
550
-                    $response['espresso_thank_you_page'] = array(
551
-                        'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
552
-                        'txn_status'          => $TXN->status_ID()
553
-                    );
554
-                    break;
555
-                // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
556
-                case EEM_Transaction::failed_status_code:
557
-                default:
558
-                    // keep on waiting...
559
-                    return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
560
-            }
561
-            // or is the TXN still failed (never been updated) ???
562
-        } else if ($TXN->failed()) {
563
-            // keep on waiting...
564
-            return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
565
-        }
566
-        // TXN is happening so let's get the payments now
567
-        // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
568
-        $since = isset($data['espresso_thank_you_page']['get_payments_since'])
569
-            ? $data['espresso_thank_you_page']['get_payments_since']
570
-            : 0;
571
-        // then check for payments
572
-        $payments = $espresso_thank_you_page->get_txn_payments($since);
573
-        // has a payment been processed ?
574
-        if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
575
-            if ($since) {
576
-                $response['espresso_thank_you_page'] = array(
577
-                    'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
578
-                    'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
579
-                    'txn_status'          => $TXN->status_ID()
580
-                );
581
-            } else {
582
-                $response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
583
-                    $payments
584
-                );
585
-            }
586
-            // reset time to check for payments
587
-            $response['espresso_thank_you_page']['get_payments_since'] = time();
588
-        } else {
589
-            $response['espresso_thank_you_page']['get_payments_since'] = $since;
590
-        }
591
-        return $response;
592
-    }
593
-
594
-
595
-
596
-    /**
597
-     * _update_server_wait_time
598
-     *
599
-     * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
600
-     * @return array
601
-     * @throws \EE_Error
602
-     */
603
-    private function _update_server_wait_time($thank_you_page_data = array())
604
-    {
605
-        $response['espresso_thank_you_page'] = array(
606
-            'still_waiting' => isset($thank_you_page_data['initial_access'])
607
-                ? time() - $thank_you_page_data['initial_access']
608
-                : 0,
609
-            'txn_status'    => $this->_current_txn->status_ID()
610
-        );
611
-        return $response;
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * get_registration_details
618
-     *
619
-     * @throws \EE_Error
620
-     */
621
-    public function get_registration_details()
622
-    {
623
-        //prepare variables for displaying
624
-        $template_args = array();
625
-        $template_args['transaction'] = $this->_current_txn;
626
-        $template_args['reg_url_link'] = $this->_reg_url_link;
627
-        $template_args['is_primary'] = $this->_is_primary;
628
-        $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
629
-        $template_args['resend_reg_confirmation_url'] = add_query_arg(
630
-            array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
631
-            EE_Registry::instance()->CFG->core->thank_you_page_url()
632
-        );
633
-        // verify template arguments
634
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
635
-        EEH_Template_Validator::verify_isnt_null(
636
-            $template_args['SPCO_attendee_information_url'],
637
-            '$SPCO_attendee_information_url'
638
-        );
639
-        echo EEH_Template::locate_template(
640
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
641
-            $template_args,
642
-            true,
643
-            true
644
-        );
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     * resend_reg_confirmation_email
651
-     *
652
-     * @throws \EE_Error
653
-     */
654
-    public static function resend_reg_confirmation_email()
655
-    {
656
-        EE_Registry::instance()->load_core('Request_Handler');
657
-        $reg_url_link = EE_Registry::instance()->REQ->get('token');
658
-        // was a REG_ID passed ?
659
-        if ($reg_url_link) {
660
-            $registration = EE_Registry::instance()->load_model('Registration')->get_one(
661
-                array(array('REG_url_link' => $reg_url_link))
662
-            );
663
-            if ($registration instanceof EE_Registration) {
664
-                // resend email
665
-                EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
666
-            } else {
667
-                EE_Error::add_error(
668
-                    __(
669
-                        'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
670
-                        'event_espresso'
671
-                    ),
672
-                    __FILE__,
673
-                    __FUNCTION__,
674
-                    __LINE__
675
-                );
676
-            }
677
-        } else {
678
-            EE_Error::add_error(
679
-                __(
680
-                    'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
681
-                    'event_espresso'
682
-                ),
683
-                __FILE__,
684
-                __FUNCTION__,
685
-                __LINE__
686
-            );
687
-        }
688
-        // request sent via AJAX ?
689
-        if (EE_FRONT_AJAX) {
690
-            echo wp_json_encode(EE_Error::get_notices(false));
691
-            die();
692
-            // or was JS disabled ?
693
-        } else {
694
-            // save errors so that they get picked up on the next request
695
-            EE_Error::get_notices(true, true);
696
-            wp_safe_redirect(
697
-                add_query_arg(
698
-                    array('e_reg_url_link' => $reg_url_link),
699
-                    EE_Registry::instance()->CFG->core->thank_you_page_url()
700
-                )
701
-            );
702
-        }
703
-    }
704
-
705
-
706
-
707
-    /**
708
-     * get_ajax_content
709
-     *
710
-     * @return void
711
-     * @throws \EE_Error
712
-     */
713
-    public function get_ajax_content()
714
-    {
715
-        if ( ! $this->get_txn()) {
716
-            return;
717
-        }
718
-        // first determine which event(s) require pre-approval or not
719
-        $events = array();
720
-        $events_requiring_pre_approval = array();
721
-        foreach ($this->_current_txn->registrations() as $registration) {
722
-            if ($registration instanceof EE_Registration) {
723
-                $event = $registration->event();
724
-                if ($event instanceof EE_Event) {
725
-                    if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
726
-                        $events_requiring_pre_approval[$event->ID()] = $event;
727
-                    } else {
728
-                        $events[$event->ID()] = $event;
729
-                    }
730
-                }
731
-            }
732
-        }
733
-        $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
734
-        $this->display_details_for_events($events);
735
-    }
736
-
737
-
738
-
739
-    /**
740
-     * display_details_for_events
741
-     *
742
-     * @param EE_Event[] $events
743
-     * @return void
744
-     */
745
-    public function display_details_for_events($events = array())
746
-    {
747
-        if ( ! empty($events)) {
748
-            ?>
17
+	/**
18
+	 * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
+	 */
20
+	const IPN_wait_time = 1200;
21
+
22
+	/**
23
+	 * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
+	 *
25
+	 * @var EE_Transaction $_current_txn
26
+	 */
27
+	private $_current_txn;
28
+
29
+	/**
30
+	 * @var EE_Registration $_primary_registrant
31
+	 */
32
+	private $_primary_registrant;
33
+
34
+	/**
35
+	 * The reg_url_link passed from the Request, or from the Session
36
+	 *
37
+	 * @var string $_reg_url_link
38
+	 */
39
+	private $_reg_url_link;
40
+
41
+	/**
42
+	 * whether the incoming reg_url_link is for the primary registrant or not
43
+	 *
44
+	 * @var boolean $_is_primary
45
+	 */
46
+	private $_is_primary;
47
+
48
+	/**
49
+	 * The URL for revisiting the SPCO attendee information step
50
+	 *
51
+	 * @var string $_SPCO_attendee_information_url
52
+	 */
53
+	private $_SPCO_attendee_information_url;
54
+
55
+	/**
56
+	 * The URL for revisiting the SPCO payment options step
57
+	 *
58
+	 * @var string $_SPCO_payment_options_url
59
+	 */
60
+	private $_SPCO_payment_options_url;
61
+
62
+	/**
63
+	 * whether to display the Payment Options link
64
+	 *
65
+	 * @var boolean $_show_try_pay_again_link
66
+	 */
67
+	private $_show_try_pay_again_link = false;
68
+
69
+	/**
70
+	 * whether payments are allowed at this time
71
+	 *
72
+	 * @var boolean $_payments_closed
73
+	 */
74
+	private $_payments_closed = false;
75
+
76
+	/**
77
+	 * whether the selected payment method is Bank, Check , Invoice, etc
78
+	 *
79
+	 * @var boolean $_is_offline_payment_method
80
+	 */
81
+	private $_is_offline_payment_method = true;
82
+
83
+
84
+
85
+	/**
86
+	 * @return EED_Module|EED_Thank_You_Page
87
+	 */
88
+	public static function instance()
89
+	{
90
+		return parent::get_instance(__CLASS__);
91
+	}
92
+
93
+
94
+	/**
95
+	 * set_hooks - for hooking into EE Core, modules, etc
96
+	 *
97
+	 * @return void
98
+	 */
99
+	public static function set_hooks()
100
+	{
101
+		add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
+	}
103
+
104
+
105
+
106
+	/**
107
+	 * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
+	 *
109
+	 * @return void
110
+	 */
111
+	public static function set_hooks_admin()
112
+	{
113
+		// AJAX for IPN monitoring
114
+		add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
+		add_filter(
116
+			'heartbeat_nopriv_received',
117
+			array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
+			10,
119
+			3
120
+		);
121
+		add_action(
122
+			'wp_ajax_espresso_resend_reg_confirmation_email',
123
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
+			10,
125
+			2
126
+		);
127
+		add_action(
128
+			'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
+			10,
131
+			2
132
+		);
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * set_definitions
139
+	 *
140
+	 * @return void
141
+	 */
142
+	public static function set_definitions()
143
+	{
144
+		define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
+		define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * get_txn
152
+	 *
153
+	 * @return EE_Transaction
154
+	 */
155
+	public function get_txn()
156
+	{
157
+		if ($this->_current_txn instanceof EE_Transaction) {
158
+			return $this->_current_txn;
159
+		}
160
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
161
+		if ( ! $TXN_model instanceof EEM_Transaction) {
162
+			EE_Error::add_error(
163
+				__('The transaction model could not be established.', 'event_espresso'),
164
+				__FILE__,
165
+				__FUNCTION__,
166
+				__LINE__
167
+			);
168
+			return null;
169
+		}
170
+		//get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
+		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
+		// verify TXN
173
+		if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
+			EE_Error::add_error(
175
+				__(
176
+					'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
+					'event_espresso'
178
+				),
179
+				__FILE__,
180
+				__FUNCTION__,
181
+				__LINE__
182
+			);
183
+			return null;
184
+		}
185
+		return $this->_current_txn;
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * get_txn_payments
192
+	 *
193
+	 * @param int $since
194
+	 * @return mixed array of EE_Payment || FALSE
195
+	 * @throws \EE_Error
196
+	 */
197
+	public function get_txn_payments($since = 0)
198
+	{
199
+		if ( ! $this->get_txn()) {
200
+			return false;
201
+		}
202
+		$args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
+		if ($since > 0) {
204
+			$args[0] = array('PAY_timestamp' => array('>', $since));
205
+		}
206
+		// get array of payments with most recent first
207
+		return $this->_current_txn->payments($args);
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * get_reg_url_link
214
+	 *
215
+	 * @return void
216
+	 */
217
+	private function _get_reg_url_link()
218
+	{
219
+		if ( ! empty($this->_reg_url_link)) {
220
+			return;
221
+		}
222
+		// only do thank you page stuff if we have a REG_url_link in the url
223
+		if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
+			EE_Error::add_error(
225
+				__(
226
+					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
+					'event_espresso'
228
+				),
229
+				__FILE__,
230
+				__FUNCTION__,
231
+				__LINE__
232
+			);
233
+			return;
234
+		}
235
+		// check for reg_url_link
236
+		$this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * set_reg_url_link
243
+	 *
244
+	 * @param string $reg_url_link
245
+	 */
246
+	public function set_reg_url_link($reg_url_link = null)
247
+	{
248
+		$this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * run - initial module setup
255
+	 * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
+	 *
257
+	 * @param WP $WP
258
+	 * @return void
259
+	 * @throws \EE_Error
260
+	 */
261
+	public function run($WP)
262
+	{
263
+
264
+	}
265
+
266
+
267
+
268
+	/**
269
+	 * load_resources
270
+	 *
271
+	 * @return void
272
+	 * @throws \EE_Error
273
+	 */
274
+	public function load_resources() {
275
+		$this->_get_reg_url_link();
276
+		// resend_reg_confirmation_email ?
277
+		if (EE_Registry::instance()->REQ->is_set('resend')) {
278
+			EED_Thank_You_Page::resend_reg_confirmation_email();
279
+		}
280
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
+		$this->_translate_strings();
282
+		// load assets
283
+		add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * load_js
290
+	 *
291
+	 * @return void
292
+	 */
293
+	protected function _translate_strings()
294
+	{
295
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
+		EE_Registry::$i18n_js_strings['initial_access'] = time();
297
+		EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
+		EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
+		EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
+		EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
+			'checking for new payments...',
302
+			'event_espresso'
303
+		);
304
+		EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
+			'loading payment information...',
306
+			'event_espresso'
307
+		);
308
+		EE_Registry::$i18n_js_strings['server_error'] = __(
309
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
+			'event_espresso'
311
+		);
312
+		EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
+			'EED_Thank_You_Page__load_js__slow_IPN',
314
+			sprintf(
315
+				__(
316
+					'%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
+					'event_espresso'
318
+				),
319
+				'<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
+				'</div>'
321
+			)
322
+		);
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * load_js
329
+	 *
330
+	 * @return void
331
+	 */
332
+	public function load_js()
333
+	{
334
+		wp_register_script(
335
+			'thank_you_page',
336
+			THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
+			array('espresso_core', 'heartbeat'),
338
+			EVENT_ESPRESSO_VERSION,
339
+			true
340
+		);
341
+		wp_enqueue_script('thank_you_page');
342
+		wp_enqueue_style('espresso_default');
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * init
349
+	 *
350
+	 * @return void
351
+	 * @throws \EE_Error
352
+	 */
353
+	public function init()
354
+	{
355
+		$this->_get_reg_url_link();
356
+		if ( ! $this->get_txn()) {
357
+			echo EEH_HTML::div(
358
+				EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
359
+				sprintf(
360
+					__(
361
+						'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
362
+						'event_espresso'
363
+					),
364
+					'<br/>'
365
+				),
366
+				'',
367
+				'ee-attention'
368
+			);
369
+			return null;
370
+		}
371
+		// if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
372
+		if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
373
+			$this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
374
+			$this->_current_txn->save();
375
+		}
376
+		$this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
377
+			? $this->_current_txn->primary_registration()
378
+			: null;
379
+		$this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
380
+		$show_try_pay_again_link_default = apply_filters(
381
+			'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
382
+			true
383
+		);
384
+		$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
385
+		// txn status ?
386
+		if ($this->_current_txn->is_completed()) {
387
+			$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
388
+		} else if (
389
+			$this->_current_txn->is_incomplete()
390
+			&& ($this->_primary_registrant->is_approved()
391
+				|| $this->_primary_registrant->is_pending_payment())
392
+		) {
393
+			$this->_show_try_pay_again_link = true;
394
+		} else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
395
+			// its pending
396
+			$this->_show_try_pay_again_link = isset(
397
+												  EE_Registry::instance()->CFG->registration->show_pending_payment_options
398
+											  )
399
+											  && EE_Registry::instance()->CFG->registration->show_pending_payment_options
400
+				? true
401
+				: $show_try_pay_again_link_default;
402
+		}
403
+		$this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
404
+			? true
405
+			: false;
406
+		$this->_is_offline_payment_method = false;
407
+		if (
408
+			// if payment method is unknown
409
+			! $this->_current_txn->payment_method() instanceof EE_Payment_Method
410
+			|| (
411
+				// or is an offline payment method
412
+				$this->_current_txn->payment_method() instanceof EE_Payment_Method
413
+				&& $this->_current_txn->payment_method()->is_off_line()
414
+			)
415
+		) {
416
+			$this->_is_offline_payment_method = true;
417
+		}
418
+		// link to SPCO
419
+		$revisit_spco_url = add_query_arg(
420
+			array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
421
+			EE_Registry::instance()->CFG->core->reg_page_url()
422
+		);
423
+		// link to SPCO payment_options
424
+		$this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
425
+			? $this->_primary_registrant->payment_overview_url()
426
+			: add_query_arg(
427
+				array('step' => 'payment_options'),
428
+				$revisit_spco_url
429
+			);
430
+		// link to SPCO attendee_information
431
+		$this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
432
+			? $this->_primary_registrant->edit_attendee_information_url()
433
+			: false;
434
+		do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
435
+		// set no cache headers and constants
436
+		EE_System::do_not_cache();
437
+	}
438
+
439
+
440
+
441
+	/**
442
+	 * display_thank_you_page_results
443
+	 *
444
+	 * @return string
445
+	 * @throws \EE_Error
446
+	 */
447
+	public function thank_you_page_results()
448
+	{
449
+		$this->init();
450
+		if ( ! $this->_current_txn instanceof EE_Transaction) {
451
+			return EE_Error::get_notices();
452
+		}
453
+		// link to receipt
454
+		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
455
+		if ( ! empty($template_args['TXN_receipt_url'])) {
456
+			$template_args['order_conf_desc'] = __(
457
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
458
+				'event_espresso'
459
+			);
460
+		} else {
461
+			$template_args['order_conf_desc'] = __(
462
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
463
+				'event_espresso'
464
+			);
465
+		}
466
+		$template_args['transaction'] = $this->_current_txn;
467
+		$template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
468
+		add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
469
+		if ($this->_is_primary && ! $this->_current_txn->is_free()) {
470
+			add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
471
+		}
472
+		return EEH_Template::locate_template(
473
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
474
+			$template_args,
475
+			true,
476
+			true
477
+		);
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * thank_you_page_IPN_monitor
484
+	 * this basically just pulls the TXN based on the reg_url_link sent from the server,
485
+	 * then checks that the TXN status is not failed, and that no other errors have been generated.
486
+	 * it also calculates the IPN wait time since the Thank You page was first loaded
487
+	 *
488
+	 * @param array $response
489
+	 * @param array $data
490
+	 * @return array
491
+	 * @throws \EE_Error
492
+	 */
493
+	public static function thank_you_page_IPN_monitor($response = array(), $data = array())
494
+	{
495
+		// does this heartbeat contain our data ?
496
+		if ( ! isset($data['espresso_thank_you_page'])) {
497
+			return $response;
498
+		}
499
+		// check for reg_url_link in the incoming heartbeat data
500
+		if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
501
+			$response['espresso_thank_you_page'] = array(
502
+				'errors' => ! empty($notices['errors'])
503
+					? $notices['errors']
504
+					: __(
505
+						'No transaction information could be retrieved because the registration URL link is missing or invalid.',
506
+						'event_espresso'
507
+					)
508
+			);
509
+			return $response;
510
+		}
511
+		// kk heartbeat has our data
512
+		$response['espresso_thank_you_page'] = array();
513
+		// set_definitions, instantiate the thank you page class, and get the ball rolling
514
+		EED_Thank_You_Page::set_definitions();
515
+		/** @var $espresso_thank_you_page EED_Thank_You_Page */
516
+		$espresso_thank_you_page = EED_Thank_You_Page::instance();
517
+		$espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
518
+		$espresso_thank_you_page->init();
519
+		//get TXN
520
+		$TXN = $espresso_thank_you_page->get_txn();
521
+		// no TXN? then get out
522
+		if ( ! $TXN instanceof EE_Transaction) {
523
+			$notices = EE_Error::get_notices();
524
+			$response['espresso_thank_you_page'] = array(
525
+				'errors' => ! empty($notices['errors'])
526
+					? $notices['errors']
527
+					: sprintf(
528
+						__(
529
+							'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
530
+							'event_espresso'
531
+						),
532
+						__LINE__
533
+					)
534
+			);
535
+			return $response;
536
+		}
537
+		// grab transient of TXN's status
538
+		$txn_status = isset($data['espresso_thank_you_page']['txn_status'])
539
+			? $data['espresso_thank_you_page']['txn_status']
540
+			: null;
541
+		// has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
542
+		if ($txn_status !== $TXN->status_ID()) {
543
+			// switch between two possible basic outcomes
544
+			switch ($TXN->status_ID()) {
545
+				// TXN has been updated in some way
546
+				case EEM_Transaction::overpaid_status_code:
547
+				case EEM_Transaction::complete_status_code:
548
+				case EEM_Transaction::incomplete_status_code:
549
+					// send updated TXN results back to client,
550
+					$response['espresso_thank_you_page'] = array(
551
+						'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
552
+						'txn_status'          => $TXN->status_ID()
553
+					);
554
+					break;
555
+				// or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
556
+				case EEM_Transaction::failed_status_code:
557
+				default:
558
+					// keep on waiting...
559
+					return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
560
+			}
561
+			// or is the TXN still failed (never been updated) ???
562
+		} else if ($TXN->failed()) {
563
+			// keep on waiting...
564
+			return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
565
+		}
566
+		// TXN is happening so let's get the payments now
567
+		// if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
568
+		$since = isset($data['espresso_thank_you_page']['get_payments_since'])
569
+			? $data['espresso_thank_you_page']['get_payments_since']
570
+			: 0;
571
+		// then check for payments
572
+		$payments = $espresso_thank_you_page->get_txn_payments($since);
573
+		// has a payment been processed ?
574
+		if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
575
+			if ($since) {
576
+				$response['espresso_thank_you_page'] = array(
577
+					'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
578
+					'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
579
+					'txn_status'          => $TXN->status_ID()
580
+				);
581
+			} else {
582
+				$response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
583
+					$payments
584
+				);
585
+			}
586
+			// reset time to check for payments
587
+			$response['espresso_thank_you_page']['get_payments_since'] = time();
588
+		} else {
589
+			$response['espresso_thank_you_page']['get_payments_since'] = $since;
590
+		}
591
+		return $response;
592
+	}
593
+
594
+
595
+
596
+	/**
597
+	 * _update_server_wait_time
598
+	 *
599
+	 * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
600
+	 * @return array
601
+	 * @throws \EE_Error
602
+	 */
603
+	private function _update_server_wait_time($thank_you_page_data = array())
604
+	{
605
+		$response['espresso_thank_you_page'] = array(
606
+			'still_waiting' => isset($thank_you_page_data['initial_access'])
607
+				? time() - $thank_you_page_data['initial_access']
608
+				: 0,
609
+			'txn_status'    => $this->_current_txn->status_ID()
610
+		);
611
+		return $response;
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * get_registration_details
618
+	 *
619
+	 * @throws \EE_Error
620
+	 */
621
+	public function get_registration_details()
622
+	{
623
+		//prepare variables for displaying
624
+		$template_args = array();
625
+		$template_args['transaction'] = $this->_current_txn;
626
+		$template_args['reg_url_link'] = $this->_reg_url_link;
627
+		$template_args['is_primary'] = $this->_is_primary;
628
+		$template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
629
+		$template_args['resend_reg_confirmation_url'] = add_query_arg(
630
+			array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
631
+			EE_Registry::instance()->CFG->core->thank_you_page_url()
632
+		);
633
+		// verify template arguments
634
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
635
+		EEH_Template_Validator::verify_isnt_null(
636
+			$template_args['SPCO_attendee_information_url'],
637
+			'$SPCO_attendee_information_url'
638
+		);
639
+		echo EEH_Template::locate_template(
640
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
641
+			$template_args,
642
+			true,
643
+			true
644
+		);
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 * resend_reg_confirmation_email
651
+	 *
652
+	 * @throws \EE_Error
653
+	 */
654
+	public static function resend_reg_confirmation_email()
655
+	{
656
+		EE_Registry::instance()->load_core('Request_Handler');
657
+		$reg_url_link = EE_Registry::instance()->REQ->get('token');
658
+		// was a REG_ID passed ?
659
+		if ($reg_url_link) {
660
+			$registration = EE_Registry::instance()->load_model('Registration')->get_one(
661
+				array(array('REG_url_link' => $reg_url_link))
662
+			);
663
+			if ($registration instanceof EE_Registration) {
664
+				// resend email
665
+				EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
666
+			} else {
667
+				EE_Error::add_error(
668
+					__(
669
+						'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
670
+						'event_espresso'
671
+					),
672
+					__FILE__,
673
+					__FUNCTION__,
674
+					__LINE__
675
+				);
676
+			}
677
+		} else {
678
+			EE_Error::add_error(
679
+				__(
680
+					'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
681
+					'event_espresso'
682
+				),
683
+				__FILE__,
684
+				__FUNCTION__,
685
+				__LINE__
686
+			);
687
+		}
688
+		// request sent via AJAX ?
689
+		if (EE_FRONT_AJAX) {
690
+			echo wp_json_encode(EE_Error::get_notices(false));
691
+			die();
692
+			// or was JS disabled ?
693
+		} else {
694
+			// save errors so that they get picked up on the next request
695
+			EE_Error::get_notices(true, true);
696
+			wp_safe_redirect(
697
+				add_query_arg(
698
+					array('e_reg_url_link' => $reg_url_link),
699
+					EE_Registry::instance()->CFG->core->thank_you_page_url()
700
+				)
701
+			);
702
+		}
703
+	}
704
+
705
+
706
+
707
+	/**
708
+	 * get_ajax_content
709
+	 *
710
+	 * @return void
711
+	 * @throws \EE_Error
712
+	 */
713
+	public function get_ajax_content()
714
+	{
715
+		if ( ! $this->get_txn()) {
716
+			return;
717
+		}
718
+		// first determine which event(s) require pre-approval or not
719
+		$events = array();
720
+		$events_requiring_pre_approval = array();
721
+		foreach ($this->_current_txn->registrations() as $registration) {
722
+			if ($registration instanceof EE_Registration) {
723
+				$event = $registration->event();
724
+				if ($event instanceof EE_Event) {
725
+					if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
726
+						$events_requiring_pre_approval[$event->ID()] = $event;
727
+					} else {
728
+						$events[$event->ID()] = $event;
729
+					}
730
+				}
731
+			}
732
+		}
733
+		$this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
734
+		$this->display_details_for_events($events);
735
+	}
736
+
737
+
738
+
739
+	/**
740
+	 * display_details_for_events
741
+	 *
742
+	 * @param EE_Event[] $events
743
+	 * @return void
744
+	 */
745
+	public function display_details_for_events($events = array())
746
+	{
747
+		if ( ! empty($events)) {
748
+			?>
749 749
             <div id="espresso-thank-you-page-ajax-content-dv">
750 750
                 <div id="espresso-thank-you-page-ajax-transaction-dv"></div>
751 751
                 <div id="espresso-thank-you-page-ajax-payment-dv"></div>
752 752
                 <div id="espresso-thank-you-page-ajax-loading-dv">
753 753
                     <div id="ee-ajax-loading-dv" class="float-left lt-blue-text">
754 754
                         <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"><?php _e(
755
-                                'loading transaction and payment information...',
756
-                                'event_espresso'
757
-                            ); ?></span>
755
+								'loading transaction and payment information...',
756
+								'event_espresso'
757
+							); ?></span>
758 758
                     </div>
759 759
                     <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
760 760
                         <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
761 761
                             <?php echo apply_filters(
762
-                                'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
763
-                                __(
764
-                                    'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
765
-                                    'event_espresso'
766
-                                )
767
-                            ); ?>
762
+								'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
763
+								__(
764
+									'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
765
+									'event_espresso'
766
+								)
767
+							); ?>
768 768
                             <br/>
769 769
                             <span class="jst-rght ee-block small-text lt-grey-text">
770 770
 								<?php _e('current wait time ', 'event_espresso'); ?>
@@ -775,120 +775,120 @@  discard block
 block discarded – undo
775 775
                 <div class="clear"></div>
776 776
             </div>
777 777
             <?php
778
-        }
779
-    }
778
+		}
779
+	}
780 780
 
781 781
 
782 782
 
783
-    /**
784
-     * display_details_for_events_requiring_pre_approval
785
-     *
786
-     * @param EE_Event[] $events
787
-     * @return void
788
-     */
789
-    public function display_details_for_events_requiring_pre_approval($events = array())
790
-    {
791
-        if ( ! empty($events)) {
792
-            ?>
783
+	/**
784
+	 * display_details_for_events_requiring_pre_approval
785
+	 *
786
+	 * @param EE_Event[] $events
787
+	 * @return void
788
+	 */
789
+	public function display_details_for_events_requiring_pre_approval($events = array())
790
+	{
791
+		if ( ! empty($events)) {
792
+			?>
793 793
             <div id="espresso-thank-you-page-not-approved-message-dv">
794 794
                 <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4>
795 795
                 <p id="events-requiring-pre-approval-pg" class="small-text">
796 796
                     <?php echo apply_filters(
797
-                        'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
798
-                        __(
799
-                            'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have 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.',
800
-                            'event_espresso'
801
-                        )
802
-                    ); ?>
797
+						'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
798
+						__(
799
+							'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have 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.',
800
+							'event_espresso'
801
+						)
802
+					); ?>
803 803
                 </p>
804 804
                 <ul class="events-requiring-pre-approval-ul">
805 805
                     <?php foreach ($events as $event) {
806
-                        if ($event instanceof EE_Event) {
807
-                            echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
808
-                            $event->name(),
809
-                            '</li>';
810
-                        }
811
-                    } ?>
806
+						if ($event instanceof EE_Event) {
807
+							echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
808
+							$event->name(),
809
+							'</li>';
810
+						}
811
+					} ?>
812 812
                 </ul>
813 813
                 <div class="clear"></div>
814 814
             </div>
815 815
             <?php
816
-        }
817
-    }
818
-
819
-
820
-
821
-    /**
822
-     * get_transaction_details
823
-     *
824
-     * @return string
825
-     * @throws \EE_Error
826
-     */
827
-    public function get_transaction_details()
828
-    {
829
-        //prepare variables for displaying
830
-        $template_args = array();
831
-        $template_args['transaction'] = $this->_current_txn;
832
-        $template_args['reg_url_link'] = $this->_reg_url_link;
833
-        $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
834
-        // link to SPCO payment_options
835
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
836
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
837
-        // verify template arguments
838
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
839
-        EEH_Template_Validator::verify_isnt_null(
840
-            $template_args['show_try_pay_again_link'],
841
-            '$show_try_pay_again_link'
842
-        );
843
-        EEH_Template_Validator::verify_isnt_null(
844
-            $template_args['SPCO_payment_options_url'],
845
-            '$SPCO_payment_options_url'
846
-        );
847
-        return EEH_Template::locate_template(
848
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
849
-            $template_args,
850
-            true,
851
-            true
852
-        );
853
-    }
854
-
855
-
856
-
857
-    /**
858
-     * get_payment_row_html
859
-     *
860
-     * @param EE_Payment $payment
861
-     * @return string
862
-     * @throws \EE_Error
863
-     */
864
-    public function get_payment_row_html($payment = null)
865
-    {
866
-        $html = '';
867
-        if ($payment instanceof EE_Payment) {
868
-            if (
869
-                $payment->payment_method() instanceof EE_Payment_Method
870
-                && $payment->status() === EEM_Payment::status_id_failed
871
-                && $payment->payment_method()->is_off_site()
872
-            ) {
873
-                // considering the registrant has made it to the Thank You page,
874
-                // any failed payments may actually be pending and the IPN is just slow
875
-                // so let's
876
-                $payment->set_status(EEM_Payment::status_id_pending);
877
-            }
878
-            $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
879
-                ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
880
-                : '';
881
-            $html .= '
816
+		}
817
+	}
818
+
819
+
820
+
821
+	/**
822
+	 * get_transaction_details
823
+	 *
824
+	 * @return string
825
+	 * @throws \EE_Error
826
+	 */
827
+	public function get_transaction_details()
828
+	{
829
+		//prepare variables for displaying
830
+		$template_args = array();
831
+		$template_args['transaction'] = $this->_current_txn;
832
+		$template_args['reg_url_link'] = $this->_reg_url_link;
833
+		$template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
834
+		// link to SPCO payment_options
835
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
836
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
837
+		// verify template arguments
838
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
839
+		EEH_Template_Validator::verify_isnt_null(
840
+			$template_args['show_try_pay_again_link'],
841
+			'$show_try_pay_again_link'
842
+		);
843
+		EEH_Template_Validator::verify_isnt_null(
844
+			$template_args['SPCO_payment_options_url'],
845
+			'$SPCO_payment_options_url'
846
+		);
847
+		return EEH_Template::locate_template(
848
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
849
+			$template_args,
850
+			true,
851
+			true
852
+		);
853
+	}
854
+
855
+
856
+
857
+	/**
858
+	 * get_payment_row_html
859
+	 *
860
+	 * @param EE_Payment $payment
861
+	 * @return string
862
+	 * @throws \EE_Error
863
+	 */
864
+	public function get_payment_row_html($payment = null)
865
+	{
866
+		$html = '';
867
+		if ($payment instanceof EE_Payment) {
868
+			if (
869
+				$payment->payment_method() instanceof EE_Payment_Method
870
+				&& $payment->status() === EEM_Payment::status_id_failed
871
+				&& $payment->payment_method()->is_off_site()
872
+			) {
873
+				// considering the registrant has made it to the Thank You page,
874
+				// any failed payments may actually be pending and the IPN is just slow
875
+				// so let's
876
+				$payment->set_status(EEM_Payment::status_id_pending);
877
+			}
878
+			$payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
879
+				? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
880
+				: '';
881
+			$html .= '
882 882
 				<tr>
883 883
 					<td>
884 884
 						' . $payment->timestamp() . '
885 885
 					</td>
886 886
 					<td>
887 887
 						' . (
888
-                $payment->payment_method() instanceof EE_Payment_Method
889
-                    ? $payment->payment_method()->name()
890
-                    : __('Unknown', 'event_espresso')
891
-                ) . '
888
+				$payment->payment_method() instanceof EE_Payment_Method
889
+					? $payment->payment_method()->name()
890
+					: __('Unknown', 'event_espresso')
891
+				) . '
892 892
 					</td>
893 893
 					<td class="jst-rght">
894 894
 						' . EEH_Template::format_currency($payment->amount()) . '
@@ -897,87 +897,87 @@  discard block
 block discarded – undo
897 897
 						' . $payment->pretty_status(true) . $payment_declined_msg . '
898 898
 					</td>
899 899
 				</tr>';
900
-            do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
901
-        }
902
-        return $html;
903
-    }
904
-
905
-
906
-
907
-    /**
908
-     * get_payment_details
909
-     *
910
-     * @param array $payments
911
-     * @return string
912
-     * @throws \EE_Error
913
-     */
914
-    public function get_payment_details($payments = array())
915
-    {
916
-        //prepare variables for displaying
917
-        $template_args = array();
918
-        $template_args['transaction'] = $this->_current_txn;
919
-        $template_args['reg_url_link'] = $this->_reg_url_link;
920
-        $template_args['payments'] = array();
921
-        foreach ($payments as $payment) {
922
-            $template_args['payments'][] = $this->get_payment_row_html($payment);
923
-        }
924
-        //create a hacky payment object, but dont save it
925
-        $payment = EE_Payment::new_instance(
926
-            array(
927
-                'TXN_ID'        => $this->_current_txn->ID(),
928
-                'STS_ID'        => EEM_Payment::status_id_pending,
929
-                'PAY_timestamp' => time(),
930
-                'PAY_amount'    => $this->_current_txn->total(),
931
-                'PMD_ID'        => $this->_current_txn->payment_method_ID()
932
-            )
933
-        );
934
-        $payment_method = $this->_current_txn->payment_method();
935
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
936
-            $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
937
-        } else {
938
-            $template_args['gateway_content'] = '';
939
-        }
940
-        // link to SPCO payment_options
941
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
942
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
943
-        // verify template arguments
944
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
945
-        EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
946
-        EEH_Template_Validator::verify_isnt_null(
947
-            $template_args['show_try_pay_again_link'],
948
-            '$show_try_pay_again_link'
949
-        );
950
-        EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
951
-        EEH_Template_Validator::verify_isnt_null(
952
-            $template_args['SPCO_payment_options_url'],
953
-            '$SPCO_payment_options_url'
954
-        );
955
-        return EEH_Template::locate_template(
956
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
957
-            $template_args,
958
-            true,
959
-            true
960
-        );
961
-    }
962
-
963
-
964
-
965
-    /**
966
-     * get_payment_details
967
-     *
968
-     * @param array $payments
969
-     * @return string
970
-     * @throws \EE_Error
971
-     */
972
-    public function get_new_payments($payments = array())
973
-    {
974
-        $payments_html = '';
975
-        //prepare variables for displaying
976
-        foreach ($payments as $payment) {
977
-            $payments_html .= $this->get_payment_row_html($payment);
978
-        }
979
-        return $payments_html;
980
-    }
900
+			do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
901
+		}
902
+		return $html;
903
+	}
904
+
905
+
906
+
907
+	/**
908
+	 * get_payment_details
909
+	 *
910
+	 * @param array $payments
911
+	 * @return string
912
+	 * @throws \EE_Error
913
+	 */
914
+	public function get_payment_details($payments = array())
915
+	{
916
+		//prepare variables for displaying
917
+		$template_args = array();
918
+		$template_args['transaction'] = $this->_current_txn;
919
+		$template_args['reg_url_link'] = $this->_reg_url_link;
920
+		$template_args['payments'] = array();
921
+		foreach ($payments as $payment) {
922
+			$template_args['payments'][] = $this->get_payment_row_html($payment);
923
+		}
924
+		//create a hacky payment object, but dont save it
925
+		$payment = EE_Payment::new_instance(
926
+			array(
927
+				'TXN_ID'        => $this->_current_txn->ID(),
928
+				'STS_ID'        => EEM_Payment::status_id_pending,
929
+				'PAY_timestamp' => time(),
930
+				'PAY_amount'    => $this->_current_txn->total(),
931
+				'PMD_ID'        => $this->_current_txn->payment_method_ID()
932
+			)
933
+		);
934
+		$payment_method = $this->_current_txn->payment_method();
935
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
936
+			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
937
+		} else {
938
+			$template_args['gateway_content'] = '';
939
+		}
940
+		// link to SPCO payment_options
941
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
942
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
943
+		// verify template arguments
944
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
945
+		EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
946
+		EEH_Template_Validator::verify_isnt_null(
947
+			$template_args['show_try_pay_again_link'],
948
+			'$show_try_pay_again_link'
949
+		);
950
+		EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
951
+		EEH_Template_Validator::verify_isnt_null(
952
+			$template_args['SPCO_payment_options_url'],
953
+			'$SPCO_payment_options_url'
954
+		);
955
+		return EEH_Template::locate_template(
956
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
957
+			$template_args,
958
+			true,
959
+			true
960
+		);
961
+	}
962
+
963
+
964
+
965
+	/**
966
+	 * get_payment_details
967
+	 *
968
+	 * @param array $payments
969
+	 * @return string
970
+	 * @throws \EE_Error
971
+	 */
972
+	public function get_new_payments($payments = array())
973
+	{
974
+		$payments_html = '';
975
+		//prepare variables for displaying
976
+		foreach ($payments as $payment) {
977
+			$payments_html .= $this->get_payment_row_html($payment);
978
+		}
979
+		return $payments_html;
980
+	}
981 981
 
982 982
 
983 983
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoThankYou.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             return;
53 53
         }
54 54
         $post = reset($wp_query->posts);
55
-        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
55
+        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
56 56
             return;
57 57
         }
58 58
         $this->is_thank_you_page = true;
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -20,75 +20,75 @@
 block discarded – undo
20 20
 class EspressoThankYou extends EspressoShortcode
21 21
 {
22 22
 
23
-    /**
24
-     * @var boolean $is_thank_you_page
25
-     */
26
-    private $is_thank_you_page = false;
27
-
28
-    /**
29
-     * the actual shortcode tag that gets registered with WordPress
30
-     *
31
-     * @return string
32
-     */
33
-    public function getTag()
34
-    {
35
-        return 'ESPRESSO_THANK_YOU';
36
-    }
37
-
38
-
39
-
40
-    /**
41
-     * the time in seconds to cache the results of the processShortcode() method
42
-     * 0 means the processShortcode() results will NOT be cached at all
43
-     *
44
-     * @return int
45
-     */
46
-    public function cacheExpiration()
47
-    {
48
-        return 0;
49
-    }
50
-
51
-
52
-    /**
53
-     * a place for adding any initialization code that needs to run prior to wp_header().
54
-     * this may be required for shortcodes that utilize a corresponding module,
55
-     * and need to enqueue assets for that module
56
-     *
57
-     * @return void
58
-     * @throws \EE_Error
59
-     */
60
-    public function initializeShortcode()
61
-    {
62
-        global $wp_query;
63
-        if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
-            return;
65
-        }
66
-        $post = reset($wp_query->posts);
67
-        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
-            return;
69
-        }
70
-        $this->is_thank_you_page = true;
71
-        \EED_Thank_You_Page::instance()->load_resources();
72
-        $this->shortcodeHasBeenInitialized();
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     * callback that runs when the shortcode is encountered in post content.
79
-     * IMPORTANT !!!
80
-     * remember that shortcode content should be RETURNED and NOT echoed out
81
-     *
82
-     * @param array $attributes
83
-     * @return string
84
-     * @throws \EE_Error
85
-     */
86
-    public function processShortcode($attributes = array())
87
-    {
88
-        return $this->is_thank_you_page
89
-            ? \EED_Thank_You_Page::instance()->thank_you_page_results()
90
-            : '';
91
-    }
23
+	/**
24
+	 * @var boolean $is_thank_you_page
25
+	 */
26
+	private $is_thank_you_page = false;
27
+
28
+	/**
29
+	 * the actual shortcode tag that gets registered with WordPress
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function getTag()
34
+	{
35
+		return 'ESPRESSO_THANK_YOU';
36
+	}
37
+
38
+
39
+
40
+	/**
41
+	 * the time in seconds to cache the results of the processShortcode() method
42
+	 * 0 means the processShortcode() results will NOT be cached at all
43
+	 *
44
+	 * @return int
45
+	 */
46
+	public function cacheExpiration()
47
+	{
48
+		return 0;
49
+	}
50
+
51
+
52
+	/**
53
+	 * a place for adding any initialization code that needs to run prior to wp_header().
54
+	 * this may be required for shortcodes that utilize a corresponding module,
55
+	 * and need to enqueue assets for that module
56
+	 *
57
+	 * @return void
58
+	 * @throws \EE_Error
59
+	 */
60
+	public function initializeShortcode()
61
+	{
62
+		global $wp_query;
63
+		if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
+			return;
65
+		}
66
+		$post = reset($wp_query->posts);
67
+		if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
+			return;
69
+		}
70
+		$this->is_thank_you_page = true;
71
+		\EED_Thank_You_Page::instance()->load_resources();
72
+		$this->shortcodeHasBeenInitialized();
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 * callback that runs when the shortcode is encountered in post content.
79
+	 * IMPORTANT !!!
80
+	 * remember that shortcode content should be RETURNED and NOT echoed out
81
+	 *
82
+	 * @param array $attributes
83
+	 * @return string
84
+	 * @throws \EE_Error
85
+	 */
86
+	public function processShortcode($attributes = array())
87
+	{
88
+		return $this->is_thank_you_page
89
+			? \EED_Thank_You_Page::instance()->thank_you_page_results()
90
+			: '';
91
+	}
92 92
 
93 93
 
94 94
 
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket.class.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,8 @@
 block discarded – undo
128 128
      *
129 129
      * @param bool        $display   true = we'll return a localized string, otherwise we just return the value of the relevant status const
130 130
      * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing
131
-     * @return mixed status int if the display string isn't requested
131
+     * @param boolean $remaining
132
+     * @return string status int if the display string isn't requested
132 133
      * @throws \EE_Error
133 134
      */
134 135
 	public function ticket_status( $display = FALSE, $remaining = null ) {
Please login to merge, or discard this patch.
Spacing   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\UnexpectedEntityException;
2 2
 
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * Event Espresso
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      * @return EE_Ticket
71 71
      * @throws \EE_Error
72 72
      */
73
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
74
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
75
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
73
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
74
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
75
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
76 76
 	}
77 77
 
78 78
 
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      * @return EE_Ticket
85 85
      * @throws \EE_Error
86 86
      */
87
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
88
-		return new self( $props_n_values, TRUE, $timezone );
87
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
88
+		return new self($props_n_values, TRUE, $timezone);
89 89
 	}
90 90
 
91 91
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * @throws \EE_Error
96 96
      */
97 97
 	public function parent() {
98
-		return $this->get( 'TKT_parent' );
98
+		return $this->get('TKT_parent');
99 99
 	}
100 100
 
101 101
 
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
      * @return boolean
108 108
      * @throws \EE_Error
109 109
      */
110
-	public function available( $DTT_ID = 0 ) {
110
+	public function available($DTT_ID = 0) {
111 111
 		// are we checking availability for a particular datetime ?
112
-		if ( $DTT_ID ) {
112
+		if ($DTT_ID) {
113 113
 			// get that datetime object
114
-			$datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
114
+			$datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
115 115
 			// if  ticket sales for this datetime have exceeded the reg limit...
116
-			if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) {
116
+			if ($datetime instanceof EE_Datetime && $datetime->sold_out()) {
117 117
 				return FALSE;
118 118
 			}
119 119
 		}
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
      * @return mixed status int if the display string isn't requested
132 132
      * @throws \EE_Error
133 133
      */
134
-	public function ticket_status( $display = FALSE, $remaining = null ) {
135
-		$remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining();
136
-		if ( ! $remaining ) {
137
-			return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out;
134
+	public function ticket_status($display = FALSE, $remaining = null) {
135
+		$remaining = is_bool($remaining) ? $remaining : $this->is_remaining();
136
+		if ( ! $remaining) {
137
+			return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out;
138 138
 		}
139
-		if ( $this->get( 'TKT_deleted' ) ) {
140
-			return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived;
139
+		if ($this->get('TKT_deleted')) {
140
+			return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived;
141 141
 		}
142
-		if ( $this->is_expired() ) {
143
-			return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired;
142
+		if ($this->is_expired()) {
143
+			return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired;
144 144
 		}
145
-		if ( $this->is_pending() ) {
146
-			return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending;
145
+		if ($this->is_pending()) {
146
+			return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending;
147 147
 		}
148
-		if ( $this->is_on_sale() ) {
149
-			return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale;
148
+		if ($this->is_on_sale()) {
149
+			return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale;
150 150
 		}
151 151
 		return '';
152 152
 	}
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
      * @return boolean         true = tickets remaining, false not.
162 162
      * @throws \EE_Error
163 163
      */
164
-	public function is_remaining( $DTT_ID = 0 ) {
165
-		$num_remaining = $this->remaining( $DTT_ID );
166
-		if ( $num_remaining === 0 ) {
164
+	public function is_remaining($DTT_ID = 0) {
165
+		$num_remaining = $this->remaining($DTT_ID);
166
+		if ($num_remaining === 0) {
167 167
 			return FALSE;
168 168
 		}
169
-		if ( $num_remaining > 0 && $num_remaining < $this->min() ) {
169
+		if ($num_remaining > 0 && $num_remaining < $this->min()) {
170 170
 			return FALSE;
171 171
 		}
172 172
 		return TRUE;
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
      * @return int
183 183
      * @throws \EE_Error
184 184
      */
185
-	public function remaining( $DTT_ID = 0 ) {
186
-		return $this->real_quantity_on_ticket('saleable', $DTT_ID );
185
+	public function remaining($DTT_ID = 0) {
186
+		return $this->real_quantity_on_ticket('saleable', $DTT_ID);
187 187
 	}
188 188
 
189 189
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @throws \EE_Error
196 196
      */
197 197
 	public function min() {
198
-		return $this->get( 'TKT_min' );
198
+		return $this->get('TKT_min');
199 199
 	}
200 200
 
201 201
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @throws \EE_Error
208 208
      */
209 209
 	public function is_expired() {
210
-		return ( $this->get_raw( 'TKT_end_date' ) < time() );
210
+		return ($this->get_raw('TKT_end_date') < time());
211 211
 	}
212 212
 
213 213
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      * @throws \EE_Error
220 220
      */
221 221
 	public function is_pending() {
222
-		return ( $this->get_raw( 'TKT_start_date' ) > time() );
222
+		return ($this->get_raw('TKT_start_date') > time());
223 223
 	}
224 224
 
225 225
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * @throws \EE_Error
232 232
      */
233 233
 	public function is_on_sale() {
234
-		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
234
+		return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time());
235 235
 	}
236 236
 
237 237
 
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
      * @return string
245 245
      * @throws \EE_Error
246 246
      */
247
-	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
248
-		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
249
-		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
247
+	public function date_range($dt_frmt = '', $conjunction = ' - ') {
248
+		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : '';
249
+		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : '';
250 250
 
251
-		return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
251
+		return $first_date && $last_date ? $first_date.$conjunction.$last_date : '';
252 252
 	}
253 253
 
254 254
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
      * @throws \EE_Error
261 261
      */
262 262
 	public function first_datetime() {
263
-		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
264
-		return reset( $datetimes );
263
+		$datetimes = $this->datetimes(array('limit' => 1));
264
+		return reset($datetimes);
265 265
 	}
266 266
 
267 267
 
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
      * @return EE_Datetime[]|EE_Base_Class[]
275 275
      * @throws \EE_Error
276 276
      */
277
-	public function datetimes( $query_params = array() ) {
278
-		if ( ! isset( $query_params[ 'order_by' ] ) ) {
279
-			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
277
+	public function datetimes($query_params = array()) {
278
+		if ( ! isset($query_params['order_by'])) {
279
+			$query_params['order_by']['DTT_order'] = 'ASC';
280 280
 		}
281
-		return $this->get_many_related( 'Datetime', $query_params );
281
+		return $this->get_many_related('Datetime', $query_params);
282 282
 	}
283 283
 
284 284
 
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
      * @throws \EE_Error
291 291
      */
292 292
 	public function last_datetime() {
293
-		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
294
-		return end( $datetimes );
293
+		$datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC')));
294
+		return end($datetimes);
295 295
 	}
296 296
 
297 297
 
@@ -309,22 +309,22 @@  discard block
 block discarded – undo
309 309
      * @return mixed (array|int)          how many tickets have sold
310 310
      * @throws \EE_Error
311 311
      */
312
-	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
312
+	public function tickets_sold($what = 'ticket', $dtt_id = NULL) {
313 313
 		$total = 0;
314 314
 		$tickets_sold = $this->_all_tickets_sold();
315
-		switch ( $what ) {
315
+		switch ($what) {
316 316
 			case 'ticket' :
317
-				return $tickets_sold[ 'ticket' ];
317
+				return $tickets_sold['ticket'];
318 318
 				break;
319 319
 			case 'datetime' :
320
-				if ( empty( $tickets_sold[ 'datetime' ] ) ) {
320
+				if (empty($tickets_sold['datetime'])) {
321 321
 					return $total;
322 322
 				}
323
-				if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) {
324
-					EE_Error::add_error( __( 'You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
323
+				if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) {
324
+					EE_Error::add_error(__('You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
325 325
 					return $total;
326 326
 				}
327
-				return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ];
327
+				return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id];
328 328
 				break;
329 329
 			default:
330 330
 				return $total;
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
      * @throws \EE_Error
341 341
      */
342 342
 	protected function _all_tickets_sold() {
343
-		$datetimes = $this->get_many_related( 'Datetime' );
343
+		$datetimes = $this->get_many_related('Datetime');
344 344
 		$tickets_sold = array();
345
-		if ( ! empty( $datetimes ) ) {
346
-			foreach ( $datetimes as $datetime ) {
347
-				$tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' );
345
+		if ( ! empty($datetimes)) {
346
+			foreach ($datetimes as $datetime) {
347
+				$tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold');
348 348
 			}
349 349
 		}
350 350
 		//Tickets sold
351
-		$tickets_sold[ 'ticket' ] = $this->sold();
351
+		$tickets_sold['ticket'] = $this->sold();
352 352
 		return $tickets_sold;
353 353
 	}
354 354
 
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
      * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
362 362
      * @throws \EE_Error
363 363
      */
364
-	public function base_price( $return_array = FALSE ) {
365
-		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
364
+	public function base_price($return_array = FALSE) {
365
+		$_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price);
366 366
 		return $return_array
367
-            ? $this->get_many_related( 'Price', array( $_where ) )
368
-            : $this->get_first_related( 'Price', array( $_where ) );
367
+            ? $this->get_many_related('Price', array($_where))
368
+            : $this->get_first_related('Price', array($_where));
369 369
 	}
370 370
 
371 371
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
      * @throws \EE_Error
379 379
      */
380 380
 	public function price_modifiers() {
381
-		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
382
-		return $this->prices( $query_params );
381
+		$query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax))));
382
+		return $this->prices($query_params);
383 383
 	}
384 384
 
385 385
 
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
      * @return EE_Price[]|EE_Base_Class[]
392 392
      * @throws \EE_Error
393 393
      */
394
-	public function prices( $query_params = array() ) {
395
-		return $this->get_many_related( 'Price', $query_params );
394
+	public function prices($query_params = array()) {
395
+		return $this->get_many_related('Price', $query_params);
396 396
 	}
397 397
 
398 398
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
      * @return EE_Datetime_Ticket|EE_Base_Class[]
405 405
      * @throws \EE_Error
406 406
      */
407
-	public function datetime_tickets( $query_params = array() ) {
408
-		return $this->get_many_related( 'Datetime_Ticket', $query_params );
407
+	public function datetime_tickets($query_params = array()) {
408
+		return $this->get_many_related('Datetime_Ticket', $query_params);
409 409
 	}
410 410
 
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
      * @return EE_Datetime[]
419 419
      * @throws \EE_Error
420 420
      */
421
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
422
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
421
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) {
422
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted);
423 423
 	}
424 424
 
425 425
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      * @throws \EE_Error
432 432
      */
433 433
 	public function ID() {
434
-		return $this->get( 'TKT_ID' );
434
+		return $this->get('TKT_ID');
435 435
 	}
436 436
 
437 437
 
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      * @throws \EE_Error
457 457
      */
458 458
 	public function template() {
459
-		return $this->get_first_related( 'Ticket_Template' );
459
+		return $this->get_first_related('Ticket_Template');
460 460
 	}
461 461
 
462 462
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      * @throws \EE_Error
479 479
      */
480 480
 	public function ticket_price() {
481
-		return $this->get( 'TKT_price' );
481
+		return $this->get('TKT_price');
482 482
 	}
483 483
 
484 484
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
      * @throws \EE_Error
489 489
      */
490 490
 	public function pretty_price() {
491
-		return $this->get_pretty( 'TKT_price' );
491
+		return $this->get_pretty('TKT_price');
492 492
 	}
493 493
 
494 494
 
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
      * @return float
511 511
      * @throws \EE_Error
512 512
      */
513
-	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
514
-		if ($this->_ticket_total_with_taxes === null || $no_cache ) {
513
+	public function get_ticket_total_with_taxes($no_cache = FALSE) {
514
+		if ($this->_ticket_total_with_taxes === null || $no_cache) {
515 515
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
516 516
 		}
517 517
 		return (float) $this->_ticket_total_with_taxes;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
 
522 522
 	public function ensure_TKT_Price_correct() {
523
-		$this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) );
523
+		$this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this));
524 524
 		$this->save();
525 525
 	}
526 526
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
      * @throws \EE_Error
532 532
      */
533 533
 	public function get_ticket_subtotal() {
534
-		return EE_Taxes::get_subtotal_for_admin( $this );
534
+		return EE_Taxes::get_subtotal_for_admin($this);
535 535
 	}
536 536
 
537 537
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
      * @throws \EE_Error
544 544
      */
545 545
 	public function get_ticket_taxes_total_for_admin() {
546
-		return EE_Taxes::get_total_taxes_for_admin( $this );
546
+		return EE_Taxes::get_total_taxes_for_admin($this);
547 547
 	}
548 548
 
549 549
 
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
      * @param string $name
555 555
      * @throws \EE_Error
556 556
      */
557
-	public function set_name( $name ) {
558
-		$this->set( 'TKT_name', $name );
557
+	public function set_name($name) {
558
+		$this->set('TKT_name', $name);
559 559
 	}
560 560
 
561 561
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      * @throws \EE_Error
568 568
      */
569 569
 	public function description() {
570
-		return $this->get( 'TKT_description' );
570
+		return $this->get('TKT_description');
571 571
 	}
572 572
 
573 573
 
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
      * @param string $description
579 579
      * @throws \EE_Error
580 580
      */
581
-	public function set_description( $description ) {
582
-		$this->set( 'TKT_description', $description );
581
+	public function set_description($description) {
582
+		$this->set('TKT_description', $description);
583 583
 	}
584 584
 
585 585
 
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
      * @return string
593 593
      * @throws \EE_Error
594 594
      */
595
-	public function start_date( $dt_frmt = '', $tm_frmt = '' ) {
596
-		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
595
+	public function start_date($dt_frmt = '', $tm_frmt = '') {
596
+		return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt);
597 597
 	}
598 598
 
599 599
 
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
      * @return void
606 606
      * @throws \EE_Error
607 607
      */
608
-	public function set_start_date( $start_date ) {
609
-		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
608
+	public function set_start_date($start_date) {
609
+		$this->_set_date_time('B', $start_date, 'TKT_start_date');
610 610
 	}
611 611
 
612 612
 
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
      * @return string
620 620
      * @throws \EE_Error
621 621
      */
622
-	public function end_date( $dt_frmt = '', $tm_frmt = '' ) {
623
-		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
622
+	public function end_date($dt_frmt = '', $tm_frmt = '') {
623
+		return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt);
624 624
 	}
625 625
 
626 626
 
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
      * @return void
633 633
      * @throws \EE_Error
634 634
      */
635
-	public function set_end_date( $end_date ) {
636
-		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
635
+	public function set_end_date($end_date) {
636
+		$this->_set_date_time('B', $end_date, 'TKT_end_date');
637 637
 	}
638 638
 
639 639
 
@@ -645,8 +645,8 @@  discard block
 block discarded – undo
645 645
      * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
646 646
      * @throws \EE_Error
647 647
      */
648
-	public function set_end_time( $time ) {
649
-		$this->_set_time_for( $time, 'TKT_end_date' );
648
+	public function set_end_time($time) {
649
+		$this->_set_time_for($time, 'TKT_end_date');
650 650
 	}
651 651
 
652 652
 
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
      * @return void
659 659
      * @throws \EE_Error
660 660
      */
661
-	public function set_min( $min ) {
662
-		$this->set( 'TKT_min', $min );
661
+	public function set_min($min) {
662
+		$this->set('TKT_min', $min);
663 663
 	}
664 664
 
665 665
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
      * @throws \EE_Error
672 672
      */
673 673
 	public function max() {
674
-		return $this->get( 'TKT_max' );
674
+		return $this->get('TKT_max');
675 675
 	}
676 676
 
677 677
 
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
      * @return void
684 684
      * @throws \EE_Error
685 685
      */
686
-	public function set_max( $max ) {
687
-		$this->set( 'TKT_max', $max );
686
+	public function set_max($max) {
687
+		$this->set('TKT_max', $max);
688 688
 	}
689 689
 
690 690
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
      * @return void
697 697
      * @throws \EE_Error
698 698
      */
699
-	public function set_price( $price ) {
700
-		$this->set( 'TKT_price', $price );
699
+	public function set_price($price) {
700
+		$this->set('TKT_price', $price);
701 701
 	}
702 702
 
703 703
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
      * @throws \EE_Error
710 710
      */
711 711
 	public function sold() {
712
-		return $this->get_raw( 'TKT_sold' );
712
+		return $this->get_raw('TKT_sold');
713 713
 	}
714 714
 
715 715
 
@@ -721,10 +721,10 @@  discard block
 block discarded – undo
721 721
      * @return void
722 722
      * @throws \EE_Error
723 723
      */
724
-	public function set_sold( $sold ) {
724
+	public function set_sold($sold) {
725 725
 		// sold can not go below zero
726
-		$sold = max( 0, $sold );
727
-		$this->set( 'TKT_sold', $sold );
726
+		$sold = max(0, $sold);
727
+		$this->set('TKT_sold', $sold);
728 728
 	}
729 729
 
730 730
 
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
      * @return void
737 737
      * @throws \EE_Error
738 738
      */
739
-	public function increase_sold( $qty = 1 ) {
739
+	public function increase_sold($qty = 1) {
740 740
 		$sold = $this->sold() + $qty;
741 741
 		// remove ticket reservation, but don't adjust datetime reservations,  because that will happen
742 742
 		// via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called
743
-		$this->decrease_reserved( $qty, false );
744
-		$this->_increase_sold_for_datetimes( $qty );
745
-		$this->set_sold( $sold );
743
+		$this->decrease_reserved($qty, false);
744
+		$this->_increase_sold_for_datetimes($qty);
745
+		$this->set_sold($sold);
746 746
 	}
747 747
 
748 748
 
@@ -754,12 +754,12 @@  discard block
 block discarded – undo
754 754
      * @return void
755 755
      * @throws \EE_Error
756 756
      */
757
-	protected function _increase_sold_for_datetimes( $qty = 1 ) {
757
+	protected function _increase_sold_for_datetimes($qty = 1) {
758 758
 		$datetimes = $this->datetimes();
759
-		if ( is_array( $datetimes ) ) {
760
-			foreach ( $datetimes as $datetime ) {
761
-				if ( $datetime instanceof EE_Datetime ) {
762
-					$datetime->increase_sold( $qty );
759
+		if (is_array($datetimes)) {
760
+			foreach ($datetimes as $datetime) {
761
+				if ($datetime instanceof EE_Datetime) {
762
+					$datetime->increase_sold($qty);
763 763
 					$datetime->save();
764 764
 				}
765 765
 			}
@@ -775,10 +775,10 @@  discard block
 block discarded – undo
775 775
      * @return void
776 776
      * @throws \EE_Error
777 777
      */
778
-	public function decrease_sold( $qty = 1 ) {
778
+	public function decrease_sold($qty = 1) {
779 779
 		$sold = $this->sold() - $qty;
780
-		$this->_decrease_sold_for_datetimes( $qty );
781
-		$this->set_sold( $sold );
780
+		$this->_decrease_sold_for_datetimes($qty);
781
+		$this->set_sold($sold);
782 782
 	}
783 783
 
784 784
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
      * @return void
791 791
      * @throws \EE_Error
792 792
      */
793
-	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
793
+	protected function _decrease_sold_for_datetimes($qty = 1) {
794 794
 		$datetimes = $this->datetimes();
795
-		if ( is_array( $datetimes ) ) {
796
-			foreach ( $datetimes as $datetime ) {
797
-				if ( $datetime instanceof EE_Datetime ) {
798
-					$datetime->decrease_sold( $qty );
795
+		if (is_array($datetimes)) {
796
+			foreach ($datetimes as $datetime) {
797
+				if ($datetime instanceof EE_Datetime) {
798
+					$datetime->decrease_sold($qty);
799 799
 					$datetime->save();
800 800
 				}
801 801
 			}
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
      * @throws \EE_Error
812 812
      */
813 813
 	public function reserved() {
814
-		return $this->get_raw( 'TKT_reserved' );
814
+		return $this->get_raw('TKT_reserved');
815 815
 	}
816 816
 
817 817
 
@@ -823,10 +823,10 @@  discard block
 block discarded – undo
823 823
      * @return void
824 824
      * @throws \EE_Error
825 825
      */
826
-	public function set_reserved( $reserved ) {
826
+	public function set_reserved($reserved) {
827 827
 		// reserved can not go below zero
828
-		$reserved = max( 0, (int) $reserved );
829
-		$this->set( 'TKT_reserved', $reserved );
828
+		$reserved = max(0, (int) $reserved);
829
+		$this->set('TKT_reserved', $reserved);
830 830
 	}
831 831
 
832 832
 
@@ -838,11 +838,11 @@  discard block
 block discarded – undo
838 838
      * @return void
839 839
      * @throws \EE_Error
840 840
      */
841
-	public function increase_reserved( $qty = 1 ) {
842
-		$qty = absint( $qty );
841
+	public function increase_reserved($qty = 1) {
842
+		$qty = absint($qty);
843 843
 		$reserved = $this->reserved() + $qty;
844
-		$this->_increase_reserved_for_datetimes( $qty );
845
-		$this->set_reserved( $reserved );
844
+		$this->_increase_reserved_for_datetimes($qty);
845
+		$this->set_reserved($reserved);
846 846
 	}
847 847
 
848 848
 
@@ -854,12 +854,12 @@  discard block
 block discarded – undo
854 854
      * @return void
855 855
      * @throws \EE_Error
856 856
      */
857
-	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
857
+	protected function _increase_reserved_for_datetimes($qty = 1) {
858 858
 		$datetimes = $this->datetimes();
859
-		if ( is_array( $datetimes ) ) {
860
-			foreach ( $datetimes as $datetime ) {
861
-				if ( $datetime instanceof EE_Datetime ) {
862
-					$datetime->increase_reserved( $qty );
859
+		if (is_array($datetimes)) {
860
+			foreach ($datetimes as $datetime) {
861
+				if ($datetime instanceof EE_Datetime) {
862
+					$datetime->increase_reserved($qty);
863 863
 					$datetime->save();
864 864
 				}
865 865
 			}
@@ -876,12 +876,12 @@  discard block
 block discarded – undo
876 876
      * @return void
877 877
      * @throws \EE_Error
878 878
      */
879
-	public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
880
-		$reserved = $this->reserved() - absint( $qty );
881
-		if ( $adjust_datetimes ) {
882
-			$this->_decrease_reserved_for_datetimes( $qty );
879
+	public function decrease_reserved($qty = 1, $adjust_datetimes = true) {
880
+		$reserved = $this->reserved() - absint($qty);
881
+		if ($adjust_datetimes) {
882
+			$this->_decrease_reserved_for_datetimes($qty);
883 883
 		}
884
-		$this->set_reserved( $reserved );
884
+		$this->set_reserved($reserved);
885 885
 	}
886 886
 
887 887
 
@@ -893,12 +893,12 @@  discard block
 block discarded – undo
893 893
      * @return void
894 894
      * @throws \EE_Error
895 895
      */
896
-	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
896
+	protected function _decrease_reserved_for_datetimes($qty = 1) {
897 897
 		$datetimes = $this->datetimes();
898
-		if ( is_array( $datetimes ) ) {
899
-			foreach ( $datetimes as $datetime ) {
900
-				if ( $datetime instanceof EE_Datetime ) {
901
-					$datetime->decrease_reserved( $qty );
898
+		if (is_array($datetimes)) {
899
+			foreach ($datetimes as $datetime) {
900
+				if ($datetime instanceof EE_Datetime) {
901
+					$datetime->decrease_reserved($qty);
902 902
 					$datetime->save();
903 903
 				}
904 904
 			}
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
      * @return int
920 920
      * @throws \EE_Error
921 921
      */
922
-	public function qty( $context = '' ) {
923
-		switch ( $context ) {
922
+	public function qty($context = '') {
923
+		switch ($context) {
924 924
 			case 'reg_limit' :
925 925
 				return $this->real_quantity_on_ticket();
926 926
 			case 'saleable' :
927
-				return $this->real_quantity_on_ticket( 'saleable' );
927
+				return $this->real_quantity_on_ticket('saleable');
928 928
 			default:
929
-				return $this->get_raw( 'TKT_qty' );
929
+				return $this->get_raw('TKT_qty');
930 930
 		}
931 931
 	}
932 932
 
@@ -945,15 +945,15 @@  discard block
 block discarded – undo
945 945
      * @return int
946 946
      * @throws \EE_Error
947 947
      */
948
-	public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) {
949
-		$raw = $this->get_raw( 'TKT_qty' );
948
+	public function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) {
949
+		$raw = $this->get_raw('TKT_qty');
950 950
 		// return immediately if it's zero
951
-		if ( $raw === 0 ) {
951
+		if ($raw === 0) {
952 952
 			return $raw;
953 953
 		}
954 954
 		//echo "\n\n<br />Ticket: " . $this->name() . '<br />';
955 955
 		// ensure qty doesn't exceed raw value for THIS ticket
956
-		$qty = min( EE_INF, $raw );
956
+		$qty = min(EE_INF, $raw);
957 957
 		//echo "\n . qty: " . $qty . '<br />';
958 958
 		// calculate this ticket's total sales and reservations
959 959
 		$sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved();
@@ -962,23 +962,23 @@  discard block
 block discarded – undo
962 962
 		//echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />';
963 963
 		// first we need to calculate the maximum number of tickets available for the datetime
964 964
 		// do we want data for one datetime or all of them ?
965
-		$query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array();
966
-		$datetimes = $this->datetimes( $query_params );
967
-		if ( is_array( $datetimes ) && ! empty( $datetimes ) ) {
968
-			foreach ( $datetimes as $datetime ) {
969
-				if ( $datetime instanceof EE_Datetime ) {
965
+		$query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array();
966
+		$datetimes = $this->datetimes($query_params);
967
+		if (is_array($datetimes) && ! empty($datetimes)) {
968
+			foreach ($datetimes as $datetime) {
969
+				if ($datetime instanceof EE_Datetime) {
970 970
 					$datetime->refresh_from_db();
971 971
 					//echo "\n . . datetime name: " . $datetime->name() . '<br />';
972 972
 					//echo "\n . . datetime ID: " . $datetime->ID() . '<br />';
973 973
 					// initialize with no restrictions for each datetime
974 974
 					// but adjust datetime qty based on datetime reg limit
975
-					$datetime_qty = min( EE_INF, $datetime->reg_limit() );
975
+					$datetime_qty = min(EE_INF, $datetime->reg_limit());
976 976
 					//echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />';
977 977
 					//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
978 978
 					// if we want the actual saleable amount, then we need to consider OTHER ticket sales
979 979
 					// and reservations for this datetime, that do NOT include sales and reservations
980 980
 					// for this ticket (so we add $this->sold() and $this->reserved() back in)
981
-					if ( $context === 'saleable' ) {
981
+					if ($context === 'saleable') {
982 982
 						$datetime_qty = max(
983 983
 							$datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket,
984 984
 							0
@@ -990,16 +990,16 @@  discard block
 block discarded – undo
990 990
 						$datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0;
991 991
 						//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
992 992
 					}
993
-					$qty = min( $datetime_qty, $qty );
993
+					$qty = min($datetime_qty, $qty);
994 994
 					//echo "\n . . qty: " . $qty . '<br />';
995 995
 				}
996 996
 			}
997 997
 		}
998 998
 		// NOW that we know the  maximum number of tickets available for the datetime
999 999
 		// we can finally factor in the details for this specific ticket
1000
-		if ( $qty > 0 && $context === 'saleable' ) {
1000
+		if ($qty > 0 && $context === 'saleable') {
1001 1001
 			// and subtract the sales for THIS ticket
1002
-			$qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 );
1002
+			$qty = max($qty - $sold_and_reserved_for_this_ticket, 0);
1003 1003
 			//echo "\n . qty: " . $qty . '<br />';
1004 1004
 		}
1005 1005
 		//echo "\nFINAL QTY: " . $qty . "<br /><br />";
@@ -1015,14 +1015,14 @@  discard block
 block discarded – undo
1015 1015
 	 * @return void
1016 1016
 	 * @throws \EE_Error
1017 1017
 	 */
1018
-	public function set_qty( $qty ) {
1018
+	public function set_qty($qty) {
1019 1019
 		$datetimes = $this->datetimes();
1020
-		foreach ( $datetimes as $datetime ) {
1021
-			if ( $datetime instanceof EE_Datetime ) {
1022
-				$qty = min( $qty, $datetime->reg_limit() );
1020
+		foreach ($datetimes as $datetime) {
1021
+			if ($datetime instanceof EE_Datetime) {
1022
+				$qty = min($qty, $datetime->reg_limit());
1023 1023
 			}
1024 1024
 		}
1025
-		$this->set( 'TKT_qty', $qty );
1025
+		$this->set('TKT_qty', $qty);
1026 1026
 	}
1027 1027
 
1028 1028
 
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
      * @throws \EE_Error
1035 1035
      */
1036 1036
 	public function uses() {
1037
-		return $this->get( 'TKT_uses' );
1037
+		return $this->get('TKT_uses');
1038 1038
 	}
1039 1039
 
1040 1040
 
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
      * @return void
1047 1047
      * @throws \EE_Error
1048 1048
      */
1049
-	public function set_uses( $uses ) {
1050
-		$this->set( 'TKT_uses', $uses );
1049
+	public function set_uses($uses) {
1050
+		$this->set('TKT_uses', $uses);
1051 1051
 	}
1052 1052
 
1053 1053
 
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
      * @throws \EE_Error
1060 1060
      */
1061 1061
 	public function required() {
1062
-		return $this->get( 'TKT_required' );
1062
+		return $this->get('TKT_required');
1063 1063
 	}
1064 1064
 
1065 1065
 
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
      * @return void
1072 1072
      * @throws \EE_Error
1073 1073
      */
1074
-	public function set_required( $required ) {
1075
-		$this->set( 'TKT_required', $required );
1074
+	public function set_required($required) {
1075
+		$this->set('TKT_required', $required);
1076 1076
 	}
1077 1077
 
1078 1078
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
      * @throws \EE_Error
1085 1085
      */
1086 1086
 	public function taxable() {
1087
-		return $this->get( 'TKT_taxable' );
1087
+		return $this->get('TKT_taxable');
1088 1088
 	}
1089 1089
 
1090 1090
 
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
      * @return void
1097 1097
      * @throws \EE_Error
1098 1098
      */
1099
-	public function set_taxable( $taxable ) {
1100
-		$this->set( 'TKT_taxable', $taxable );
1099
+	public function set_taxable($taxable) {
1100
+		$this->set('TKT_taxable', $taxable);
1101 1101
 	}
1102 1102
 
1103 1103
 
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
      * @throws \EE_Error
1110 1110
      */
1111 1111
 	public function is_default() {
1112
-		return $this->get( 'TKT_is_default' );
1112
+		return $this->get('TKT_is_default');
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1121,8 +1121,8 @@  discard block
 block discarded – undo
1121 1121
      * @return void
1122 1122
      * @throws \EE_Error
1123 1123
      */
1124
-	public function set_is_default( $is_default ) {
1125
-		$this->set( 'TKT_is_default', $is_default );
1124
+	public function set_is_default($is_default) {
1125
+		$this->set('TKT_is_default', $is_default);
1126 1126
 	}
1127 1127
 
1128 1128
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
      * @throws \EE_Error
1135 1135
      */
1136 1136
 	public function order() {
1137
-		return $this->get( 'TKT_order' );
1137
+		return $this->get('TKT_order');
1138 1138
 	}
1139 1139
 
1140 1140
 
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
      * @return void
1147 1147
      * @throws \EE_Error
1148 1148
      */
1149
-	public function set_order( $order ) {
1150
-		$this->set( 'TKT_order', $order );
1149
+	public function set_order($order) {
1150
+		$this->set('TKT_order', $order);
1151 1151
 	}
1152 1152
 
1153 1153
 
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
      * @throws \EE_Error
1160 1160
      */
1161 1161
 	public function row() {
1162
-		return $this->get( 'TKT_row' );
1162
+		return $this->get('TKT_row');
1163 1163
 	}
1164 1164
 
1165 1165
 
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
      * @return void
1172 1172
      * @throws \EE_Error
1173 1173
      */
1174
-	public function set_row( $row ) {
1175
-		$this->set( 'TKT_row', $row );
1174
+	public function set_row($row) {
1175
+		$this->set('TKT_row', $row);
1176 1176
 	}
1177 1177
 
1178 1178
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      * @throws \EE_Error
1185 1185
      */
1186 1186
 	public function deleted() {
1187
-		return $this->get( 'TKT_deleted' );
1187
+		return $this->get('TKT_deleted');
1188 1188
 	}
1189 1189
 
1190 1190
 
@@ -1196,8 +1196,8 @@  discard block
 block discarded – undo
1196 1196
      * @return void
1197 1197
      * @throws \EE_Error
1198 1198
      */
1199
-	public function set_deleted( $deleted ) {
1200
-		$this->set( 'TKT_deleted', $deleted );
1199
+	public function set_deleted($deleted) {
1200
+		$this->set('TKT_deleted', $deleted);
1201 1201
 	}
1202 1202
 
1203 1203
 
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
      * @throws \EE_Error
1210 1210
      */
1211 1211
 	public function parent_ID() {
1212
-		return $this->get( 'TKT_parent' );
1212
+		return $this->get('TKT_parent');
1213 1213
 	}
1214 1214
 
1215 1215
 
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
      * @return void
1222 1222
      * @throws \EE_Error
1223 1223
      */
1224
-	public function set_parent_ID( $parent ) {
1225
-		$this->set( 'TKT_parent', $parent );
1224
+	public function set_parent_ID($parent) {
1225
+		$this->set('TKT_parent', $parent);
1226 1226
 	}
1227 1227
 
1228 1228
 
@@ -1235,10 +1235,10 @@  discard block
 block discarded – undo
1235 1235
      */
1236 1236
 	public function name_and_info() {
1237 1237
 		$times = array();
1238
-		foreach ( $this->datetimes() as $datetime ) {
1238
+		foreach ($this->datetimes() as $datetime) {
1239 1239
 			$times[] = $datetime->start_date_and_time();
1240 1240
 		}
1241
-		return $this->name() . ' @ ' . implode( ', ', $times ) . ' for ' . $this->pretty_price();
1241
+		return $this->name().' @ '.implode(', ', $times).' for '.$this->pretty_price();
1242 1242
 	}
1243 1243
 
1244 1244
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
      * @throws \EE_Error
1251 1251
      */
1252 1252
 	public function name() {
1253
-		return $this->get( 'TKT_name' );
1253
+		return $this->get('TKT_name');
1254 1254
 	}
1255 1255
 
1256 1256
 
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
      * @throws \EE_Error
1263 1263
      */
1264 1264
 	public function price() {
1265
-		return $this->get( 'TKT_price' );
1265
+		return $this->get('TKT_price');
1266 1266
 	}
1267 1267
 
1268 1268
 
@@ -1274,8 +1274,8 @@  discard block
 block discarded – undo
1274 1274
      * @return EE_Registration[]|EE_Base_Class[]
1275 1275
      * @throws \EE_Error
1276 1276
      */
1277
-	public function registrations( $query_params = array() ) {
1278
-		return $this->get_many_related( 'Registration', $query_params );
1277
+	public function registrations($query_params = array()) {
1278
+		return $this->get_many_related('Registration', $query_params);
1279 1279
 	}
1280 1280
 
1281 1281
 
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 	 * @param array $query_params like EEM_Base::get_all's
1315 1315
 	 * @return int
1316 1316
 	 */
1317
-	public function count_registrations( $query_params = array() ) {
1317
+	public function count_registrations($query_params = array()) {
1318 1318
 		return $this->count_related('Registration', $query_params);
1319 1319
 	}
1320 1320
 
@@ -1342,23 +1342,23 @@  discard block
 block discarded – undo
1342 1342
 	public function get_related_event() {
1343 1343
 		//get one datetime to use for getting the event
1344 1344
 		$datetime = $this->first_datetime();
1345
-		if ( ! $datetime instanceof \EE_Datetime ) {
1345
+		if ( ! $datetime instanceof \EE_Datetime) {
1346 1346
 			throw new UnexpectedEntityException(
1347 1347
 				$datetime,
1348 1348
                 'EE_Datetime',
1349 1349
 				sprintf(
1350
-					__( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1350
+					__('The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1351 1351
 					$this->name()
1352 1352
 				)
1353 1353
 			);
1354 1354
 		}
1355 1355
 		$event = $datetime->event();
1356
-		if ( ! $event instanceof \EE_Event ) {
1356
+		if ( ! $event instanceof \EE_Event) {
1357 1357
 			throw new UnexpectedEntityException(
1358 1358
 				$event,
1359 1359
                 'EE_Event',
1360 1360
 				sprintf(
1361
-					__( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1361
+					__('The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1362 1362
 					$this->name()
1363 1363
 				)
1364 1364
 			);
Please login to merge, or discard this patch.
Indentation   +591 added lines, -591 removed lines patch added patch discarded remove patch
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * @param array  $props_n_values          incoming values
66
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
67
-     *                                        used.)
68
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
69
-     *                                        date_format and the second value is the time format
70
-     * @return EE_Ticket
71
-     * @throws \EE_Error
72
-     */
64
+	/**
65
+	 * @param array  $props_n_values          incoming values
66
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
67
+	 *                                        used.)
68
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
69
+	 *                                        date_format and the second value is the time format
70
+	 * @return EE_Ticket
71
+	 * @throws \EE_Error
72
+	 */
73 73
 	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
74 74
 		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
75 75
 		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
@@ -77,36 +77,36 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
 
80
-    /**
81
-     * @param array  $props_n_values  incoming values from the database
82
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
83
-     *                                the website will be used.
84
-     * @return EE_Ticket
85
-     * @throws \EE_Error
86
-     */
80
+	/**
81
+	 * @param array  $props_n_values  incoming values from the database
82
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
83
+	 *                                the website will be used.
84
+	 * @return EE_Ticket
85
+	 * @throws \EE_Error
86
+	 */
87 87
 	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
88 88
 		return new self( $props_n_values, TRUE, $timezone );
89 89
 	}
90 90
 
91 91
 
92 92
 
93
-    /**
94
-     * @return bool
95
-     * @throws \EE_Error
96
-     */
93
+	/**
94
+	 * @return bool
95
+	 * @throws \EE_Error
96
+	 */
97 97
 	public function parent() {
98 98
 		return $this->get( 'TKT_parent' );
99 99
 	}
100 100
 
101 101
 
102 102
 
103
-    /**
104
-     * return if a ticket has quantities available for purchase
105
-     *
106
-     * @param  int $DTT_ID the primary key for a particular datetime
107
-     * @return boolean
108
-     * @throws \EE_Error
109
-     */
103
+	/**
104
+	 * return if a ticket has quantities available for purchase
105
+	 *
106
+	 * @param  int $DTT_ID the primary key for a particular datetime
107
+	 * @return boolean
108
+	 * @throws \EE_Error
109
+	 */
110 110
 	public function available( $DTT_ID = 0 ) {
111 111
 		// are we checking availability for a particular datetime ?
112 112
 		if ( $DTT_ID ) {
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 
125 125
 
126
-    /**
127
-     * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired
128
-     *
129
-     * @param bool        $display   true = we'll return a localized string, otherwise we just return the value of the relevant status const
130
-     * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing
131
-     * @return mixed status int if the display string isn't requested
132
-     * @throws \EE_Error
133
-     */
126
+	/**
127
+	 * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired
128
+	 *
129
+	 * @param bool        $display   true = we'll return a localized string, otherwise we just return the value of the relevant status const
130
+	 * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing
131
+	 * @return mixed status int if the display string isn't requested
132
+	 * @throws \EE_Error
133
+	 */
134 134
 	public function ticket_status( $display = FALSE, $remaining = null ) {
135 135
 		$remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining();
136 136
 		if ( ! $remaining ) {
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 
154 154
 
155 155
 
156
-    /**
157
-     * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out.
158
-     *
159
-     * @access public
160
-     * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
161
-     * @return boolean         true = tickets remaining, false not.
162
-     * @throws \EE_Error
163
-     */
156
+	/**
157
+	 * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out.
158
+	 *
159
+	 * @access public
160
+	 * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
161
+	 * @return boolean         true = tickets remaining, false not.
162
+	 * @throws \EE_Error
163
+	 */
164 164
 	public function is_remaining( $DTT_ID = 0 ) {
165 165
 		$num_remaining = $this->remaining( $DTT_ID );
166 166
 		if ( $num_remaining === 0 ) {
@@ -174,76 +174,76 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 
177
-    /**
178
-     * return the total number of tickets available for purchase
179
-     *
180
-     * @param  int $DTT_ID the primary key for a particular datetime.
181
-     *                     set to 0 for all related datetimes
182
-     * @return int
183
-     * @throws \EE_Error
184
-     */
177
+	/**
178
+	 * return the total number of tickets available for purchase
179
+	 *
180
+	 * @param  int $DTT_ID the primary key for a particular datetime.
181
+	 *                     set to 0 for all related datetimes
182
+	 * @return int
183
+	 * @throws \EE_Error
184
+	 */
185 185
 	public function remaining( $DTT_ID = 0 ) {
186 186
 		return $this->real_quantity_on_ticket('saleable', $DTT_ID );
187 187
 	}
188 188
 
189 189
 
190 190
 
191
-    /**
192
-     * Gets min
193
-     *
194
-     * @return int
195
-     * @throws \EE_Error
196
-     */
191
+	/**
192
+	 * Gets min
193
+	 *
194
+	 * @return int
195
+	 * @throws \EE_Error
196
+	 */
197 197
 	public function min() {
198 198
 		return $this->get( 'TKT_min' );
199 199
 	}
200 200
 
201 201
 
202 202
 
203
-    /**
204
-     * return if a ticket is no longer available cause its available dates have expired.
205
-     *
206
-     * @return boolean
207
-     * @throws \EE_Error
208
-     */
203
+	/**
204
+	 * return if a ticket is no longer available cause its available dates have expired.
205
+	 *
206
+	 * @return boolean
207
+	 * @throws \EE_Error
208
+	 */
209 209
 	public function is_expired() {
210 210
 		return ( $this->get_raw( 'TKT_end_date' ) < time() );
211 211
 	}
212 212
 
213 213
 
214 214
 
215
-    /**
216
-     * Return if a ticket is yet to go on sale or not
217
-     *
218
-     * @return boolean
219
-     * @throws \EE_Error
220
-     */
215
+	/**
216
+	 * Return if a ticket is yet to go on sale or not
217
+	 *
218
+	 * @return boolean
219
+	 * @throws \EE_Error
220
+	 */
221 221
 	public function is_pending() {
222 222
 		return ( $this->get_raw( 'TKT_start_date' ) > time() );
223 223
 	}
224 224
 
225 225
 
226 226
 
227
-    /**
228
-     * Return if a ticket is on sale or not
229
-     *
230
-     * @return boolean
231
-     * @throws \EE_Error
232
-     */
227
+	/**
228
+	 * Return if a ticket is on sale or not
229
+	 *
230
+	 * @return boolean
231
+	 * @throws \EE_Error
232
+	 */
233 233
 	public function is_on_sale() {
234 234
 		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
235 235
 	}
236 236
 
237 237
 
238 238
 
239
-    /**
240
-     * This returns the chronologically last datetime that this ticket is associated with
241
-     *
242
-     * @param string $dt_frmt
243
-     * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
244
-     * @return string
245
-     * @throws \EE_Error
246
-     */
239
+	/**
240
+	 * This returns the chronologically last datetime that this ticket is associated with
241
+	 *
242
+	 * @param string $dt_frmt
243
+	 * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
244
+	 * @return string
245
+	 * @throws \EE_Error
246
+	 */
247 247
 	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
248 248
 		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
249 249
 		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
 
254 254
 
255 255
 
256
-    /**
257
-     * This returns the chronologically first datetime that this ticket is associated with
258
-     *
259
-     * @return EE_Datetime
260
-     * @throws \EE_Error
261
-     */
256
+	/**
257
+	 * This returns the chronologically first datetime that this ticket is associated with
258
+	 *
259
+	 * @return EE_Datetime
260
+	 * @throws \EE_Error
261
+	 */
262 262
 	public function first_datetime() {
263 263
 		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
264 264
 		return reset( $datetimes );
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 
267 267
 
268 268
 
269
-    /**
270
-     * Gets all the datetimes this ticket can be used for attending.
271
-     * Unless otherwise specified, orders datetimes by start date.
272
-     *
273
-     * @param array $query_params see EEM_Base::get_all()
274
-     * @return EE_Datetime[]|EE_Base_Class[]
275
-     * @throws \EE_Error
276
-     */
269
+	/**
270
+	 * Gets all the datetimes this ticket can be used for attending.
271
+	 * Unless otherwise specified, orders datetimes by start date.
272
+	 *
273
+	 * @param array $query_params see EEM_Base::get_all()
274
+	 * @return EE_Datetime[]|EE_Base_Class[]
275
+	 * @throws \EE_Error
276
+	 */
277 277
 	public function datetimes( $query_params = array() ) {
278 278
 		if ( ! isset( $query_params[ 'order_by' ] ) ) {
279 279
 			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 
284 284
 
285 285
 
286
-    /**
287
-     * This returns the chronologically last datetime that this ticket is associated with
288
-     *
289
-     * @return EE_Datetime
290
-     * @throws \EE_Error
291
-     */
286
+	/**
287
+	 * This returns the chronologically last datetime that this ticket is associated with
288
+	 *
289
+	 * @return EE_Datetime
290
+	 * @throws \EE_Error
291
+	 */
292 292
 	public function last_datetime() {
293 293
 		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
294 294
 		return end( $datetimes );
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
 
297 297
 
298 298
 
299
-    /**
300
-     * This returns the total tickets sold depending on the given parameters.
301
-     *
302
-     * @param  string $what   Can be one of two options: 'ticket', 'datetime'.
303
-     *                        'ticket' = total ticket sales for all datetimes this ticket is related to
304
-     *                        'datetime' = total ticket sales for a specified datetime (required $dtt_id)
305
-     *                        'datetime' = total ticket sales in the datetime_ticket table.
306
-     *                        If $dtt_id is not given then we return an array of sales indexed by datetime.
307
-     *                        If $dtt_id IS given then we return the tickets sold for that given datetime.
308
-     * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
309
-     * @return mixed (array|int)          how many tickets have sold
310
-     * @throws \EE_Error
311
-     */
299
+	/**
300
+	 * This returns the total tickets sold depending on the given parameters.
301
+	 *
302
+	 * @param  string $what   Can be one of two options: 'ticket', 'datetime'.
303
+	 *                        'ticket' = total ticket sales for all datetimes this ticket is related to
304
+	 *                        'datetime' = total ticket sales for a specified datetime (required $dtt_id)
305
+	 *                        'datetime' = total ticket sales in the datetime_ticket table.
306
+	 *                        If $dtt_id is not given then we return an array of sales indexed by datetime.
307
+	 *                        If $dtt_id IS given then we return the tickets sold for that given datetime.
308
+	 * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
309
+	 * @return mixed (array|int)          how many tickets have sold
310
+	 * @throws \EE_Error
311
+	 */
312 312
 	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
313 313
 		$total = 0;
314 314
 		$tickets_sold = $this->_all_tickets_sold();
@@ -333,12 +333,12 @@  discard block
 block discarded – undo
333 333
 
334 334
 
335 335
 
336
-    /**
337
-     * This returns an array indexed by datetime_id for tickets sold with this ticket.
338
-     *
339
-     * @return EE_Ticket[]
340
-     * @throws \EE_Error
341
-     */
336
+	/**
337
+	 * This returns an array indexed by datetime_id for tickets sold with this ticket.
338
+	 *
339
+	 * @return EE_Ticket[]
340
+	 * @throws \EE_Error
341
+	 */
342 342
 	protected function _all_tickets_sold() {
343 343
 		$datetimes = $this->get_many_related( 'Datetime' );
344 344
 		$tickets_sold = array();
@@ -354,29 +354,29 @@  discard block
 block discarded – undo
354 354
 
355 355
 
356 356
 
357
-    /**
358
-     * This returns the base price object for the ticket.
359
-     *
360
-     * @param  bool $return_array whether to return as an array indexed by price id or just the object.
361
-     * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
362
-     * @throws \EE_Error
363
-     */
357
+	/**
358
+	 * This returns the base price object for the ticket.
359
+	 *
360
+	 * @param  bool $return_array whether to return as an array indexed by price id or just the object.
361
+	 * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
362
+	 * @throws \EE_Error
363
+	 */
364 364
 	public function base_price( $return_array = FALSE ) {
365 365
 		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
366 366
 		return $return_array
367
-            ? $this->get_many_related( 'Price', array( $_where ) )
368
-            : $this->get_first_related( 'Price', array( $_where ) );
367
+			? $this->get_many_related( 'Price', array( $_where ) )
368
+			: $this->get_first_related( 'Price', array( $_where ) );
369 369
 	}
370 370
 
371 371
 
372 372
 
373
-    /**
374
-     * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price)
375
-     *
376
-     * @access public
377
-     * @return EE_Price[]
378
-     * @throws \EE_Error
379
-     */
373
+	/**
374
+	 * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price)
375
+	 *
376
+	 * @access public
377
+	 * @return EE_Price[]
378
+	 * @throws \EE_Error
379
+	 */
380 380
 	public function price_modifiers() {
381 381
 		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
382 382
 		return $this->prices( $query_params );
@@ -384,132 +384,132 @@  discard block
 block discarded – undo
384 384
 
385 385
 
386 386
 
387
-    /**
388
-     * Gets all the prices that combine to form the final price of this ticket
389
-     *
390
-     * @param array $query_params like EEM_Base::get_all
391
-     * @return EE_Price[]|EE_Base_Class[]
392
-     * @throws \EE_Error
393
-     */
387
+	/**
388
+	 * Gets all the prices that combine to form the final price of this ticket
389
+	 *
390
+	 * @param array $query_params like EEM_Base::get_all
391
+	 * @return EE_Price[]|EE_Base_Class[]
392
+	 * @throws \EE_Error
393
+	 */
394 394
 	public function prices( $query_params = array() ) {
395 395
 		return $this->get_many_related( 'Price', $query_params );
396 396
 	}
397 397
 
398 398
 
399 399
 
400
-    /**
401
-     * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
402
-     *
403
-     * @param array $query_params see EEM_Base::get_all()
404
-     * @return EE_Datetime_Ticket|EE_Base_Class[]
405
-     * @throws \EE_Error
406
-     */
400
+	/**
401
+	 * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
402
+	 *
403
+	 * @param array $query_params see EEM_Base::get_all()
404
+	 * @return EE_Datetime_Ticket|EE_Base_Class[]
405
+	 * @throws \EE_Error
406
+	 */
407 407
 	public function datetime_tickets( $query_params = array() ) {
408 408
 		return $this->get_many_related( 'Datetime_Ticket', $query_params );
409 409
 	}
410 410
 
411 411
 
412 412
 
413
-    /**
414
-     * Gets all the datetimes from the db ordered by DTT_order
415
-     *
416
-     * @param boolean $show_expired
417
-     * @param boolean $show_deleted
418
-     * @return EE_Datetime[]
419
-     * @throws \EE_Error
420
-     */
413
+	/**
414
+	 * Gets all the datetimes from the db ordered by DTT_order
415
+	 *
416
+	 * @param boolean $show_expired
417
+	 * @param boolean $show_deleted
418
+	 * @return EE_Datetime[]
419
+	 * @throws \EE_Error
420
+	 */
421 421
 	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
422 422
 		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
423 423
 	}
424 424
 
425 425
 
426 426
 
427
-    /**
428
-     * Gets ID
429
-     *
430
-     * @return string
431
-     * @throws \EE_Error
432
-     */
427
+	/**
428
+	 * Gets ID
429
+	 *
430
+	 * @return string
431
+	 * @throws \EE_Error
432
+	 */
433 433
 	public function ID() {
434 434
 		return $this->get( 'TKT_ID' );
435 435
 	}
436 436
 
437 437
 
438 438
 
439
-    /**
440
-     * get the author of the ticket.
441
-     *
442
-     * @since 4.5.0
443
-     * @return int
444
-     * @throws \EE_Error
445
-     */
439
+	/**
440
+	 * get the author of the ticket.
441
+	 *
442
+	 * @since 4.5.0
443
+	 * @return int
444
+	 * @throws \EE_Error
445
+	 */
446 446
 	public function wp_user() {
447 447
 		return $this->get('TKT_wp_user');
448 448
 	}
449 449
 
450 450
 
451 451
 
452
-    /**
453
-     * Gets the template for the ticket
454
-     *
455
-     * @return EE_Ticket_Template|EE_Base_Class
456
-     * @throws \EE_Error
457
-     */
452
+	/**
453
+	 * Gets the template for the ticket
454
+	 *
455
+	 * @return EE_Ticket_Template|EE_Base_Class
456
+	 * @throws \EE_Error
457
+	 */
458 458
 	public function template() {
459 459
 		return $this->get_first_related( 'Ticket_Template' );
460 460
 	}
461 461
 
462 462
 
463 463
 
464
-    /**
465
-     * Simply returns an array of EE_Price objects that are taxes.
466
-     *
467
-     * @return EE_Price[]
468
-     * @throws \EE_Error
469
-     */
464
+	/**
465
+	 * Simply returns an array of EE_Price objects that are taxes.
466
+	 *
467
+	 * @return EE_Price[]
468
+	 * @throws \EE_Error
469
+	 */
470 470
 	public function get_ticket_taxes_for_admin() {
471 471
 		return EE_Taxes::get_taxes_for_admin();
472 472
 	}
473 473
 
474 474
 
475 475
 
476
-    /**
477
-     * @return float
478
-     * @throws \EE_Error
479
-     */
476
+	/**
477
+	 * @return float
478
+	 * @throws \EE_Error
479
+	 */
480 480
 	public function ticket_price() {
481 481
 		return $this->get( 'TKT_price' );
482 482
 	}
483 483
 
484 484
 
485 485
 
486
-    /**
487
-     * @return mixed
488
-     * @throws \EE_Error
489
-     */
486
+	/**
487
+	 * @return mixed
488
+	 * @throws \EE_Error
489
+	 */
490 490
 	public function pretty_price() {
491 491
 		return $this->get_pretty( 'TKT_price' );
492 492
 	}
493 493
 
494 494
 
495 495
 
496
-    /**
497
-     * @return bool
498
-     * @throws \EE_Error
499
-     */
496
+	/**
497
+	 * @return bool
498
+	 * @throws \EE_Error
499
+	 */
500 500
 	public function is_free() {
501 501
 		return $this->get_ticket_total_with_taxes() === (float) 0;
502 502
 	}
503 503
 
504 504
 
505 505
 
506
-    /**
507
-     * get_ticket_total_with_taxes
508
-     *
509
-     * @param bool $no_cache
510
-     * @return float
511
-     * @throws \EE_Error
512
-     */
506
+	/**
507
+	 * get_ticket_total_with_taxes
508
+	 *
509
+	 * @param bool $no_cache
510
+	 * @return float
511
+	 * @throws \EE_Error
512
+	 */
513 513
 	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
514 514
 		if ($this->_ticket_total_with_taxes === null || $no_cache ) {
515 515
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
@@ -526,201 +526,201 @@  discard block
 block discarded – undo
526 526
 
527 527
 
528 528
 
529
-    /**
530
-     * @return float
531
-     * @throws \EE_Error
532
-     */
529
+	/**
530
+	 * @return float
531
+	 * @throws \EE_Error
532
+	 */
533 533
 	public function get_ticket_subtotal() {
534 534
 		return EE_Taxes::get_subtotal_for_admin( $this );
535 535
 	}
536 536
 
537 537
 
538 538
 
539
-    /**
540
-     * Returns the total taxes applied to this ticket
541
-     *
542
-     * @return float
543
-     * @throws \EE_Error
544
-     */
539
+	/**
540
+	 * Returns the total taxes applied to this ticket
541
+	 *
542
+	 * @return float
543
+	 * @throws \EE_Error
544
+	 */
545 545
 	public function get_ticket_taxes_total_for_admin() {
546 546
 		return EE_Taxes::get_total_taxes_for_admin( $this );
547 547
 	}
548 548
 
549 549
 
550 550
 
551
-    /**
552
-     * Sets name
553
-     *
554
-     * @param string $name
555
-     * @throws \EE_Error
556
-     */
551
+	/**
552
+	 * Sets name
553
+	 *
554
+	 * @param string $name
555
+	 * @throws \EE_Error
556
+	 */
557 557
 	public function set_name( $name ) {
558 558
 		$this->set( 'TKT_name', $name );
559 559
 	}
560 560
 
561 561
 
562 562
 
563
-    /**
564
-     * Gets description
565
-     *
566
-     * @return string
567
-     * @throws \EE_Error
568
-     */
563
+	/**
564
+	 * Gets description
565
+	 *
566
+	 * @return string
567
+	 * @throws \EE_Error
568
+	 */
569 569
 	public function description() {
570 570
 		return $this->get( 'TKT_description' );
571 571
 	}
572 572
 
573 573
 
574 574
 
575
-    /**
576
-     * Sets description
577
-     *
578
-     * @param string $description
579
-     * @throws \EE_Error
580
-     */
575
+	/**
576
+	 * Sets description
577
+	 *
578
+	 * @param string $description
579
+	 * @throws \EE_Error
580
+	 */
581 581
 	public function set_description( $description ) {
582 582
 		$this->set( 'TKT_description', $description );
583 583
 	}
584 584
 
585 585
 
586 586
 
587
-    /**
588
-     * Gets start_date
589
-     *
590
-     * @param string $dt_frmt
591
-     * @param string $tm_frmt
592
-     * @return string
593
-     * @throws \EE_Error
594
-     */
587
+	/**
588
+	 * Gets start_date
589
+	 *
590
+	 * @param string $dt_frmt
591
+	 * @param string $tm_frmt
592
+	 * @return string
593
+	 * @throws \EE_Error
594
+	 */
595 595
 	public function start_date( $dt_frmt = '', $tm_frmt = '' ) {
596 596
 		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
597 597
 	}
598 598
 
599 599
 
600 600
 
601
-    /**
602
-     * Sets start_date
603
-     *
604
-     * @param string $start_date
605
-     * @return void
606
-     * @throws \EE_Error
607
-     */
601
+	/**
602
+	 * Sets start_date
603
+	 *
604
+	 * @param string $start_date
605
+	 * @return void
606
+	 * @throws \EE_Error
607
+	 */
608 608
 	public function set_start_date( $start_date ) {
609 609
 		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
610 610
 	}
611 611
 
612 612
 
613 613
 
614
-    /**
615
-     * Gets end_date
616
-     *
617
-     * @param string $dt_frmt
618
-     * @param string $tm_frmt
619
-     * @return string
620
-     * @throws \EE_Error
621
-     */
614
+	/**
615
+	 * Gets end_date
616
+	 *
617
+	 * @param string $dt_frmt
618
+	 * @param string $tm_frmt
619
+	 * @return string
620
+	 * @throws \EE_Error
621
+	 */
622 622
 	public function end_date( $dt_frmt = '', $tm_frmt = '' ) {
623 623
 		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
624 624
 	}
625 625
 
626 626
 
627 627
 
628
-    /**
629
-     * Sets end_date
630
-     *
631
-     * @param string $end_date
632
-     * @return void
633
-     * @throws \EE_Error
634
-     */
628
+	/**
629
+	 * Sets end_date
630
+	 *
631
+	 * @param string $end_date
632
+	 * @return void
633
+	 * @throws \EE_Error
634
+	 */
635 635
 	public function set_end_date( $end_date ) {
636 636
 		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
637 637
 	}
638 638
 
639 639
 
640 640
 
641
-    /**
642
-     * Sets sell until time
643
-     *
644
-     * @since 4.5.0
645
-     * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
646
-     * @throws \EE_Error
647
-     */
641
+	/**
642
+	 * Sets sell until time
643
+	 *
644
+	 * @since 4.5.0
645
+	 * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
646
+	 * @throws \EE_Error
647
+	 */
648 648
 	public function set_end_time( $time ) {
649 649
 		$this->_set_time_for( $time, 'TKT_end_date' );
650 650
 	}
651 651
 
652 652
 
653 653
 
654
-    /**
655
-     * Sets min
656
-     *
657
-     * @param int $min
658
-     * @return void
659
-     * @throws \EE_Error
660
-     */
654
+	/**
655
+	 * Sets min
656
+	 *
657
+	 * @param int $min
658
+	 * @return void
659
+	 * @throws \EE_Error
660
+	 */
661 661
 	public function set_min( $min ) {
662 662
 		$this->set( 'TKT_min', $min );
663 663
 	}
664 664
 
665 665
 
666 666
 
667
-    /**
668
-     * Gets max
669
-     *
670
-     * @return int
671
-     * @throws \EE_Error
672
-     */
667
+	/**
668
+	 * Gets max
669
+	 *
670
+	 * @return int
671
+	 * @throws \EE_Error
672
+	 */
673 673
 	public function max() {
674 674
 		return $this->get( 'TKT_max' );
675 675
 	}
676 676
 
677 677
 
678 678
 
679
-    /**
680
-     * Sets max
681
-     *
682
-     * @param int $max
683
-     * @return void
684
-     * @throws \EE_Error
685
-     */
679
+	/**
680
+	 * Sets max
681
+	 *
682
+	 * @param int $max
683
+	 * @return void
684
+	 * @throws \EE_Error
685
+	 */
686 686
 	public function set_max( $max ) {
687 687
 		$this->set( 'TKT_max', $max );
688 688
 	}
689 689
 
690 690
 
691 691
 
692
-    /**
693
-     * Sets price
694
-     *
695
-     * @param float $price
696
-     * @return void
697
-     * @throws \EE_Error
698
-     */
692
+	/**
693
+	 * Sets price
694
+	 *
695
+	 * @param float $price
696
+	 * @return void
697
+	 * @throws \EE_Error
698
+	 */
699 699
 	public function set_price( $price ) {
700 700
 		$this->set( 'TKT_price', $price );
701 701
 	}
702 702
 
703 703
 
704 704
 
705
-    /**
706
-     * Gets sold
707
-     *
708
-     * @return int
709
-     * @throws \EE_Error
710
-     */
705
+	/**
706
+	 * Gets sold
707
+	 *
708
+	 * @return int
709
+	 * @throws \EE_Error
710
+	 */
711 711
 	public function sold() {
712 712
 		return $this->get_raw( 'TKT_sold' );
713 713
 	}
714 714
 
715 715
 
716 716
 
717
-    /**
718
-     * Sets sold
719
-     *
720
-     * @param int $sold
721
-     * @return void
722
-     * @throws \EE_Error
723
-     */
717
+	/**
718
+	 * Sets sold
719
+	 *
720
+	 * @param int $sold
721
+	 * @return void
722
+	 * @throws \EE_Error
723
+	 */
724 724
 	public function set_sold( $sold ) {
725 725
 		// sold can not go below zero
726 726
 		$sold = max( 0, $sold );
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
 
730 730
 
731 731
 
732
-    /**
733
-     * increments sold by amount passed by $qty
734
-     *
735
-     * @param int $qty
736
-     * @return void
737
-     * @throws \EE_Error
738
-     */
732
+	/**
733
+	 * increments sold by amount passed by $qty
734
+	 *
735
+	 * @param int $qty
736
+	 * @return void
737
+	 * @throws \EE_Error
738
+	 */
739 739
 	public function increase_sold( $qty = 1 ) {
740 740
 		$sold = $this->sold() + $qty;
741 741
 		// remove ticket reservation, but don't adjust datetime reservations,  because that will happen
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
 
748 748
 
749 749
 
750
-    /**
751
-     * Increases sold on related datetimes
752
-     *
753
-     * @param int $qty
754
-     * @return void
755
-     * @throws \EE_Error
756
-     */
750
+	/**
751
+	 * Increases sold on related datetimes
752
+	 *
753
+	 * @param int $qty
754
+	 * @return void
755
+	 * @throws \EE_Error
756
+	 */
757 757
 	protected function _increase_sold_for_datetimes( $qty = 1 ) {
758 758
 		$datetimes = $this->datetimes();
759 759
 		if ( is_array( $datetimes ) ) {
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 
769 769
 
770 770
 
771
-    /**
772
-     * decrements (subtracts) sold by amount passed by $qty
773
-     *
774
-     * @param int $qty
775
-     * @return void
776
-     * @throws \EE_Error
777
-     */
771
+	/**
772
+	 * decrements (subtracts) sold by amount passed by $qty
773
+	 *
774
+	 * @param int $qty
775
+	 * @return void
776
+	 * @throws \EE_Error
777
+	 */
778 778
 	public function decrease_sold( $qty = 1 ) {
779 779
 		$sold = $this->sold() - $qty;
780 780
 		$this->_decrease_sold_for_datetimes( $qty );
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 
784 784
 
785 785
 
786
-    /**
787
-     * Decreases sold on related datetimes
788
-     *
789
-     * @param int $qty
790
-     * @return void
791
-     * @throws \EE_Error
792
-     */
786
+	/**
787
+	 * Decreases sold on related datetimes
788
+	 *
789
+	 * @param int $qty
790
+	 * @return void
791
+	 * @throws \EE_Error
792
+	 */
793 793
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
794 794
 		$datetimes = $this->datetimes();
795 795
 		if ( is_array( $datetimes ) ) {
@@ -804,25 +804,25 @@  discard block
 block discarded – undo
804 804
 
805 805
 
806 806
 
807
-    /**
808
-     * Gets qty of reserved tickets
809
-     *
810
-     * @return int
811
-     * @throws \EE_Error
812
-     */
807
+	/**
808
+	 * Gets qty of reserved tickets
809
+	 *
810
+	 * @return int
811
+	 * @throws \EE_Error
812
+	 */
813 813
 	public function reserved() {
814 814
 		return $this->get_raw( 'TKT_reserved' );
815 815
 	}
816 816
 
817 817
 
818 818
 
819
-    /**
820
-     * Sets reserved
821
-     *
822
-     * @param int $reserved
823
-     * @return void
824
-     * @throws \EE_Error
825
-     */
819
+	/**
820
+	 * Sets reserved
821
+	 *
822
+	 * @param int $reserved
823
+	 * @return void
824
+	 * @throws \EE_Error
825
+	 */
826 826
 	public function set_reserved( $reserved ) {
827 827
 		// reserved can not go below zero
828 828
 		$reserved = max( 0, (int) $reserved );
@@ -831,13 +831,13 @@  discard block
 block discarded – undo
831 831
 
832 832
 
833 833
 
834
-    /**
835
-     * increments reserved by amount passed by $qty
836
-     *
837
-     * @param int $qty
838
-     * @return void
839
-     * @throws \EE_Error
840
-     */
834
+	/**
835
+	 * increments reserved by amount passed by $qty
836
+	 *
837
+	 * @param int $qty
838
+	 * @return void
839
+	 * @throws \EE_Error
840
+	 */
841 841
 	public function increase_reserved( $qty = 1 ) {
842 842
 		$qty = absint( $qty );
843 843
 		$reserved = $this->reserved() + $qty;
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 
848 848
 
849 849
 
850
-    /**
851
-     * Increases sold on related datetimes
852
-     *
853
-     * @param int $qty
854
-     * @return void
855
-     * @throws \EE_Error
856
-     */
850
+	/**
851
+	 * Increases sold on related datetimes
852
+	 *
853
+	 * @param int $qty
854
+	 * @return void
855
+	 * @throws \EE_Error
856
+	 */
857 857
 	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
858 858
 		$datetimes = $this->datetimes();
859 859
 		if ( is_array( $datetimes ) ) {
@@ -868,14 +868,14 @@  discard block
 block discarded – undo
868 868
 
869 869
 
870 870
 
871
-    /**
872
-     * decrements (subtracts) reserved by amount passed by $qty
873
-     *
874
-     * @param int  $qty
875
-     * @param bool $adjust_datetimes
876
-     * @return void
877
-     * @throws \EE_Error
878
-     */
871
+	/**
872
+	 * decrements (subtracts) reserved by amount passed by $qty
873
+	 *
874
+	 * @param int  $qty
875
+	 * @param bool $adjust_datetimes
876
+	 * @return void
877
+	 * @throws \EE_Error
878
+	 */
879 879
 	public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
880 880
 		$reserved = $this->reserved() - absint( $qty );
881 881
 		if ( $adjust_datetimes ) {
@@ -886,13 +886,13 @@  discard block
 block discarded – undo
886 886
 
887 887
 
888 888
 
889
-    /**
890
-     * Increases sold on related datetimes
891
-     *
892
-     * @param int $qty
893
-     * @return void
894
-     * @throws \EE_Error
895
-     */
889
+	/**
890
+	 * Increases sold on related datetimes
891
+	 *
892
+	 * @param int $qty
893
+	 * @return void
894
+	 * @throws \EE_Error
895
+	 */
896 896
 	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
897 897
 		$datetimes = $this->datetimes();
898 898
 		if ( is_array( $datetimes ) ) {
@@ -907,18 +907,18 @@  discard block
 block discarded – undo
907 907
 
908 908
 
909 909
 
910
-    /**
911
-     * Gets ticket quantity
912
-     *
913
-     * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
914
-     *                            therefore $context can be one of three values: '', 'reg_limit', or 'saleable'
915
-     *                            '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects
916
-     *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
917
-     *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
918
-     *                            is therefore the truest measure of tickets that can be purchased at the moment
919
-     * @return int
920
-     * @throws \EE_Error
921
-     */
910
+	/**
911
+	 * Gets ticket quantity
912
+	 *
913
+	 * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
914
+	 *                            therefore $context can be one of three values: '', 'reg_limit', or 'saleable'
915
+	 *                            '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects
916
+	 *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
917
+	 *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
918
+	 *                            is therefore the truest measure of tickets that can be purchased at the moment
919
+	 * @return int
920
+	 * @throws \EE_Error
921
+	 */
922 922
 	public function qty( $context = '' ) {
923 923
 		switch ( $context ) {
924 924
 			case 'reg_limit' :
@@ -932,19 +932,19 @@  discard block
 block discarded – undo
932 932
 
933 933
 
934 934
 
935
-    /**
936
-     * Gets ticket quantity
937
-     *
938
-     * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
939
-     *                            therefore $context can be one of two values: 'reg_limit', or 'saleable'
940
-     *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
941
-     *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
942
-     *                            is therefore the truest measure of tickets that can be purchased at the moment
943
-     * @param  int   $DTT_ID      the primary key for a particular datetime.
944
-     *                            set to 0 for all related datetimes
945
-     * @return int
946
-     * @throws \EE_Error
947
-     */
935
+	/**
936
+	 * Gets ticket quantity
937
+	 *
938
+	 * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
939
+	 *                            therefore $context can be one of two values: 'reg_limit', or 'saleable'
940
+	 *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
941
+	 *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
942
+	 *                            is therefore the truest measure of tickets that can be purchased at the moment
943
+	 * @param  int   $DTT_ID      the primary key for a particular datetime.
944
+	 *                            set to 0 for all related datetimes
945
+	 * @return int
946
+	 * @throws \EE_Error
947
+	 */
948 948
 	public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) {
949 949
 		$raw = $this->get_raw( 'TKT_qty' );
950 950
 		// return immediately if it's zero
@@ -1027,212 +1027,212 @@  discard block
 block discarded – undo
1027 1027
 
1028 1028
 
1029 1029
 
1030
-    /**
1031
-     * Gets uses
1032
-     *
1033
-     * @return int
1034
-     * @throws \EE_Error
1035
-     */
1030
+	/**
1031
+	 * Gets uses
1032
+	 *
1033
+	 * @return int
1034
+	 * @throws \EE_Error
1035
+	 */
1036 1036
 	public function uses() {
1037 1037
 		return $this->get( 'TKT_uses' );
1038 1038
 	}
1039 1039
 
1040 1040
 
1041 1041
 
1042
-    /**
1043
-     * Sets uses
1044
-     *
1045
-     * @param int $uses
1046
-     * @return void
1047
-     * @throws \EE_Error
1048
-     */
1042
+	/**
1043
+	 * Sets uses
1044
+	 *
1045
+	 * @param int $uses
1046
+	 * @return void
1047
+	 * @throws \EE_Error
1048
+	 */
1049 1049
 	public function set_uses( $uses ) {
1050 1050
 		$this->set( 'TKT_uses', $uses );
1051 1051
 	}
1052 1052
 
1053 1053
 
1054 1054
 
1055
-    /**
1056
-     * returns whether ticket is required or not.
1057
-     *
1058
-     * @return boolean
1059
-     * @throws \EE_Error
1060
-     */
1055
+	/**
1056
+	 * returns whether ticket is required or not.
1057
+	 *
1058
+	 * @return boolean
1059
+	 * @throws \EE_Error
1060
+	 */
1061 1061
 	public function required() {
1062 1062
 		return $this->get( 'TKT_required' );
1063 1063
 	}
1064 1064
 
1065 1065
 
1066 1066
 
1067
-    /**
1068
-     * sets the TKT_required property
1069
-     *
1070
-     * @param boolean $required
1071
-     * @return void
1072
-     * @throws \EE_Error
1073
-     */
1067
+	/**
1068
+	 * sets the TKT_required property
1069
+	 *
1070
+	 * @param boolean $required
1071
+	 * @return void
1072
+	 * @throws \EE_Error
1073
+	 */
1074 1074
 	public function set_required( $required ) {
1075 1075
 		$this->set( 'TKT_required', $required );
1076 1076
 	}
1077 1077
 
1078 1078
 
1079 1079
 
1080
-    /**
1081
-     * Gets taxable
1082
-     *
1083
-     * @return boolean
1084
-     * @throws \EE_Error
1085
-     */
1080
+	/**
1081
+	 * Gets taxable
1082
+	 *
1083
+	 * @return boolean
1084
+	 * @throws \EE_Error
1085
+	 */
1086 1086
 	public function taxable() {
1087 1087
 		return $this->get( 'TKT_taxable' );
1088 1088
 	}
1089 1089
 
1090 1090
 
1091 1091
 
1092
-    /**
1093
-     * Sets taxable
1094
-     *
1095
-     * @param boolean $taxable
1096
-     * @return void
1097
-     * @throws \EE_Error
1098
-     */
1092
+	/**
1093
+	 * Sets taxable
1094
+	 *
1095
+	 * @param boolean $taxable
1096
+	 * @return void
1097
+	 * @throws \EE_Error
1098
+	 */
1099 1099
 	public function set_taxable( $taxable ) {
1100 1100
 		$this->set( 'TKT_taxable', $taxable );
1101 1101
 	}
1102 1102
 
1103 1103
 
1104 1104
 
1105
-    /**
1106
-     * Gets is_default
1107
-     *
1108
-     * @return boolean
1109
-     * @throws \EE_Error
1110
-     */
1105
+	/**
1106
+	 * Gets is_default
1107
+	 *
1108
+	 * @return boolean
1109
+	 * @throws \EE_Error
1110
+	 */
1111 1111
 	public function is_default() {
1112 1112
 		return $this->get( 'TKT_is_default' );
1113 1113
 	}
1114 1114
 
1115 1115
 
1116 1116
 
1117
-    /**
1118
-     * Sets is_default
1119
-     *
1120
-     * @param boolean $is_default
1121
-     * @return void
1122
-     * @throws \EE_Error
1123
-     */
1117
+	/**
1118
+	 * Sets is_default
1119
+	 *
1120
+	 * @param boolean $is_default
1121
+	 * @return void
1122
+	 * @throws \EE_Error
1123
+	 */
1124 1124
 	public function set_is_default( $is_default ) {
1125 1125
 		$this->set( 'TKT_is_default', $is_default );
1126 1126
 	}
1127 1127
 
1128 1128
 
1129 1129
 
1130
-    /**
1131
-     * Gets order
1132
-     *
1133
-     * @return int
1134
-     * @throws \EE_Error
1135
-     */
1130
+	/**
1131
+	 * Gets order
1132
+	 *
1133
+	 * @return int
1134
+	 * @throws \EE_Error
1135
+	 */
1136 1136
 	public function order() {
1137 1137
 		return $this->get( 'TKT_order' );
1138 1138
 	}
1139 1139
 
1140 1140
 
1141 1141
 
1142
-    /**
1143
-     * Sets order
1144
-     *
1145
-     * @param int $order
1146
-     * @return void
1147
-     * @throws \EE_Error
1148
-     */
1142
+	/**
1143
+	 * Sets order
1144
+	 *
1145
+	 * @param int $order
1146
+	 * @return void
1147
+	 * @throws \EE_Error
1148
+	 */
1149 1149
 	public function set_order( $order ) {
1150 1150
 		$this->set( 'TKT_order', $order );
1151 1151
 	}
1152 1152
 
1153 1153
 
1154 1154
 
1155
-    /**
1156
-     * Gets row
1157
-     *
1158
-     * @return int
1159
-     * @throws \EE_Error
1160
-     */
1155
+	/**
1156
+	 * Gets row
1157
+	 *
1158
+	 * @return int
1159
+	 * @throws \EE_Error
1160
+	 */
1161 1161
 	public function row() {
1162 1162
 		return $this->get( 'TKT_row' );
1163 1163
 	}
1164 1164
 
1165 1165
 
1166 1166
 
1167
-    /**
1168
-     * Sets row
1169
-     *
1170
-     * @param int $row
1171
-     * @return void
1172
-     * @throws \EE_Error
1173
-     */
1167
+	/**
1168
+	 * Sets row
1169
+	 *
1170
+	 * @param int $row
1171
+	 * @return void
1172
+	 * @throws \EE_Error
1173
+	 */
1174 1174
 	public function set_row( $row ) {
1175 1175
 		$this->set( 'TKT_row', $row );
1176 1176
 	}
1177 1177
 
1178 1178
 
1179 1179
 
1180
-    /**
1181
-     * Gets deleted
1182
-     *
1183
-     * @return boolean
1184
-     * @throws \EE_Error
1185
-     */
1180
+	/**
1181
+	 * Gets deleted
1182
+	 *
1183
+	 * @return boolean
1184
+	 * @throws \EE_Error
1185
+	 */
1186 1186
 	public function deleted() {
1187 1187
 		return $this->get( 'TKT_deleted' );
1188 1188
 	}
1189 1189
 
1190 1190
 
1191 1191
 
1192
-    /**
1193
-     * Sets deleted
1194
-     *
1195
-     * @param boolean $deleted
1196
-     * @return void
1197
-     * @throws \EE_Error
1198
-     */
1192
+	/**
1193
+	 * Sets deleted
1194
+	 *
1195
+	 * @param boolean $deleted
1196
+	 * @return void
1197
+	 * @throws \EE_Error
1198
+	 */
1199 1199
 	public function set_deleted( $deleted ) {
1200 1200
 		$this->set( 'TKT_deleted', $deleted );
1201 1201
 	}
1202 1202
 
1203 1203
 
1204 1204
 
1205
-    /**
1206
-     * Gets parent
1207
-     *
1208
-     * @return int
1209
-     * @throws \EE_Error
1210
-     */
1205
+	/**
1206
+	 * Gets parent
1207
+	 *
1208
+	 * @return int
1209
+	 * @throws \EE_Error
1210
+	 */
1211 1211
 	public function parent_ID() {
1212 1212
 		return $this->get( 'TKT_parent' );
1213 1213
 	}
1214 1214
 
1215 1215
 
1216 1216
 
1217
-    /**
1218
-     * Sets parent
1219
-     *
1220
-     * @param int $parent
1221
-     * @return void
1222
-     * @throws \EE_Error
1223
-     */
1217
+	/**
1218
+	 * Sets parent
1219
+	 *
1220
+	 * @param int $parent
1221
+	 * @return void
1222
+	 * @throws \EE_Error
1223
+	 */
1224 1224
 	public function set_parent_ID( $parent ) {
1225 1225
 		$this->set( 'TKT_parent', $parent );
1226 1226
 	}
1227 1227
 
1228 1228
 
1229 1229
 
1230
-    /**
1231
-     * Gets a string which is handy for showing in gateways etc that describes the ticket.
1232
-     *
1233
-     * @return string
1234
-     * @throws \EE_Error
1235
-     */
1230
+	/**
1231
+	 * Gets a string which is handy for showing in gateways etc that describes the ticket.
1232
+	 *
1233
+	 * @return string
1234
+	 * @throws \EE_Error
1235
+	 */
1236 1236
 	public function name_and_info() {
1237 1237
 		$times = array();
1238 1238
 		foreach ( $this->datetimes() as $datetime ) {
@@ -1243,67 +1243,67 @@  discard block
 block discarded – undo
1243 1243
 
1244 1244
 
1245 1245
 
1246
-    /**
1247
-     * Gets name
1248
-     *
1249
-     * @return string
1250
-     * @throws \EE_Error
1251
-     */
1246
+	/**
1247
+	 * Gets name
1248
+	 *
1249
+	 * @return string
1250
+	 * @throws \EE_Error
1251
+	 */
1252 1252
 	public function name() {
1253 1253
 		return $this->get( 'TKT_name' );
1254 1254
 	}
1255 1255
 
1256 1256
 
1257 1257
 
1258
-    /**
1259
-     * Gets price
1260
-     *
1261
-     * @return float
1262
-     * @throws \EE_Error
1263
-     */
1258
+	/**
1259
+	 * Gets price
1260
+	 *
1261
+	 * @return float
1262
+	 * @throws \EE_Error
1263
+	 */
1264 1264
 	public function price() {
1265 1265
 		return $this->get( 'TKT_price' );
1266 1266
 	}
1267 1267
 
1268 1268
 
1269 1269
 
1270
-    /**
1271
-     * Gets all the registrations for this ticket
1272
-     *
1273
-     * @param array $query_params like EEM_Base::get_all's
1274
-     * @return EE_Registration[]|EE_Base_Class[]
1275
-     * @throws \EE_Error
1276
-     */
1270
+	/**
1271
+	 * Gets all the registrations for this ticket
1272
+	 *
1273
+	 * @param array $query_params like EEM_Base::get_all's
1274
+	 * @return EE_Registration[]|EE_Base_Class[]
1275
+	 * @throws \EE_Error
1276
+	 */
1277 1277
 	public function registrations( $query_params = array() ) {
1278 1278
 		return $this->get_many_related( 'Registration', $query_params );
1279 1279
 	}
1280 1280
 
1281 1281
 
1282 1282
 
1283
-    /**
1284
-     * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket.
1285
-     * into account
1286
-     *
1287
-     * @return int
1288
-     * @throws \EE_Error
1289
-     */
1283
+	/**
1284
+	 * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket.
1285
+	 * into account
1286
+	 *
1287
+	 * @return int
1288
+	 * @throws \EE_Error
1289
+	 */
1290 1290
 	public function update_tickets_sold() {
1291
-        $count_regs_for_this_ticket = $this->count_registrations(
1292
-            array(
1293
-                array(
1294
-                    'STS_ID'      => EEM_Registration::status_id_approved,
1295
-                    'REG_deleted' => 0,
1296
-                ),
1297
-            )
1298
-        );
1299
-        $sold = $this->sold();
1300
-        if ($count_regs_for_this_ticket > $sold) {
1301
-            $this->increase_sold($count_regs_for_this_ticket - $sold);
1302
-            $this->save();
1303
-        } else if ($count_regs_for_this_ticket < $sold) {
1304
-            $this->decrease_sold($count_regs_for_this_ticket - $sold);
1305
-            $this->save();
1306
-        }
1291
+		$count_regs_for_this_ticket = $this->count_registrations(
1292
+			array(
1293
+				array(
1294
+					'STS_ID'      => EEM_Registration::status_id_approved,
1295
+					'REG_deleted' => 0,
1296
+				),
1297
+			)
1298
+		);
1299
+		$sold = $this->sold();
1300
+		if ($count_regs_for_this_ticket > $sold) {
1301
+			$this->increase_sold($count_regs_for_this_ticket - $sold);
1302
+			$this->save();
1303
+		} else if ($count_regs_for_this_ticket < $sold) {
1304
+			$this->decrease_sold($count_regs_for_this_ticket - $sold);
1305
+			$this->save();
1306
+		}
1307 1307
 		return $count_regs_for_this_ticket;
1308 1308
 	}
1309 1309
 
@@ -1331,21 +1331,21 @@  discard block
 block discarded – undo
1331 1331
 
1332 1332
 
1333 1333
 
1334
-    /**
1335
-     * Implementation of the EEI_Event_Relation interface method
1336
-     *
1337
-     * @see EEI_Event_Relation for comments
1338
-     * @return EE_Event
1339
-     * @throws \EE_Error
1340
-     * @throws UnexpectedEntityException
1341
-     */
1334
+	/**
1335
+	 * Implementation of the EEI_Event_Relation interface method
1336
+	 *
1337
+	 * @see EEI_Event_Relation for comments
1338
+	 * @return EE_Event
1339
+	 * @throws \EE_Error
1340
+	 * @throws UnexpectedEntityException
1341
+	 */
1342 1342
 	public function get_related_event() {
1343 1343
 		//get one datetime to use for getting the event
1344 1344
 		$datetime = $this->first_datetime();
1345 1345
 		if ( ! $datetime instanceof \EE_Datetime ) {
1346 1346
 			throw new UnexpectedEntityException(
1347 1347
 				$datetime,
1348
-                'EE_Datetime',
1348
+				'EE_Datetime',
1349 1349
 				sprintf(
1350 1350
 					__( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1351 1351
 					$this->name()
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 		if ( ! $event instanceof \EE_Event ) {
1357 1357
 			throw new UnexpectedEntityException(
1358 1358
 				$event,
1359
-                'EE_Event',
1359
+				'EE_Event',
1360 1360
 				sprintf(
1361 1361
 					__( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1362 1362
 					$this->name()
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
 
1370 1370
 
1371
-    /**
1372
-     * Implementation of the EEI_Event_Relation interface method
1373
-     *
1374
-     * @see EEI_Event_Relation for comments
1375
-     * @return string
1376
-     * @throws UnexpectedEntityException
1377
-     * @throws \EE_Error
1378
-     */
1371
+	/**
1372
+	 * Implementation of the EEI_Event_Relation interface method
1373
+	 *
1374
+	 * @see EEI_Event_Relation for comments
1375
+	 * @return string
1376
+	 * @throws UnexpectedEntityException
1377
+	 * @throws \EE_Error
1378
+	 */
1379 1379
 	public function get_event_name() {
1380 1380
 		$event = $this->get_related_event();
1381 1381
 		return $event instanceof EE_Event ? $event->name() : '';
@@ -1383,28 +1383,28 @@  discard block
 block discarded – undo
1383 1383
 
1384 1384
 
1385 1385
 
1386
-    /**
1387
-     * Implementation of the EEI_Event_Relation interface method
1388
-     *
1389
-     * @see EEI_Event_Relation for comments
1390
-     * @return int
1391
-     * @throws UnexpectedEntityException
1392
-     * @throws \EE_Error
1393
-     */
1386
+	/**
1387
+	 * Implementation of the EEI_Event_Relation interface method
1388
+	 *
1389
+	 * @see EEI_Event_Relation for comments
1390
+	 * @return int
1391
+	 * @throws UnexpectedEntityException
1392
+	 * @throws \EE_Error
1393
+	 */
1394 1394
 	public function get_event_ID() {
1395 1395
 		$event = $this->get_related_event();
1396 1396
 		return $event instanceof EE_Event ? $event->ID() : 0;
1397 1397
 	}
1398 1398
 
1399 1399
 
1400
-    /**
1401
-     * This simply returns whether a ticket can be permanently deleted or not.
1402
-     * The criteria for determining this is whether the ticket has any related registrations.
1403
-     * If there are none then it can be permanently deleted.
1404
-     *
1405
-     * @return bool
1406
-     */
1400
+	/**
1401
+	 * This simply returns whether a ticket can be permanently deleted or not.
1402
+	 * The criteria for determining this is whether the ticket has any related registrations.
1403
+	 * If there are none then it can be permanently deleted.
1404
+	 *
1405
+	 * @return bool
1406
+	 */
1407 1407
 	public function is_permanently_deleteable() {
1408
-	    return $this->count_registrations() === 0;
1409
-    }
1408
+		return $this->count_registrations() === 0;
1409
+	}
1410 1410
 } //end EE_Ticket class
Please login to merge, or discard this patch.
modules/ticket_selector/DatetimeSelector.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -16,175 +16,175 @@
 block discarded – undo
16 16
 class DatetimeSelector
17 17
 {
18 18
 
19
-    /**
20
-     * @var \EE_Event $event
21
-     */
22
-    protected $event;
23
-
24
-    /**
25
-     * @var \EE_Ticket[] $tickets
26
-     */
27
-    protected $tickets;
28
-
29
-    /**
30
-     * @var \EE_Datetime[] $datetimes
31
-     */
32
-    protected $datetimes;
33
-
34
-    /**
35
-     * @var \EE_Datetime[] $unique_dates
36
-     */
37
-    protected $unique_dates;
38
-
39
-    /**
40
-     * @var \EE_Ticket_Selector_Config $template_settings
41
-     */
42
-    protected $template_settings;
43
-
44
-    /**
45
-     * @var boolean $active
46
-     */
47
-    protected $active = false;
48
-
49
-
50
-
51
-    /**
52
-     * DatetimeSelector constructor.
53
-     *
54
-     * @param \EE_Event                  $event
55
-     * @param \EE_Ticket[]               $tickets
56
-     * @param \EE_Ticket_Selector_Config $template_settings
57
-     * @param string                     $date_format
58
-     * @param string                     $time_format
59
-     * @throws \EE_Error
60
-     */
61
-    public function __construct(
62
-        \EE_Event $event,
63
-        array $tickets,
64
-        \EE_Ticket_Selector_Config $template_settings,
65
-        $date_format = 'Y-m-d',
66
-        $time_format = 'g:i a'
67
-    ) {
68
-        $this->event = $event;
69
-        $this->tickets = $tickets;
70
-        $this->template_settings = $template_settings;
71
-        $this->datetimes = $this->getAllDatetimesForAllTicket($tickets);
72
-        $this->unique_dates = $this->getUniqueDatetimeOptions($date_format, $time_format);
73
-        $this->active = $this->template_settings->showDatetimeSelector($this->unique_dates);
74
-    }
75
-
76
-
77
-
78
-    /**
79
-     * @param \EE_Ticket[] $tickets
80
-     * @return array
81
-     * @throws \EE_Error
82
-     */
83
-    protected function getAllDatetimesForAllTicket($tickets = array())
84
-    {
85
-        $datetimes = array();
86
-        foreach ($tickets as $ticket) {
87
-            $datetimes = $this->getTicketDatetimes($ticket, $datetimes);
88
-        }
89
-        return $datetimes;
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     * @param \EE_Ticket      $ticket
96
-     * @param  \EE_Datetime[] $datetimes
97
-     * @return \EE_Datetime[]
98
-     * @throws \EE_Error
99
-     */
100
-    protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array())
101
-    {
102
-        $ticket_datetimes = $ticket->datetimes(
103
-            array(
104
-                'order_by'                 => array(
105
-                    'DTT_order'     => 'ASC',
106
-                    'DTT_EVT_start' => 'ASC'
107
-                ),
108
-                'default_where_conditions' => 'none',
109
-            )
110
-        );
111
-        foreach ($ticket_datetimes as $ticket_datetime) {
112
-            if ( ! $ticket_datetime instanceof \EE_Datetime) {
113
-                continue;
114
-            }
115
-            $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime;
116
-        }
117
-        return $datetimes;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @param \EE_Ticket                 $ticket
124
-     * @return string
125
-     * @throws \EE_Error
126
-     */
127
-    public function getTicketDatetimeClasses( \EE_Ticket $ticket ) {
128
-        if ( ! $this->active) {
129
-            return '';
130
-        }
131
-        $ticket_datetimes = $this->getTicketDatetimes($ticket);
132
-        $classes = '';
133
-        foreach ($this->datetimes as $datetime) {
134
-            if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes, true)) {
135
-                continue;
136
-            }
137
-            $classes .= ' ee-ticket-datetimes-' . $datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_');
138
-        }
139
-        return $classes;
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @param string $date_format
146
-     * @param string $time_format
147
-     * @return array
148
-     * @throws \EE_Error
149
-     */
150
-    public function getUniqueDatetimeOptions($date_format = 'Y-m-d', $time_format = 'g:i a') {
151
-        $datetime_options = array();
152
-        foreach ($this->datetimes as $datetime) {
153
-            if ( ! $datetime instanceof \EE_Datetime) {
154
-                continue;
155
-            }
156
-            $datetime_options[$datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_')] =
157
-                $datetime->date_and_time_range($date_format, $time_format, ' - ');
158
-        }
159
-        return $datetime_options;
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * @return string
166
-     * @throws \EE_Error
167
-     */
168
-    public function getDatetimeSelector() {
169
-        if ( ! $this->active) {
170
-            return '';
171
-        }
172
-        $dropdown_selector = new \EE_Checkbox_Dropdown_Selector_Input(
173
-            $this->unique_dates,
174
-            array(
175
-                'html_id'               => 'datetime-selector-' . $this->event->ID(),
176
-                'html_name'             => 'datetime_selector_' . $this->event->ID(),
177
-                'html_class'            => 'datetime-selector',
178
-                'select_button_text'       => '<span class="dashicons dashicons-calendar-alt"></span> '
179
-                                            . esc_html__('Filter by Date', 'event_espresso'),
180
-                'other_html_attributes' => ' data-tkt_slctr_evt="' . $this->event->ID() . '"',
181
-            )
182
-        );
183
-        return \EEH_HTML::div(
184
-            $dropdown_selector->get_html_for_input(),
185
-            '', 'datetime_selector-dv'
186
-        );
187
-    }
19
+	/**
20
+	 * @var \EE_Event $event
21
+	 */
22
+	protected $event;
23
+
24
+	/**
25
+	 * @var \EE_Ticket[] $tickets
26
+	 */
27
+	protected $tickets;
28
+
29
+	/**
30
+	 * @var \EE_Datetime[] $datetimes
31
+	 */
32
+	protected $datetimes;
33
+
34
+	/**
35
+	 * @var \EE_Datetime[] $unique_dates
36
+	 */
37
+	protected $unique_dates;
38
+
39
+	/**
40
+	 * @var \EE_Ticket_Selector_Config $template_settings
41
+	 */
42
+	protected $template_settings;
43
+
44
+	/**
45
+	 * @var boolean $active
46
+	 */
47
+	protected $active = false;
48
+
49
+
50
+
51
+	/**
52
+	 * DatetimeSelector constructor.
53
+	 *
54
+	 * @param \EE_Event                  $event
55
+	 * @param \EE_Ticket[]               $tickets
56
+	 * @param \EE_Ticket_Selector_Config $template_settings
57
+	 * @param string                     $date_format
58
+	 * @param string                     $time_format
59
+	 * @throws \EE_Error
60
+	 */
61
+	public function __construct(
62
+		\EE_Event $event,
63
+		array $tickets,
64
+		\EE_Ticket_Selector_Config $template_settings,
65
+		$date_format = 'Y-m-d',
66
+		$time_format = 'g:i a'
67
+	) {
68
+		$this->event = $event;
69
+		$this->tickets = $tickets;
70
+		$this->template_settings = $template_settings;
71
+		$this->datetimes = $this->getAllDatetimesForAllTicket($tickets);
72
+		$this->unique_dates = $this->getUniqueDatetimeOptions($date_format, $time_format);
73
+		$this->active = $this->template_settings->showDatetimeSelector($this->unique_dates);
74
+	}
75
+
76
+
77
+
78
+	/**
79
+	 * @param \EE_Ticket[] $tickets
80
+	 * @return array
81
+	 * @throws \EE_Error
82
+	 */
83
+	protected function getAllDatetimesForAllTicket($tickets = array())
84
+	{
85
+		$datetimes = array();
86
+		foreach ($tickets as $ticket) {
87
+			$datetimes = $this->getTicketDatetimes($ticket, $datetimes);
88
+		}
89
+		return $datetimes;
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 * @param \EE_Ticket      $ticket
96
+	 * @param  \EE_Datetime[] $datetimes
97
+	 * @return \EE_Datetime[]
98
+	 * @throws \EE_Error
99
+	 */
100
+	protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array())
101
+	{
102
+		$ticket_datetimes = $ticket->datetimes(
103
+			array(
104
+				'order_by'                 => array(
105
+					'DTT_order'     => 'ASC',
106
+					'DTT_EVT_start' => 'ASC'
107
+				),
108
+				'default_where_conditions' => 'none',
109
+			)
110
+		);
111
+		foreach ($ticket_datetimes as $ticket_datetime) {
112
+			if ( ! $ticket_datetime instanceof \EE_Datetime) {
113
+				continue;
114
+			}
115
+			$datetimes[ $ticket_datetime->ID() ] = $ticket_datetime;
116
+		}
117
+		return $datetimes;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @param \EE_Ticket                 $ticket
124
+	 * @return string
125
+	 * @throws \EE_Error
126
+	 */
127
+	public function getTicketDatetimeClasses( \EE_Ticket $ticket ) {
128
+		if ( ! $this->active) {
129
+			return '';
130
+		}
131
+		$ticket_datetimes = $this->getTicketDatetimes($ticket);
132
+		$classes = '';
133
+		foreach ($this->datetimes as $datetime) {
134
+			if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes, true)) {
135
+				continue;
136
+			}
137
+			$classes .= ' ee-ticket-datetimes-' . $datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_');
138
+		}
139
+		return $classes;
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @param string $date_format
146
+	 * @param string $time_format
147
+	 * @return array
148
+	 * @throws \EE_Error
149
+	 */
150
+	public function getUniqueDatetimeOptions($date_format = 'Y-m-d', $time_format = 'g:i a') {
151
+		$datetime_options = array();
152
+		foreach ($this->datetimes as $datetime) {
153
+			if ( ! $datetime instanceof \EE_Datetime) {
154
+				continue;
155
+			}
156
+			$datetime_options[$datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_')] =
157
+				$datetime->date_and_time_range($date_format, $time_format, ' - ');
158
+		}
159
+		return $datetime_options;
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * @return string
166
+	 * @throws \EE_Error
167
+	 */
168
+	public function getDatetimeSelector() {
169
+		if ( ! $this->active) {
170
+			return '';
171
+		}
172
+		$dropdown_selector = new \EE_Checkbox_Dropdown_Selector_Input(
173
+			$this->unique_dates,
174
+			array(
175
+				'html_id'               => 'datetime-selector-' . $this->event->ID(),
176
+				'html_name'             => 'datetime_selector_' . $this->event->ID(),
177
+				'html_class'            => 'datetime-selector',
178
+				'select_button_text'       => '<span class="dashicons dashicons-calendar-alt"></span> '
179
+											. esc_html__('Filter by Date', 'event_espresso'),
180
+				'other_html_attributes' => ' data-tkt_slctr_evt="' . $this->event->ID() . '"',
181
+			)
182
+		);
183
+		return \EEH_HTML::div(
184
+			$dropdown_selector->get_html_for_input(),
185
+			'', 'datetime_selector-dv'
186
+		);
187
+	}
188 188
 
189 189
 
190 190
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             if ( ! $ticket_datetime instanceof \EE_Datetime) {
113 113
                 continue;
114 114
             }
115
-            $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime;
115
+            $datetimes[$ticket_datetime->ID()] = $ticket_datetime;
116 116
         }
117 117
         return $datetimes;
118 118
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @return string
125 125
      * @throws \EE_Error
126 126
      */
127
-    public function getTicketDatetimeClasses( \EE_Ticket $ticket ) {
127
+    public function getTicketDatetimeClasses(\EE_Ticket $ticket) {
128 128
         if ( ! $this->active) {
129 129
             return '';
130 130
         }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes, true)) {
135 135
                 continue;
136 136
             }
137
-            $classes .= ' ee-ticket-datetimes-' . $datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_');
137
+            $classes .= ' ee-ticket-datetimes-'.$datetime->date_and_time_range('Y_m_d', 'H_i', '-', '_');
138 138
         }
139 139
         return $classes;
140 140
     }
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
         $dropdown_selector = new \EE_Checkbox_Dropdown_Selector_Input(
173 173
             $this->unique_dates,
174 174
             array(
175
-                'html_id'               => 'datetime-selector-' . $this->event->ID(),
176
-                'html_name'             => 'datetime_selector_' . $this->event->ID(),
175
+                'html_id'               => 'datetime-selector-'.$this->event->ID(),
176
+                'html_name'             => 'datetime_selector_'.$this->event->ID(),
177 177
                 'html_class'            => 'datetime-selector',
178 178
                 'select_button_text'       => '<span class="dashicons dashicons-calendar-alt"></span> '
179 179
                                             . esc_html__('Filter by Date', 'event_espresso'),
180
-                'other_html_attributes' => ' data-tkt_slctr_evt="' . $this->event->ID() . '"',
180
+                'other_html_attributes' => ' data-tkt_slctr_evt="'.$this->event->ID().'"',
181 181
             )
182 182
         );
183 183
         return \EEH_HTML::div(
Please login to merge, or discard this patch.
modules/ticket_selector/templates/standard_ticket_selector.template.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 			<tr>
29 29
 				<th scope="col" class="ee-ticket-selector-ticket-details-th">
30 30
 					<?php
31
-                    echo apply_filters(
32
-                        'FHEE__ticket_selector_chart_template__table_header_available_tickets',
33
-                        esc_html(''),
34
-                        $EVT_ID
35
-                    );
36
-                    ?>
31
+					echo apply_filters(
32
+						'FHEE__ticket_selector_chart_template__table_header_available_tickets',
33
+						esc_html(''),
34
+						$EVT_ID
35
+					);
36
+					?>
37 37
 				</th>
38 38
 				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
39 39
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
@@ -47,28 +47,28 @@  discard block
 block discarded – undo
47 47
 						 * @param int $EVT_ID The Event ID
48 48
 						 */
49 49
 						echo apply_filters(
50
-                            'FHEE__ticket_selector_chart_template__table_header_price',
51
-                            esc_html__( 'Price', 'event_espresso' ),
52
-                            $EVT_ID
53
-                        );
50
+							'FHEE__ticket_selector_chart_template__table_header_price',
51
+							esc_html__( 'Price', 'event_espresso' ),
52
+							$EVT_ID
53
+						);
54 54
 					?>
55 55
 				</th>
56 56
 				<?php } ?>
57 57
 				<th scope="col" class="ee-ticket-selector-ticket-qty-th cntr">
58 58
 					<?php
59 59
 						/**
60
-						* Filters the text printed for the header of the quantity column in the ticket selector table
61
-						*
62
-						* @since 4.7.2
63
-						*
64
-						* @param string 'Qty' The translatable text to display in the table header for the Quantity of tickets
65
-						* @param int $EVT_ID The Event ID
66
-						*/
60
+						 * Filters the text printed for the header of the quantity column in the ticket selector table
61
+						 *
62
+						 * @since 4.7.2
63
+						 *
64
+						 * @param string 'Qty' The translatable text to display in the table header for the Quantity of tickets
65
+						 * @param int $EVT_ID The Event ID
66
+						 */
67 67
 						echo apply_filters(
68
-                            'FHEE__ticket_selector_chart_template__table_header_qty',
69
-                            esc_html__( 'Qty', 'event_espresso' ),
70
-                            $EVT_ID
71
-                        );
68
+							'FHEE__ticket_selector_chart_template__table_header_qty',
69
+							esc_html__( 'Qty', 'event_espresso' ),
70
+							$EVT_ID
71
+						);
72 72
 					?>
73 73
 				</th>
74 74
 			</tr>
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 if ( $max_atndz > 0 ) {
99 99
 	echo apply_filters(
100 100
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
101
-        esc_html('')
101
+		esc_html('')
102 102
 	);
103 103
 }
104 104
 if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 ?>
22 22
 <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv">
23 23
 
24
-	<?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?>
24
+	<?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?>
25 25
 	<?php echo $datetime_selector; ?>
26 26
 
27 27
 	<table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl">
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
                     );
37 37
                     ?>
38 38
 				</th>
39
-				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
39
+				<?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
40 40
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
41 41
 					<?php
42 42
 						/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 						 */
50 50
 						echo apply_filters(
51 51
                             'FHEE__ticket_selector_chart_template__table_header_price',
52
-                            esc_html__( 'Price', 'event_espresso' ),
52
+                            esc_html__('Price', 'event_espresso'),
53 53
                             $EVT_ID
54 54
                         );
55 55
 					?>
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 						*/
68 68
 						echo apply_filters(
69 69
                             'FHEE__ticket_selector_chart_template__table_header_qty',
70
-                            esc_html__( 'Qty', 'event_espresso' ),
70
+                            esc_html__('Qty', 'event_espresso'),
71 71
                             $EVT_ID
72 72
                         );
73 73
 					?>
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 			</tr>
76 76
 		</thead>
77 77
 		<tbody>
78
-			<?php echo $ticket_row_html;?>
78
+			<?php echo $ticket_row_html; ?>
79 79
 		</tbody>
80 80
 	</table>
81 81
 	<?php
82
-	if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) {
83
-		if ( $prices_displayed_including_taxes ) {
84
-			$ticket_price_includes_taxes = esc_html__( '* price includes taxes', 'event_espresso' );
82
+	if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
83
+		if ($prices_displayed_including_taxes) {
84
+			$ticket_price_includes_taxes = esc_html__('* price includes taxes', 'event_espresso');
85 85
 		} else {
86
-			$ticket_price_includes_taxes = esc_html__( '* price does not include taxes', 'event_espresso' );
86
+			$ticket_price_includes_taxes = esc_html__('* price does not include taxes', 'event_espresso');
87 87
 		}
88
-		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>';
88
+		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>';
89 89
 	}
90 90
 	?>
91 91
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 
94 94
 
95 95
 <?php
96
-if ( $max_atndz > 0 ) {
96
+if ($max_atndz > 0) {
97 97
 	echo apply_filters(
98 98
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
99 99
         esc_html('')
100 100
 	);
101 101
 }
102
-if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
103
-	add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' );
102
+if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
103
+	add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true');
104 104
 }
105
-do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
106 105
\ No newline at end of file
106
+do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
107 107
\ No newline at end of file
Please login to merge, or discard this patch.