Completed
Branch remove-ticket-selector-typing (a57cdc)
by
unknown
20:05 queued 18:22
created
modules/ticket_selector/ProcessTicketSelectorPostData.php 2 patches
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -16,235 +16,235 @@
 block discarded – undo
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      = 'qty';
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_ROWS          => self::INPUT_KEY_ROWS,
76
-            self::DATA_KEY_QUANTITY      => self::INPUT_KEY_QTY,
77
-            self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID,
78
-            self::DATA_KEY_RETURN_URL    => self::INPUT_KEY_RETURN_URL,
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
-        // first get number of ticket option rows
166
-        $rows    = $this->request->getRequestParam(self::INPUT_KEY_ROWS . $this->event_id, 1, 'int');
167
-        $raw_qty = $this->request->getRequestParam($input_key);
168
-        // explode integers by the dash if qty is a string
169
-        $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : '';
170
-        /** @var array $row_qty */
171
-        $row_qty = $this->request->getRequestParam($input_key, [], 'int', true, $delimiter);
172
-        // if qty is coming from a radio button input, then we need to assemble an array of rows
173
-        if ($delimiter === '-') {
174
-            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
175
-            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
176
-            // restructure the row qty array so that $row is now the key instead of the first value
177
-            $row_qty = [$row => $qty];
178
-            for ($x = 1; $x <= $rows; $x++) {
179
-                if (! isset($row_qty[ $x ])) {
180
-                    $row_qty[ $x ] = 0;
181
-                }
182
-            }
183
-        }
184
-        if (empty($row_qty) || ! is_array($row_qty) || $rows !== count($row_qty)) {
185
-            throw new DomainException(
186
-                sprintf(
187
-                    esc_html__(
188
-                        'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.',
189
-                        'event_espresso'
190
-                    ),
191
-                    '<br/>'
192
-                )
193
-            );
194
-        }
195
-        ksort($row_qty);
196
-        // cycle thru values
197
-        foreach ($row_qty as $qty) {
198
-            $qty = absint($qty);
199
-            // sanitize as integers
200
-            $this->valid_data[ self::DATA_KEY_QUANTITY ][]     = $qty;
201
-            $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty;
202
-        }
203
-    }
204
-
205
-
206
-    /**
207
-     * @param string $input_key
208
-     */
209
-    protected function processReturnURL($input_key)
210
-    {
211
-        // grab and sanitize return-url
212
-        $input_value = $this->request->getRequestParam($input_key, '', 'url');
213
-        // was the request coming from an iframe ? if so, then:
214
-        if (strpos($input_value, 'event_list=iframe')) {
215
-            // get anchor fragment
216
-            $input_value = explode('#', $input_value);
217
-            $input_value = end($input_value);
218
-            // use event list url instead, but append anchor
219
-            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
220
-        }
221
-        $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value;
222
-    }
223
-
224
-
225
-    /**
226
-     * @param string $input_key
227
-     * @throws DomainException
228
-     */
229
-    protected function processTicketIDs($input_key)
230
-    {
231
-        $ticket_ids          = (array) $this->request->getRequestParam($input_key, [], 'int', true);
232
-        $filtered_ticket_ids = array_filter($ticket_ids);
233
-        if (empty($filtered_ticket_ids)) {
234
-            throw new DomainException(
235
-                sprintf(
236
-                    esc_html__(
237
-                        'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.',
238
-                        'event_espresso'
239
-                    ),
240
-                    '<br/>'
241
-                )
242
-            );
243
-        }
244
-        // cycle thru values
245
-        foreach ($ticket_ids as $key => $value) {
246
-            // allow only integers
247
-            $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value);
248
-        }
249
-    }
19
+	const DATA_KEY_EVENT_ID      = 'id';
20
+
21
+	const DATA_KEY_MAX_ATNDZ     = 'max_atndz';
22
+
23
+	const DATA_KEY_QUANTITY      = 'qty';
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_ROWS          => self::INPUT_KEY_ROWS,
76
+			self::DATA_KEY_QUANTITY      => self::INPUT_KEY_QTY,
77
+			self::DATA_KEY_TOTAL_TICKETS => self::INPUT_KEY_TICKET_ID,
78
+			self::DATA_KEY_RETURN_URL    => self::INPUT_KEY_RETURN_URL,
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
+		// first get number of ticket option rows
166
+		$rows    = $this->request->getRequestParam(self::INPUT_KEY_ROWS . $this->event_id, 1, 'int');
167
+		$raw_qty = $this->request->getRequestParam($input_key);
168
+		// explode integers by the dash if qty is a string
169
+		$delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : '';
170
+		/** @var array $row_qty */
171
+		$row_qty = $this->request->getRequestParam($input_key, [], 'int', true, $delimiter);
172
+		// if qty is coming from a radio button input, then we need to assemble an array of rows
173
+		if ($delimiter === '-') {
174
+			$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
175
+			$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
176
+			// restructure the row qty array so that $row is now the key instead of the first value
177
+			$row_qty = [$row => $qty];
178
+			for ($x = 1; $x <= $rows; $x++) {
179
+				if (! isset($row_qty[ $x ])) {
180
+					$row_qty[ $x ] = 0;
181
+				}
182
+			}
183
+		}
184
+		if (empty($row_qty) || ! is_array($row_qty) || $rows !== count($row_qty)) {
185
+			throw new DomainException(
186
+				sprintf(
187
+					esc_html__(
188
+						'An error occurred while trying to retrieve the ticket selections for the event.%sPlease click the back button on your browser and try again.',
189
+						'event_espresso'
190
+					),
191
+					'<br/>'
192
+				)
193
+			);
194
+		}
195
+		ksort($row_qty);
196
+		// cycle thru values
197
+		foreach ($row_qty as $qty) {
198
+			$qty = absint($qty);
199
+			// sanitize as integers
200
+			$this->valid_data[ self::DATA_KEY_QUANTITY ][]     = $qty;
201
+			$this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty;
202
+		}
203
+	}
204
+
205
+
206
+	/**
207
+	 * @param string $input_key
208
+	 */
209
+	protected function processReturnURL($input_key)
210
+	{
211
+		// grab and sanitize return-url
212
+		$input_value = $this->request->getRequestParam($input_key, '', 'url');
213
+		// was the request coming from an iframe ? if so, then:
214
+		if (strpos($input_value, 'event_list=iframe')) {
215
+			// get anchor fragment
216
+			$input_value = explode('#', $input_value);
217
+			$input_value = end($input_value);
218
+			// use event list url instead, but append anchor
219
+			$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
220
+		}
221
+		$this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value;
222
+	}
223
+
224
+
225
+	/**
226
+	 * @param string $input_key
227
+	 * @throws DomainException
228
+	 */
229
+	protected function processTicketIDs($input_key)
230
+	{
231
+		$ticket_ids          = (array) $this->request->getRequestParam($input_key, [], 'int', true);
232
+		$filtered_ticket_ids = array_filter($ticket_ids);
233
+		if (empty($filtered_ticket_ids)) {
234
+			throw new DomainException(
235
+				sprintf(
236
+					esc_html__(
237
+						'An error occurred while trying to retrieve the ticket IDs for the event.%sPlease click the back button on your browser and try again.',
238
+						'event_espresso'
239
+					),
240
+					'<br/>'
241
+				)
242
+			);
243
+		}
244
+		// cycle thru values
245
+		foreach ($ticket_ids as $key => $value) {
246
+			// allow only integers
247
+			$this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value);
248
+		}
249
+	}
250 250
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     protected function processQuantity($input_key)
164 164
     {
165 165
         // first get number of ticket option rows
166
-        $rows    = $this->request->getRequestParam(self::INPUT_KEY_ROWS . $this->event_id, 1, 'int');
166
+        $rows    = $this->request->getRequestParam(self::INPUT_KEY_ROWS.$this->event_id, 1, 'int');
167 167
         $raw_qty = $this->request->getRequestParam($input_key);
168 168
         // explode integers by the dash if qty is a string
169 169
         $delimiter = is_string($raw_qty) && strpos($raw_qty, '-') ? '-' : '';
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
             // restructure the row qty array so that $row is now the key instead of the first value
177 177
             $row_qty = [$row => $qty];
178 178
             for ($x = 1; $x <= $rows; $x++) {
179
-                if (! isset($row_qty[ $x ])) {
180
-                    $row_qty[ $x ] = 0;
179
+                if ( ! isset($row_qty[$x])) {
180
+                    $row_qty[$x] = 0;
181 181
                 }
182 182
             }
183 183
         }
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
         foreach ($row_qty as $qty) {
198 198
             $qty = absint($qty);
199 199
             // sanitize as integers
200
-            $this->valid_data[ self::DATA_KEY_QUANTITY ][]     = $qty;
201
-            $this->valid_data[ self:: DATA_KEY_TOTAL_TICKETS ] += $qty;
200
+            $this->valid_data[self::DATA_KEY_QUANTITY][] = $qty;
201
+            $this->valid_data[self:: DATA_KEY_TOTAL_TICKETS] += $qty;
202 202
         }
203 203
     }
