PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.10 2.0.11 All 82 releases
← All changes | app/Controllers/SettingsController.php +33 -6 3.0.13trunk View file →
@@ -102,8 +102,10 @@
102 102 'scheduled_payment_days' => 15, // Days until first scheduled payment
103 103 'scheduled_payment_installments' => 1, // Number of installments (if type is installments)
104 104 'scheduled_payment_interval' => 30, // Days between installments
105 105 'scheduled_payment_reminder_days' => 3, // Days before to send reminder
106 + 'balance_anchor' => 'booking', // 'booking' (BC default) | 'tour' (relative to tour date)
107 + 'balance_due_days' => 14, // When anchor=tour: balance due this many days before the tour
106 108 'allow_save_payment_methods' => false,
107 109
108 110 // Email Settings (WordPress site defaults when Yatra options are missing)
109 111 'admin_email' => $wpAdminEmail,
@@ -231,8 +233,12 @@
231 233 'search_show_destination' => true,
232 234 'search_show_activities' => true,
233 235 'search_show_duration' => true,
234 236 'search_show_budget' => true,
237 + // Date field is opt-in (default false) so updating the plugin never
238 + // changes an existing site's search bar. Operators enable it to let
239 + // customers find trips with a departure on a specific date.
240 + 'search_show_date' => false,
235 241 'collapse_filters_on_mobile' => false,
236 242
237 243 // Booking Page Settings
238 244 'use_booking_page' => false,
@@ -389,15 +395,23 @@
389 395 {
390 396 try {
391 397 $settings = [];
392 398
393 - // Get all settings from WordPress options table with yatra_ prefix
399 + // Get all settings from WordPress options table with yatra_ prefix.
400 + // A sentinel default is essential here: get_option() returns boolean
401 + // false for a stored-false option just as it does for a missing one,
402 + // so checking `=== false` would reset every saved-off boolean back to
403 + // its default. That is exactly the "Show sold-out dates" bug — the
404 + // storefront honoured the saved value (isEnabled coerces '' -> false)
405 + // while the admin checkbox re-appeared enabled because this endpoint
406 + // handed React the default (true) instead of the saved false.
407 + $unset_sentinel = "\0__yatra_option_unset__\0";
394 408 foreach ($this->default_settings as $key => $default_value) {
395 409 $option_name = 'yatra_' . $key;
396 - $value = get_option($option_name, false);
397 -
398 - // Only use default if option doesn't exist (wasn't set by InstallerService)
399 - if ($value === false) {
410 + $value = get_option($option_name, $unset_sentinel);
411 +
412 + // Only use default when the option truly does not exist.
413 + if ($value === $unset_sentinel) {
400 414 $value = $default_value;
401 415 }
402 416
403 417 // Stored empty string should behave like "unset" for delivery identity (matches installer / backfill).
@@ -418,9 +432,18 @@
418 432 // Ensure arrays are returned as arrays (not objects)
419 433 if (is_array($default_value) && !is_array($value)) {
420 434 $value = [];
421 435 }
422 -
436 +
437 + // Boolean settings must round-trip to the admin as real booleans.
438 + // update_option() stores false as '' and the object cache can
439 + // return boolean false, so without this a disabled toggle would
440 + // reach React as '' / false and the checkbox (checked unless the
441 + // value is strictly !== false) would render enabled again.
442 + if (is_bool($default_value)) {
443 + $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
444 + }
445 +
423 446 $settings[$key] = $value;
424 447 }
425 448
426 449 // Special handling for booking_form_config - always use getBookingFormConfig which handles locked fields
@@ -445,8 +468,10 @@
445 468 'scheduled_payment_days',
446 469 'scheduled_payment_installments',
447 470 'scheduled_payment_interval',
448 471 'scheduled_payment_reminder_days',
472 + 'balance_anchor',
473 + 'balance_due_days',
449 474 ] as $sk
450 475 ) {
451 476 if (array_key_exists($sk, $this->default_settings)) {
452 477 $settings[$sk] = \Yatra\Services\SettingsService::get(
@@ -505,8 +530,10 @@
505 530 'scheduled_payment_days',
506 531 'scheduled_payment_installments',
507 532 'scheduled_payment_interval',
508 533 'scheduled_payment_reminder_days',
534 + 'balance_anchor',
535 + 'balance_due_days',
509 536 ];
510 537
511 538 // Collect flexible payment settings to delegate to Pro
512 539 $flexible_payment_settings = [];