{__(
"Connect your Google Calendar to sync your bookings automatically. Each booking gets an event with the trip, date and traveller details, or, with \"One event per departure\" turned on in the Google Calendar dashboard, each departure gets one event listing its bookings.",
"yatra",
)}
{__("Create an OAuth client in", "yatra")}{" "}
{__("Google Cloud Credentials", "yatra")}
{__(", then paste the OAuth 2.0 Client ID here.", "yatra")}{" "}
{__("Example:", "yatra")}{" "}
123...apps.googleusercontent.com
>
}
>
setClientId(e.target.value)}
placeholder="123456789-xxxxx.apps.googleusercontent.com"
/>
{__(
"Copy the Client Secret from the same OAuth client in",
"yatra",
)}{" "}
{__("Google Cloud Credentials", "yatra")}
{__(".", "yatra")} {__("Keep this private.", "yatra")}
>
}
>
setClientSecret(e.target.value)}
placeholder="GOCSPX-xxxxxxxxxxxxxxxxxx"
/>
);
};
type SettingsSection =
| "api"
| "general"
| "design"
| "booking"
| "booking_form"
| "payment"
| "pricing"
| "trip"
| "search"
| "customer"
| "review"
| "labels"
| "tax"
| "currency"
| "integration"
| "permalink"
| "seo"
| "advanced"
| "uninstall";
// Form Builder Types
// Booking form builder types live in components/settings/booking-form-types.ts
// (shared with the per-trip Conditions popup).
interface PaymentGatewayConfig {
enabled: boolean;
icon?: string;
title?: string;
description?: string;
[key: string]: any;
}
interface GatewayField {
id: string;
type: string;
label: string;
description?: string;
placeholder?: string;
default?: any;
options?: Record;
condition?: string;
show_when?: Record; // Conditional display based on other field values
min?: number;
max?: number;
readonly?: boolean;
help_text?: string;
help_url?: string;
help_url_test?: string;
help_url_live?: string;
}
interface GatewayDefinition {
id: string;
title: string;
description: string;
icon: string;
sandbox_url?: string;
is_offline: boolean;
supports: string[];
fields: GatewayField[];
config: PaymentGatewayConfig;
enabled: boolean;
is_premium?: boolean;
requires_pro?: boolean;
}
interface SettingsData {
// General Settings
company_name: string;
company_email: string;
company_phone: string;
company_address: string;
company_city: string;
company_state: string;
company_country: string;
company_zip: string;
company_website: string;
company_logo: string;
timezone: string;
date_format: string;
time_format: string;
/** Hex brand color for public trip/booking/listing UI (buttons, links, accents) */
frontend_primary_color: string;
/** CSS max width for Yatra containers; empty = follow theme / theme.json */
frontend_container_max_width: string;
/** Trip listing card density: "standard" | "compact_mobile" | "compact_all" */
frontend_listing_card_layout: string;
// Google Calendar Settings
google_calendar_client_id?: string;
google_calendar_client_secret?: string;
google_calendar_calendar_id?: string;
google_calendar_calendar_name?: string;
google_calendar_connected?: boolean;
google_calendar_last_sync?: string | null;
google_calendar_enabled?: boolean;
// Search & Listing storefront UX
search_show_keyword: boolean;
search_show_destination: boolean;
search_show_activities: boolean;
search_show_duration: boolean;
search_show_budget: boolean;
search_show_date: boolean;
collapse_filters_on_mobile: boolean;
// Booking Settings
booking_confirmation: boolean;
auto_confirm_bookings: boolean;
auto_confirm_mode: "none" | "online" | "all";
pending_payment_email: "confirmation" | "after_payment";
require_login: boolean;
allow_guest_checkout: boolean;
require_guest_email_verification: boolean;
booking_expiry_hours: number;
booking_fee_type: string; // 3.3: none | fixed | percent
booking_fee_amount: number;
booking_fee_label: string;
travel_insurance_enabled: boolean;
travel_insurance_title: string;
travel_insurance_description: string;
travel_insurance_price_type: string;
travel_insurance_amount: number | string;
travel_insurance_terms_url: string;
travel_insurance_require_choice: boolean;
booking_reminder_days: number;
allow_waitlist: boolean;
waitlist_auto_confirm: boolean;
date_picker_as_dropdown: boolean;
// Payment Settings
currency: string;
payment_test_mode: boolean;
payment_gateways: string[];
payment_methods: string[];
partial_payment: boolean;
partial_payment_percentage: number;
deposit_required: boolean;
deposit_percentage: number;
auto_confirm_pay_later: boolean;
customer_requests_enabled: boolean;
customer_request_cutoff_days: number;
label_overrides: { from: string; to: string }[];
weather_enabled: boolean;
recently_viewed_enabled: boolean;
weather_api_key: string;
weather_units: string;
social_proof_popup: boolean;
social_proof_popup_names: boolean;
social_proof_days: number | string;
social_proof_booked_badge: boolean;
social_proof_badge_min: number | string;
enquiry_custom_fields: {
id: string;
label: string;
type: string;
required: boolean;
options: string[];
}[];
enable_scheduled_payments: boolean;
scheduled_payment_type: string;
scheduled_payment_days: number;
scheduled_payment_installments: number;
scheduled_payment_interval: number;
scheduled_payment_reminder_days: number;
balance_anchor: string;
balance_due_days: number;
gateway_configs: Record;
gateway_order?: string[];
// Pricing Settings
// Controls how Advanced Discount + Dynamic Pricing combine on the same
// booking. Surfaced in Settings → Pricing only when BOTH modules are
// enabled; backend enforcement is also gated by both modules being on,
// so a stale 'discount_only' value on a site that disabled DP is inert.
discount_stacking_mode?:
| "both"
| "discount_only"
| "dynamic_pricing_only"
| "best_for_customer";
// Email Settings
admin_email: string;
from_email: string;
from_name: string;
email_template_booking: boolean;
email_template_confirmation: boolean;
email_template_cancellation: boolean;
email_template_reminder: boolean;
email_template_admin_new_booking: boolean;
email_template_admin_payment: boolean;
email_template_admin_cancellation: boolean;
email_template_trip_consent: boolean;
email_template_customer_verification: boolean;
email_template_guest_verification: boolean;
email_template_booking_completed: boolean;
email_template_booking_expired_customer: boolean;
email_template_admin_booking_expired: boolean;
email_template_scheduled_payment_reminder: boolean;
email_template_scheduled_payment_succeeded: boolean;
email_template_scheduled_payment_failed: boolean;
email_template_admin_scheduled_payment_failed: boolean;
email_template_enquiry_received: boolean;
email_template_enquiry_admin: boolean;
email_template_enquiry_response: boolean;
email_template_review_request: boolean;
email_template_abandoned_booking_recovery_first: boolean;
email_template_abandoned_booking_recovery_second: boolean;
email_template_abandoned_booking_recovery_final: boolean;
smtp_enabled: boolean;
smtp_host: string;
smtp_port: number;
smtp_username: string;
smtp_password: string;
smtp_encryption: string;
email_tpl_booking_subject: string;
email_tpl_booking_body: string;
email_tpl_payment_subject: string;
email_tpl_payment_body: string;
email_tpl_cancellation_subject: string;
email_tpl_cancellation_body: string;
email_tpl_reminder_subject: string;
email_tpl_reminder_body: string;
email_tpl_admin_booking_subject: string;
email_tpl_admin_booking_body: string;
email_tpl_admin_payment_subject: string;
email_tpl_admin_payment_body: string;
email_tpl_admin_cancellation_subject: string;
email_tpl_admin_cancellation_body: string;
email_tpl_trip_consent_subject: string;
email_tpl_trip_consent_body: string;
email_tpl_customer_verification_subject: string;
email_tpl_customer_verification_body: string;
email_tpl_guest_verification_subject: string;
email_tpl_guest_verification_body: string;
email_tpl_booking_completed_subject: string;
email_tpl_booking_completed_body: string;
email_tpl_booking_expired_customer_subject: string;
email_tpl_booking_expired_customer_body: string;
email_tpl_admin_booking_expired_subject: string;
email_tpl_admin_booking_expired_body: string;
email_tpl_scheduled_payment_reminder_subject: string;
email_tpl_scheduled_payment_reminder_body: string;
email_tpl_scheduled_payment_succeeded_subject: string;
email_tpl_scheduled_payment_succeeded_body: string;
email_tpl_scheduled_payment_failed_subject: string;
email_tpl_scheduled_payment_failed_body: string;
email_tpl_admin_scheduled_payment_failed_subject: string;
email_tpl_admin_scheduled_payment_failed_body: string;
email_tpl_enquiry_received_subject: string;
email_tpl_enquiry_received_body: string;
email_tpl_enquiry_admin_subject: string;
email_tpl_enquiry_admin_body: string;
email_tpl_enquiry_response_subject: string;
email_tpl_enquiry_response_body: string;
email_tpl_review_request_subject: string;
email_tpl_review_request_body: string;
email_tpl_abandoned_booking_recovery_first_subject: string;
email_tpl_abandoned_booking_recovery_first_body: string;
email_tpl_abandoned_booking_recovery_second_subject: string;
email_tpl_abandoned_booking_recovery_second_body: string;
email_tpl_abandoned_booking_recovery_final_subject: string;
email_tpl_abandoned_booking_recovery_final_body: string;
// Customer Settings
customer_registration: boolean;
customer_fields: string[];
require_email_verification: boolean;
customer_account_page: string;
allow_customer_reviews: boolean;
customer_dashboard_enabled: boolean;
/** Wishlist / saved trips (Yatra Pro); toggled in Customer settings */
enable_wishlist?: boolean;
/** Keep sold-out departure dates visible on the storefront (default true) */
show_sold_out?: boolean;
/** How many months ahead customers can see and book (1–36, default 12) */
availability_horizon_months?: number;
// Review Settings
enable_reviews: boolean;
require_booking: boolean;
auto_approve_reviews: boolean;
review_moderation: boolean;
min_rating: number;
allow_anonymous_reviews: boolean;
review_reminder_days: number;
review_reminder_max_age_days: number;
// Tax Settings
enable_tax: boolean;
tax_name: string;
tax_rate: number;
tax_inclusive: boolean;
vat_number: string;
tax_by_country: boolean;
tax_rates: Record;
multiple_taxes_enabled: boolean;
multiple_taxes: Array<{ name: string; rate: number }>;
multiple_taxes_by_country: Record<
string,
Array<{ name: string; rate: number }>
>;
// Currency Settings
default_currency: string;
multi_currency: boolean;
currency_position: string;
currency_decimals: number;
thousand_separator: string;
decimal_separator: string;
// Notification Settings (SMS; booking emails use Email → Templates)
sms_notifications: boolean;
sms_provider: string;
sms_api_key: string;
// Integration Settings
google_analytics: string;
facebook_pixel: string;
recaptcha_enabled: boolean;
recaptcha_site_key: string;
recaptcha_secret_key: string;
recaptcha_score_threshold: number;
recaptcha_protect_enquiry: boolean;
recaptcha_protect_booking: boolean;
recaptcha_protect_registration: boolean;
// Mailchimp Integration (Pro)
mailchimp_api_key?: string;
mailchimp_list_id?: string;
mailchimp_list_name?: string;
mailchimp_sync_on_booking?: boolean;
mailchimp_sync_on_payment?: boolean;
mailchimp_double_optin?: boolean;
mailchimp_subscribe_without_optin?: boolean;
mailchimp_add_tags?: boolean;
mailchimp_default_tags?: string[];
mailchimp_field_mapping?: Record;
// Facebook Pixel Enhanced (Pro)
facebook_pixel_id?: string;
fb_track_view_content?: boolean;
fb_track_initiate_checkout?: boolean;
fb_track_purchase?: boolean;
fb_track_add_to_cart?: boolean;
fb_use_conversions_api?: boolean;
facebook_access_token?: string;
fb_test_event_code?: string;
fb_event_config?: Record<
string,
{ enabled: boolean; custom_params?: string[] }
>;
fb_parameter_mapping?: Record;
// Google Analytics 4 Enhanced (Pro)
ga4_measurement_id?: string;
ga4_track_view_item?: boolean;
ga4_track_add_to_cart?: boolean;
ga4_track_begin_checkout?: boolean;
ga4_track_purchase?: boolean;
ga4_use_measurement_protocol?: boolean;
ga4_require_consent?: boolean;
ga4_api_secret?: string;
ga4_debug_mode?: boolean;
ga4_custom_dimensions?: Array<{
name: string;
yatra_field: string;
scope?: string;
}>;
ga4_event_config?: Record<
string,
{ enabled: boolean; custom_params?: string[] }
>;
// Permalink Settings
trip_base: string;
destination_base: string;
activity_base: string;
trip_category_base: string;
booking_base: string;
// Booking Page Settings
use_booking_page: boolean;
booking_page_id: number;
terms_page_id: number;
privacy_policy_page_id: number;
// Advanced Settings
debug_mode: boolean;
enable_logging: boolean;
delete_data_on_uninstall: boolean;
cache_enabled: boolean;
api_key: string;
api_rate_limit: number;
session_timeout: number;
// Booking Form Builder
booking_form_config: BookingFormConfig;
// SEO Settings
seo_trip_meta_title: string;
seo_trip_meta_description: string;
seo_trip_meta_keywords: string;
seo_trip_meta_image: number;
enable_sitemap: boolean;
sitemap_types: string[];
sitemap_noindex_excluded: boolean;
}
// Form Builder Component
type BookingFormSubTab =
| "contact_form"
| "emergency_contact_form"
| "traveler_form";
interface BookingFormBuilderProps {
formData: SettingsData;
setFormData: React.Dispatch>;
}
// Get initial sub-tab from localStorage
const getInitialFormSubTab = (): BookingFormSubTab => {
if (typeof window !== "undefined") {
const saved = localStorage.getItem("yatra_settings_booking_form_subtab");
if (
saved &&
["contact_form", "emergency_contact_form", "traveler_form"].includes(
saved,
)
) {
return saved as BookingFormSubTab;
}
}
return "contact_form";
};
const BookingFormBuilder: React.FC = ({
formData,
setFormData,
}) => {
const [activeFormTab, setActiveFormTab] =
useState(getInitialFormSubTab);
// Check if Dynamic Form Field module is enabled via modules API.
// NOTE: the key must differ from useModulesQuery()'s ["modules"] — this
// query caches the RAW { success, data } envelope, and the Modules page
// reads the same cache entry expecting a plain array. Sharing the key made
// Modules crash with "modules.forEach is not a function" after visiting
// Settings → Booking Form. The "modules" prefix keeps it invalidated by the
// module toggles.
const { data: modulesData } = useQuery({
queryKey: ["modules", "raw-envelope"],
queryFn: async () => {
const response = await apiService.getModules();
return response;
},
staleTime: 30000, // Cache for 30 seconds
});
// Check if module is enabled from API response or fallback to yatraAdmin
const isDynamicFormFieldEnabled = React.useMemo(() => {
if (modulesData?.data) {
const module = modulesData.data.find(
(m: any) => m.slug === "dynamic_form_field",
);
return module?.enabled === true && module?.is_available === true;
}
// Fallback to yatraAdmin if modules API hasn't loaded yet.
// Truthy check (not `=== true`) because wp_localize_script
// serialises every scalar to a string before exposing it to JS —
// true becomes "1", false becomes "". Same gotcha that bit the
// Discount Stacking tab visibility earlier this session.
return !!window.yatraAdmin?.dynamicFormFieldEnabled;
}, [modulesData]);
// Per-trip "Conditions" popup for the active form. Needs the module on AND a
// Pro build that resolves conditions at checkout (older Pro builds set the
// module flag but not this one — offering the popup there would save rules
// that never apply). Target names (trips / categories) are only fetched when
// there is something to label.
const conditionsSupported =
isDynamicFormFieldEnabled &&
!!window.yatraAdmin?.bookingFormConditionsEnabled;
const [conditionsOpen, setConditionsOpen] = useState(false);
const hasAnyConditions = React.useMemo(() => {
const cfg = formData?.booking_form_config;
return !!cfg && Object.values(cfg).some(
(s: any) => Array.isArray(s?.conditions) && s.conditions.length > 0,
);
}, [formData?.booking_form_config]);
const { options: conditionTargetOptions } = useConditionTargets(
conditionsSupported && hasAnyConditions,
);
// Save sub-tab to localStorage when it changes
const handleSubTabChange = (tab: BookingFormSubTab) => {
setActiveFormTab(tab);
if (typeof window !== "undefined") {
localStorage.setItem("yatra_settings_booking_form_subtab", tab);
}
};
// Traveler-section "Applies to" choices (only shown on the Traveler tab).
const appliesToOptions: { value: "all" | "lead"; label: string }[] = [
{ value: "all", label: __("All travelers", "yatra") },
{ value: "lead", label: __("Lead traveler only", "yatra") },
];
const formTabs = [
{
id: "contact_form" as const,
label: __("Contact Form", "yatra"),
description: "Lead traveler contact details",
},
{
id: "emergency_contact_form" as const,
label: __("Emergency Contact", "yatra"),
description: "Emergency contact information",
},
{
id: "traveler_form" as const,
label: __("Traveler Form", "yatra"),
description: "Individual traveler details",
},
];
const fieldTypes = [
{ value: "text", label: __("Text", "yatra") },
{ value: "email", label: __("Email", "yatra") },
{ value: "tel", label: __("Phone", "yatra") },
{ value: "date", label: __("Date", "yatra") },
{ value: "select", label: __("Dropdown", "yatra") },
{ value: "country", label: __("Country Selector", "yatra") },
{ value: "textarea", label: __("Text Area", "yatra") },
{ value: "number", label: __("Number", "yatra") },
{ value: "checkbox", label: __("Checkbox", "yatra") },
{ value: "text_block", label: __("Text Block (display only)", "yatra") },
];
const widthOptions = [
{ value: "full", label: "Full Width" },
{ value: "half", label: "Half Width" },
{ value: "third", label: "One Third" },
];
const getCurrentFormConfig = () => {
return (
formData?.booking_form_config?.[activeFormTab] || {
title: "",
description: "",
enabled: true,
fields: [],
}
);
};
// Booking confirmation, the customer account and the voucher all need an email.
// Warn the operator when neither the Contact nor the Traveler form will capture
// one (section disabled, or its email field disabled) — checkout enforces the
// same rule (lead-traveler email is used as a fallback when Contact is off).
const bookingFormCapturesEmail = (() => {
const cfg = formData?.booking_form_config;
if (!cfg) return true;
const sectionHasEnabledEmail = (section?: FormSectionConfig): boolean => {
if (!section || section.enabled === false) return false;
return (section.fields || []).some(
(f) => (f.type === "email" || f.id === "email") && f.enabled !== false,
);
};
return (
sectionHasEnabledEmail(cfg.contact_form) ||
sectionHasEnabledEmail(cfg.traveler_form)
);
})();
const updateFormConfig = (updates: Partial) => {
setFormData((prev) => {
if (!prev) return prev;
return {
...prev,
booking_form_config: {
...prev.booking_form_config,
[activeFormTab]: {
...prev.booking_form_config[activeFormTab],
...updates,
},
},
};
});
};
const currentConfig = getCurrentFormConfig();
return (
{/* Form Type Tabs */}
{/* No-email warning — booking confirmation/account/voucher all need one */}
{!bookingFormCapturesEmail && (
⚠
{__(
"No form is set to collect an email address. An email is required for booking confirmation, the customer account and the voucher. Please enable an email field on the Contact or Traveler form — otherwise customers can't complete checkout.",
"yatra",
)}
{(window as any).yatraAdmin?.wordPressTimezone ? (
) : null}
handleFieldChange({
target: {
name: "timezone",
id: "timezone",
value: val,
type: "select-one",
},
} as React.ChangeEvent)
}
options={timeZoneSelectOptions}
searchPlaceholder={__(
"Search by city, region, or code…",
"yatra",
)}
placeholder={__("Select timezone…", "yatra")}
showValueId={false}
/>
{formData.weather_enabled && (
)}
);
case "design":
return (
{__(
"Control how Yatra looks on the public site (trip pages, booking, listings, and shortcodes). These options complement your WordPress theme.",
"yatra",
)}
);
case "booking_form":
return (
);
case "payment":
return (
<>
{__("Flexible Payments", "yatra")}
{__(
"Enable deposit and partial payment options for bookings. Allow customers to pay a percentage upfront and the rest later.",
"yatra",
)}
{__(
"Allow customers to pay a portion now and the rest later",
"yatra",
)}
{formData.partial_payment && (
%
)}
{__("Require a deposit to confirm bookings", "yatra")}
{formData.deposit_required && (
%
)}
{__("Scheduled balance payments", "yatra")}
{__(
"After a deposit or partial payment, automatically schedule the remaining balance with your gateway (Stripe invoices or subscription schedules). Requires a gateway customer and payment method from checkout.",
"yatra",
)}
{__(
"When a booking still has an amount due after checkout, create gateway-side schedules using the rules below.",
"yatra",
)}
{/* Auto-confirm Pay Later Bookings - Available in Free version */}
{__(
'Automatically confirm bookings when "Book Now, Pay Later" is selected. If disabled, bookings will remain pending until payment is received. Pay Later bookings are never cancelled automatically for being unpaid.',
"yatra",
)}
{isExpanded && (
{/* Info banner for offline gateways */}
{gateway.is_offline && (
{gateway.id === "pay_later"
? __(
"Allow customers to book now and pay later. Payment must be completed before the trip date.",
"yatra",
)
: __(
"This is an offline payment method. Customers will be shown these details after booking.",
"yatra",
)}
)}
{/* Frontend Display Settings */}
{__("Frontend Display Settings", "yatra")}
handleGatewayConfigChange(
gatewayId,
"icon",
e.target.value,
)
}
placeholder={__(
"Enter icon URL or leave empty to use default",
"yatra",
)}
className="flex-1"
/>
{config.icon || gateway.icon ? (
{
(
e.target as HTMLImageElement
).style.display = "none";
}}
/>
) : null}
);
}
// Read-only display field (e.g. PayPal webhook URL): show the
// value with a Copy button; not editable, never saved.
if (field.readonly) {
const roValue = String(
config[field.id] ?? field.default ?? "",
);
return (
handleGatewayConfigChange(
gatewayId,
field.id,
// Keep an empty field empty while
// editing so the last character can
// be cleared and retyped. Coercing
// "" to 0 (parseFloat("") || 0) made
// the field snap back and blocked
// re-entry. Numbers are coerced on
// save; "" persists harmlessly.
field.type === "number"
? e.target.value === ""
? ""
: parseFloat(
e.target.value,
) || 0
: e.target.value,
)
}
placeholder={field.placeholder}
min={field.min}
max={field.max}
/>
{field.help_text && (
{
setSelectedPremiumGateway(gateway.title);
setShowPremiumDialog(true);
}}
/>
)}
);
})}
{/* Show message if no gateways loaded */}
{(!gatewayDefinitions ||
Object.keys(gatewayDefinitions).length === 0) && (
{__("Loading payment gateways...", "yatra")}
)}
>
);
case "search":
return (
{__("Search Bar Fields", "yatra")}
{__(
"Choose which fields appear in the trip search bar. Turn off the ones you don't need for a cleaner search.",
"yatra",
)}
{[
{
key: "search_show_keyword" as const,
label: __("Keyword search", "yatra"),
description: __(
"Free-text field to search by trip name or keyword.",
"yatra",
),
},
{
key: "search_show_destination" as const,
label: __("Destination", "yatra"),
description: __(
"Dropdown to filter trips by destination.",
"yatra",
),
},
{
key: "search_show_activities" as const,
label: __("Activities", "yatra"),
description: __(
"Dropdown to filter trips by activity.",
"yatra",
),
},
{
key: "search_show_duration" as const,
label: __("Duration", "yatra"),
description: __(
"Range slider to filter trips by number of days.",
"yatra",
),
},
{
key: "search_show_budget" as const,
label: __("Budget", "yatra"),
description: __(
"Dropdown to filter trips by price range.",
"yatra",
),
},
{
key: "search_show_date" as const,
label: __("Date", "yatra"),
description: __(
"Date picker to find trips with a departure on a specific date.",
"yatra",
),
},
].map((row) => (
{row.description}
))}
{__("Mobile Filters", "yatra")}
{__(
"Controls the filter sidebar on the trip listing page on mobile devices.",
"yatra",
)}
{__(
"On mobile, show filter sections collapsed so trip listings are visible right away. Visitors tap a section to expand it. Desktop is unaffected.",
"yatra",
)}
);
// Continue with other sections... (I'll add the most important ones)
case "booking":
return (
{__(
"Send a confirmation email to the customer immediately after a successful booking. The post-checkout page is always shown; this toggle only controls the email.",
"yatra",
)}
{__("Auto-Confirm Bookings", "yatra")}
{__(
"Choose when a booking is automatically set to Confirmed. Offline methods (bank transfer, pay later) stay pending until you confirm them.",
"yatra",
)}
{[
{
value: "none",
label: __("Don't auto-confirm", "yatra"),
sub: __(
"Every booking stays Pending until you confirm it manually.",
"yatra",
),
},
{
value: "online",
label: __("Auto-confirm online payments only", "yatra"),
sub: __(
"When an online payment (Stripe, PayPal, Razorpay…) pays the balance in full, the booking is confirmed. Deposits/partial payments and offline methods stay Pending; Pay Later follows its own “Auto-confirm Pay Later bookings” setting.",
"yatra",
),
},
{
value: "all",
label: __("Auto-confirm all bookings", "yatra"),
sub: __(
"Every booking is confirmed at checkout, whether or not it was paid.",
"yatra",
),
},
].map((opt) => (
))}
{__("Email While Payment Is Pending", "yatra")}
{__(
"A booking and its reference are created before the card is charged, because the payment gateway needs a booking to charge against. This is what the customer is sent in that window. Pay-later, bank transfer and zero-balance bookings are unaffected \u2014 they have no payment to wait for.",
"yatra",
)}
{[
{
value: "confirmation",
label: __("Send the booking confirmation straight away", "yatra"),
sub: __(
"The customer is emailed as soon as the booking is created, before payment completes.",
"yatra",
),
},
{
value: "after_payment",
label: __("Wait until the payment succeeds", "yatra"),
sub: __(
"Nothing is emailed while payment is outstanding, so an abandoned or failed card attempt never produces a confirmation.",
"yatra",
),
},
].map((opt) => (
))}
{__(
"Customers must create an account to make bookings",
"yatra",
)}
{__(
"Allow customers to book without creating an account",
"yatra",
)}
{/*
Guest email verification — only meaningful when guest
checkout is allowed AND login isn't required, since
logged-in customers' emails are verified by WordPress
on registration. We still render the checkbox at all
times so operators can pre-configure before flipping
the parent toggles; the help text explains the
dependency rather than hiding the control.
*/}
{__(
"Hold guest bookings until the customer clicks a magic link sent to their email. Stops typo'd addresses and form-spam bots. Only applies when guest checkout is allowed and login isn't required — logged-in customers are already verified.",
"yatra",
)}
{__(
"Keep sold-out dates on the calendar marked \"Sold out\" — needed for the waitlist below. Turn this off to hide them entirely, the way blocked dates are hidden.",
"yatra",
)}
{__(
"Customers can join a waitlist instead of being blocked when seats are gone (per-trip caps still apply).",
"yatra",
)}
{__(
"When a spot opens, move the next waitlisted booking to confirmed; otherwise it becomes pending for staff review.",
"yatra",
)}
{/* Pro feature: replace flatpickr calendar with a dropdown of
available departure dates on the single-trip sidebar + the
mobile sticky bar. The checkbox stays interactive for non-Pro
installs so the value can be staged, but the frontend gate
ignores it unless Pro is active. */}
{__(
"Replace the calendar date picker with a dropdown listing every available departure date on the single-trip sidebar and the mobile sticky bar. Best for trips with a small set of fixed departures.",
"yatra",
)}
{/*
Cancellation & Refund Policy section removed.
Earlier versions exposed three settings here
(cancellation_policy dropdown, cancellation_days number,
refund_policy textarea). All three were display-only —
they appeared in the booking confirmation email but
did NOT enforce any cancellation cutoff or compute any
refund amount, because Yatra has no customer-facing
self-service cancellation flow. The names implied
enforcement that did not exist, which is worse than
having no setting at all.
Per-trip cancellation copy still lives on the Trip
editor (Trip Builder → cancellation_policy field) and
is what the booking confirmation page + email now
show. To restore site-wide cancellation enforcement,
build the cancellation REST endpoint and re-add gated
settings here.
*/}
{__(
"Adds a request form to the booking in the customer's account. You get an email and the request shows on the booking; nothing is cancelled or refunded until you do it.",
"yatra",
)}
{__(
"Ask your own questions on the trip enquiry form, after the travellers field. Answers are added to the enquiry message, so you see them on the Enquiries screen and in the enquiry email.",
"yatra",
)}
{__(
"Built only from real bookings. The countdown is set per trip in the trip editor (Availability & Booking).",
"yatra",
)}
{formData.social_proof_popup && (
)}
)}
);
case "pricing": {
// Snapshot the two Pro-module flags. The free plugin's
// AdminAssetsProvider sets these directly from the canonical
// ModuleManager::isModuleEnabled(). Truthy check (not
// `=== true`) is mandatory because wp_localize_script
// serializes every scalar to a string before handing it to
// JS — true becomes "1", false becomes "". Comparing
// === true would always be false for an enabled module,
// which was why every operator saw the "not active" banner
// even on a correctly-configured site.
const adEnabled = !!(window as any)?.yatraAdmin
?.advancedDiscountEnabled;
const dpEnabled = !!(window as any)?.yatraAdmin?.dynamicPricingEnabled;
const bothActive = adEnabled && dpEnabled;
return (
{__(
"Controls what happens when both a Discount (coupon or group discount) and a Dynamic Pricing rule could apply to the same booking. The control only takes effect when both the Advanced Discount and Dynamic Pricing modules are turned on.",
"yatra",
)}
{/* Module-status banner. Green when both modules are on,
amber when the setting is inert because one (or both)
is off. Either way the dropdown stays rendered so the
operator knows the feature exists and what it does. */}
{bothActive ? (
{__("Active", "yatra")}
{__(
"Advanced Discount and Dynamic Pricing are both enabled. Your stacking choice below is being applied to every new booking calculation.",
"yatra",
)}
) : (
{__("Not active yet", "yatra")}
{__(
"This setting only applies when BOTH modules below are enabled. Without both, bookings calculate exactly as they do today (no stacking control).",
"yatra",
)}
{__("Both apply", "yatra")}
{" — "}
{__(
"default and matches the original behavior. A coupon stacks on top of the Dynamic Pricing-adjusted price.",
"yatra",
)}
{__("Best for the customer", "yatra")}
{" — "}
{__(
"calculates both scenarios and picks the cheaper one for the customer. Never combines.",
"yatra",
)}
{__("Discount only", "yatra")}
{" — "}
{__(
"when a discount is valid, Dynamic Pricing is skipped for that booking.",
"yatra",
)}
{__("Dynamic Pricing only", "yatra")}
{" — "}
{__(
"when a Dynamic Pricing rule reduced the price, discount codes and group discounts are ignored for that booking.",
"yatra",
)}
);
}
case "customer":
return (
{__(
"Allow customers to create accounts on your website",
"yatra",
)}
{__(
"Rename texts your customers see — for example \"Book Now\" → \"Reserve\" or \"Travelers\" → \"Guests\". Enter Yatra's text exactly as it appears in English (it works on translated sites too). Applies to the website, emails and the booking pages; admin screens keep the original wording.",
"yatra",
)}
);
case "api":
return (
setFormData((prev) => (prev ? ({ ...prev, [key]: value } as SettingsData) : prev))
}
/>
);
case "integration":
return (
{/* Google Calendar Integration - Only show if Pro is active */}
{window.yatraAdmin &&
(window as any).yatraAdmin.showGoogleCalendarSettingsUI && (
<>
>
)}
{/* Mailchimp Integration - Pro Feature */}
{__("Mailchimp", "yatra")}
{(window as any).yatraAdmin?.mailchimp?.connectionStatus
?.connected ? (
{__("Connected", "yatra")}
) : (
{__("Not Connected", "yatra")}
)}
{__(
"Automatically sync customers to Mailchimp lists when they book. Add tags based on trips booked and build targeted email campaigns.",
"yatra",
)}
{(window as any).yatraAdmin?.mailchimp
?.connectionStatus?.connected ? (
<>
{__("Connected successfully!", "yatra")}
>
) : (window as any).yatraAdmin?.mailchimp
?.connectionStatus?.error ? (
<>
{
(window as any).yatraAdmin?.mailchimp
?.connectionStatus?.error
}
>
) : (
<>
{__(
"API key entered. Click 'Validate' to test connection.",
"yatra",
)}
>
)}
)}
{__(
"Add customers to Mailchimp when they book (customers who ticked the newsletter box, unless you allow everyone below)",
"yatra",
)}
{__(
"Require email confirmation before adding to list (recommended for GDPR)",
"yatra",
)}
{__(
"Off: only customers who tick \"Subscribe to our newsletter\" at checkout are added. Turn on only if you have another lawful basis to email every customer.",
"yatra",
)}
{/* Facebook Pixel Integration - Pro Feature */}
{__("Facebook Pixel", "yatra")}
{(window as any).yatraAdmin?.facebookPixel?.connectionStatus
?.pixelConnected ? (
{__("Connected", "yatra")}
) : (
{__("Not Connected", "yatra")}
)}
{__(
"Track booking conversions with Facebook Pixel. Retarget visitors who viewed trips and optimize ad campaigns with accurate conversion data.",
"yatra",
)}
{__(
"Your Facebook Pixel ID (e.g., 123456789012345).",
"yatra",
)}
{__("How to get your Pixel ID:", "yatra")}
{__(
"Go to Facebook Business Manager: business.facebook.com",
"yatra",
)}
{__("Select your Business Account", "yatra")}
{__(
"Click 'All tools' and select 'Pixels'",
"yatra",
)}
{__(
"Click 'Add Pixel' if you don't have one",
"yatra",
)}
{__(
"Enter a Pixel name and enter your website URL",
"yatra",
)}
{__("Click 'Create Pixel'", "yatra")}
{__(
"Your Pixel ID will be displayed (e.g., 123456789012345)",
"yatra",
)}
{__(
"Copy this Pixel ID and paste it in the field above",
"yatra",
)}
{(window as any).yatraAdmin?.facebookPixel
?.connectionStatus?.pixelConnected ? (
<>
{__("Pixel ID is valid!", "yatra")}
>
) : (window as any).yatraAdmin?.facebookPixel
?.connectionStatus?.pixelError ? (
<>
{
(window as any).yatraAdmin?.facebookPixel
?.connectionStatus?.pixelError
}
>
) : (
<>
{__(
"Click 'Validate' to test Pixel ID.",
"yatra",
)}
>
)}
)}
{formData.fb_use_conversions_api && (
{__(
"Required for Conversions API. Enables server-side tracking for better accuracy.",
"yatra",
)}
{__("How to get Access Token:", "yatra")}
{__(
"Go to Facebook Business Manager: business.facebook.com",
"yatra",
)}
{__("Select your Business Account", "yatra")}
{__(
"Click 'All tools' and select 'Events Manager'",
"yatra",
)}
{__(
"Find your Pixel ID in the data sources list (it should match the Pixel ID you entered above)",
"yatra",
)}
{__(
"Click on your Pixel name to open its settings",
"yatra",
)}
{__(
"Click 'Settings' (gear icon ⚙️) in the top right",
"yatra",
)}
{__(
"Scroll down to 'Conversions API' section",
"yatra",
)}
{__("Click 'Generate access token'", "yatra")}
{__(
"Choose permissions: 'ads_management' and 'business_management'",
"yatra",
)}
{__("Click 'Generate token'", "yatra")}
{__(
"Copy the generated access token",
"yatra",
)}
{__("Paste it in the field above", "yatra")}
{__("💡 Tip:", "yatra")}{" "}
{__(
"If you have multiple Pixels, look for the one that matches the Pixel ID you entered above. The Pixel ID is displayed next to each Pixel name in the list.",
"yatra",
)}
{__(
"⚠️ Keep your access token secure and never share it publicly.",
"yatra",
)}
{__(
"Connect GA4 for ecommerce events (view item, add to cart, checkout, purchase). Optional Measurement Protocol sends verified server-side events for more reliable attribution.",
"yatra",
)}
{/* Connection */}
{__("Connection", "yatra")}
{__(
"Use your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). Find it under Admin → Data streams → your stream.",
"yatra",
)}
{__(
"Your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). The Validate button checks the format only — confirm the stream is live in your GA4 Admin.",
"yatra",
)}
{__("How to get your Measurement ID:", "yatra")}
{__(
"Go to Google Analytics: analytics.google.com",
"yatra",
)}
{__(
"Sign in and select the property you want to track this site with (or create one: Admin → Create → Property → choose your business details).",
"yatra",
)}
{__(
"In the bottom-left corner click the gear icon (Admin).",
"yatra",
)}
{__(
"In the Property column click Data Streams.",
"yatra",
)}
{__(
"Click your existing Web stream — or click Add stream → Web, enter your site URL and a stream name, then Create stream.",
"yatra",
)}
{__(
"On the stream details panel, copy the Measurement ID at the top right (format G-XXXXXXXXXX).",
"yatra",
)}
{__(
"Paste it in the field above and click Validate.",
"yatra",
)}
{__(
"Send duplicate events from your server with an API secret—useful when ad blockers affect the browser tag or for reconciliation.",
"yatra",
)}
{__(
"Requires an API secret from the same GA4 data stream.",
"yatra",
)}
{formData.ga4_use_measurement_protocol && (
{/* Only a Yatra Pro that honours the option advertises it. */}
{(window as any).yatraAdmin?.googleAnalytics
?.requireConsentSupported && (
{__(
"Server-side events always follow visitor consent recorded through the WP Consent API (used by WPConsent, Complianz, CookieYes and others). Turn this on to send nothing server-side when that plugin is not active.",
"yatra",
)}
)}
{__(
"Send Measurement Protocol hits to Google’s validation URL for troubleshooting. Events won’t appear in standard reports.",
"yatra",
)}
{__(
"Treat this like a password — anyone with it can send fake events to your GA4 property. Restrict who can view Yatra settings.",
"yatra",
)}
{__("How to get your API secret:", "yatra")}
{__(
"Go to Google Analytics: analytics.google.com",
"yatra",
)}
{__(
"Sign in and select the same property you used for the Measurement ID above.",
"yatra",
)}
{__(
"Click the gear icon (Admin) in the bottom-left corner.",
"yatra",
)}
{__(
"In the Property column click Data Streams, then click your Web stream.",
"yatra",
)}
{__(
"Scroll to Events → Measurement Protocol API secrets → Create.",
"yatra",
)}
{__(
"Give the secret a nickname (e.g. “Yatra server”) and click Create.",
"yatra",
)}
{__(
"Copy the Secret value (not the nickname) and paste it in the field above.",
"yatra",
)}
{__(
"Maps are powered by OpenStreetMap - a free, open-source mapping service. No API key required! Maps will automatically display trip starting locations with custom markers.",
"yatra",
)}
{__("Protect forms from spam and bots", "yatra")}
{formData.recaptcha_enabled && (
<>
{__(
"Uses reCAPTCHA v3 (invisible, score-based). Create v3 keys at google.com/recaptcha and paste them above.",
"yatra",
)}
{__(
"Choose which forms reCAPTCHA should verify. Booking protection is off by default to avoid blocking a legitimate payment on a low score.",
"yatra",
)}
);
case "permalink": {
const listingSite = (
((window as any)?.yatraAdmin?.siteUrl || "") as string
).replace(/\/$/, "");
const listingHref = (segment: string) =>
buildYatraListingPublicUrl(segment, listingSite || undefined);
const bookingConfirmationPreviewUrl = (bookingBase: string) => {
const bb = (bookingBase || "book").replace(/^\/|\/$/g, "");
const site = listingSite || "";
if (isWordPressPlainPermalink()) {
return site
? `${site}/?yatra_booking_confirmation=`
: "/?yatra_booking_confirmation=";
}
return site ? `${site}/${bb}/confirmation/` : `/${bb}/confirmation/`;
};
return (
{__("Permalink Settings", "yatra")}
{__(
"Configure URL slugs for your Yatra content types. These settings control how your trips, destinations, and activities appear in URLs.",
"yatra",
)}
{__(
"Configure the booking page URL. By default, bookings use /book/{trip-slug}. You can customize the URL base or use a custom WordPress page.",
"yatra",
)}
{__(
"Recommended size: 1200x630 pixels for optimal social media display.",
"yatra",
)}
) : (
{__("Add SEO Image", "yatra")}
{__(
"Upload an image that will appear when your trip archive page is shared on social media. Recommended size: 1200x630 pixels.",
"yatra",
)}
)}
{__("Sitemap", "yatra")}
{__(
"Yatra publishes one sitemap of all trips, destinations, activities and categories so search engines can find them. It is advertised in robots.txt and linked into Yoast, Rank Math, AIOSEO and WordPress core sitemaps automatically.",
"yatra",
)}
{__(
"Generate /yatra-sitemap.xml and advertise it to search engines.",
"yatra",
)}
{__(
"Optional: submit this URL in Google Search Console or Bing Webmaster Tools. It is already listed in robots.txt, so search engines find it automatically.",
"yatra",
)}
{formData.enable_sitemap && (
{__(
"Uncheck a type to keep it out of /yatra-sitemap.xml.",
"yatra",
)}
{__(
"Leaving a type out of the sitemap does not stop Google indexing it. Turn this on to send noindex on those pages as well — they will drop out of search results, so only do this for content you do not want found.",
"yatra",
)}
)}
)}
);
case "uninstall":
return (
{__(
"This only applies when Yatra is deleted from the Plugins screen. Deactivating the plugin never removes anything.",
"yatra",
)}
{__(
"Permanently remove every Yatra database table, setting and scheduled task when the plugin is deleted. Yatra Pro follows the same switch and removes its own data too.",
"yatra",
)}
{formData.delete_data_on_uninstall ? (
{__("This cannot be undone", "yatra")}
{__(
"Trips, bookings, customers, payments, reviews and enquiries are destroyed along with the plugin. Take a backup, or use Tools to export first, if you may want this data again.",
"yatra",
)}
) : (
{__(
"Your data is kept when Yatra is deleted, so reinstalling restores everything as it was.",
"yatra",
)}
)}
);
case "advanced":
return (
{__(
"For PHP-level debug output, use WordPress wp-config.php (WP_DEBUG). The options below are implemented by the plugin.",
"yatra",
)}
{__(
"Log system events and errors for troubleshooting",
"yatra",
)}
{__(
"Extra plugin-side diagnostics. When on, Yatra object cache is bypassed (same as when WP_DEBUG is true in wp-config).",
"yatra",
)}
{__(
"Stores frequently used data for faster loads. Stays off while WP_DEBUG or Debug mode (above) is on.",
"yatra",
)}
{__("Legal pages (Booking UI)", "yatra")}
{__(
"Select the pages that will be linked from the booking Terms and Privacy consent checkboxes.",
"yatra",
)}
{__(
"If not set here, WordPress Settings → Privacy will be used when available.",
"yatra",
)}
{/* Premium Upgrade Dialog for Payment Gateways */}
setShowPremiumDialog(false)}
moduleName={selectedPremiumGateway}
moduleDescription={`Unlock ${selectedPremiumGateway} payment gateway to accept payments from your customers. This premium gateway provides secure payment processing with advanced features.`}
purchaseUrl={
(window as any).yatraAdmin?.pricingUrl ||
"https://wpyatra.com/pricing"
}
/>
);
};
/**
* Currency switcher (Yatra Pro): the other currencies visitors can see
* prices in, with the rate from the store currency. Bookings and payments
* stay in the store currency.
*/
const DisplayCurrenciesCard: React.FC<{
rows: { code: string; rate: number }[];
autoRates: boolean;
baseCurrency: string;
onChange: (rows: { code: string; rate: number }[], autoRates: boolean) => void;
}> = ({ rows, autoRates, baseCurrency, onChange }) => {
const update = (i: number, patch: Partial<{ code: string; rate: number }>) =>
onChange(
rows.map((r, n) => (n === i ? { ...r, ...patch } : r)),
autoRates,
);
return (
{__("Currency switcher", "yatra")}
{sprintf(
__(
"Visitors can view trip prices in these currencies. Bookings and payments stay in %s; checkout says so. Rate = how much of the currency 1 %s is.",
"yatra",
),
baseCurrency,
baseCurrency,
)}