@@ -16,233 +16,233 @@ |
||
16 | 16 | class ProcessTicketSelectorPostData |
17 | 17 | { |
18 | 18 | |
19 | - const DATA_KEY_EVENT_ID = 'id'; |
|
20 | - |
|
21 | - const DATA_KEY_MAX_ATNDZ = 'max_atndz'; |
|
22 | - |
|
23 | - const DATA_KEY_QUANTITY = 'ticket-selections'; |
|
24 | - |
|
25 | - const DATA_KEY_RETURN_URL = 'return_url'; |
|
26 | - |
|
27 | - const DATA_KEY_ROWS = 'rows'; |
|
28 | - |
|
29 | - const DATA_KEY_TICKET_ID = 'ticket_id'; |
|
30 | - |
|
31 | - const DATA_KEY_TOTAL_TICKETS = 'total_tickets'; |
|
32 | - |
|
33 | - const INPUT_KEY_EVENT_ID = 'tkt-slctr-event-id'; |
|
34 | - |
|
35 | - const INPUT_KEY_MAX_ATNDZ = 'tkt-slctr-max-atndz-'; |
|
36 | - |
|
37 | - const INPUT_KEY_ROWS = 'tkt-slctr-rows-'; |
|
38 | - |
|
39 | - const INPUT_KEY_QTY = 'tkt-slctr-qty-'; |
|
40 | - |
|
41 | - const INPUT_KEY_TICKET_ID = 'tkt-slctr-ticket-id-'; |
|
42 | - |
|
43 | - const INPUT_KEY_RETURN_URL = 'tkt-slctr-return-url-'; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @var int |
|
48 | - */ |
|
49 | - protected $event_id; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var array |
|
53 | - */ |
|
54 | - protected $inputs_to_clean = []; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var array |
|
58 | - */ |
|
59 | - protected $valid_data = []; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var RequestInterface |
|
63 | - */ |
|
64 | - protected $request; |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @param RequestInterface $request |
|
69 | - */ |
|
70 | - public function __construct(RequestInterface $request) |
|
71 | - { |
|
72 | - $this->request = $request; |
|
73 | - $this->inputs_to_clean = [ |
|
74 | - self::DATA_KEY_MAX_ATNDZ => self::INPUT_KEY_MAX_ATNDZ, |
|
75 | - self::DATA_KEY_RETURN_URL => self::INPUT_KEY_RETURN_URL, |
|
76 | - self::DATA_KEY_ROWS => self::INPUT_KEY_ROWS, |
|
77 | - self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID, |
|
78 | - self::DATA_KEY_QUANTITY => self::INPUT_KEY_QTY, |
|
79 | - ]; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return int |
|
85 | - * @throws DomainException |
|
86 | - */ |
|
87 | - public function getEventId() |
|
88 | - { |
|
89 | - // do we have an event id? |
|
90 | - if ($this->event_id === null) { |
|
91 | - $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
|
92 | - if (! $this->event_id) { |
|
93 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
94 | - throw new DomainException( |
|
95 | - sprintf( |
|
96 | - esc_html__( |
|
97 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - '<br/>' |
|
101 | - ) |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
105 | - // event id is valid |
|
106 | - return $this->event_id; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return array |
|
112 | - * @throws DomainException |
|
113 | - */ |
|
114 | - public function validatePostData() |
|
115 | - { |
|
116 | - // grab valid id |
|
117 | - $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
118 | - // let's track the total number of tickets ordered.' |
|
119 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
120 | - // cycle through $inputs_to_clean array |
|
121 | - foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
|
122 | - $input_key = "{$input_to_clean}{$this->event_id}"; |
|
123 | - // check for POST data |
|
124 | - if ($this->request->requestParamIsSet($input_key)) { |
|
125 | - switch ($what) { |
|
126 | - // integers |
|
127 | - case self::DATA_KEY_ROWS: |
|
128 | - case self::DATA_KEY_MAX_ATNDZ: |
|
129 | - $this->processInteger($what, $input_key); |
|
130 | - break; |
|
131 | - // arrays of integers |
|
132 | - case self::DATA_KEY_QUANTITY: |
|
133 | - $this->processQuantity($input_key); |
|
134 | - break; |
|
135 | - // array of integers |
|
136 | - case self::DATA_KEY_TOTAL_TICKETS: |
|
137 | - $this->processTicketIDs($input_key); |
|
138 | - break; |
|
139 | - case self::DATA_KEY_RETURN_URL: |
|
140 | - $this->processReturnURL($input_key); |
|
141 | - break; |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - return $this->valid_data; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $what |
|
151 | - * @param string $input_key |
|
152 | - */ |
|
153 | - protected function processInteger($what, $input_key) |
|
154 | - { |
|
155 | - $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param string $input_key |
|
161 | - * @throws DomainException |
|
162 | - */ |
|
163 | - protected function processQuantity($input_key) |
|
164 | - { |
|
165 | - /** @var array $row_qty */ |
|
166 | - $row_qty = $this->request->getRequestParam($input_key, [], 'int', true); |
|
167 | - if (empty($row_qty) || ! is_array($row_qty)) { |
|
168 | - throw new DomainException( |
|
169 | - sprintf( |
|
170 | - esc_html__( |
|
171 | - 'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.', |
|
172 | - 'event_espresso' |
|
173 | - ), |
|
174 | - '<br/>' |
|
175 | - ) |
|
176 | - ); |
|
177 | - } |
|
178 | - $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
179 | - // if max attendees is 1 then the incoming row qty array |
|
180 | - // will only have one element and the value will be the ticket ID |
|
181 | - // ex: row qty = [ 0 => TKT_ID ] |
|
182 | - if ($max_atndz === 1 && count($row_qty) === 1) { |
|
183 | - // if the TS used radio buttons, then the ticket ID is stored differently in the request data |
|
184 | - $raw_qty = $this->request->getRequestParam($input_key); |
|
185 | - // explode integers by the dash if qty is a string |
|
186 | - $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : ''; |
|
187 | - if ($delimiter !== '') { |
|
188 | - $row_qty = explode($delimiter, $raw_qty); |
|
189 | - } |
|
190 | - // grab that ticket ID regardless of where it is |
|
191 | - $ticket_id = isset($row_qty[0]) ? $row_qty[0] : key($row_qty); |
|
192 | - // use it as the key, and set the value to 1 |
|
193 | - // ex: row qty = [ TKT_ID => 1 ] |
|
194 | - $row_qty = [$ticket_id => 1]; |
|
195 | - } |
|
196 | - foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
197 | - $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
198 | - $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
199 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @param string $input_key |
|
206 | - */ |
|
207 | - protected function processReturnURL($input_key) |
|
208 | - { |
|
209 | - // grab and sanitize return-url |
|
210 | - $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
211 | - // was the request coming from an iframe ? if so, then: |
|
212 | - if (strpos($input_value, 'event_list=iframe')) { |
|
213 | - // get anchor fragment |
|
214 | - $input_value = explode('#', $input_value); |
|
215 | - $input_value = end($input_value); |
|
216 | - // use event list url instead, but append anchor |
|
217 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
218 | - } |
|
219 | - $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @param string $input_key |
|
225 | - * @throws DomainException |
|
226 | - */ |
|
227 | - protected function processTicketIDs($input_key) |
|
228 | - { |
|
229 | - $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
230 | - $filtered_ticket_ids = array_filter($ticket_ids); |
|
231 | - if (empty($filtered_ticket_ids)) { |
|
232 | - throw new DomainException( |
|
233 | - sprintf( |
|
234 | - esc_html__( |
|
235 | - 'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.', |
|
236 | - 'event_espresso' |
|
237 | - ), |
|
238 | - '<br/>' |
|
239 | - ) |
|
240 | - ); |
|
241 | - } |
|
242 | - // cycle thru values |
|
243 | - foreach ($ticket_ids as $key => $value) { |
|
244 | - // allow only integers |
|
245 | - $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
246 | - } |
|
247 | - } |
|
19 | + const DATA_KEY_EVENT_ID = 'id'; |
|
20 | + |
|
21 | + const DATA_KEY_MAX_ATNDZ = 'max_atndz'; |
|
22 | + |
|
23 | + const DATA_KEY_QUANTITY = 'ticket-selections'; |
|
24 | + |
|
25 | + const DATA_KEY_RETURN_URL = 'return_url'; |
|
26 | + |
|
27 | + const DATA_KEY_ROWS = 'rows'; |
|
28 | + |
|
29 | + const DATA_KEY_TICKET_ID = 'ticket_id'; |
|
30 | + |
|
31 | + const DATA_KEY_TOTAL_TICKETS = 'total_tickets'; |
|
32 | + |
|
33 | + const INPUT_KEY_EVENT_ID = 'tkt-slctr-event-id'; |
|
34 | + |
|
35 | + const INPUT_KEY_MAX_ATNDZ = 'tkt-slctr-max-atndz-'; |
|
36 | + |
|
37 | + const INPUT_KEY_ROWS = 'tkt-slctr-rows-'; |
|
38 | + |
|
39 | + const INPUT_KEY_QTY = 'tkt-slctr-qty-'; |
|
40 | + |
|
41 | + const INPUT_KEY_TICKET_ID = 'tkt-slctr-ticket-id-'; |
|
42 | + |
|
43 | + const INPUT_KEY_RETURN_URL = 'tkt-slctr-return-url-'; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @var int |
|
48 | + */ |
|
49 | + protected $event_id; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var array |
|
53 | + */ |
|
54 | + protected $inputs_to_clean = []; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + protected $valid_data = []; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var RequestInterface |
|
63 | + */ |
|
64 | + protected $request; |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @param RequestInterface $request |
|
69 | + */ |
|
70 | + public function __construct(RequestInterface $request) |
|
71 | + { |
|
72 | + $this->request = $request; |
|
73 | + $this->inputs_to_clean = [ |
|
74 | + self::DATA_KEY_MAX_ATNDZ => self::INPUT_KEY_MAX_ATNDZ, |
|
75 | + self::DATA_KEY_RETURN_URL => self::INPUT_KEY_RETURN_URL, |
|
76 | + self::DATA_KEY_ROWS => self::INPUT_KEY_ROWS, |
|
77 | + self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID, |
|
78 | + self::DATA_KEY_QUANTITY => self::INPUT_KEY_QTY, |
|
79 | + ]; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return int |
|
85 | + * @throws DomainException |
|
86 | + */ |
|
87 | + public function getEventId() |
|
88 | + { |
|
89 | + // do we have an event id? |
|
90 | + if ($this->event_id === null) { |
|
91 | + $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
|
92 | + if (! $this->event_id) { |
|
93 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
94 | + throw new DomainException( |
|
95 | + sprintf( |
|
96 | + esc_html__( |
|
97 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + '<br/>' |
|
101 | + ) |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | + // event id is valid |
|
106 | + return $this->event_id; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return array |
|
112 | + * @throws DomainException |
|
113 | + */ |
|
114 | + public function validatePostData() |
|
115 | + { |
|
116 | + // grab valid id |
|
117 | + $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
118 | + // let's track the total number of tickets ordered.' |
|
119 | + $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
120 | + // cycle through $inputs_to_clean array |
|
121 | + foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
|
122 | + $input_key = "{$input_to_clean}{$this->event_id}"; |
|
123 | + // check for POST data |
|
124 | + if ($this->request->requestParamIsSet($input_key)) { |
|
125 | + switch ($what) { |
|
126 | + // integers |
|
127 | + case self::DATA_KEY_ROWS: |
|
128 | + case self::DATA_KEY_MAX_ATNDZ: |
|
129 | + $this->processInteger($what, $input_key); |
|
130 | + break; |
|
131 | + // arrays of integers |
|
132 | + case self::DATA_KEY_QUANTITY: |
|
133 | + $this->processQuantity($input_key); |
|
134 | + break; |
|
135 | + // array of integers |
|
136 | + case self::DATA_KEY_TOTAL_TICKETS: |
|
137 | + $this->processTicketIDs($input_key); |
|
138 | + break; |
|
139 | + case self::DATA_KEY_RETURN_URL: |
|
140 | + $this->processReturnURL($input_key); |
|
141 | + break; |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + return $this->valid_data; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @param string $what |
|
151 | + * @param string $input_key |
|
152 | + */ |
|
153 | + protected function processInteger($what, $input_key) |
|
154 | + { |
|
155 | + $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param string $input_key |
|
161 | + * @throws DomainException |
|
162 | + */ |
|
163 | + protected function processQuantity($input_key) |
|
164 | + { |
|
165 | + /** @var array $row_qty */ |
|
166 | + $row_qty = $this->request->getRequestParam($input_key, [], 'int', true); |
|
167 | + if (empty($row_qty) || ! is_array($row_qty)) { |
|
168 | + throw new DomainException( |
|
169 | + sprintf( |
|
170 | + esc_html__( |
|
171 | + 'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.', |
|
172 | + 'event_espresso' |
|
173 | + ), |
|
174 | + '<br/>' |
|
175 | + ) |
|
176 | + ); |
|
177 | + } |
|
178 | + $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
179 | + // if max attendees is 1 then the incoming row qty array |
|
180 | + // will only have one element and the value will be the ticket ID |
|
181 | + // ex: row qty = [ 0 => TKT_ID ] |
|
182 | + if ($max_atndz === 1 && count($row_qty) === 1) { |
|
183 | + // if the TS used radio buttons, then the ticket ID is stored differently in the request data |
|
184 | + $raw_qty = $this->request->getRequestParam($input_key); |
|
185 | + // explode integers by the dash if qty is a string |
|
186 | + $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : ''; |
|
187 | + if ($delimiter !== '') { |
|
188 | + $row_qty = explode($delimiter, $raw_qty); |
|
189 | + } |
|
190 | + // grab that ticket ID regardless of where it is |
|
191 | + $ticket_id = isset($row_qty[0]) ? $row_qty[0] : key($row_qty); |
|
192 | + // use it as the key, and set the value to 1 |
|
193 | + // ex: row qty = [ TKT_ID => 1 ] |
|
194 | + $row_qty = [$ticket_id => 1]; |
|
195 | + } |
|
196 | + foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
197 | + $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
198 | + $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
199 | + $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @param string $input_key |
|
206 | + */ |
|
207 | + protected function processReturnURL($input_key) |
|
208 | + { |
|
209 | + // grab and sanitize return-url |
|
210 | + $input_value = $this->request->getRequestParam($input_key, '', 'url'); |
|
211 | + // was the request coming from an iframe ? if so, then: |
|
212 | + if (strpos($input_value, 'event_list=iframe')) { |
|
213 | + // get anchor fragment |
|
214 | + $input_value = explode('#', $input_value); |
|
215 | + $input_value = end($input_value); |
|
216 | + // use event list url instead, but append anchor |
|
217 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
218 | + } |
|
219 | + $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @param string $input_key |
|
225 | + * @throws DomainException |
|
226 | + */ |
|
227 | + protected function processTicketIDs($input_key) |
|
228 | + { |
|
229 | + $ticket_ids = (array) $this->request->getRequestParam($input_key, [], 'int', true); |
|
230 | + $filtered_ticket_ids = array_filter($ticket_ids); |
|
231 | + if (empty($filtered_ticket_ids)) { |
|
232 | + throw new DomainException( |
|
233 | + sprintf( |
|
234 | + esc_html__( |
|
235 | + 'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.', |
|
236 | + 'event_espresso' |
|
237 | + ), |
|
238 | + '<br/>' |
|
239 | + ) |
|
240 | + ); |
|
241 | + } |
|
242 | + // cycle thru values |
|
243 | + foreach ($ticket_ids as $key => $value) { |
|
244 | + // allow only integers |
|
245 | + $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
246 | + } |
|
247 | + } |
|
248 | 248 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // do we have an event id? |
90 | 90 | if ($this->event_id === null) { |
91 | 91 | $this->event_id = $this->request->getRequestParam(self::INPUT_KEY_EVENT_ID, 0, 'int'); |
92 | - if (! $this->event_id) { |
|
92 | + if ( ! $this->event_id) { |
|
93 | 93 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
94 | 94 | throw new DomainException( |
95 | 95 | sprintf( |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | public function validatePostData() |
115 | 115 | { |
116 | 116 | // grab valid id |
117 | - $this->valid_data[ self::DATA_KEY_EVENT_ID ] = $this->getEventId(); |
|
117 | + $this->valid_data[self::DATA_KEY_EVENT_ID] = $this->getEventId(); |
|
118 | 118 | // let's track the total number of tickets ordered.' |
119 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] = 0; |
|
119 | + $this->valid_data[self:: DATA_KEY_TOTAL_TICKETS] = 0; |
|
120 | 120 | // cycle through $inputs_to_clean array |
121 | 121 | foreach ($this->inputs_to_clean as $what => $input_to_clean) { |
122 | 122 | $input_key = "{$input_to_clean}{$this->event_id}"; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function processInteger($what, $input_key) |
154 | 154 | { |
155 | - $this->valid_data[ $what ] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
155 | + $this->valid_data[$what] = $this->request->getRequestParam($input_key, 0, 'int'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | } |
178 | - $max_atndz = $this->valid_data[ self::DATA_KEY_MAX_ATNDZ ]; |
|
178 | + $max_atndz = $this->valid_data[self::DATA_KEY_MAX_ATNDZ]; |
|
179 | 179 | // if max attendees is 1 then the incoming row qty array |
180 | 180 | // will only have one element and the value will be the ticket ID |
181 | 181 | // ex: row qty = [ 0 => TKT_ID ] |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | // ex: row qty = [ TKT_ID => 1 ] |
194 | 194 | $row_qty = [$ticket_id => 1]; |
195 | 195 | } |
196 | - foreach ($this->valid_data[ self::DATA_KEY_TICKET_ID ] as $ticket_id) { |
|
197 | - $qty = isset($row_qty[ $ticket_id ]) ? $row_qty[ $ticket_id ] : 0; |
|
198 | - $this->valid_data[ self::DATA_KEY_QUANTITY ][ $ticket_id ] = $qty; |
|
199 | - $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty; |
|
196 | + foreach ($this->valid_data[self::DATA_KEY_TICKET_ID] as $ticket_id) { |
|
197 | + $qty = isset($row_qty[$ticket_id]) ? $row_qty[$ticket_id] : 0; |
|
198 | + $this->valid_data[self::DATA_KEY_QUANTITY][$ticket_id] = $qty; |
|
199 | + $this->valid_data[self:: DATA_KEY_TOTAL_TICKETS] += $qty; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | $input_value = explode('#', $input_value); |
215 | 215 | $input_value = end($input_value); |
216 | 216 | // use event list url instead, but append anchor |
217 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
217 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
218 | 218 | } |
219 | - $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value; |
|
219 | + $this->valid_data[self::DATA_KEY_RETURN_URL] = $input_value; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | // cycle thru values |
243 | 243 | foreach ($ticket_ids as $key => $value) { |
244 | 244 | // allow only integers |
245 | - $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value); |
|
245 | + $this->valid_data[self::DATA_KEY_TICKET_ID][$key] = absint($value); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
@@ -20,364 +20,364 @@ |
||
20 | 20 | class TicketSelectorRowStandard extends TicketSelectorRow |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var TicketDetails |
|
25 | - */ |
|
26 | - protected $ticket_details; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Ticket_Selector_Config |
|
30 | - */ |
|
31 | - protected $template_settings; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var EE_Tax_Config |
|
35 | - */ |
|
36 | - protected $tax_settings; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - protected $prices_displayed_including_taxes; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var int |
|
45 | - */ |
|
46 | - protected $row; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - protected $cols; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var boolean |
|
55 | - */ |
|
56 | - protected $hidden_input_qty = false; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $ticket_datetime_classes; |
|
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_attendees |
|
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_attendees, |
|
84 | - $row, |
|
85 | - $cols, |
|
86 | - $required_ticket_sold_out, |
|
87 | - $event_status, |
|
88 | - $ticket_datetime_classes |
|
89 | - ) { |
|
90 | - $this->ticket_details = $ticket_details; |
|
91 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
92 | - $this->tax_settings = $tax_settings; |
|
93 | - $this->row = $row; |
|
94 | - $this->cols = $cols; |
|
95 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
96 | - parent::__construct( |
|
97 | - $ticket_details->getTicket(), |
|
98 | - $max_attendees, |
|
99 | - $ticket_details->getDateFormat(), |
|
100 | - $event_status, |
|
101 | - $required_ticket_sold_out, |
|
102 | - $total_tickets |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * other ticket rows will need to know if a required ticket is sold out, |
|
109 | - * so that they are not offered for sale |
|
110 | - * |
|
111 | - * @return boolean |
|
112 | - */ |
|
113 | - public function getRequiredTicketSoldOut() |
|
114 | - { |
|
115 | - return $this->required_ticket_sold_out; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function getCols() |
|
123 | - { |
|
124 | - return $this->cols; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * getHtml |
|
130 | - * |
|
131 | - * @return string |
|
132 | - * @throws EE_Error |
|
133 | - * @throws ReflectionException |
|
134 | - */ |
|
135 | - public function getHtml() |
|
136 | - { |
|
137 | - $this->min = 0; |
|
138 | - $this->max = $this->ticket->max(); |
|
139 | - $remaining = $this->ticket->remaining(); |
|
140 | - $this->setTicketMinAndMax($remaining); |
|
141 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
142 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
143 | - ? $this->ticket->start_date() |
|
144 | - : $this->required_ticket_sold_out; |
|
145 | - $this->setTicketPriceDetails(); |
|
146 | - $this->setTicketStatusClasses($remaining); |
|
147 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
148 | - if ($filtered_row_html !== false) { |
|
149 | - return $filtered_row_html; |
|
150 | - } |
|
151 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
152 | - '', |
|
153 | - '', |
|
154 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
155 | - . espresso_get_object_css_class($this->ticket) |
|
156 | - ); |
|
157 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
158 | - if ($filtered_row_content !== false) { |
|
159 | - if ($this->max_attendees === 1) { |
|
160 | - return $ticket_selector_row_html |
|
161 | - . $filtered_row_content |
|
162 | - . $this->ticketQtyAndIdHiddenInputs() |
|
163 | - . EEH_HTML::trx(); |
|
164 | - } |
|
165 | - return $ticket_selector_row_html |
|
166 | - . $filtered_row_content |
|
167 | - . EEH_HTML::trx(); |
|
168 | - } |
|
169 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
170 | - |
|
171 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
172 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
173 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
174 | - '', |
|
175 | - '', |
|
176 | - 'tckt-slctr-tbl-td-qty cntr', |
|
177 | - '', |
|
178 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
179 | - ); |
|
180 | - $this->setTicketStatusDisplay($remaining); |
|
181 | - if (empty($this->ticket_status_display)) { |
|
182 | - if ($this->max_attendees === 1) { |
|
183 | - // only ONE attendee is allowed to register at a time |
|
184 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
185 | - } elseif ($this->max > 0) { |
|
186 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
187 | - } |
|
188 | - } |
|
189 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
190 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
191 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
192 | - $this->ticket_price, |
|
193 | - $remaining, |
|
194 | - $this->cols |
|
195 | - ); |
|
196 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
197 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
198 | - |
|
199 | - |
|
200 | - $this->row++; |
|
201 | - return $ticket_selector_row_html; |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * getTicketPriceDetails |
|
207 | - * |
|
208 | - * @return void |
|
209 | - * @throws EE_Error |
|
210 | - */ |
|
211 | - protected function setTicketPriceDetails() |
|
212 | - { |
|
213 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
214 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
215 | - : $this->ticket->get_ticket_subtotal(); |
|
216 | - $this->ticket_bundle = false; |
|
217 | - $ticket_min = $this->ticket->min(); |
|
218 | - // for ticket bundles, set min and max qty the same |
|
219 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
220 | - $this->ticket_price *= $ticket_min; |
|
221 | - $this->ticket_bundle = true; |
|
222 | - } |
|
223 | - $this->ticket_price = apply_filters( |
|
224 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
225 | - $this->ticket_price, |
|
226 | - $this->ticket |
|
227 | - ); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * ticketNameTableCell |
|
233 | - * |
|
234 | - * @return string |
|
235 | - * @throws EE_Error |
|
236 | - * @throws ReflectionException |
|
237 | - */ |
|
238 | - protected function ticketNameTableCell() |
|
239 | - { |
|
240 | - $html = EEH_HTML::td( |
|
241 | - '', |
|
242 | - '', |
|
243 | - 'tckt-slctr-tbl-td-name', |
|
244 | - '', |
|
245 | - 'headers="details-' . $this->EVT_ID . '"' |
|
246 | - ); |
|
247 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
248 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
249 | - if ($this->ticket->required()) { |
|
250 | - $html .= EEH_HTML::p( |
|
251 | - apply_filters( |
|
252 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
253 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
254 | - ), |
|
255 | - '', |
|
256 | - 'ticket-required-pg' |
|
257 | - ); |
|
258 | - } |
|
259 | - $html .= EEH_HTML::tdx(); |
|
260 | - return $html; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * ticketPriceTableCell |
|
266 | - * |
|
267 | - * @return string |
|
268 | - * @throws EE_Error |
|
269 | - */ |
|
270 | - protected function ticketPriceTableCell() |
|
271 | - { |
|
272 | - $html = ''; |
|
273 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
274 | - $html .= EEH_HTML::td( |
|
275 | - '', |
|
276 | - '', |
|
277 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
278 | - '', |
|
279 | - 'headers="price-' . $this->EVT_ID . '"' |
|
280 | - ); |
|
281 | - $html .= EEH_Template::format_currency($this->ticket_price); |
|
282 | - $html .= $this->ticket->taxable() |
|
283 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
284 | - : ''; |
|
285 | - $html .= ' '; |
|
286 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
287 | - $html .= EEH_HTML::span( |
|
288 | - $this->ticket_bundle |
|
289 | - ? apply_filters( |
|
290 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
291 | - esc_html__(' / bundle', 'event_espresso') |
|
292 | - ) |
|
293 | - : apply_filters( |
|
294 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
295 | - esc_html__('', 'event_espresso') |
|
296 | - ), |
|
297 | - '', |
|
298 | - 'smaller-text no-bold' |
|
299 | - ); |
|
300 | - $html .= ' '; |
|
301 | - $html .= EEH_HTML::tdx(); |
|
302 | - $this->cols++; |
|
303 | - } |
|
304 | - return $html; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * onlyOneAttendeeCanRegister |
|
310 | - * |
|
311 | - * @return string |
|
312 | - * @throws EE_Error |
|
313 | - */ |
|
314 | - protected function onlyOneAttendeeCanRegister() |
|
315 | - { |
|
316 | - $this->hidden_input_qty = false; |
|
317 | - // display submit button since we have tickets available |
|
318 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
319 | - |
|
320 | - $TKT = $this->ticket->ID(); |
|
321 | - $label = esc_html__('Select this ticket', 'event_espresso'); |
|
322 | - $name = "tkt-slctr-qty-{$this->EVT_ID}"; |
|
323 | - $class = "ticket-selector-tbl-qty-slct"; |
|
324 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
325 | - $checked = $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
326 | - |
|
327 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
328 | - $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}-1' title='' />"; |
|
329 | - return $html; |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - /** |
|
334 | - * ticketQuantitySelector |
|
335 | - * |
|
336 | - * @return string |
|
337 | - * @throws EE_Error |
|
338 | - */ |
|
339 | - protected function ticketQuantitySelector() |
|
340 | - { |
|
341 | - $this->hidden_input_qty = false; |
|
342 | - // display submit button since we have tickets available |
|
343 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
344 | - |
|
345 | - $TKT = $this->ticket->ID(); |
|
346 | - $label = esc_html__('Quantity', 'event_espresso'); |
|
347 | - $class = 'ticket-selector-tbl-qty-slct'; |
|
348 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
349 | - |
|
350 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
351 | - $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
352 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
353 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
354 | - $html .= "<option value='0'> 0 </option>"; |
|
355 | - } |
|
356 | - // offer ticket quantities from the min to the max |
|
357 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
358 | - $html .= "<option value='{$i}'> {$i} </option>"; |
|
359 | - } |
|
360 | - $html .= "</select>"; |
|
361 | - return $html; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * getHiddenInputs |
|
367 | - * |
|
368 | - * @return string |
|
369 | - * @throws EE_Error |
|
370 | - */ |
|
371 | - protected function ticketQtyAndIdHiddenInputs() |
|
372 | - { |
|
373 | - $html = ''; |
|
374 | - $EVT = $this->EVT_ID; |
|
375 | - $TKT = $this->ticket->ID(); |
|
376 | - // depending on group reg we need to change the format for qty |
|
377 | - if ($this->hidden_input_qty) { |
|
378 | - $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
379 | - } |
|
380 | - $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
381 | - return $html; |
|
382 | - } |
|
23 | + /** |
|
24 | + * @var TicketDetails |
|
25 | + */ |
|
26 | + protected $ticket_details; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Ticket_Selector_Config |
|
30 | + */ |
|
31 | + protected $template_settings; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var EE_Tax_Config |
|
35 | + */ |
|
36 | + protected $tax_settings; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + protected $prices_displayed_including_taxes; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var int |
|
45 | + */ |
|
46 | + protected $row; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + protected $cols; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var boolean |
|
55 | + */ |
|
56 | + protected $hidden_input_qty = false; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $ticket_datetime_classes; |
|
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_attendees |
|
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_attendees, |
|
84 | + $row, |
|
85 | + $cols, |
|
86 | + $required_ticket_sold_out, |
|
87 | + $event_status, |
|
88 | + $ticket_datetime_classes |
|
89 | + ) { |
|
90 | + $this->ticket_details = $ticket_details; |
|
91 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
92 | + $this->tax_settings = $tax_settings; |
|
93 | + $this->row = $row; |
|
94 | + $this->cols = $cols; |
|
95 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
96 | + parent::__construct( |
|
97 | + $ticket_details->getTicket(), |
|
98 | + $max_attendees, |
|
99 | + $ticket_details->getDateFormat(), |
|
100 | + $event_status, |
|
101 | + $required_ticket_sold_out, |
|
102 | + $total_tickets |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * other ticket rows will need to know if a required ticket is sold out, |
|
109 | + * so that they are not offered for sale |
|
110 | + * |
|
111 | + * @return boolean |
|
112 | + */ |
|
113 | + public function getRequiredTicketSoldOut() |
|
114 | + { |
|
115 | + return $this->required_ticket_sold_out; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function getCols() |
|
123 | + { |
|
124 | + return $this->cols; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * getHtml |
|
130 | + * |
|
131 | + * @return string |
|
132 | + * @throws EE_Error |
|
133 | + * @throws ReflectionException |
|
134 | + */ |
|
135 | + public function getHtml() |
|
136 | + { |
|
137 | + $this->min = 0; |
|
138 | + $this->max = $this->ticket->max(); |
|
139 | + $remaining = $this->ticket->remaining(); |
|
140 | + $this->setTicketMinAndMax($remaining); |
|
141 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
142 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
143 | + ? $this->ticket->start_date() |
|
144 | + : $this->required_ticket_sold_out; |
|
145 | + $this->setTicketPriceDetails(); |
|
146 | + $this->setTicketStatusClasses($remaining); |
|
147 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
148 | + if ($filtered_row_html !== false) { |
|
149 | + return $filtered_row_html; |
|
150 | + } |
|
151 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
152 | + '', |
|
153 | + '', |
|
154 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
155 | + . espresso_get_object_css_class($this->ticket) |
|
156 | + ); |
|
157 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
158 | + if ($filtered_row_content !== false) { |
|
159 | + if ($this->max_attendees === 1) { |
|
160 | + return $ticket_selector_row_html |
|
161 | + . $filtered_row_content |
|
162 | + . $this->ticketQtyAndIdHiddenInputs() |
|
163 | + . EEH_HTML::trx(); |
|
164 | + } |
|
165 | + return $ticket_selector_row_html |
|
166 | + . $filtered_row_content |
|
167 | + . EEH_HTML::trx(); |
|
168 | + } |
|
169 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
170 | + |
|
171 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
172 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
173 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
174 | + '', |
|
175 | + '', |
|
176 | + 'tckt-slctr-tbl-td-qty cntr', |
|
177 | + '', |
|
178 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
179 | + ); |
|
180 | + $this->setTicketStatusDisplay($remaining); |
|
181 | + if (empty($this->ticket_status_display)) { |
|
182 | + if ($this->max_attendees === 1) { |
|
183 | + // only ONE attendee is allowed to register at a time |
|
184 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
185 | + } elseif ($this->max > 0) { |
|
186 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
187 | + } |
|
188 | + } |
|
189 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
190 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
191 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
192 | + $this->ticket_price, |
|
193 | + $remaining, |
|
194 | + $this->cols |
|
195 | + ); |
|
196 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
197 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
198 | + |
|
199 | + |
|
200 | + $this->row++; |
|
201 | + return $ticket_selector_row_html; |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * getTicketPriceDetails |
|
207 | + * |
|
208 | + * @return void |
|
209 | + * @throws EE_Error |
|
210 | + */ |
|
211 | + protected function setTicketPriceDetails() |
|
212 | + { |
|
213 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
214 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
215 | + : $this->ticket->get_ticket_subtotal(); |
|
216 | + $this->ticket_bundle = false; |
|
217 | + $ticket_min = $this->ticket->min(); |
|
218 | + // for ticket bundles, set min and max qty the same |
|
219 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
220 | + $this->ticket_price *= $ticket_min; |
|
221 | + $this->ticket_bundle = true; |
|
222 | + } |
|
223 | + $this->ticket_price = apply_filters( |
|
224 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
225 | + $this->ticket_price, |
|
226 | + $this->ticket |
|
227 | + ); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * ticketNameTableCell |
|
233 | + * |
|
234 | + * @return string |
|
235 | + * @throws EE_Error |
|
236 | + * @throws ReflectionException |
|
237 | + */ |
|
238 | + protected function ticketNameTableCell() |
|
239 | + { |
|
240 | + $html = EEH_HTML::td( |
|
241 | + '', |
|
242 | + '', |
|
243 | + 'tckt-slctr-tbl-td-name', |
|
244 | + '', |
|
245 | + 'headers="details-' . $this->EVT_ID . '"' |
|
246 | + ); |
|
247 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
248 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
249 | + if ($this->ticket->required()) { |
|
250 | + $html .= EEH_HTML::p( |
|
251 | + apply_filters( |
|
252 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
253 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
254 | + ), |
|
255 | + '', |
|
256 | + 'ticket-required-pg' |
|
257 | + ); |
|
258 | + } |
|
259 | + $html .= EEH_HTML::tdx(); |
|
260 | + return $html; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * ticketPriceTableCell |
|
266 | + * |
|
267 | + * @return string |
|
268 | + * @throws EE_Error |
|
269 | + */ |
|
270 | + protected function ticketPriceTableCell() |
|
271 | + { |
|
272 | + $html = ''; |
|
273 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
274 | + $html .= EEH_HTML::td( |
|
275 | + '', |
|
276 | + '', |
|
277 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
278 | + '', |
|
279 | + 'headers="price-' . $this->EVT_ID . '"' |
|
280 | + ); |
|
281 | + $html .= EEH_Template::format_currency($this->ticket_price); |
|
282 | + $html .= $this->ticket->taxable() |
|
283 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
284 | + : ''; |
|
285 | + $html .= ' '; |
|
286 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
287 | + $html .= EEH_HTML::span( |
|
288 | + $this->ticket_bundle |
|
289 | + ? apply_filters( |
|
290 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
291 | + esc_html__(' / bundle', 'event_espresso') |
|
292 | + ) |
|
293 | + : apply_filters( |
|
294 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
295 | + esc_html__('', 'event_espresso') |
|
296 | + ), |
|
297 | + '', |
|
298 | + 'smaller-text no-bold' |
|
299 | + ); |
|
300 | + $html .= ' '; |
|
301 | + $html .= EEH_HTML::tdx(); |
|
302 | + $this->cols++; |
|
303 | + } |
|
304 | + return $html; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * onlyOneAttendeeCanRegister |
|
310 | + * |
|
311 | + * @return string |
|
312 | + * @throws EE_Error |
|
313 | + */ |
|
314 | + protected function onlyOneAttendeeCanRegister() |
|
315 | + { |
|
316 | + $this->hidden_input_qty = false; |
|
317 | + // display submit button since we have tickets available |
|
318 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
319 | + |
|
320 | + $TKT = $this->ticket->ID(); |
|
321 | + $label = esc_html__('Select this ticket', 'event_espresso'); |
|
322 | + $name = "tkt-slctr-qty-{$this->EVT_ID}"; |
|
323 | + $class = "ticket-selector-tbl-qty-slct"; |
|
324 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
325 | + $checked = $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
326 | + |
|
327 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
328 | + $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}-1' title='' />"; |
|
329 | + return $html; |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + /** |
|
334 | + * ticketQuantitySelector |
|
335 | + * |
|
336 | + * @return string |
|
337 | + * @throws EE_Error |
|
338 | + */ |
|
339 | + protected function ticketQuantitySelector() |
|
340 | + { |
|
341 | + $this->hidden_input_qty = false; |
|
342 | + // display submit button since we have tickets available |
|
343 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
344 | + |
|
345 | + $TKT = $this->ticket->ID(); |
|
346 | + $label = esc_html__('Quantity', 'event_espresso'); |
|
347 | + $class = 'ticket-selector-tbl-qty-slct'; |
|
348 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
349 | + |
|
350 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
351 | + $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
352 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
353 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
354 | + $html .= "<option value='0'> 0 </option>"; |
|
355 | + } |
|
356 | + // offer ticket quantities from the min to the max |
|
357 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
358 | + $html .= "<option value='{$i}'> {$i} </option>"; |
|
359 | + } |
|
360 | + $html .= "</select>"; |
|
361 | + return $html; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * getHiddenInputs |
|
367 | + * |
|
368 | + * @return string |
|
369 | + * @throws EE_Error |
|
370 | + */ |
|
371 | + protected function ticketQtyAndIdHiddenInputs() |
|
372 | + { |
|
373 | + $html = ''; |
|
374 | + $EVT = $this->EVT_ID; |
|
375 | + $TKT = $this->ticket->ID(); |
|
376 | + // depending on group reg we need to change the format for qty |
|
377 | + if ($this->hidden_input_qty) { |
|
378 | + $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
379 | + } |
|
380 | + $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
381 | + return $html; |
|
382 | + } |
|
383 | 383 | } |