204 204
 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
             $input_value = explode('#', $input_value);
217 217
             $input_value = end($input_value);
218 218
             // use event list url instead, but append anchor
219
-            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
219
+            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
220 220
         }
221
-        $this->valid_data[ self::DATA_KEY_RETURN_URL ] = $input_value;
221
+        $this->valid_data[self::DATA_KEY_RETURN_URL] = $input_value;
222 222
     }
223 223
 
224 224
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         // cycle thru values
245 245
         foreach ($ticket_ids as $key => $value) {
246 246
             // allow only integers
247
-            $this->valid_data[ self::DATA_KEY_TICKET_ID ][ $key ] = absint($value);
247
+            $this->valid_data[self::DATA_KEY_TICKET_ID][$key] = absint($value);
248 248
         }
249 249
     }
250 250
 }
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 2 patches
Indentation   +377 added lines, -377 removed lines patch added patch discarded remove patch
@@ -34,402 +34,402 @@
 block discarded – undo
34 34
 class ProcessTicketSelector
35 35
 {
36 36
 
37
-    /**
38
-     * @var EE_Cart $cart
39
-     */
40
-    private $cart;
37
+	/**
38
+	 * @var EE_Cart $cart
39
+	 */
40
+	private $cart;
41 41
 
42
-    /**
43
-     * @var EE_Core_Config $core_config
44
-     */
45
-    private $core_config;
42
+	/**
43
+	 * @var EE_Core_Config $core_config
44
+	 */
45
+	private $core_config;
46 46
 
47
-    /**
48
-     * @var RequestInterface $request
49
-     */
50
-    private $request;
47
+	/**
48
+	 * @var RequestInterface $request
49
+	 */
50
+	private $request;
51 51
 
52
-    /**
53
-     * @var EE_Session $session
54
-     */
55
-    private $session;
52
+	/**
53
+	 * @var EE_Session $session
54
+	 */
55
+	private $session;
56 56
 
57
-    /**
58
-     * @var EEM_Ticket $ticket_model
59
-     */
60
-    private $ticket_model;
57
+	/**
58
+	 * @var EEM_Ticket $ticket_model
59
+	 */
60
+	private $ticket_model;
61 61
 
62
-    /**
63
-     * @var TicketDatetimeAvailabilityTracker $tracker
64
-     */
65
-    private $tracker;
62
+	/**
63
+	 * @var TicketDatetimeAvailabilityTracker $tracker
64
+	 */
65
+	private $tracker;
66 66
 
67 67
 
68
-    /**
69
-     * ProcessTicketSelector constructor.
70
-     * NOTE: PLZ use the Loader to instantiate this class if need be
71
-     * so that all dependencies get injected correctly (which will happen automatically)
72
-     * Null values for parameters are only for backwards compatibility but will be removed later on.
73
-     *
74
-     * @param EE_Core_Config                    $core_config
75
-     * @param RequestInterface                           $request
76
-     * @param EE_Session                        $session
77
-     * @param EEM_Ticket                        $ticket_model
78
-     * @param TicketDatetimeAvailabilityTracker $tracker
79
-     * @throws InvalidArgumentException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     */
83
-    public function __construct(
84
-        EE_Core_Config $core_config = null,
85
-        RequestInterface $request = null,
86
-        EE_Session $session = null,
87
-        EEM_Ticket $ticket_model = null,
88
-        TicketDatetimeAvailabilityTracker $tracker = null
89
-    ) {
90
-        $loader = LoaderFactory::getLoader();
91
-        $this->core_config = $core_config instanceof EE_Core_Config
92
-            ? $core_config
93
-            : $loader->getShared('EE_Core_Config');
94
-        $this->request = $request instanceof RequestInterface
95
-            ? $request
96
-            : $loader->getShared('EventEspresso\core\services\request\Request');
97
-        $this->session = $session instanceof EE_Session
98
-            ? $session
99
-            : $loader->getShared('EE_Session');
100
-        $this->ticket_model = $ticket_model instanceof EEM_Ticket
101
-            ? $ticket_model
102
-            : $loader->getShared('EEM_Ticket');
103
-        $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
-            ? $tracker
105
-            : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
-    }
68
+	/**
69
+	 * ProcessTicketSelector constructor.
70
+	 * NOTE: PLZ use the Loader to instantiate this class if need be
71
+	 * so that all dependencies get injected correctly (which will happen automatically)
72
+	 * Null values for parameters are only for backwards compatibility but will be removed later on.
73
+	 *
74
+	 * @param EE_Core_Config                    $core_config
75
+	 * @param RequestInterface                           $request
76
+	 * @param EE_Session                        $session
77
+	 * @param EEM_Ticket                        $ticket_model
78
+	 * @param TicketDatetimeAvailabilityTracker $tracker
79
+	 * @throws InvalidArgumentException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 */
83
+	public function __construct(
84
+		EE_Core_Config $core_config = null,
85
+		RequestInterface $request = null,
86
+		EE_Session $session = null,
87
+		EEM_Ticket $ticket_model = null,
88
+		TicketDatetimeAvailabilityTracker $tracker = null
89
+	) {
90
+		$loader = LoaderFactory::getLoader();
91
+		$this->core_config = $core_config instanceof EE_Core_Config
92
+			? $core_config
93
+			: $loader->getShared('EE_Core_Config');
94
+		$this->request = $request instanceof RequestInterface
95
+			? $request
96
+			: $loader->getShared('EventEspresso\core\services\request\Request');
97
+		$this->session = $session instanceof EE_Session
98
+			? $session
99
+			: $loader->getShared('EE_Session');
100
+		$this->ticket_model = $ticket_model instanceof EEM_Ticket
101
+			? $ticket_model
102
+			: $loader->getShared('EEM_Ticket');
103
+		$this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
+			? $tracker
105
+			: $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * cancelTicketSelections
111
-     *
112
-     * @return bool
113
-     * @throws EE_Error
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidInterfaceException
116
-     * @throws InvalidDataTypeException
117
-     * @throws ReflectionException
118
-     */
119
-    public function cancelTicketSelections()
120
-    {
121
-        // check nonce
122
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
123
-            return false;
124
-        }
125
-        $this->session->clear_session(__CLASS__, __FUNCTION__);
126
-        if ($this->request->requestParamIsSet('event_id')) {
127
-            EEH_URL::safeRedirectAndExit(
128
-                EEH_Event_View::event_link_url(
129
-                    $this->request->getRequestParam('event_id', 0, 'int')
130
-                )
131
-            );
132
-        }
133
-        EEH_URL::safeRedirectAndExit(
134
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
135
-        );
136
-        return true;
137
-    }
109
+	/**
110
+	 * cancelTicketSelections
111
+	 *
112
+	 * @return bool
113
+	 * @throws EE_Error
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidInterfaceException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws ReflectionException
118
+	 */
119
+	public function cancelTicketSelections()
120
+	{
121
+		// check nonce
122
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
123
+			return false;
124
+		}
125
+		$this->session->clear_session(__CLASS__, __FUNCTION__);
126
+		if ($this->request->requestParamIsSet('event_id')) {
127
+			EEH_URL::safeRedirectAndExit(
128
+				EEH_Event_View::event_link_url(
129
+					$this->request->getRequestParam('event_id', 0, 'int')
130
+				)
131
+			);
132
+		}
133
+		EEH_URL::safeRedirectAndExit(
134
+			site_url('/' . $this->core_config->event_cpt_slug . '/')
135
+		);
136
+		return true;
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * processTicketSelectorNonce
142
-     *
143
-     * @param  string $nonce_name
144
-     * @param string  $id
145
-     * @return bool
146
-     */
147
-    private function processTicketSelectorNonce($nonce_name, $id = '')
148
-    {
149
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
150
-        if (
151
-            ! $this->request->isAdmin()
152
-            && (
153
-                ! $this->request->requestParamIsSet($nonce_name_with_id)
154
-                || ! wp_verify_nonce(
155
-                    $this->request->getRequestParam($nonce_name_with_id),
156
-                    $nonce_name
157
-                )
158
-            )
159
-        ) {
160
-            EE_Error::add_error(
161
-                sprintf(
162
-                    esc_html__(
163
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
164
-                        'event_espresso'
165
-                    ),
166
-                    '<br/>'
167
-                ),
168
-                __FILE__,
169
-                __FUNCTION__,
170
-                __LINE__
171
-            );
172
-            return false;
173
-        }
174
-        return true;
175
-    }
140
+	/**
141
+	 * processTicketSelectorNonce
142
+	 *
143
+	 * @param  string $nonce_name
144
+	 * @param string  $id
145
+	 * @return bool
146
+	 */
147
+	private function processTicketSelectorNonce($nonce_name, $id = '')
148
+	{
149
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
150
+		if (
151
+			! $this->request->isAdmin()
152
+			&& (
153
+				! $this->request->requestParamIsSet($nonce_name_with_id)
154
+				|| ! wp_verify_nonce(
155
+					$this->request->getRequestParam($nonce_name_with_id),
156
+					$nonce_name
157
+				)
158
+			)
159
+		) {
160
+			EE_Error::add_error(
161
+				sprintf(
162
+					esc_html__(
163
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
164
+						'event_espresso'
165
+					),
166
+					'<br/>'
167
+				),
168
+				__FILE__,
169
+				__FUNCTION__,
170
+				__LINE__
171
+			);
172
+			return false;
173
+		}
174
+		return true;
175
+	}
176 176
 
177 177
 
178
-    /**
179
-     * process_ticket_selections
180
-     *
181
-     * @return bool
182
-     * @throws EE_Error
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     * @throws ReflectionException
187
-     */
188
-    public function processTicketSelections()
189
-    {
190
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
191
-        if ($this->request->isBot()) {
192
-            EEH_URL::safeRedirectAndExit(
193
-                apply_filters(
194
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
195
-                    site_url()
196
-                )
197
-            );
198
-        }
199
-        // we should really only have 1 registration in the works now
200
-        // (ie, no MER) so unless otherwise requested, clear the session
201
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
202
-            $this->session->clear_session(__CLASS__, __FUNCTION__);
203
-        }
204
-        // validate/sanitize/filter data
205
-        $id = null;
206
-        $valid = [];
207
-        try {
208
-            $post_data_validator = new ProcessTicketSelectorPostData($this->request);
209
-            $id = $post_data_validator->getEventId();
210
-            $valid               = apply_filters(
211
-                'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
212
-                $post_data_validator->validatePostData()
213
-            );
214
-        } catch (Exception $exception) {
215
-            EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
216
-        }
217
-        // check total tickets ordered vs max number of attendees that can register
218
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
219
-            $this->maxAttendeesViolation($valid);
220
-        } else {
221
-            // all data appears to be valid
222
-            if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
223
-                return true;
224
-            }
225
-        }
226
-        // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
227
-        // at this point, just return if registration is being made from admin
228
-        if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
229
-            return false;
230
-        }
231
-        if (! empty($valid['return_url'])) {
232
-            EEH_URL::safeRedirectAndExit($valid['return_url']);
233
-        }
234
-        // do we have an event id?
235
-        if ($id) {
236
-            EEH_URL::safeRedirectAndExit(get_permalink($id));
237
-        }
238
-        echo EE_Error::get_notices(); // already escaped
239
-        return false;
240
-    }
178
+	/**
179
+	 * process_ticket_selections
180
+	 *
181
+	 * @return bool
182
+	 * @throws EE_Error
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 * @throws ReflectionException
187
+	 */
188
+	public function processTicketSelections()
189
+	{
190
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
191
+		if ($this->request->isBot()) {
192
+			EEH_URL::safeRedirectAndExit(
193
+				apply_filters(
194
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
195
+					site_url()
196
+				)
197
+			);
198
+		}
199
+		// we should really only have 1 registration in the works now
200
+		// (ie, no MER) so unless otherwise requested, clear the session
201
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
202
+			$this->session->clear_session(__CLASS__, __FUNCTION__);
203
+		}
204
+		// validate/sanitize/filter data
205
+		$id = null;
206
+		$valid = [];
207
+		try {
208
+			$post_data_validator = new ProcessTicketSelectorPostData($this->request);
209
+			$id = $post_data_validator->getEventId();
210
+			$valid               = apply_filters(
211
+				'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
212
+				$post_data_validator->validatePostData()
213
+			);
214
+		} catch (Exception $exception) {
215
+			EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
216
+		}
217
+		// check total tickets ordered vs max number of attendees that can register
218
+		if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
219
+			$this->maxAttendeesViolation($valid);
220
+		} else {
221
+			// all data appears to be valid
222
+			if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
223
+				return true;
224
+			}
225
+		}
226
+		// die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
227
+		// at this point, just return if registration is being made from admin
228
+		if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
229
+			return false;
230
+		}
231
+		if (! empty($valid['return_url'])) {
232
+			EEH_URL::safeRedirectAndExit($valid['return_url']);
233
+		}
234
+		// do we have an event id?
235
+		if ($id) {
236
+			EEH_URL::safeRedirectAndExit(get_permalink($id));
237
+		}
238
+		echo EE_Error::get_notices(); // already escaped
239
+		return false;
240
+	}
241 241
 
