@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
8 | 8 | |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -24,101 +24,101 @@ discard block |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param \EE_Event $event |
|
29 | - * @param \EE_Transaction $transaction |
|
30 | - * @param \EE_Ticket $ticket |
|
31 | - * @param \EE_Line_Item $ticket_line_item |
|
32 | - * @param $reg_count |
|
33 | - * @param $reg_group_size |
|
34 | - * @return \EE_Registration |
|
35 | - * @throws \EE_Error |
|
36 | - * @throws UnexpectedEntityException |
|
37 | - */ |
|
38 | - public function create( |
|
39 | - \EE_Event $event, |
|
40 | - \EE_Transaction $transaction, |
|
41 | - \EE_Ticket $ticket, |
|
42 | - \EE_Line_Item $ticket_line_item, |
|
43 | - $reg_count, |
|
44 | - $reg_group_size |
|
45 | - ) { |
|
46 | - $registrations = $transaction->registrations(); |
|
47 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
48 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
49 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
50 | - // generate new EE_Registration |
|
51 | - $registration = \EE_Registration::new_instance( |
|
52 | - array( |
|
53 | - 'EVT_ID' => $event->ID(), |
|
54 | - 'TXN_ID' => $transaction->ID(), |
|
55 | - 'TKT_ID' => $ticket->ID(), |
|
56 | - 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
57 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
58 | - 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
59 | - 'REG_count' => $reg_count, |
|
60 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
61 | - 'REG_url_link' => $reg_url_link, |
|
62 | - 'REG_code' => $reg_code, |
|
63 | - ) |
|
64 | - ); |
|
65 | - if ( ! $registration instanceof \EE_Registration) { |
|
66 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
67 | - } |
|
68 | - // save registration so that we have an ID |
|
69 | - $registration->save(); |
|
70 | - // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
71 | - // because that is done as soon as the tickets are added/removed from the cart |
|
72 | - $registration->reserve_ticket(); |
|
73 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
74 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
75 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
76 | - $registration->save(); |
|
77 | - return $registration; |
|
78 | - } |
|
27 | + /** |
|
28 | + * @param \EE_Event $event |
|
29 | + * @param \EE_Transaction $transaction |
|
30 | + * @param \EE_Ticket $ticket |
|
31 | + * @param \EE_Line_Item $ticket_line_item |
|
32 | + * @param $reg_count |
|
33 | + * @param $reg_group_size |
|
34 | + * @return \EE_Registration |
|
35 | + * @throws \EE_Error |
|
36 | + * @throws UnexpectedEntityException |
|
37 | + */ |
|
38 | + public function create( |
|
39 | + \EE_Event $event, |
|
40 | + \EE_Transaction $transaction, |
|
41 | + \EE_Ticket $ticket, |
|
42 | + \EE_Line_Item $ticket_line_item, |
|
43 | + $reg_count, |
|
44 | + $reg_group_size |
|
45 | + ) { |
|
46 | + $registrations = $transaction->registrations(); |
|
47 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
48 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
49 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
50 | + // generate new EE_Registration |
|
51 | + $registration = \EE_Registration::new_instance( |
|
52 | + array( |
|
53 | + 'EVT_ID' => $event->ID(), |
|
54 | + 'TXN_ID' => $transaction->ID(), |
|
55 | + 'TKT_ID' => $ticket->ID(), |
|
56 | + 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
57 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
58 | + 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
59 | + 'REG_count' => $reg_count, |
|
60 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
61 | + 'REG_url_link' => $reg_url_link, |
|
62 | + 'REG_code' => $reg_code, |
|
63 | + ) |
|
64 | + ); |
|
65 | + if ( ! $registration instanceof \EE_Registration) { |
|
66 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
67 | + } |
|
68 | + // save registration so that we have an ID |
|
69 | + $registration->save(); |
|
70 | + // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
71 | + // because that is done as soon as the tickets are added/removed from the cart |
|
72 | + $registration->reserve_ticket(); |
|
73 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
74 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
75 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
76 | + $registration->save(); |
|
77 | + return $registration; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param \EE_Transaction $transaction |
|
84 | - * @param \EE_Ticket $ticket |
|
85 | - * @param \EE_Line_Item $ticket_line_item |
|
86 | - * @return float |
|
87 | - */ |
|
88 | - protected function resolveFinalPrice( |
|
89 | - \EE_Transaction $transaction, |
|
90 | - \EE_Ticket $ticket, |
|
91 | - \EE_Line_Item $ticket_line_item |
|
92 | - ) { |
|
93 | - $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
94 | - $transaction->total_line_item(), |
|
95 | - $ticket_line_item |
|
96 | - ); |
|
97 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
98 | - return (float)$final_price; |
|
99 | - } |
|
82 | + /** |
|
83 | + * @param \EE_Transaction $transaction |
|
84 | + * @param \EE_Ticket $ticket |
|
85 | + * @param \EE_Line_Item $ticket_line_item |
|
86 | + * @return float |
|
87 | + */ |
|
88 | + protected function resolveFinalPrice( |
|
89 | + \EE_Transaction $transaction, |
|
90 | + \EE_Ticket $ticket, |
|
91 | + \EE_Line_Item $ticket_line_item |
|
92 | + ) { |
|
93 | + $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
94 | + $transaction->total_line_item(), |
|
95 | + $ticket_line_item |
|
96 | + ); |
|
97 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
98 | + return (float)$final_price; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @param \EE_Registration[] $registrations |
|
105 | - * @param boolean $update_existing_registrations |
|
106 | - * @return int |
|
107 | - * @throws \EE_Error |
|
108 | - */ |
|
109 | - protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
110 | - { |
|
111 | - $new_reg_count = count($registrations) + 1; |
|
112 | - if ($update_existing_registrations) { |
|
113 | - foreach ($registrations as $registration) { |
|
114 | - if ($registration instanceof \EE_Registration) { |
|
115 | - $registration->set_count($new_reg_count); |
|
116 | - $registration->save(); |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
120 | - return $new_reg_count; |
|
121 | - } |
|
103 | + /** |
|
104 | + * @param \EE_Registration[] $registrations |
|
105 | + * @param boolean $update_existing_registrations |
|
106 | + * @return int |
|
107 | + * @throws \EE_Error |
|
108 | + */ |
|
109 | + protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
110 | + { |
|
111 | + $new_reg_count = count($registrations) + 1; |
|
112 | + if ($update_existing_registrations) { |
|
113 | + foreach ($registrations as $registration) { |
|
114 | + if ($registration instanceof \EE_Registration) { |
|
115 | + $registration->set_count($new_reg_count); |
|
116 | + $registration->save(); |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | + return $new_reg_count; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | 124 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | public function __construct($pm_instance = NULL) { |
23 | 23 | $this->_setup_properties(); |
24 | 24 | parent::__construct($pm_instance); |
25 | - $this->_gateway->set_unsupported_character_remover(new \EventEspresso\core\services\formatters\Windows1252()); |
|
25 | + $this->_gateway->set_unsupported_character_remover(new \EventEspresso\core\services\formatters\Windows1252()); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | $this->_gateway->set_template_helper( new EEH_Template() ); |
107 | 107 | $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
108 | 108 | $this->_gateway->set_money_helper( new EEH_Money() ); |
109 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
110 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
111 | - do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
109 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
110 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
111 | + do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
112 | 112 | } |
113 | 113 | if ( ! isset( $this->_has_billing_form ) ) { |
114 | 114 | // by default, On Site gateways have a billing form |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | //if we know who the attendee is, and this is a billing form |
283 | 283 | //that uses attendee info, populate it |
284 | 284 | if ( |
285 | - apply_filters( |
|
286 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
287 | - ( |
|
288 | - $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
289 | - && $transaction instanceof EE_Transaction |
|
290 | - && $transaction->primary_registration() instanceof EE_Registration |
|
291 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
292 | - ), |
|
293 | - $this->_billing_form, |
|
294 | - $transaction |
|
295 | - ) |
|
285 | + apply_filters( |
|
286 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
287 | + ( |
|
288 | + $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
289 | + && $transaction instanceof EE_Transaction |
|
290 | + && $transaction->primary_registration() instanceof EE_Registration |
|
291 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
292 | + ), |
|
293 | + $this->_billing_form, |
|
294 | + $transaction |
|
295 | + ) |
|
296 | 296 | ){ |
297 | 297 | $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
298 | 298 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @since $VID:$ |
17 | 17 | * |
18 | 18 | */ |
19 | -abstract class EE_PMT_Base{ |
|
19 | +abstract class EE_PMT_Base { |
|
20 | 20 | |
21 | 21 | const onsite = 'on-site'; |
22 | 22 | const offsite = 'off-site'; |
@@ -97,34 +97,34 @@ discard block |
||
97 | 97 | * @return EE_PMT_Base |
98 | 98 | */ |
99 | 99 | function __construct($pm_instance = NULL) { |
100 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
100 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
101 | 101 | $this->set_instance($pm_instance); |
102 | 102 | } |
103 | - if($this->_gateway){ |
|
104 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
105 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
106 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
107 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
108 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
103 | + if ($this->_gateway) { |
|
104 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
105 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
106 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
107 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
108 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
109 | 109 | $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
110 | 110 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
111 | - do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
111 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
112 | 112 | } |
113 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
113 | + if ( ! isset($this->_has_billing_form)) { |
|
114 | 114 | // by default, On Site gateways have a billing form |
115 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
116 | - $this->set_has_billing_form( true ); |
|
115 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
116 | + $this->set_has_billing_form(true); |
|
117 | 117 | } else { |
118 | - $this->set_has_billing_form( false ); |
|
118 | + $this->set_has_billing_form(false); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - if( ! $this->_pretty_name){ |
|
122 | + if ( ! $this->_pretty_name) { |
|
123 | 123 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
124 | 124 | } |
125 | 125 | //if the child didn't specify a default button, use the credit card one |
126 | - if( $this->_default_button_url === NULL){ |
|
127 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
126 | + if ($this->_default_button_url === NULL) { |
|
127 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @param boolean $has_billing_form |
135 | 135 | */ |
136 | - public function set_has_billing_form( $has_billing_form ) { |
|
137 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
136 | + public function set_has_billing_form($has_billing_form) { |
|
137 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * sets the file_folder property |
144 | 144 | */ |
145 | - protected function _set_file_folder(){ |
|
145 | + protected function _set_file_folder() { |
|
146 | 146 | $reflector = new ReflectionClass(get_class($this)); |
147 | 147 | $fn = $reflector->getFileName(); |
148 | - $this->_file_folder = dirname($fn).DS; |
|
148 | + $this->_file_folder = dirname($fn).DS; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * sets the file URL with a trailing slash for this PMT |
155 | 155 | */ |
156 | - protected function _set_file_url(){ |
|
157 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
158 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
159 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
156 | + protected function _set_file_url() { |
|
157 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
158 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
159 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
160 | 160 | $this->_file_url = $file_path; |
161 | 161 | } |
162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * Gets the default description on all payment methods of this type |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function default_description(){ |
|
167 | + public function default_description() { |
|
168 | 168 | return $this->_default_description; |
169 | 169 | } |
170 | 170 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * Returns the folder containing the PMT child class, with a trailing slash |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - public function file_folder(){ |
|
178 | - if( ! $this->_file_folder ) { |
|
177 | + public function file_folder() { |
|
178 | + if ( ! $this->_file_folder) { |
|
179 | 179 | $this->_set_file_folder(); |
180 | 180 | } |
181 | 181 | return $this->_file_folder; |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * @return string |
188 | 188 | */ |
189 | - public function file_url(){ |
|
190 | - if( ! $this->_file_url ) { |
|
189 | + public function file_url() { |
|
190 | + if ( ! $this->_file_url) { |
|
191 | 191 | $this->_set_file_url(); |
192 | 192 | } |
193 | 193 | return $this->_file_url; |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | * Its important teh payment method instance is set before |
201 | 201 | * @param EE_Payment_Method $payment_method_instance |
202 | 202 | */ |
203 | - function set_instance($payment_method_instance){ |
|
203 | + function set_instance($payment_method_instance) { |
|
204 | 204 | $this->_pm_instance = $payment_method_instance; |
205 | 205 | //if they have already requested the settings form, make sure its |
206 | 206 | //data matches this model object |
207 | - if($this->_settings_form){ |
|
207 | + if ($this->_settings_form) { |
|
208 | 208 | $this->settings_form()->populate_model_obj($payment_method_instance); |
209 | 209 | } |
210 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
210 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
211 | 211 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
212 | 212 | } |
213 | 213 | } |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | * Gets teh form for displaying to admins where they setup the payment method |
219 | 219 | * @return EE_Payment_Method_Form |
220 | 220 | */ |
221 | - function settings_form(){ |
|
222 | - if( ! $this->_settings_form){ |
|
221 | + function settings_form() { |
|
222 | + if ( ! $this->_settings_form) { |
|
223 | 223 | $this->_settings_form = $this->generate_new_settings_form(); |
224 | - $this->_settings_form->set_payment_method_type( $this ); |
|
224 | + $this->_settings_form->set_payment_method_type($this); |
|
225 | 225 | //if we have already assigned a model object to this pmt, make |
226 | 226 | //sure its reflected in teh form we just generated |
227 | - if($this->_pm_instance){ |
|
227 | + if ($this->_pm_instance) { |
|
228 | 228 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
229 | 229 | } |
230 | 230 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * this payment method type's settings form later in the request |
251 | 251 | * @param EE_Payment_Method_Form $form |
252 | 252 | */ |
253 | - public function set_settings_form($form){ |
|
253 | + public function set_settings_form($form) { |
|
254 | 254 | $this->_settings_form = $form; |
255 | 255 | } |
256 | 256 | |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | * @param array $extra_args |
274 | 274 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
275 | 275 | */ |
276 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
276 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
277 | 277 | // has billing form already been regenerated ? or overwrite cache? |
278 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
279 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
278 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
279 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
280 | 280 | } |
281 | 281 | //if we know who the attendee is, and this is a billing form |
282 | 282 | //that uses attendee info, populate it |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | $this->_billing_form, |
293 | 293 | $transaction |
294 | 294 | ) |
295 | - ){ |
|
296 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
295 | + ) { |
|
296 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
297 | 297 | } |
298 | 298 | return $this->_billing_form; |
299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param \EE_Transaction $transaction |
305 | 305 | * @return \EE_Billing_Info_Form |
306 | 306 | */ |
307 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
307 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
308 | 308 | |
309 | 309 | |
310 | 310 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param \EE_Billing_Info_Form $billing_form |
316 | 316 | * @return \EE_Billing_Info_Form |
317 | 317 | */ |
318 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
318 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
319 | 319 | return $billing_form; |
320 | 320 | } |
321 | 321 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * if you have form |
327 | 327 | * @param EE_Payment_Method $form |
328 | 328 | */ |
329 | - public function set_billing_form($form){ |
|
329 | + public function set_billing_form($form) { |
|
330 | 330 | $this->_billing_form = $form; |
331 | 331 | } |
332 | 332 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * Returns whether or not this payment method requires HTTPS to be used |
337 | 337 | * @return boolean |
338 | 338 | */ |
339 | - function requires_https(){ |
|
339 | + function requires_https() { |
|
340 | 340 | return $this->_requires_https; |
341 | 341 | } |
342 | 342 | |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | * @return EE_Payment |
355 | 355 | * @throws EE_Error |
356 | 356 | */ |
357 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
357 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
358 | 358 | // @todo: add surcharge for the payment method, if any |
359 | - if ( $this->_gateway ) { |
|
359 | + if ($this->_gateway) { |
|
360 | 360 | //there is a gateway, so we're going to make a payment object |
361 | 361 | //but wait! do they already have a payment in progress that we thought was failed? |
362 | 362 | $duplicate_properties = array( |
@@ -367,10 +367,10 @@ discard block |
||
367 | 367 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
368 | 368 | 'PAY_gateway_response' => null, |
369 | 369 | ); |
370 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
370 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
371 | 371 | //if we didn't already have a payment in progress for the same thing, |
372 | 372 | //then we actually want to make a new payment |
373 | - if ( ! $payment instanceof EE_Payment ){ |
|
373 | + if ( ! $payment instanceof EE_Payment) { |
|
374 | 374 | $payment = EE_Payment::new_instance( |
375 | 375 | array_merge( |
376 | 376 | $duplicate_properties, |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | } |
387 | 387 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
388 | 388 | $payment->save(); |
389 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
389 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
390 | 390 | |
391 | 391 | // Offsite Gateway |
392 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
392 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
393 | 393 | |
394 | 394 | $payment = $this->_gateway->set_redirection_info( |
395 | 395 | $payment, |
@@ -405,17 +405,17 @@ discard block |
||
405 | 405 | ); |
406 | 406 | $payment->save(); |
407 | 407 | // Onsite Gateway |
408 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
408 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
409 | 409 | |
410 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
410 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
411 | 411 | $payment->save(); |
412 | 412 | |
413 | 413 | } else { |
414 | 414 | throw new EE_Error( |
415 | 415 | sprintf( |
416 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
416 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
417 | 417 | get_class($this), |
418 | - gettype( $this->_gateway ) |
|
418 | + gettype($this->_gateway) |
|
419 | 419 | ) |
420 | 420 | ); |
421 | 421 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | // if there is billing info, clean it and save it now |
440 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
441 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
440 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
441 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | return $payment; |
@@ -451,10 +451,10 @@ discard block |
||
451 | 451 | * @param EE_Billing_Info_Form $billing_form |
452 | 452 | * @return array |
453 | 453 | */ |
454 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
455 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
456 | - return $billing_form->input_pretty_values( true ); |
|
457 | - }else{ |
|
454 | + protected function _get_billing_values_from_form($billing_form) { |
|
455 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
456 | + return $billing_form->input_pretty_values(true); |
|
457 | + } else { |
|
458 | 458 | return NULL; |
459 | 459 | } |
460 | 460 | } |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | * @return EE_Payment |
469 | 469 | * @throws EE_Error |
470 | 470 | */ |
471 | - public function handle_ipn($req_data,$transaction){ |
|
471 | + public function handle_ipn($req_data, $transaction) { |
|
472 | 472 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
473 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
474 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
473 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
474 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
475 | 475 | |
476 | 476 | } |
477 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
477 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
478 | 478 | return $payment; |
479 | 479 | } |
480 | 480 | |
@@ -487,22 +487,22 @@ discard block |
||
487 | 487 | * @param EE_Transaction $transaction |
488 | 488 | * @return boolean success |
489 | 489 | */ |
490 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
491 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
490 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
491 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
492 | 492 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
493 | 493 | return false; |
494 | 494 | } |
495 | 495 | $primary_reg = $transaction->primary_registration(); |
496 | - if( ! $primary_reg ){ |
|
496 | + if ( ! $primary_reg) { |
|
497 | 497 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
498 | 498 | return false; |
499 | 499 | } |
500 | 500 | $attendee = $primary_reg->attendee(); |
501 | - if( ! $attendee ){ |
|
501 | + if ( ! $attendee) { |
|
502 | 502 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
503 | 503 | return false; |
504 | 504 | } |
505 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
505 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
506 | 506 | |
507 | 507 | } |
508 | 508 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @param array $req_data |
516 | 516 | * @return EE_Payment |
517 | 517 | */ |
518 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
518 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
519 | 519 | return $transaction->last_payment(); |
520 | 520 | } |
521 | 521 | |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
533 | 533 | * @throws EE_Error |
534 | 534 | */ |
535 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
536 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
535 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
536 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param EE_Transaction $transaction |
550 | 550 | * @return EE_Payment |
551 | 551 | */ |
552 | - public function finalize_payment_for($transaction){ |
|
552 | + public function finalize_payment_for($transaction) { |
|
553 | 553 | return $transaction->last_payment(); |
554 | 554 | } |
555 | 555 | |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * Whether or not this payment method's gateway supports sending refund requests |
560 | 560 | * @return boolean |
561 | 561 | */ |
562 | - public function supports_sending_refunds(){ |
|
563 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
562 | + public function supports_sending_refunds() { |
|
563 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
564 | 564 | return $this->_gateway->supports_sending_refunds(); |
565 | - }else{ |
|
565 | + } else { |
|
566 | 566 | return false; |
567 | 567 | } |
568 | 568 | } |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | * @throws EE_Error |
577 | 577 | * @return EE_Payment |
578 | 578 | */ |
579 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
580 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
581 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
579 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
580 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
581 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
582 | 582 | } else { |
583 | 583 | throw new EE_Error( |
584 | 584 | sprintf( |
585 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
586 | - get_class( $this ) |
|
585 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
586 | + get_class($this) |
|
587 | 587 | ) |
588 | 588 | ); |
589 | 589 | } |
@@ -597,15 +597,15 @@ discard block |
||
597 | 597 | * @return string |
598 | 598 | * @throws EE_Error |
599 | 599 | */ |
600 | - public function payment_occurs(){ |
|
601 | - if( ! $this->_gateway){ |
|
600 | + public function payment_occurs() { |
|
601 | + if ( ! $this->_gateway) { |
|
602 | 602 | return EE_PMT_Base::offline; |
603 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
603 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
604 | 604 | return EE_PMT_Base::onsite; |
605 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
605 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
606 | 606 | return EE_PMT_Base::offsite; |
607 | - }else{ |
|
608 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
607 | + } else { |
|
608 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * @param EE_Payment $payment |
619 | 619 | * @return string |
620 | 620 | */ |
621 | - public function payment_overview_content(EE_Payment $payment){ |
|
622 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
621 | + public function payment_overview_content(EE_Payment $payment) { |
|
622 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @type array $template_args any arguments you want passed to the template file while rendering. |
633 | 633 | * Keys will be variable names and values with be their values. |
634 | 634 | */ |
635 | - public function help_tabs_config(){ |
|
635 | + public function help_tabs_config() { |
|
636 | 636 | return array(); |
637 | 637 | } |
638 | 638 | |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * the payment method's table's PMT_type column) |
644 | 644 | * @return string |
645 | 645 | */ |
646 | - public function system_name(){ |
|
646 | + public function system_name() { |
|
647 | 647 | $classname = get_class($this); |
648 | - return str_replace("EE_PMT_",'',$classname); |
|
648 | + return str_replace("EE_PMT_", '', $classname); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * A pretty i18n version of the PMT name |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public function pretty_name(){ |
|
657 | + public function pretty_name() { |
|
658 | 658 | return $this->_pretty_name; |
659 | 659 | } |
660 | 660 | |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * Gets the default absolute URL to the payment method type's button |
665 | 665 | * @return string |
666 | 666 | */ |
667 | - public function default_button_url(){ |
|
667 | + public function default_button_url() { |
|
668 | 668 | return $this->_default_button_url; |
669 | 669 | } |
670 | 670 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * Gets the gateway used by this payment method (if any) |
675 | 675 | * @return EE_Gateway |
676 | 676 | */ |
677 | - public function get_gateway(){ |
|
677 | + public function get_gateway() { |
|
678 | 678 | return $this->_gateway; |
679 | 679 | } |
680 | 680 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | /** |
684 | 684 | * @return string html for the link to a help tab |
685 | 685 | */ |
686 | - public function get_help_tab_link(){ |
|
687 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
686 | + public function get_help_tab_link() { |
|
687 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * Returns the name of the help tab for this PMT |
694 | 694 | * @return string |
695 | 695 | */ |
696 | - public function get_help_tab_name(){ |
|
697 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
696 | + public function get_help_tab_name() { |
|
697 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * this PMT by an admin |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - public function cap_name(){ |
|
706 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
705 | + public function cap_name() { |
|
706 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -715,9 +715,9 @@ discard block |
||
715 | 715 | * @param EE_Payment $payment |
716 | 716 | * @return void |
717 | 717 | */ |
718 | - public function update_txn_based_on_payment( $payment ){ |
|
719 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
720 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
718 | + public function update_txn_based_on_payment($payment) { |
|
719 | + if ($this->_gateway instanceof EE_Gateway) { |
|
720 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
721 | 721 | } |
722 | 722 | } |
723 | 723 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @return string |
733 | 733 | */ |
734 | 734 | public function introductory_html() { |
735 | - return EEH_Template::locate_template( $this->file_folder() . 'templates' . DS . strtolower( $this->system_name() ) . '_intro.template.php', array( 'pmt_obj' => $this, 'pm_instance' => $this->_pm_instance ) ); |
|
735 | + return EEH_Template::locate_template($this->file_folder().'templates'.DS.strtolower($this->system_name()).'_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 |
@@ -232,7 +232,7 @@ |
||
232 | 232 | * setTicketMinAndMax |
233 | 233 | * |
234 | 234 | * @param int $remaining |
235 | - * @return array |
|
235 | + * @return integer[] |
|
236 | 236 | * @throws EE_Error |
237 | 237 | */ |
238 | 238 | protected function setTicketMinAndMax($remaining) |
@@ -19,404 +19,404 @@ |
||
19 | 19 | class TicketSelectorRowStandard extends TicketSelectorRow |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var TicketDetails $ticket_details |
|
24 | - */ |
|
25 | - protected $ticket_details; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
29 | - */ |
|
30 | - protected $template_settings; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var \EE_Tax_Config $tax_settings |
|
34 | - */ |
|
35 | - protected $tax_settings; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var boolean $prices_displayed_including_taxes |
|
39 | - */ |
|
40 | - protected $prices_displayed_including_taxes; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int $row |
|
44 | - */ |
|
45 | - protected $row; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int $cols |
|
49 | - */ |
|
50 | - protected $cols; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var boolean $hidden_input_qty |
|
54 | - */ |
|
55 | - protected $hidden_input_qty; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $ticket_datetime_classes |
|
59 | - */ |
|
60 | - protected $ticket_datetime_classes; |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * TicketDetails constructor. |
|
66 | - * |
|
67 | - * @param TicketDetails $ticket_details |
|
68 | - * @param \EE_Tax_Config $tax_settings |
|
69 | - * @param int $total_tickets |
|
70 | - * @param int $max_atndz |
|
71 | - * @param int $row |
|
72 | - * @param int $cols |
|
73 | - * @param boolean $required_ticket_sold_out |
|
74 | - * @param string $event_status |
|
75 | - * @param string $ticket_datetime_classes |
|
76 | - * @throws EE_Error |
|
77 | - * @throws UnexpectedEntityException |
|
78 | - */ |
|
79 | - public function __construct( |
|
80 | - TicketDetails $ticket_details, |
|
81 | - \EE_Tax_Config $tax_settings, |
|
82 | - $total_tickets, |
|
83 | - $max_atndz, |
|
84 | - $row, |
|
85 | - $cols, |
|
86 | - $required_ticket_sold_out, |
|
87 | - $event_status, |
|
88 | - $ticket_datetime_classes |
|
89 | - ) { |
|
90 | - $this->ticket = $ticket_details->getTicket(); |
|
91 | - $this->ticket_details = $ticket_details; |
|
92 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
93 | - $this->tax_settings = $tax_settings; |
|
94 | - $this->total_tickets = $total_tickets; |
|
95 | - $this->max_atndz = $max_atndz; |
|
96 | - $this->row = $row; |
|
97 | - $this->cols = $cols; |
|
98 | - $this->date_format = $ticket_details->getDateFormat(); |
|
99 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
100 | - parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * other ticket rows will need to know if a required ticket is sold out, |
|
107 | - * so that they are not offered for sale |
|
108 | - * |
|
109 | - * @return boolean |
|
110 | - */ |
|
111 | - public function getRequiredTicketSoldOut() |
|
112 | - { |
|
113 | - return $this->required_ticket_sold_out; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getCols() |
|
122 | - { |
|
123 | - return $this->cols; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * getHtml |
|
130 | - * |
|
131 | - * @return string |
|
132 | - * @throws EE_Error |
|
133 | - */ |
|
134 | - public function getHtml() |
|
135 | - { |
|
136 | - $min = 0; |
|
137 | - $max = $this->ticket->max(); |
|
138 | - $remaining = $this->ticket->remaining(); |
|
139 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
140 | - list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
141 | - } else { |
|
142 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
143 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
144 | - ? $this->ticket->start_date() |
|
145 | - : $this->required_ticket_sold_out; |
|
146 | - } |
|
147 | - list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
148 | - list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
149 | - /** |
|
150 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
151 | - * something else if they want. |
|
152 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
153 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
154 | - * current row. |
|
155 | - * |
|
156 | - * @var string|bool |
|
157 | - */ |
|
158 | - $ticket_selector_row_html = apply_filters( |
|
159 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
160 | - false, |
|
161 | - $this->ticket, |
|
162 | - $max, |
|
163 | - $min, |
|
164 | - $this->required_ticket_sold_out, |
|
165 | - $ticket_price, |
|
166 | - $ticket_bundle, |
|
167 | - $ticket_status, |
|
168 | - $status_class |
|
169 | - ); |
|
170 | - if ($ticket_selector_row_html !== false) { |
|
171 | - return $ticket_selector_row_html; |
|
172 | - } |
|
173 | - $ticket_selector_row_html = \EEH_HTML::tr( |
|
174 | - '', '', |
|
175 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
176 | - ); |
|
177 | - /** |
|
178 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
179 | - * row to do something else if they want. |
|
180 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
181 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
182 | - * current row. |
|
183 | - * |
|
184 | - * @var string|bool |
|
185 | - */ |
|
186 | - $new_row_cells_content = apply_filters( |
|
187 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
188 | - false, |
|
189 | - $this->ticket, |
|
190 | - $max, |
|
191 | - $min, |
|
192 | - $this->required_ticket_sold_out, |
|
193 | - $ticket_price, |
|
194 | - $ticket_bundle, |
|
195 | - $ticket_status, |
|
196 | - $status_class |
|
197 | - ); |
|
198 | - if ($new_row_cells_content !== false && $this->max_atndz === 1) { |
|
199 | - return $ticket_selector_row_html |
|
200 | - . $new_row_cells_content |
|
201 | - . $this->ticketQtyAndIdHiddenInputs() |
|
202 | - . \EEH_HTML::trx(); |
|
203 | - } |
|
204 | - if ($new_row_cells_content !== false) { |
|
205 | - return $ticket_selector_row_html |
|
206 | - . $new_row_cells_content |
|
207 | - . \EEH_HTML::trx(); |
|
208 | - } |
|
209 | - $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
210 | - |
|
211 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
212 | - $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
213 | - $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
214 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
215 | - if (empty($this->ticket_status_display)) { |
|
216 | - if ($this->max_atndz === 1) { |
|
217 | - // only ONE attendee is allowed to register at a time |
|
218 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
219 | - } else if ($max > 0) { |
|
220 | - $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
221 | - } |
|
222 | - } |
|
223 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
224 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
225 | - $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
226 | - $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
227 | - $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
228 | - |
|
229 | - |
|
230 | - $this->row++; |
|
231 | - return $ticket_selector_row_html; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * setTicketMinAndMax |
|
238 | - * |
|
239 | - * @param int $remaining |
|
240 | - * @return array |
|
241 | - * @throws EE_Error |
|
242 | - */ |
|
243 | - protected function setTicketMinAndMax($remaining) |
|
244 | - { |
|
245 | - // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
246 | - $max = min($remaining, $this->max_atndz); |
|
247 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
248 | - // however, the max still can't be higher than what was just set above |
|
249 | - $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
250 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
251 | - $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
252 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
253 | - $min = $this->ticket->required() ? max($min, 1) : $min; |
|
254 | - return array($min, $max); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * getTicketPriceDetails |
|
261 | - * |
|
262 | - * @return array |
|
263 | - * @throws EE_Error |
|
264 | - */ |
|
265 | - protected function getTicketPriceDetails() |
|
266 | - { |
|
267 | - $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
268 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
269 | - : $this->ticket->get_ticket_subtotal(); |
|
270 | - $ticket_bundle = false; |
|
271 | - $ticket_min = $this->ticket->min(); |
|
272 | - // for ticket bundles, set min and max qty the same |
|
273 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
274 | - $ticket_price *= $ticket_min; |
|
275 | - $ticket_bundle = true; |
|
276 | - } |
|
277 | - $ticket_price = apply_filters( |
|
278 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
279 | - $ticket_price, |
|
280 | - $this->ticket |
|
281 | - ); |
|
282 | - return array($ticket_price, $ticket_bundle); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * ticketNameTableCell |
|
290 | - * |
|
291 | - * @return string |
|
292 | - * @throws EE_Error |
|
293 | - */ |
|
294 | - protected function ticketNameTableCell() |
|
295 | - { |
|
296 | - $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
297 | - $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
298 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
299 | - if ($this->ticket->required()) { |
|
300 | - $html .= \EEH_HTML::p( |
|
301 | - apply_filters( |
|
302 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
303 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
304 | - ), |
|
305 | - '', 'ticket-required-pg' |
|
306 | - ); |
|
307 | - } |
|
308 | - $html .= \EEH_HTML::tdx(); |
|
309 | - return $html; |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * ticketPriceTableCell |
|
316 | - * |
|
317 | - * @param float $ticket_price |
|
318 | - * @param bool $ticket_bundle |
|
319 | - * @return string |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
323 | - { |
|
324 | - $html = ''; |
|
325 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
326 | - $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
327 | - $html .= \EEH_Template::format_currency($ticket_price); |
|
328 | - $html .= $this->ticket->taxable() |
|
329 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
330 | - : ''; |
|
331 | - $html .= ' '; |
|
332 | - $html .= \EEH_HTML::span( |
|
333 | - $ticket_bundle |
|
334 | - ? apply_filters( |
|
335 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
336 | - __(' / bundle', 'event_espresso') |
|
337 | - ) |
|
338 | - : apply_filters( |
|
339 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
340 | - __('', 'event_espresso') |
|
341 | - ), |
|
342 | - '', 'smaller-text no-bold' |
|
343 | - ); |
|
344 | - $html .= ' '; |
|
345 | - $html .= \EEH_HTML::tdx(); |
|
346 | - $this->cols++; |
|
347 | - } |
|
348 | - return $html; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * onlyOneAttendeeCanRegister |
|
355 | - * |
|
356 | - * @return string |
|
357 | - */ |
|
358 | - protected function onlyOneAttendeeCanRegister() |
|
359 | - { |
|
360 | - // display submit button since we have tickets available |
|
361 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
362 | - $this->hidden_input_qty = false; |
|
363 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
364 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
365 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
366 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
367 | - $html .= ' title=""/>'; |
|
368 | - return $html; |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * ticketQuantitySelector |
|
375 | - * |
|
376 | - * @param int $min |
|
377 | - * @param int $max |
|
378 | - * @return string |
|
379 | - * @throws EE_Error |
|
380 | - */ |
|
381 | - protected function ticketQuantitySelector($min = 0, $max = 0) |
|
382 | - { |
|
383 | - // display submit button since we have tickets available |
|
384 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
385 | - $this->hidden_input_qty = false; |
|
386 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
387 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
388 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
389 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
390 | - if ($min !== 0 && ! $this->ticket->required()) { |
|
391 | - $html .= '<option value="0"> 0 </option>'; |
|
392 | - } |
|
393 | - // offer ticket quantities from the min to the max |
|
394 | - for ($i = $min; $i <= $max; $i++) { |
|
395 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
396 | - } |
|
397 | - $html .= '</select>'; |
|
398 | - return $html; |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * getHiddenInputs |
|
405 | - * |
|
406 | - * @return string |
|
407 | - * @throws EE_Error |
|
408 | - */ |
|
409 | - protected function ticketQtyAndIdHiddenInputs() |
|
410 | - { |
|
411 | - $html = ''; |
|
412 | - // depending on group reg we need to change the format for qty |
|
413 | - if ($this->hidden_input_qty) { |
|
414 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
415 | - } |
|
416 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
417 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
418 | - return $html; |
|
419 | - } |
|
22 | + /** |
|
23 | + * @var TicketDetails $ticket_details |
|
24 | + */ |
|
25 | + protected $ticket_details; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
29 | + */ |
|
30 | + protected $template_settings; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var \EE_Tax_Config $tax_settings |
|
34 | + */ |
|
35 | + protected $tax_settings; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var boolean $prices_displayed_including_taxes |
|
39 | + */ |
|
40 | + protected $prices_displayed_including_taxes; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int $row |
|
44 | + */ |
|
45 | + protected $row; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int $cols |
|
49 | + */ |
|
50 | + protected $cols; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var boolean $hidden_input_qty |
|
54 | + */ |
|
55 | + protected $hidden_input_qty; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $ticket_datetime_classes |
|
59 | + */ |
|
60 | + protected $ticket_datetime_classes; |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * TicketDetails constructor. |
|
66 | + * |
|
67 | + * @param TicketDetails $ticket_details |
|
68 | + * @param \EE_Tax_Config $tax_settings |
|
69 | + * @param int $total_tickets |
|
70 | + * @param int $max_atndz |
|
71 | + * @param int $row |
|
72 | + * @param int $cols |
|
73 | + * @param boolean $required_ticket_sold_out |
|
74 | + * @param string $event_status |
|
75 | + * @param string $ticket_datetime_classes |
|
76 | + * @throws EE_Error |
|
77 | + * @throws UnexpectedEntityException |
|
78 | + */ |
|
79 | + public function __construct( |
|
80 | + TicketDetails $ticket_details, |
|
81 | + \EE_Tax_Config $tax_settings, |
|
82 | + $total_tickets, |
|
83 | + $max_atndz, |
|
84 | + $row, |
|
85 | + $cols, |
|
86 | + $required_ticket_sold_out, |
|
87 | + $event_status, |
|
88 | + $ticket_datetime_classes |
|
89 | + ) { |
|
90 | + $this->ticket = $ticket_details->getTicket(); |
|
91 | + $this->ticket_details = $ticket_details; |
|
92 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
93 | + $this->tax_settings = $tax_settings; |
|
94 | + $this->total_tickets = $total_tickets; |
|
95 | + $this->max_atndz = $max_atndz; |
|
96 | + $this->row = $row; |
|
97 | + $this->cols = $cols; |
|
98 | + $this->date_format = $ticket_details->getDateFormat(); |
|
99 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
100 | + parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * other ticket rows will need to know if a required ticket is sold out, |
|
107 | + * so that they are not offered for sale |
|
108 | + * |
|
109 | + * @return boolean |
|
110 | + */ |
|
111 | + public function getRequiredTicketSoldOut() |
|
112 | + { |
|
113 | + return $this->required_ticket_sold_out; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getCols() |
|
122 | + { |
|
123 | + return $this->cols; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * getHtml |
|
130 | + * |
|
131 | + * @return string |
|
132 | + * @throws EE_Error |
|
133 | + */ |
|
134 | + public function getHtml() |
|
135 | + { |
|
136 | + $min = 0; |
|
137 | + $max = $this->ticket->max(); |
|
138 | + $remaining = $this->ticket->remaining(); |
|
139 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
140 | + list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
141 | + } else { |
|
142 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
143 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
144 | + ? $this->ticket->start_date() |
|
145 | + : $this->required_ticket_sold_out; |
|
146 | + } |
|
147 | + list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
148 | + list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
149 | + /** |
|
150 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
151 | + * something else if they want. |
|
152 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
153 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
154 | + * current row. |
|
155 | + * |
|
156 | + * @var string|bool |
|
157 | + */ |
|
158 | + $ticket_selector_row_html = apply_filters( |
|
159 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
160 | + false, |
|
161 | + $this->ticket, |
|
162 | + $max, |
|
163 | + $min, |
|
164 | + $this->required_ticket_sold_out, |
|
165 | + $ticket_price, |
|
166 | + $ticket_bundle, |
|
167 | + $ticket_status, |
|
168 | + $status_class |
|
169 | + ); |
|
170 | + if ($ticket_selector_row_html !== false) { |
|
171 | + return $ticket_selector_row_html; |
|
172 | + } |
|
173 | + $ticket_selector_row_html = \EEH_HTML::tr( |
|
174 | + '', '', |
|
175 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
176 | + ); |
|
177 | + /** |
|
178 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
179 | + * row to do something else if they want. |
|
180 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
181 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
182 | + * current row. |
|
183 | + * |
|
184 | + * @var string|bool |
|
185 | + */ |
|
186 | + $new_row_cells_content = apply_filters( |
|
187 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
188 | + false, |
|
189 | + $this->ticket, |
|
190 | + $max, |
|
191 | + $min, |
|
192 | + $this->required_ticket_sold_out, |
|
193 | + $ticket_price, |
|
194 | + $ticket_bundle, |
|
195 | + $ticket_status, |
|
196 | + $status_class |
|
197 | + ); |
|
198 | + if ($new_row_cells_content !== false && $this->max_atndz === 1) { |
|
199 | + return $ticket_selector_row_html |
|
200 | + . $new_row_cells_content |
|
201 | + . $this->ticketQtyAndIdHiddenInputs() |
|
202 | + . \EEH_HTML::trx(); |
|
203 | + } |
|
204 | + if ($new_row_cells_content !== false) { |
|
205 | + return $ticket_selector_row_html |
|
206 | + . $new_row_cells_content |
|
207 | + . \EEH_HTML::trx(); |
|
208 | + } |
|
209 | + $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
210 | + |
|
211 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
212 | + $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
213 | + $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
214 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
215 | + if (empty($this->ticket_status_display)) { |
|
216 | + if ($this->max_atndz === 1) { |
|
217 | + // only ONE attendee is allowed to register at a time |
|
218 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
219 | + } else if ($max > 0) { |
|
220 | + $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
221 | + } |
|
222 | + } |
|
223 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
224 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
225 | + $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
226 | + $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
227 | + $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
228 | + |
|
229 | + |
|
230 | + $this->row++; |
|
231 | + return $ticket_selector_row_html; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * setTicketMinAndMax |
|
238 | + * |
|
239 | + * @param int $remaining |
|
240 | + * @return array |
|
241 | + * @throws EE_Error |
|
242 | + */ |
|
243 | + protected function setTicketMinAndMax($remaining) |
|
244 | + { |
|
245 | + // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
246 | + $max = min($remaining, $this->max_atndz); |
|
247 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
248 | + // however, the max still can't be higher than what was just set above |
|
249 | + $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
250 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
251 | + $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
252 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
253 | + $min = $this->ticket->required() ? max($min, 1) : $min; |
|
254 | + return array($min, $max); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * getTicketPriceDetails |
|
261 | + * |
|
262 | + * @return array |
|
263 | + * @throws EE_Error |
|
264 | + */ |
|
265 | + protected function getTicketPriceDetails() |
|
266 | + { |
|
267 | + $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
268 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
269 | + : $this->ticket->get_ticket_subtotal(); |
|
270 | + $ticket_bundle = false; |
|
271 | + $ticket_min = $this->ticket->min(); |
|
272 | + // for ticket bundles, set min and max qty the same |
|
273 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
274 | + $ticket_price *= $ticket_min; |
|
275 | + $ticket_bundle = true; |
|
276 | + } |
|
277 | + $ticket_price = apply_filters( |
|
278 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
279 | + $ticket_price, |
|
280 | + $this->ticket |
|
281 | + ); |
|
282 | + return array($ticket_price, $ticket_bundle); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * ticketNameTableCell |
|
290 | + * |
|
291 | + * @return string |
|
292 | + * @throws EE_Error |
|
293 | + */ |
|
294 | + protected function ticketNameTableCell() |
|
295 | + { |
|
296 | + $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
297 | + $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
298 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
299 | + if ($this->ticket->required()) { |
|
300 | + $html .= \EEH_HTML::p( |
|
301 | + apply_filters( |
|
302 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
303 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
304 | + ), |
|
305 | + '', 'ticket-required-pg' |
|
306 | + ); |
|
307 | + } |
|
308 | + $html .= \EEH_HTML::tdx(); |
|
309 | + return $html; |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * ticketPriceTableCell |
|
316 | + * |
|
317 | + * @param float $ticket_price |
|
318 | + * @param bool $ticket_bundle |
|
319 | + * @return string |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
323 | + { |
|
324 | + $html = ''; |
|
325 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
326 | + $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
327 | + $html .= \EEH_Template::format_currency($ticket_price); |
|
328 | + $html .= $this->ticket->taxable() |
|
329 | + ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
330 | + : ''; |
|
331 | + $html .= ' '; |
|
332 | + $html .= \EEH_HTML::span( |
|
333 | + $ticket_bundle |
|
334 | + ? apply_filters( |
|
335 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
336 | + __(' / bundle', 'event_espresso') |
|
337 | + ) |
|
338 | + : apply_filters( |
|
339 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
340 | + __('', 'event_espresso') |
|
341 | + ), |
|
342 | + '', 'smaller-text no-bold' |
|
343 | + ); |
|
344 | + $html .= ' '; |
|
345 | + $html .= \EEH_HTML::tdx(); |
|
346 | + $this->cols++; |
|
347 | + } |
|
348 | + return $html; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * onlyOneAttendeeCanRegister |
|
355 | + * |
|
356 | + * @return string |
|
357 | + */ |
|
358 | + protected function onlyOneAttendeeCanRegister() |
|
359 | + { |
|
360 | + // display submit button since we have tickets available |
|
361 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
362 | + $this->hidden_input_qty = false; |
|
363 | + $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
364 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
365 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
366 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
367 | + $html .= ' title=""/>'; |
|
368 | + return $html; |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * ticketQuantitySelector |
|
375 | + * |
|
376 | + * @param int $min |
|
377 | + * @param int $max |
|
378 | + * @return string |
|
379 | + * @throws EE_Error |
|
380 | + */ |
|
381 | + protected function ticketQuantitySelector($min = 0, $max = 0) |
|
382 | + { |
|
383 | + // display submit button since we have tickets available |
|
384 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
385 | + $this->hidden_input_qty = false; |
|
386 | + $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
387 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
388 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
389 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
390 | + if ($min !== 0 && ! $this->ticket->required()) { |
|
391 | + $html .= '<option value="0"> 0 </option>'; |
|
392 | + } |
|
393 | + // offer ticket quantities from the min to the max |
|
394 | + for ($i = $min; $i <= $max; $i++) { |
|
395 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
396 | + } |
|
397 | + $html .= '</select>'; |
|
398 | + return $html; |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * getHiddenInputs |
|
405 | + * |
|
406 | + * @return string |
|
407 | + * @throws EE_Error |
|
408 | + */ |
|
409 | + protected function ticketQtyAndIdHiddenInputs() |
|
410 | + { |
|
411 | + $html = ''; |
|
412 | + // depending on group reg we need to change the format for qty |
|
413 | + if ($this->hidden_input_qty) { |
|
414 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
415 | + } |
|
416 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
417 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
418 | + return $html; |
|
419 | + } |
|
420 | 420 | |
421 | 421 | } |
422 | 422 | // End of file TicketSelectorRowStandard.php |
@@ -18,54 +18,54 @@ |
||
18 | 18 | class TicketSelectorSimple extends TicketSelector |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var \EE_Ticket $ticket |
|
23 | - */ |
|
24 | - protected $ticket; |
|
21 | + /** |
|
22 | + * @var \EE_Ticket $ticket |
|
23 | + */ |
|
24 | + protected $ticket; |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * TicketSelectorSimple constructor. |
|
30 | - * |
|
31 | - * @param \EE_Event $event |
|
32 | - * @param \EE_Ticket $ticket |
|
33 | - * @param int $max_attendees |
|
34 | - * @param array $template_args |
|
35 | - */ |
|
36 | - public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
37 | - { |
|
38 | - $this->ticket = $ticket; |
|
39 | - parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
40 | - } |
|
28 | + /** |
|
29 | + * TicketSelectorSimple constructor. |
|
30 | + * |
|
31 | + * @param \EE_Event $event |
|
32 | + * @param \EE_Ticket $ticket |
|
33 | + * @param int $max_attendees |
|
34 | + * @param array $template_args |
|
35 | + */ |
|
36 | + public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
37 | + { |
|
38 | + $this->ticket = $ticket; |
|
39 | + parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * sets any and all template args that are required for this Ticket Selector |
|
46 | - * |
|
47 | - * @return void |
|
48 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
49 | - * @throws \EE_Error |
|
50 | - */ |
|
51 | - protected function addTemplateArgs() |
|
52 | - { |
|
53 | - unset($this->template_args['tickets']); |
|
54 | - $this->template_args['ticket'] = $this->ticket; |
|
55 | - $ticket_selector_row = new TicketSelectorRowSimple( |
|
56 | - $this->ticket, |
|
57 | - $this->max_attendees, |
|
58 | - $this->template_args['date_format'], |
|
59 | - $this->template_args['event_status'] |
|
60 | - ); |
|
61 | - $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
62 | - $ticket_selector_row->setupTicketStatusDisplay(); |
|
63 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
64 | - if (empty($this->template_args['ticket_status_display'])) { |
|
65 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
66 | - } |
|
67 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
68 | - } |
|
44 | + /** |
|
45 | + * sets any and all template args that are required for this Ticket Selector |
|
46 | + * |
|
47 | + * @return void |
|
48 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
49 | + * @throws \EE_Error |
|
50 | + */ |
|
51 | + protected function addTemplateArgs() |
|
52 | + { |
|
53 | + unset($this->template_args['tickets']); |
|
54 | + $this->template_args['ticket'] = $this->ticket; |
|
55 | + $ticket_selector_row = new TicketSelectorRowSimple( |
|
56 | + $this->ticket, |
|
57 | + $this->max_attendees, |
|
58 | + $this->template_args['date_format'], |
|
59 | + $this->template_args['event_status'] |
|
60 | + ); |
|
61 | + $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
62 | + $ticket_selector_row->setupTicketStatusDisplay(); |
|
63 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
64 | + if (empty($this->template_args['ticket_status_display'])) { |
|
65 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
66 | + } |
|
67 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | 71 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | if (empty($this->template_args['ticket_status_display'])) { |
65 | 65 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
66 | 66 | } |
67 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
67 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 |
@@ -18,15 +18,15 @@ |
||
18 | 18 | class TicketSelectorRowSimple extends TicketSelectorRow |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @throws EE_Error |
|
23 | - */ |
|
24 | - public function setupTicketStatusDisplay() |
|
25 | - { |
|
26 | - $remaining = $this->ticket->remaining(); |
|
27 | - list($tkt_status, $ticket_status) = $this->getTicketStatusClasses($remaining); |
|
28 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
29 | - } |
|
21 | + /** |
|
22 | + * @throws EE_Error |
|
23 | + */ |
|
24 | + public function setupTicketStatusDisplay() |
|
25 | + { |
|
26 | + $remaining = $this->ticket->remaining(); |
|
27 | + list($tkt_status, $ticket_status) = $this->getTicketStatusClasses($remaining); |
|
28 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -19,249 +19,249 @@ |
||
19 | 19 | abstract class TicketSelectorRow |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var \EE_Ticket $ticket |
|
24 | - */ |
|
25 | - protected $ticket; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var int $total_tickets |
|
29 | - */ |
|
30 | - protected $total_tickets; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var int $max_atndz |
|
34 | - */ |
|
35 | - protected $max_atndz; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $date_format |
|
39 | - */ |
|
40 | - protected $date_format; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int $EVT_ID |
|
44 | - */ |
|
45 | - protected $EVT_ID; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $event_status |
|
49 | - */ |
|
50 | - protected $event_status; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var boolean $required_ticket_sold_out |
|
54 | - */ |
|
55 | - protected $required_ticket_sold_out; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $ticket_status_display |
|
59 | - */ |
|
60 | - protected $ticket_status_display; |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @param \EE_Ticket $ticket |
|
66 | - * @param int $max_atndz |
|
67 | - * @param string $date_format |
|
68 | - * @param string $event_status |
|
69 | - * @param bool $required_ticket_sold_out |
|
70 | - * @throws EE_Error |
|
71 | - * @throws UnexpectedEntityException |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - \EE_Ticket $ticket, |
|
75 | - $max_atndz, |
|
76 | - $date_format, |
|
77 | - $event_status, |
|
78 | - $required_ticket_sold_out = false |
|
79 | - ) { |
|
80 | - $this->ticket = $ticket; |
|
81 | - $this->max_atndz = $max_atndz; |
|
82 | - $this->date_format = $date_format; |
|
83 | - $this->EVT_ID = $this->ticket->get_event_ID(); |
|
84 | - $this->event_status = $event_status; |
|
85 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * getTicketStatusClasses |
|
92 | - * |
|
93 | - * @param int $remaining |
|
94 | - * @return array |
|
95 | - * @throws EE_Error |
|
96 | - */ |
|
97 | - protected function getTicketStatusClasses($remaining = 0) |
|
98 | - { |
|
99 | - // if a previous required ticket with the same sale start date is sold out, |
|
100 | - // then mark this ticket as sold out as well. |
|
101 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
102 | - $tkt_status = $this->required_ticket_sold_out !== false |
|
103 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
104 | - ? \EE_Ticket::sold_out |
|
105 | - : $this->ticket->ticket_status(); |
|
106 | - $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
107 | - ? \EE_Ticket::sold_out |
|
108 | - : $tkt_status; |
|
109 | - // check ticket status |
|
110 | - switch ($tkt_status) { |
|
111 | - // sold_out |
|
112 | - case \EE_Ticket::sold_out : |
|
113 | - $ticket_status = 'ticket-sales-sold-out'; |
|
114 | - $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
115 | - break; |
|
116 | - // expired |
|
117 | - case \EE_Ticket::expired : |
|
118 | - $ticket_status = 'ticket-sales-expired'; |
|
119 | - $status_class = 'ticket-sales-expired lt-grey-text'; |
|
120 | - break; |
|
121 | - // archived |
|
122 | - case \EE_Ticket::archived : |
|
123 | - $ticket_status = 'archived-ticket'; |
|
124 | - $status_class = 'archived-ticket hidden'; |
|
125 | - break; |
|
126 | - // pending |
|
127 | - case \EE_Ticket::pending : |
|
128 | - $ticket_status = 'ticket-pending'; |
|
129 | - $status_class = 'ticket-pending'; |
|
130 | - break; |
|
131 | - // onsale |
|
132 | - case \EE_Ticket::onsale : |
|
133 | - default : |
|
134 | - $ticket_status = 'ticket-on-sale'; |
|
135 | - $status_class = 'ticket-on-sale'; |
|
136 | - break; |
|
137 | - } |
|
138 | - $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
139 | - return array($tkt_status, $ticket_status, $status_class); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function getTicketStatusDisplay() |
|
147 | - { |
|
148 | - return $this->ticket_status_display; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * setTicketStatusDisplay |
|
155 | - * |
|
156 | - * @param string $tkt_status |
|
157 | - * @param string $ticket_status |
|
158 | - * @param int $remaining |
|
159 | - * @throws EE_Error |
|
160 | - */ |
|
161 | - protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
162 | - $this->ticket_status_display = ''; |
|
163 | - // now depending on the ticket and other circumstances... |
|
164 | - if ($this->max_atndz === 0) { |
|
165 | - // registration is CLOSED because admin set max attendees to ZERO |
|
166 | - $this->ticket_status_display = $this->registrationClosed(); |
|
167 | - } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
168 | - // SOLD OUT - no tickets remaining |
|
169 | - $this->ticket_status_display = $this->ticketsSoldOut(); |
|
170 | - } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
171 | - // expired or archived ticket |
|
172 | - $this->ticket_status_display = $ticket_status; |
|
173 | - } else if ($tkt_status === \EE_Ticket::pending) { |
|
174 | - // ticket not on sale yet |
|
175 | - $this->ticket_status_display = $this->ticketsSalesPending(); |
|
176 | - } else if ($this->ticket->min() > $remaining) { |
|
177 | - // min qty purchasable is less than tickets available |
|
178 | - $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * registrationClosed |
|
186 | - */ |
|
187 | - protected function registrationClosed() |
|
188 | - { |
|
189 | - return \EEH_HTML::span( |
|
190 | - apply_filters( |
|
191 | - 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
192 | - __('Closed', 'event_espresso') |
|
193 | - ), |
|
194 | - '', 'sold-out' |
|
195 | - ); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * ticketsSoldOut |
|
202 | - */ |
|
203 | - protected function ticketsSoldOut() |
|
204 | - { |
|
205 | - return \EEH_HTML::span( |
|
206 | - apply_filters( |
|
207 | - 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
208 | - __('Sold Out', 'event_espresso') |
|
209 | - ), |
|
210 | - '', 'sold-out' |
|
211 | - ); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * ticketsSalesPending |
|
218 | - * |
|
219 | - * @throws EE_Error |
|
220 | - */ |
|
221 | - protected function ticketsSalesPending() |
|
222 | - { |
|
223 | - return \EEH_HTML::span( |
|
224 | - \EEH_HTML::span( |
|
225 | - apply_filters( |
|
226 | - 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
227 | - __('Goes On Sale', 'event_espresso') |
|
228 | - ), |
|
229 | - '', 'ticket-pending' |
|
230 | - ) |
|
231 | - . \EEH_HTML::br() |
|
232 | - . \EEH_HTML::span( |
|
233 | - $this->ticket->get_i18n_datetime( |
|
234 | - 'TKT_start_date', |
|
235 | - apply_filters( |
|
236 | - 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
237 | - $this->date_format |
|
238 | - ) |
|
239 | - ), |
|
240 | - '', 'small-text' |
|
241 | - ), |
|
242 | - '', 'ticket-pending-pg' |
|
243 | - ); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * notEnoughTicketsAvailable |
|
250 | - */ |
|
251 | - protected function notEnoughTicketsAvailable() |
|
252 | - { |
|
253 | - return \EEH_HTML::div( |
|
254 | - \EEH_HTML::span( |
|
255 | - apply_filters( |
|
256 | - 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
257 | - __('Not Available', 'event_espresso') |
|
258 | - ), |
|
259 | - '', 'archived-ticket small-text' |
|
260 | - ) |
|
261 | - . \EEH_HTML::br(), |
|
262 | - '', 'archived-ticket-pg' |
|
263 | - ); |
|
264 | - } |
|
22 | + /** |
|
23 | + * @var \EE_Ticket $ticket |
|
24 | + */ |
|
25 | + protected $ticket; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var int $total_tickets |
|
29 | + */ |
|
30 | + protected $total_tickets; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var int $max_atndz |
|
34 | + */ |
|
35 | + protected $max_atndz; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $date_format |
|
39 | + */ |
|
40 | + protected $date_format; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int $EVT_ID |
|
44 | + */ |
|
45 | + protected $EVT_ID; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $event_status |
|
49 | + */ |
|
50 | + protected $event_status; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var boolean $required_ticket_sold_out |
|
54 | + */ |
|
55 | + protected $required_ticket_sold_out; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $ticket_status_display |
|
59 | + */ |
|
60 | + protected $ticket_status_display; |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @param \EE_Ticket $ticket |
|
66 | + * @param int $max_atndz |
|
67 | + * @param string $date_format |
|
68 | + * @param string $event_status |
|
69 | + * @param bool $required_ticket_sold_out |
|
70 | + * @throws EE_Error |
|
71 | + * @throws UnexpectedEntityException |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + \EE_Ticket $ticket, |
|
75 | + $max_atndz, |
|
76 | + $date_format, |
|
77 | + $event_status, |
|
78 | + $required_ticket_sold_out = false |
|
79 | + ) { |
|
80 | + $this->ticket = $ticket; |
|
81 | + $this->max_atndz = $max_atndz; |
|
82 | + $this->date_format = $date_format; |
|
83 | + $this->EVT_ID = $this->ticket->get_event_ID(); |
|
84 | + $this->event_status = $event_status; |
|
85 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * getTicketStatusClasses |
|
92 | + * |
|
93 | + * @param int $remaining |
|
94 | + * @return array |
|
95 | + * @throws EE_Error |
|
96 | + */ |
|
97 | + protected function getTicketStatusClasses($remaining = 0) |
|
98 | + { |
|
99 | + // if a previous required ticket with the same sale start date is sold out, |
|
100 | + // then mark this ticket as sold out as well. |
|
101 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
102 | + $tkt_status = $this->required_ticket_sold_out !== false |
|
103 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
104 | + ? \EE_Ticket::sold_out |
|
105 | + : $this->ticket->ticket_status(); |
|
106 | + $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
107 | + ? \EE_Ticket::sold_out |
|
108 | + : $tkt_status; |
|
109 | + // check ticket status |
|
110 | + switch ($tkt_status) { |
|
111 | + // sold_out |
|
112 | + case \EE_Ticket::sold_out : |
|
113 | + $ticket_status = 'ticket-sales-sold-out'; |
|
114 | + $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
115 | + break; |
|
116 | + // expired |
|
117 | + case \EE_Ticket::expired : |
|
118 | + $ticket_status = 'ticket-sales-expired'; |
|
119 | + $status_class = 'ticket-sales-expired lt-grey-text'; |
|
120 | + break; |
|
121 | + // archived |
|
122 | + case \EE_Ticket::archived : |
|
123 | + $ticket_status = 'archived-ticket'; |
|
124 | + $status_class = 'archived-ticket hidden'; |
|
125 | + break; |
|
126 | + // pending |
|
127 | + case \EE_Ticket::pending : |
|
128 | + $ticket_status = 'ticket-pending'; |
|
129 | + $status_class = 'ticket-pending'; |
|
130 | + break; |
|
131 | + // onsale |
|
132 | + case \EE_Ticket::onsale : |
|
133 | + default : |
|
134 | + $ticket_status = 'ticket-on-sale'; |
|
135 | + $status_class = 'ticket-on-sale'; |
|
136 | + break; |
|
137 | + } |
|
138 | + $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
139 | + return array($tkt_status, $ticket_status, $status_class); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function getTicketStatusDisplay() |
|
147 | + { |
|
148 | + return $this->ticket_status_display; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * setTicketStatusDisplay |
|
155 | + * |
|
156 | + * @param string $tkt_status |
|
157 | + * @param string $ticket_status |
|
158 | + * @param int $remaining |
|
159 | + * @throws EE_Error |
|
160 | + */ |
|
161 | + protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
162 | + $this->ticket_status_display = ''; |
|
163 | + // now depending on the ticket and other circumstances... |
|
164 | + if ($this->max_atndz === 0) { |
|
165 | + // registration is CLOSED because admin set max attendees to ZERO |
|
166 | + $this->ticket_status_display = $this->registrationClosed(); |
|
167 | + } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
168 | + // SOLD OUT - no tickets remaining |
|
169 | + $this->ticket_status_display = $this->ticketsSoldOut(); |
|
170 | + } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
171 | + // expired or archived ticket |
|
172 | + $this->ticket_status_display = $ticket_status; |
|
173 | + } else if ($tkt_status === \EE_Ticket::pending) { |
|
174 | + // ticket not on sale yet |
|
175 | + $this->ticket_status_display = $this->ticketsSalesPending(); |
|
176 | + } else if ($this->ticket->min() > $remaining) { |
|
177 | + // min qty purchasable is less than tickets available |
|
178 | + $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * registrationClosed |
|
186 | + */ |
|
187 | + protected function registrationClosed() |
|
188 | + { |
|
189 | + return \EEH_HTML::span( |
|
190 | + apply_filters( |
|
191 | + 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
192 | + __('Closed', 'event_espresso') |
|
193 | + ), |
|
194 | + '', 'sold-out' |
|
195 | + ); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * ticketsSoldOut |
|
202 | + */ |
|
203 | + protected function ticketsSoldOut() |
|
204 | + { |
|
205 | + return \EEH_HTML::span( |
|
206 | + apply_filters( |
|
207 | + 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
208 | + __('Sold Out', 'event_espresso') |
|
209 | + ), |
|
210 | + '', 'sold-out' |
|
211 | + ); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * ticketsSalesPending |
|
218 | + * |
|
219 | + * @throws EE_Error |
|
220 | + */ |
|
221 | + protected function ticketsSalesPending() |
|
222 | + { |
|
223 | + return \EEH_HTML::span( |
|
224 | + \EEH_HTML::span( |
|
225 | + apply_filters( |
|
226 | + 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
227 | + __('Goes On Sale', 'event_espresso') |
|
228 | + ), |
|
229 | + '', 'ticket-pending' |
|
230 | + ) |
|
231 | + . \EEH_HTML::br() |
|
232 | + . \EEH_HTML::span( |
|
233 | + $this->ticket->get_i18n_datetime( |
|
234 | + 'TKT_start_date', |
|
235 | + apply_filters( |
|
236 | + 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
237 | + $this->date_format |
|
238 | + ) |
|
239 | + ), |
|
240 | + '', 'small-text' |
|
241 | + ), |
|
242 | + '', 'ticket-pending-pg' |
|
243 | + ); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * notEnoughTicketsAvailable |
|
250 | + */ |
|
251 | + protected function notEnoughTicketsAvailable() |
|
252 | + { |
|
253 | + return \EEH_HTML::div( |
|
254 | + \EEH_HTML::span( |
|
255 | + apply_filters( |
|
256 | + 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
257 | + __('Not Available', 'event_espresso') |
|
258 | + ), |
|
259 | + '', 'archived-ticket small-text' |
|
260 | + ) |
|
261 | + . \EEH_HTML::br(), |
|
262 | + '', 'archived-ticket-pg' |
|
263 | + ); |
|
264 | + } |
|
265 | 265 | |
266 | 266 | |
267 | 267 |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @access public |
51 | 51 | * @param \WP $WP |
52 | 52 | */ |
53 | - public function run( WP $WP ) { |
|
54 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
53 | + public function run(WP $WP) { |
|
54 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * @param array $attributes |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function process_shortcode( $attributes = array() ) { |
|
66 | - extract( $attributes ); |
|
67 | - $event_id = isset( $event_id ) ? $event_id : 0; |
|
68 | - $event = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $event_id ); |
|
65 | + public function process_shortcode($attributes = array()) { |
|
66 | + extract($attributes); |
|
67 | + $event_id = isset($event_id) ? $event_id : 0; |
|
68 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
69 | 69 | ob_start(); |
70 | - do_action( 'AHEE__EES_Espresso_Ticket_Selector__process_shortcode__begin', $event_id ); |
|
71 | - espresso_ticket_selector( $event ); |
|
72 | - do_action( 'AHEE__EES_Espresso_Ticket_Selector__process_shortcode__end', $event_id ); |
|
70 | + do_action('AHEE__EES_Espresso_Ticket_Selector__process_shortcode__begin', $event_id); |
|
71 | + espresso_ticket_selector($event); |
|
72 | + do_action('AHEE__EES_Espresso_Ticket_Selector__process_shortcode__end', $event_id); |
|
73 | 73 | return ob_get_clean(); |
74 | 74 | } |
75 | 75 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | function ee_resurse_into_array($data) { |
9 | 9 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {//is_object($incomplete_class) actually returns false, hence why we check for it |
10 | - $data = (array)$data; |
|
10 | + $data = (array) $data; |
|
11 | 11 | } |
12 | 12 | if (is_array($data)) { |
13 | 13 | if (EEH_Array::is_associative_array($data)) { |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | ?> |
20 | 20 | <tr> |
21 | 21 | <td> |
22 | - <?php echo $data_key;?> |
|
22 | + <?php echo $data_key; ?> |
|
23 | 23 | </td> |
24 | 24 | <td> |
25 | - <?php ee_resurse_into_array($data_values);?> |
|
25 | + <?php ee_resurse_into_array($data_values); ?> |
|
26 | 26 | </td> |
27 | 27 | </tr> |
28 | 28 | <?php |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | <ul> |
37 | 37 | <?php |
38 | 38 | foreach ($data as $datum) { |
39 | - echo "<li>";ee_resurse_into_array($datum);echo "</li>"; |
|
39 | + echo "<li>"; ee_resurse_into_array($datum); echo "</li>"; |
|
40 | 40 | }?> |
41 | 41 | </ul> |
42 | 42 | <?php |
43 | 43 | } |
44 | - }else { |
|
44 | + } else { |
|
45 | 45 | //simple value |
46 | 46 | echo $data; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | ?> |
50 | 50 | <h1> |
51 | - <?php _e("System Information", "event_espresso");?> <a href="<?php echo $download_system_status_url;?>" class="button-secondary"><?php esc_html_e( 'Download to File', 'event_espresso' );?></a> |
|
51 | + <?php _e("System Information", "event_espresso"); ?> <a href="<?php echo $download_system_status_url; ?>" class="button-secondary"><?php esc_html_e('Download to File', 'event_espresso'); ?></a> |
|
52 | 52 | </h1> |
53 | 53 | <div class="padding"> |
54 | 54 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | <?php |
57 | 57 | foreach ($system_stati as $status_category_slug => $data) { |
58 | 58 | if (is_object($data)) { |
59 | - $data = (array)$data; |
|
59 | + $data = (array) $data; |
|
60 | 60 | } |
61 | 61 | ?> |
62 | 62 | <thead> |