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 +29 -7 3.0.3 → 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 /**
@@ -168,9 +177,9 @@
168 177 // Always auto-generate slug from name (backend ensures uniqueness)
169 178 if (!empty($data['name'])) {
170 179 $data['slug'] = SlugHelper::generateUniqueFromDatabase(
171 180 $data['name'],
172 - 'yatra_new_classifications',
181 + 'yatra_classifications',
173 182 'slug'
174 183 );
175 184 } elseif (isset($data['slug'])) {
176 185 // If name is empty but slug is provided, sanitize it
@@ -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);
@@ -265,9 +280,9 @@
265 280 if ($preserveSlug && isset($data['slug']) && !empty($data['slug'])) {
266 281 // Slug was manually edited - preserve it but ensure uniqueness
267 282 $data['slug'] = SlugHelper::generateUniqueFromDatabase(
268 283 $data['slug'],
269 - 'yatra_new_classifications',
284 + 'yatra_classifications',
270 285 'slug',
271 286 $id // Exclude current record when checking uniqueness
272 287 );
273 288 } elseif (!empty($data['name'])) {
@@ -273,9 +288,9 @@
273 288 } elseif (!empty($data['name'])) {
274 289 // Auto-generate slug from name if name is provided and slug not manually edited
275 290 $data['slug'] = SlugHelper::generateUniqueFromDatabase(
276 291 $data['name'],
277 - 'yatra_new_classifications',
292 + 'yatra_classifications',
278 293 'slug',
279 294 $id // Exclude current record when checking uniqueness
280 295 );
281 296 } elseif (isset($data['slug'])) {
@@ -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'])) {