242 242
 
243
-    /**
244
-     * @param array $valid
245
-     */
246
-    private function maxAttendeesViolation(array $valid)
247
-    {
248
-        // ordering too many tickets !!!
249
-        $total_tickets_string = esc_html(
250
-            _n(
251
-                'You have attempted to purchase %s ticket.',
252
-                'You have attempted to purchase %s tickets.',
253
-                $valid['total_tickets'],
254
-                'event_espresso'
255
-            )
256
-        );
257
-        $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
258
-        // dev only message
259
-        $max_attendees_string = esc_html(
260
-            _n(
261
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
262
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
263
-                $valid['max_atndz'],
264
-                'event_espresso'
265
-            )
266
-        );
267
-        $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
268
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
269
-    }
243
+	/**
244
+	 * @param array $valid
245
+	 */
246
+	private function maxAttendeesViolation(array $valid)
247
+	{
248
+		// ordering too many tickets !!!
249
+		$total_tickets_string = esc_html(
250
+			_n(
251
+				'You have attempted to purchase %s ticket.',
252
+				'You have attempted to purchase %s tickets.',
253
+				$valid['total_tickets'],
254
+				'event_espresso'
255
+			)
256
+		);
257
+		$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
258
+		// dev only message
259
+		$max_attendees_string = esc_html(
260
+			_n(
261
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
262
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
263
+				$valid['max_atndz'],
264
+				'event_espresso'
265
+			)
266
+		);
267
+		$limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
268
+		EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
269
+	}
270 270
 
