PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Services/TravelerCategoryService.php +26 -4 3.0.6 → 3.0.16 View file →
@@ -144,8 +144,17 @@
144 144 if ($min_pax > $max_pax) {
145 145 throw new \InvalidArgumentException('Maximum group size must be greater than or equal to minimum group size');
146 146 }
147 147 }
148 +
149 + // "Charge for additional groups" needs a maximum group size to know
150 + // how big one group (one priced block) is.
151 + if (
152 + ($data['group_overflow'] ?? 'block') === 'per_block' &&
153 + (!isset($data['max_pax']) || $data['max_pax'] === '' || $data['max_pax'] === null || (int) $data['max_pax'] <= 0)
154 + ) {
155 + throw new \InvalidArgumentException('Maximum group size is required to charge for additional groups');
156 + }
148 157 }
149 158 }
150 159
151 160 /**
@@ -212,16 +221,22 @@
212 221 if (isset($data['max_pax']) && $data['max_pax'] !== '' && $data['max_pax'] !== null) {
213 222 $metadata['max_pax'] = (int) $data['max_pax'];
214 223 }
215 224
225 + if (isset($data['group_overflow'])) {
226 + $metadata['group_overflow'] = in_array($data['group_overflow'], ['block', 'per_block'], true)
227 + ? $data['group_overflow']
228 + : 'block';
229 + }
230 +
216 231 // Set the type for traveler categories
217 232 $data['type'] = 'traveler_type';
218 -
233 +
219 234 // Store metadata as JSON
220 235 $data['metadata'] = wp_json_encode($metadata);
221 236
222 237 // Remove old field names that don't exist in ClassificationsTable
223 - unset($data['age_min'], $data['age_max'], $data['pricing_mode'], $data['min_pax'], $data['max_pax']);
238 + unset($data['age_min'], $data['age_max'], $data['pricing_mode'], $data['min_pax'], $data['max_pax'], $data['group_overflow']);
224 239
225 240 // Set created_by and updated_by to current user
226 241 $current_user_id = get_current_user_id();
227 242 $data['created_by'] = absint($current_user_id);
@@ -344,13 +359,20 @@
344 359 $metadata['max_pax'] = absint($data['max_pax']);
345 360 }
346 361 }
347 362
348 - // Store updated metadata as JSON
363 + if (isset($data['group_overflow'])) {
364 + $metadata['group_overflow'] = in_array($data['group_overflow'], ['block', 'per_block'], true)
365 + ? $data['group_overflow']
366 + : 'block';
367 + }
368 +
369 + // Store updated metadata as JSON (existing metadata read above, so
370 + // untouched keys are preserved — only the keys present in $data change).
349 371 $data['metadata'] = wp_json_encode($metadata);
350 372
351 373 // Remove old field names that don't exist in ClassificationsTable
352 - unset($data['age_min'], $data['age_max'], $data['pricing_mode'], $data['min_pax'], $data['max_pax']);
374 + unset($data['age_min'], $data['age_max'], $data['pricing_mode'], $data['min_pax'], $data['max_pax'], $data['group_overflow']);
353 375
354 376 // Sanitize and serialize icon if it's an array
355 377 if (isset($data['icon'])) {
356 378 if (is_array($data['icon'])) {