@@ -17,356 +17,356 @@ |
||
17 | 17 | class TicketSelectorRowStandard extends TicketSelectorRow |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TicketDetails $ticket_details |
|
22 | - */ |
|
23 | - protected $ticket_details; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | - */ |
|
28 | - protected $template_settings; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var EE_Tax_Config $tax_settings |
|
32 | - */ |
|
33 | - protected $tax_settings; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var boolean $prices_displayed_including_taxes |
|
37 | - */ |
|
38 | - protected $prices_displayed_including_taxes; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var int $row |
|
42 | - */ |
|
43 | - protected $row; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var int $cols |
|
47 | - */ |
|
48 | - protected $cols; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var boolean $hidden_input_qty |
|
52 | - */ |
|
53 | - protected $hidden_input_qty; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $ticket_datetime_classes |
|
57 | - */ |
|
58 | - protected $ticket_datetime_classes; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * TicketDetails constructor. |
|
63 | - * |
|
64 | - * @param TicketDetails $ticket_details |
|
65 | - * @param EE_Tax_Config $tax_settings |
|
66 | - * @param int $total_tickets |
|
67 | - * @param int $max_attendees |
|
68 | - * @param int $row |
|
69 | - * @param int $cols |
|
70 | - * @param boolean $required_ticket_sold_out |
|
71 | - * @param string $event_status |
|
72 | - * @param string $ticket_datetime_classes |
|
73 | - * @throws EE_Error |
|
74 | - * @throws UnexpectedEntityException |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - TicketDetails $ticket_details, |
|
78 | - EE_Tax_Config $tax_settings, |
|
79 | - $total_tickets, |
|
80 | - $max_attendees, |
|
81 | - $row, |
|
82 | - $cols, |
|
83 | - $required_ticket_sold_out, |
|
84 | - $event_status, |
|
85 | - $ticket_datetime_classes |
|
86 | - ) { |
|
87 | - $this->ticket_details = $ticket_details; |
|
88 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | - $this->tax_settings = $tax_settings; |
|
90 | - $this->row = $row; |
|
91 | - $this->cols = $cols; |
|
92 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | - parent::__construct( |
|
94 | - $ticket_details->getTicket(), |
|
95 | - $max_attendees, |
|
96 | - $ticket_details->getDateFormat(), |
|
97 | - $event_status, |
|
98 | - $required_ticket_sold_out, |
|
99 | - $total_tickets |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * other ticket rows will need to know if a required ticket is sold out, |
|
106 | - * so that they are not offered for sale |
|
107 | - * |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - public function getRequiredTicketSoldOut() |
|
111 | - { |
|
112 | - return $this->required_ticket_sold_out; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return int |
|
118 | - */ |
|
119 | - public function getCols() |
|
120 | - { |
|
121 | - return $this->cols; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * getHtml |
|
127 | - * |
|
128 | - * @return string |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function getHtml() |
|
132 | - { |
|
133 | - $this->min = 0; |
|
134 | - $this->max = $this->ticket->max(); |
|
135 | - $remaining = $this->ticket->remaining(); |
|
136 | - $this->setTicketMinAndMax($remaining); |
|
137 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
138 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
139 | - ? $this->ticket->start_date() |
|
140 | - : $this->required_ticket_sold_out; |
|
141 | - $this->setTicketPriceDetails(); |
|
142 | - $this->setTicketStatusClasses($remaining); |
|
143 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
144 | - if ($filtered_row_html !== false) { |
|
145 | - return $filtered_row_html; |
|
146 | - } |
|
147 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
148 | - '', |
|
149 | - '', |
|
150 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
151 | - . espresso_get_object_css_class($this->ticket) |
|
152 | - ); |
|
153 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
154 | - if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
155 | - return $ticket_selector_row_html |
|
156 | - . $filtered_row_content |
|
157 | - . $this->ticketQtyAndIdHiddenInputs() |
|
158 | - . EEH_HTML::trx(); |
|
159 | - } |
|
160 | - if ($filtered_row_content !== false) { |
|
161 | - return $ticket_selector_row_html |
|
162 | - . $filtered_row_content |
|
163 | - . EEH_HTML::trx(); |
|
164 | - } |
|
165 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
166 | - |
|
167 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
168 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
169 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
170 | - '', |
|
171 | - '', |
|
172 | - 'tckt-slctr-tbl-td-qty cntr', |
|
173 | - '', |
|
174 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
175 | - ); |
|
176 | - $this->setTicketStatusDisplay($remaining); |
|
177 | - if (empty($this->ticket_status_display)) { |
|
178 | - if ($this->max_attendees === 1) { |
|
179 | - // only ONE attendee is allowed to register at a time |
|
180 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
181 | - } elseif ($this->max > 0) { |
|
182 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
183 | - } |
|
184 | - } |
|
185 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
186 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
187 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
188 | - $this->ticket_price, |
|
189 | - $remaining, |
|
190 | - $this->cols |
|
191 | - ); |
|
192 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
193 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
194 | - |
|
195 | - |
|
196 | - $this->row++; |
|
197 | - return $ticket_selector_row_html; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * getTicketPriceDetails |
|
203 | - * |
|
204 | - * @return void |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - protected function setTicketPriceDetails() |
|
208 | - { |
|
209 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
210 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
211 | - : $this->ticket->get_ticket_subtotal(); |
|
212 | - $this->ticket_bundle = false; |
|
213 | - $ticket_min = $this->ticket->min(); |
|
214 | - // for ticket bundles, set min and max qty the same |
|
215 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
216 | - $this->ticket_price *= $ticket_min; |
|
217 | - $this->ticket_bundle = true; |
|
218 | - } |
|
219 | - $this->ticket_price = apply_filters( |
|
220 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
221 | - $this->ticket_price, |
|
222 | - $this->ticket |
|
223 | - ); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * ticketNameTableCell |
|
229 | - * |
|
230 | - * @return string |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - protected function ticketNameTableCell() |
|
234 | - { |
|
235 | - $html = EEH_HTML::td( |
|
236 | - '', |
|
237 | - '', |
|
238 | - 'tckt-slctr-tbl-td-name', |
|
239 | - '', |
|
240 | - 'headers="details-' . $this->EVT_ID . '"' |
|
241 | - ); |
|
242 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
243 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
244 | - if ($this->ticket->required()) { |
|
245 | - $html .= EEH_HTML::p( |
|
246 | - apply_filters( |
|
247 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
248 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
249 | - ), |
|
250 | - '', |
|
251 | - 'ticket-required-pg' |
|
252 | - ); |
|
253 | - } |
|
254 | - $html .= EEH_HTML::tdx(); |
|
255 | - return $html; |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * ticketPriceTableCell |
|
261 | - * |
|
262 | - * @return string |
|
263 | - * @throws EE_Error |
|
264 | - */ |
|
265 | - protected function ticketPriceTableCell() |
|
266 | - { |
|
267 | - $html = ''; |
|
268 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
269 | - $html .= EEH_HTML::td( |
|
270 | - '', |
|
271 | - '', |
|
272 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
273 | - '', |
|
274 | - 'headers="price-' . $this->EVT_ID . '"' |
|
275 | - ); |
|
276 | - $html .= \EEH_Template::format_currency($this->ticket_price); |
|
277 | - $html .= $this->ticket->taxable() |
|
278 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
279 | - : ''; |
|
280 | - $html .= ' '; |
|
281 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
282 | - $html .= EEH_HTML::span( |
|
283 | - $this->ticket_bundle |
|
284 | - ? apply_filters( |
|
285 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
286 | - __(' / bundle', 'event_espresso') |
|
287 | - ) |
|
288 | - : apply_filters( |
|
289 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
290 | - __('', 'event_espresso') |
|
291 | - ), |
|
292 | - '', |
|
293 | - 'smaller-text no-bold' |
|
294 | - ); |
|
295 | - $html .= ' '; |
|
296 | - $html .= EEH_HTML::tdx(); |
|
297 | - $this->cols++; |
|
298 | - } |
|
299 | - return $html; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * onlyOneAttendeeCanRegister |
|
305 | - * |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - protected function onlyOneAttendeeCanRegister() |
|
309 | - { |
|
310 | - // display submit button since we have tickets available |
|
311 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
312 | - $this->hidden_input_qty = false; |
|
313 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
314 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
315 | - $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
316 | - $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
317 | - $html .= ' id="' . $id . '"'; |
|
318 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
319 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
320 | - $html .= ' title=""/>'; |
|
321 | - return $html; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * ticketQuantitySelector |
|
327 | - * |
|
328 | - * @return string |
|
329 | - * @throws EE_Error |
|
330 | - */ |
|
331 | - protected function ticketQuantitySelector() |
|
332 | - { |
|
333 | - // display submit button since we have tickets available |
|
334 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
335 | - $this->hidden_input_qty = false; |
|
336 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
337 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
338 | - $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
339 | - $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
340 | - $html .= ' id="' . $id . '"'; |
|
341 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
342 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
343 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
344 | - $html .= '<option value="0"> 0 </option>'; |
|
345 | - } |
|
346 | - // offer ticket quantities from the min to the max |
|
347 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
348 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
349 | - } |
|
350 | - $html .= '</select>'; |
|
351 | - return $html; |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * getHiddenInputs |
|
357 | - * |
|
358 | - * @return string |
|
359 | - * @throws EE_Error |
|
360 | - */ |
|
361 | - protected function ticketQtyAndIdHiddenInputs() |
|
362 | - { |
|
363 | - $html = ''; |
|
364 | - // depending on group reg we need to change the format for qty |
|
365 | - if ($this->hidden_input_qty) { |
|
366 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
367 | - } |
|
368 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
369 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
370 | - return $html; |
|
371 | - } |
|
20 | + /** |
|
21 | + * @var TicketDetails $ticket_details |
|
22 | + */ |
|
23 | + protected $ticket_details; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | + */ |
|
28 | + protected $template_settings; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var EE_Tax_Config $tax_settings |
|
32 | + */ |
|
33 | + protected $tax_settings; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var boolean $prices_displayed_including_taxes |
|
37 | + */ |
|
38 | + protected $prices_displayed_including_taxes; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var int $row |
|
42 | + */ |
|
43 | + protected $row; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var int $cols |
|
47 | + */ |
|
48 | + protected $cols; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var boolean $hidden_input_qty |
|
52 | + */ |
|
53 | + protected $hidden_input_qty; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $ticket_datetime_classes |
|
57 | + */ |
|
58 | + protected $ticket_datetime_classes; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * TicketDetails constructor. |
|
63 | + * |
|
64 | + * @param TicketDetails $ticket_details |
|
65 | + * @param EE_Tax_Config $tax_settings |
|
66 | + * @param int $total_tickets |
|
67 | + * @param int $max_attendees |
|
68 | + * @param int $row |
|
69 | + * @param int $cols |
|
70 | + * @param boolean $required_ticket_sold_out |
|
71 | + * @param string $event_status |
|
72 | + * @param string $ticket_datetime_classes |
|
73 | + * @throws EE_Error |
|
74 | + * @throws UnexpectedEntityException |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + TicketDetails $ticket_details, |
|
78 | + EE_Tax_Config $tax_settings, |
|
79 | + $total_tickets, |
|
80 | + $max_attendees, |
|
81 | + $row, |
|
82 | + $cols, |
|
83 | + $required_ticket_sold_out, |
|
84 | + $event_status, |
|
85 | + $ticket_datetime_classes |
|
86 | + ) { |
|
87 | + $this->ticket_details = $ticket_details; |
|
88 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | + $this->tax_settings = $tax_settings; |
|
90 | + $this->row = $row; |
|
91 | + $this->cols = $cols; |
|
92 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | + parent::__construct( |
|
94 | + $ticket_details->getTicket(), |
|
95 | + $max_attendees, |
|
96 | + $ticket_details->getDateFormat(), |
|
97 | + $event_status, |
|
98 | + $required_ticket_sold_out, |
|
99 | + $total_tickets |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * other ticket rows will need to know if a required ticket is sold out, |
|
106 | + * so that they are not offered for sale |
|
107 | + * |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + public function getRequiredTicketSoldOut() |
|
111 | + { |
|
112 | + return $this->required_ticket_sold_out; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return int |
|
118 | + */ |
|
119 | + public function getCols() |
|
120 | + { |
|
121 | + return $this->cols; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * getHtml |
|
127 | + * |
|
128 | + * @return string |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function getHtml() |
|
132 | + { |
|
133 | + $this->min = 0; |
|
134 | + $this->max = $this->ticket->max(); |
|
135 | + $remaining = $this->ticket->remaining(); |
|
136 | + $this->setTicketMinAndMax($remaining); |
|
137 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
138 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
139 | + ? $this->ticket->start_date() |
|
140 | + : $this->required_ticket_sold_out; |
|
141 | + $this->setTicketPriceDetails(); |
|
142 | + $this->setTicketStatusClasses($remaining); |
|
143 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
144 | + if ($filtered_row_html !== false) { |
|
145 | + return $filtered_row_html; |
|
146 | + } |
|
147 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
148 | + '', |
|
149 | + '', |
|
150 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
151 | + . espresso_get_object_css_class($this->ticket) |
|
152 | + ); |
|
153 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
154 | + if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
155 | + return $ticket_selector_row_html |
|
156 | + . $filtered_row_content |
|
157 | + . $this->ticketQtyAndIdHiddenInputs() |
|
158 | + . EEH_HTML::trx(); |
|
159 | + } |
|
160 | + if ($filtered_row_content !== false) { |
|
161 | + return $ticket_selector_row_html |
|
162 | + . $filtered_row_content |
|
163 | + . EEH_HTML::trx(); |
|
164 | + } |
|
165 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
166 | + |
|
167 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
168 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
169 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
170 | + '', |
|
171 | + '', |
|
172 | + 'tckt-slctr-tbl-td-qty cntr', |
|
173 | + '', |
|
174 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
175 | + ); |
|
176 | + $this->setTicketStatusDisplay($remaining); |
|
177 | + if (empty($this->ticket_status_display)) { |
|
178 | + if ($this->max_attendees === 1) { |
|
179 | + // only ONE attendee is allowed to register at a time |
|
180 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
181 | + } elseif ($this->max > 0) { |
|
182 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
183 | + } |
|
184 | + } |
|
185 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
186 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
187 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
188 | + $this->ticket_price, |
|
189 | + $remaining, |
|
190 | + $this->cols |
|
191 | + ); |
|
192 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
193 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
194 | + |
|
195 | + |
|
196 | + $this->row++; |
|
197 | + return $ticket_selector_row_html; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * getTicketPriceDetails |
|
203 | + * |
|
204 | + * @return void |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + protected function setTicketPriceDetails() |
|
208 | + { |
|
209 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
210 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
211 | + : $this->ticket->get_ticket_subtotal(); |
|
212 | + $this->ticket_bundle = false; |
|
213 | + $ticket_min = $this->ticket->min(); |
|
214 | + // for ticket bundles, set min and max qty the same |
|
215 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
216 | + $this->ticket_price *= $ticket_min; |
|
217 | + $this->ticket_bundle = true; |
|
218 | + } |
|
219 | + $this->ticket_price = apply_filters( |
|
220 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
221 | + $this->ticket_price, |
|
222 | + $this->ticket |
|
223 | + ); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * ticketNameTableCell |
|
229 | + * |
|
230 | + * @return string |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + protected function ticketNameTableCell() |
|
234 | + { |
|
235 | + $html = EEH_HTML::td( |
|
236 | + '', |
|
237 | + '', |
|
238 | + 'tckt-slctr-tbl-td-name', |
|
239 | + '', |
|
240 | + 'headers="details-' . $this->EVT_ID . '"' |
|
241 | + ); |
|
242 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
243 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
244 | + if ($this->ticket->required()) { |
|
245 | + $html .= EEH_HTML::p( |
|
246 | + apply_filters( |
|
247 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
248 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
249 | + ), |
|
250 | + '', |
|
251 | + 'ticket-required-pg' |
|
252 | + ); |
|
253 | + } |
|
254 | + $html .= EEH_HTML::tdx(); |
|
255 | + return $html; |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * ticketPriceTableCell |
|
261 | + * |
|
262 | + * @return string |
|
263 | + * @throws EE_Error |
|
264 | + */ |
|
265 | + protected function ticketPriceTableCell() |
|
266 | + { |
|
267 | + $html = ''; |
|
268 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
269 | + $html .= EEH_HTML::td( |
|
270 | + '', |
|
271 | + '', |
|
272 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
273 | + '', |
|
274 | + 'headers="price-' . $this->EVT_ID . '"' |
|
275 | + ); |
|
276 | + $html .= \EEH_Template::format_currency($this->ticket_price); |
|
277 | + $html .= $this->ticket->taxable() |
|
278 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
279 | + : ''; |
|
280 | + $html .= ' '; |
|
281 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
282 | + $html .= EEH_HTML::span( |
|
283 | + $this->ticket_bundle |
|
284 | + ? apply_filters( |
|
285 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
286 | + __(' / bundle', 'event_espresso') |
|
287 | + ) |
|
288 | + : apply_filters( |
|
289 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
290 | + __('', 'event_espresso') |
|
291 | + ), |
|
292 | + '', |
|
293 | + 'smaller-text no-bold' |
|
294 | + ); |
|
295 | + $html .= ' '; |
|
296 | + $html .= EEH_HTML::tdx(); |
|
297 | + $this->cols++; |
|
298 | + } |
|
299 | + return $html; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * onlyOneAttendeeCanRegister |
|
305 | + * |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + protected function onlyOneAttendeeCanRegister() |
|
309 | + { |
|
310 | + // display submit button since we have tickets available |
|
311 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
312 | + $this->hidden_input_qty = false; |
|
313 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
314 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
315 | + $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
316 | + $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
317 | + $html .= ' id="' . $id . '"'; |
|
318 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
319 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
320 | + $html .= ' title=""/>'; |
|
321 | + return $html; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * ticketQuantitySelector |
|
327 | + * |
|
328 | + * @return string |
|
329 | + * @throws EE_Error |
|
330 | + */ |
|
331 | + protected function ticketQuantitySelector() |
|
332 | + { |
|
333 | + // display submit button since we have tickets available |
|
334 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
335 | + $this->hidden_input_qty = false; |
|
336 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
337 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
338 | + $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
339 | + $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
340 | + $html .= ' id="' . $id . '"'; |
|
341 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
342 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
343 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
344 | + $html .= '<option value="0"> 0 </option>'; |
|
345 | + } |
|
346 | + // offer ticket quantities from the min to the max |
|
347 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
348 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
349 | + } |
|
350 | + $html .= '</select>'; |
|
351 | + return $html; |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * getHiddenInputs |
|
357 | + * |
|
358 | + * @return string |
|
359 | + * @throws EE_Error |
|
360 | + */ |
|
361 | + protected function ticketQtyAndIdHiddenInputs() |
|
362 | + { |
|
363 | + $html = ''; |
|
364 | + // depending on group reg we need to change the format for qty |
|
365 | + if ($this->hidden_input_qty) { |
|
366 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
367 | + } |
|
368 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
369 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
370 | + return $html; |
|
371 | + } |
|
372 | 372 | } |
@@ -15,87 +15,87 @@ |
||
15 | 15 | class EventMutation |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Maps the GraphQL input to a format that the model functions can use |
|
20 | - * |
|
21 | - * @param array $input Data coming from the GraphQL mutation query input |
|
22 | - * @param string $mutation_name Name of the mutation being performed |
|
23 | - * @return array |
|
24 | - * @throws Exception |
|
25 | - */ |
|
26 | - public static function prepareFields(array $input, string $mutation_name): array |
|
27 | - { |
|
28 | - $args = []; |
|
29 | - |
|
30 | - if (array_key_exists('allowDonations', $input)) { |
|
31 | - $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
32 | - } |
|
33 | - |
|
34 | - if (array_key_exists('allowOverflow', $input)) { |
|
35 | - $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
36 | - } |
|
37 | - |
|
38 | - if (array_key_exists('altRegPage', $input)) { |
|
39 | - $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
40 | - } |
|
41 | - |
|
42 | - if (! empty($input['defaultRegStatus'])) { |
|
43 | - $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
44 | - } |
|
45 | - |
|
46 | - if (! empty($input['description'])) { |
|
47 | - $args['EVT_desc'] = wp_kses_post($input['description']); |
|
48 | - } |
|
49 | - |
|
50 | - if (array_key_exists('displayDescription', $input)) { |
|
51 | - $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
52 | - } |
|
53 | - |
|
54 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
55 | - $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
56 | - } |
|
57 | - |
|
58 | - if (! empty($input['maxRegistrations'])) { |
|
59 | - $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
60 | - } |
|
61 | - |
|
62 | - if (array_key_exists('memberOnly', $input)) { |
|
63 | - $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
64 | - } |
|
65 | - |
|
66 | - if (! empty($input['name'])) { |
|
67 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
68 | - } |
|
69 | - |
|
70 | - if (array_key_exists('order', $input)) { |
|
71 | - $args['EVT_order'] = absint($input['order']); |
|
72 | - } |
|
73 | - |
|
74 | - if (array_key_exists('phoneNumber', $input)) { |
|
75 | - $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
76 | - } |
|
77 | - |
|
78 | - if (! empty($input['shortDescription'])) { |
|
79 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, $context = 'db'); |
|
80 | - } |
|
81 | - |
|
82 | - if (! empty($input['timezoneString'])) { |
|
83 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
84 | - } |
|
85 | - |
|
86 | - if (! empty($input['visibleOn'])) { |
|
87 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
88 | - } |
|
89 | - |
|
90 | - if (! empty($input['manager'])) { |
|
91 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
92 | - $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
93 | - } |
|
94 | - |
|
95 | - return apply_filters( |
|
96 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
97 | - $args, |
|
98 | - $input |
|
99 | - ); |
|
100 | - } |
|
18 | + /** |
|
19 | + * Maps the GraphQL input to a format that the model functions can use |
|
20 | + * |
|
21 | + * @param array $input Data coming from the GraphQL mutation query input |
|
22 | + * @param string $mutation_name Name of the mutation being performed |
|
23 | + * @return array |
|
24 | + * @throws Exception |
|
25 | + */ |
|
26 | + public static function prepareFields(array $input, string $mutation_name): array |
|
27 | + { |
|
28 | + $args = []; |
|
29 | + |
|
30 | + if (array_key_exists('allowDonations', $input)) { |
|
31 | + $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
32 | + } |
|
33 | + |
|
34 | + if (array_key_exists('allowOverflow', $input)) { |
|
35 | + $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
36 | + } |
|
37 | + |
|
38 | + if (array_key_exists('altRegPage', $input)) { |
|
39 | + $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
40 | + } |
|
41 | + |
|
42 | + if (! empty($input['defaultRegStatus'])) { |
|
43 | + $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
44 | + } |
|
45 | + |
|
46 | + if (! empty($input['description'])) { |
|
47 | + $args['EVT_desc'] = wp_kses_post($input['description']); |
|
48 | + } |
|
49 | + |
|
50 | + if (array_key_exists('displayDescription', $input)) { |
|
51 | + $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
52 | + } |
|
53 | + |
|
54 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
55 | + $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
56 | + } |
|
57 | + |
|
58 | + if (! empty($input['maxRegistrations'])) { |
|
59 | + $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
60 | + } |
|
61 | + |
|
62 | + if (array_key_exists('memberOnly', $input)) { |
|
63 | + $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
64 | + } |
|
65 | + |
|
66 | + if (! empty($input['name'])) { |
|
67 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
68 | + } |
|
69 | + |
|
70 | + if (array_key_exists('order', $input)) { |
|
71 | + $args['EVT_order'] = absint($input['order']); |
|
72 | + } |
|
73 | + |
|
74 | + if (array_key_exists('phoneNumber', $input)) { |
|
75 | + $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
76 | + } |
|
77 | + |
|
78 | + if (! empty($input['shortDescription'])) { |
|
79 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, $context = 'db'); |
|
80 | + } |
|
81 | + |
|
82 | + if (! empty($input['timezoneString'])) { |
|
83 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
84 | + } |
|
85 | + |
|
86 | + if (! empty($input['visibleOn'])) { |
|
87 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
88 | + } |
|
89 | + |
|
90 | + if (! empty($input['manager'])) { |
|
91 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
92 | + $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
93 | + } |
|
94 | + |
|
95 | + return apply_filters( |
|
96 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
97 | + $args, |
|
98 | + $input |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | } |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
40 | 40 | } |
41 | 41 | |
42 | - if (! empty($input['defaultRegStatus'])) { |
|
42 | + if ( ! empty($input['defaultRegStatus'])) { |
|
43 | 43 | $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
44 | 44 | } |
45 | 45 | |
46 | - if (! empty($input['description'])) { |
|
46 | + if ( ! empty($input['description'])) { |
|
47 | 47 | $args['EVT_desc'] = wp_kses_post($input['description']); |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
56 | 56 | } |
57 | 57 | |
58 | - if (! empty($input['maxRegistrations'])) { |
|
58 | + if ( ! empty($input['maxRegistrations'])) { |
|
59 | 59 | $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
64 | 64 | } |
65 | 65 | |
66 | - if (! empty($input['name'])) { |
|
66 | + if ( ! empty($input['name'])) { |
|
67 | 67 | $args['EVT_name'] = sanitize_text_field($input['name']); |
68 | 68 | } |
69 | 69 | |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
76 | 76 | } |
77 | 77 | |
78 | - if (! empty($input['shortDescription'])) { |
|
78 | + if ( ! empty($input['shortDescription'])) { |
|
79 | 79 | $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, $context = 'db'); |
80 | 80 | } |
81 | 81 | |
82 | - if (! empty($input['timezoneString'])) { |
|
82 | + if ( ! empty($input['timezoneString'])) { |
|
83 | 83 | $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
84 | 84 | } |
85 | 85 | |
86 | - if (! empty($input['visibleOn'])) { |
|
86 | + if ( ! empty($input['visibleOn'])) { |
|
87 | 87 | $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
88 | 88 | } |
89 | 89 | |
90 | - if (! empty($input['manager'])) { |
|
90 | + if ( ! empty($input['manager'])) { |
|
91 | 91 | $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
92 | 92 | $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
93 | 93 | } |