271 271
 
272
-    /**
273
-     * @param array $valid
274
-     * @return int
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     */
280
-    private function addTicketsToCart(array $valid)
281
-    {
282
-        $tickets_added = 0;
283
-        $tickets_selected = false;
284
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
285
-            // load cart using factory because we don't want to do so until actually needed
286
-            $this->cart = CartFactory::getCart();
287
-            // if the user is an admin that can edit registrations,
288
-            // then we'll also allow them to add any tickets, even if they are expired
289
-            $current_user_is_admin = current_user_can('ee_edit_registrations');
290
-            // cycle thru the number of data rows sent from the event listing
291
-            for ($x = 0; $x < $valid['rows']; $x++) {
292
-                // does this row actually contain a ticket quantity?
293
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
294
-                    // YES we have a ticket quantity
295
-                    $tickets_selected = true;
296
-                    $valid_ticket = false;
297
-                    if (isset($valid['ticket_id'][ $x ])) {
298
-                        // get ticket via the ticket id we put in the form
299
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
300
-                        if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
301
-                            $valid_ticket = true;
302
-                            $tickets_added += $this->addTicketToCart(
303
-                                $ticket,
304
-                                $valid['qty'][ $x ]
305
-                            );
306
-                        }
307
-                    }
308
-                    if ($valid_ticket !== true) {
309
-                        // nothing added to cart retrieved
310
-                        EE_Error::add_error(
311
-                            sprintf(
312
-                                esc_html__(
313
-                                    'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
314
-                                    'event_espresso'
315
-                                ),
316
-                                '<br/>'
317
-                            ),
318
-                            __FILE__,
319
-                            __FUNCTION__,
320
-                            __LINE__
321
-                        );
322
-                    }
323
-                    if (EE_Error::has_error()) {
324
-                        break;
325
-                    }
326
-                }
327
-            }
328
-        }
329
-        do_action(
330
-            'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
331
-            $this->cart,
332
-            $this
333
-        );
334
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
335
-            // no ticket quantities were selected
336
-            EE_Error::add_error(
337
-                esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
338
-                __FILE__,
339
-                __FUNCTION__,
340
-                __LINE__
341
-            );
342
-        }
343
-        return $tickets_added;
344
-    }
272
+	/**
273
+	 * @param array $valid
274
+	 * @return int
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 */
280
+	private function addTicketsToCart(array $valid)
281
+	{
282
+		$tickets_added = 0;
283
+		$tickets_selected = false;
284
+		if (! empty($valid) && $valid['total_tickets'] > 0) {
285
+			// load cart using factory because we don't want to do so until actually needed
286
+			$this->cart = CartFactory::getCart();
287
+			// if the user is an admin that can edit registrations,
288
+			// then we'll also allow them to add any tickets, even if they are expired
289
+			$current_user_is_admin = current_user_can('ee_edit_registrations');
290
+			// cycle thru the number of data rows sent from the event listing
291
+			for ($x = 0; $x < $valid['rows']; $x++) {
292
+				// does this row actually contain a ticket quantity?
293
+				if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
294
+					// YES we have a ticket quantity
295
+					$tickets_selected = true;
296
+					$valid_ticket = false;
297
+					if (isset($valid['ticket_id'][ $x ])) {
298
+						// get ticket via the ticket id we put in the form
299
+						$ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
300
+						if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
301
+							$valid_ticket = true;
302
+							$tickets_added += $this->addTicketToCart(
303
+								$ticket,
304
+								$valid['qty'][ $x ]
305
+							);
306
+						}
307
+					}
308
+					if ($valid_ticket !== true) {
309
+						// nothing added to cart retrieved
310
+						EE_Error::add_error(
311
+							sprintf(
312
+								esc_html__(
313
+									'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
314
+									'event_espresso'
315
+								),
316
+								'<br/>'
317
+							),
318
+							__FILE__,
319
+							__FUNCTION__,
320
+							__LINE__
321
+						);
322
+					}
323
+					if (EE_Error::has_error()) {
324
+						break;
325
+					}
326
+				}
327
+			}
328
+		}
329
+		do_action(
330
+			'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
331
+			$this->cart,
332
+			$this
333
+		);
334
+		if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
335
+			// no ticket quantities were selected
336
+			EE_Error::add_error(
337
+				esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
338
+				__FILE__,
339
+				__FUNCTION__,
340
+				__LINE__
341
+			);
342
+		}
343
+		return $tickets_added;
344
+	}
345 345
 
346 346
 
347
-    /**
348
-     * adds a ticket to the cart
349
-     *
350
-     * @param EE_Ticket $ticket
351
-     * @param int       $qty
352
-     * @return bool TRUE on success, FALSE on fail
353
-     * @throws InvalidArgumentException
354
-     * @throws InvalidInterfaceException
355
-     * @throws InvalidDataTypeException
356
-     * @throws EE_Error
357
-     */
358
-    private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
359
-    {
360
-        // get the number of spaces left for this datetime ticket
361
-        $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
362
-        // compare available spaces against the number of tickets being purchased
363
-        if ($available_spaces >= $qty) {
364
-            // allow addons to prevent a ticket from being added to cart
365
-            if (
366
-                ! apply_filters(
367
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
368
-                    true,
369
-                    $ticket,
370
-                    $qty,
371
-                    $available_spaces
372
-                )
373
-            ) {
374
-                return false;
375
-            }
376
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
377
-            // add event to cart
378
-            if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
379
-                $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
380
-                return true;
381
-            }
382
-            return false;
383
-        }
384
-        $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
385
-        return false;
386
-    }
347
+	/**
348
+	 * adds a ticket to the cart
349
+	 *
350
+	 * @param EE_Ticket $ticket
351
+	 * @param int       $qty
352
+	 * @return bool TRUE on success, FALSE on fail
353
+	 * @throws InvalidArgumentException
354
+	 * @throws InvalidInterfaceException
355
+	 * @throws InvalidDataTypeException
356
+	 * @throws EE_Error
357
+	 */
358
+	private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
359
+	{
360
+		// get the number of spaces left for this datetime ticket
361
+		$available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
362
+		// compare available spaces against the number of tickets being purchased
363
+		if ($available_spaces >= $qty) {
364
+			// allow addons to prevent a ticket from being added to cart
365
+			if (
366
+				! apply_filters(
367
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
368
+					true,
369
+					$ticket,
370
+					$qty,
371
+					$available_spaces
372
+				)
373
+			) {
374
+				return false;
375
+			}
376
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
377
+			// add event to cart
378
+			if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
379
+				$this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
380
+				return true;
381
+			}
382
+			return false;
383
+		}
384
+		$this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
385
+		return false;
386
+	}
387 387
 
388 388
 
389
-    /**
390
-     * @param $tickets_added
391
-     * @return bool
392
-     * @throws InvalidInterfaceException
393
-     * @throws InvalidDataTypeException
394
-     * @throws EE_Error
395
-     * @throws InvalidArgumentException
396
-     */
397
-    private function processSuccessfulCart($tickets_added)
398
-    {
399
-        // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
400
-        if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
401
-            // make sure cart is loaded
402
-            if (! $this->cart instanceof EE_Cart) {
403
-                $this->cart = CartFactory::getCart();
404
-            }
405
-            do_action(
406
-                'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
407
-                $this->cart,
408
-                $this
409
-            );
410
-            $this->cart->recalculate_all_cart_totals();
411
-            $this->cart->save_cart(false);
412
-            // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
413
-            // just return TRUE for registrations being made from admin
414
-            if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
415
-                return true;
416
-            }
417
-            EEH_URL::safeRedirectAndExit(
418
-                apply_filters(
419
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
420
-                    $this->core_config->reg_page_url()
421
-                )
422
-            );
423
-        }
424
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
425
-            // nothing added to cart
426
-            EE_Error::add_attention(
427
-                esc_html__('No tickets were added for the event', 'event_espresso'),
428
-                __FILE__,
429
-                __FUNCTION__,
430
-                __LINE__
431
-            );
432
-        }
433
-        return false;
434
-    }
389
+	/**
390
+	 * @param $tickets_added
391
+	 * @return bool
392
+	 * @throws InvalidInterfaceException
393
+	 * @throws InvalidDataTypeException
394
+	 * @throws EE_Error
395
+	 * @throws InvalidArgumentException
396
+	 */
397
+	private function processSuccessfulCart($tickets_added)
398
+	{
399
+		// exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
400
+		if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
401
+			// make sure cart is loaded
402
+			if (! $this->cart instanceof EE_Cart) {
403
+				$this->cart = CartFactory::getCart();
404
+			}
405
+			do_action(
406
+				'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
407
+				$this->cart,
408
+				$this
409
+			);
410
+			$this->cart->recalculate_all_cart_totals();
411
+			$this->cart->save_cart(false);
412
+			// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
413
+			// just return TRUE for registrations being made from admin
414
+			if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
415
+				return true;
416
+			}
417
+			EEH_URL::safeRedirectAndExit(
418
+				apply_filters(
419
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
420
+					$this->core_config->reg_page_url()
421
+				)
422
+			);
423
+		}
424
+		if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
425
+			// nothing added to cart
426
+			EE_Error::add_attention(
427
+				esc_html__('No tickets were added for the event', 'event_espresso'),
428
+				__FILE__,
429
+				__FUNCTION__,
430
+				__LINE__
431
+			);
432
+		}
433
+		return false;
434
+	}
435 435
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function cancelTicketSelections()
120 120
     {
121 121
         // check nonce
122
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
123 123
             return false;
124 124
         }
125 125
         $this->session->clear_session(__CLASS__, __FUNCTION__);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             );
132 132
         }
133 133
         EEH_URL::safeRedirectAndExit(
134
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
134
+            site_url('/'.$this->core_config->event_cpt_slug.'/')
135 135
         );
136 136
         return true;
137 137
     }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
216 216
         }
217 217
         // check total tickets ordered vs max number of attendees that can register
218
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
218
+        if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
219 219
             $this->maxAttendeesViolation($valid);
220 220
         } else {
221 221
             // all data appears to be valid
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
229 229
             return false;
230 230
         }
231
-        if (! empty($valid['return_url'])) {
231
+        if ( ! empty($valid['return_url'])) {
232 232
             EEH_URL::safeRedirectAndExit($valid['return_url']);
233 233
         }
234 234
         // do we have an event id?
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             )
266 266
         );
267 267
         $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
268
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
268
+        EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
269 269
     }
270 270
 
271 271
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     {
282 282
         $tickets_added = 0;
283 283
         $tickets_selected = false;
284
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
284
+        if ( ! empty($valid) && $valid['total_tickets'] > 0) {
285 285
             // load cart using factory because we don't want to do so until actually needed
286 286
             $this->cart = CartFactory::getCart();
287 287
             // if the user is an admin that can edit registrations,
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
             // cycle thru the number of data rows sent from the event listing
291 291
             for ($x = 0; $x < $valid['rows']; $x++) {
292 292
                 // does this row actually contain a ticket quantity?
293
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
293
+                if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
294 294
                     // YES we have a ticket quantity
295 295
                     $tickets_selected = true;
296 296
                     $valid_ticket = false;
297
-                    if (isset($valid['ticket_id'][ $x ])) {
297
+                    if (isset($valid['ticket_id'][$x])) {
298 298
                         // get ticket via the ticket id we put in the form
299
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
299
+                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]);
300 300
                         if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
301 301
                             $valid_ticket = true;
302 302
                             $tickets_added += $this->addTicketToCart(
303 303
                                 $ticket,
304
-                                $valid['qty'][ $x ]
304
+                                $valid['qty'][$x]
305 305
                             );
306 306
                         }
307 307
                     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             $this->cart,
332 332
             $this
333 333
         );
334
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
334
+        if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
335 335
             // no ticket quantities were selected
336 336
             EE_Error::add_error(
337 337
                 esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
400 400
         if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
401 401
             // make sure cart is loaded
402
-            if (! $this->cart instanceof EE_Cart) {
402
+            if ( ! $this->cart instanceof EE_Cart) {
403 403
                 $this->cart = CartFactory::getCart();
404 404
             }
405 405
             do_action(
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
                 )
422 422
             );
423 423
         }
424
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
424
+        if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
425 425
             // nothing added to cart
426 426
             EE_Error::add_attention(
427 427
                 esc_html__('No tickets were added for the event', 'event_espresso'),
Please login to merge, or discard this patch.