Skip to content

Hooks & filters

Yatra is built around a wide hook surface: every meaningful state change fires an action, and most rendered values pass through a filter so you can override them. This page lists the most useful actions and filters grouped by area, plus general guidance on using them.

Yatra ships with hundreds of hooks. The list below covers the ~80 you'll reach for most often. To find a hook for a specific feature, search the plugin source for do_action('yatra_*' or apply_filters('yatra_*' — every hook follows the yatra_ prefix.

Conventions

  • Actions are named yatra_{noun}_{verb} and fire after the underlying change (e.g. yatra_booking_created fires after the booking row is inserted).
  • Filters are named yatra_{noun}_{property} and pass the value as the first argument.
  • Pro hooks carry no special prefix — Pro just adds more yatra_* hooks. A few pro-specific hooks use yatra_pro_* (license, module activation).
  • Backwards compatibility: Yatra retires hooks with notice, never silently. Deprecated hooks keep firing for at least one minor version.

Trips

Fired around trip lifecycle and rendering.

HookTypePurpose
yatra_trip_createdactionAfter a trip is inserted; receives $trip_id
yatra_trip_updatedactionAfter a trip is updated
yatra_trip_deletedactionBefore a trip is deleted (soft or hard)
yatra_trip_loaded_with_relationsfilterMutate the joined trip object (with classifications, attributes, etc.)
yatra_trip_created_with_relationsactionAfter insert + relations save
yatra_trip_updated_with_relationsactionAfter update + relations save
yatra_trip_display_pricefilterLast-mile override for the displayed price
yatra_dynamic_pricing_enabledfilterToggle Pro Dynamic Pricing per-trip
yatra_availability_pricefilterOverride price on a specific departure
yatra_get_dynamic_pricing_display_settingsfilterCustomize how dynamic-pricing surcharges/discounts render
yatra_calculate_demand_scoresactionOverride demand-score calculation (Pro)

Bookings

Lifecycle and per-booking rendering.

HookTypePurpose
yatra_booking_createdactionNew booking submitted
yatra_booking_updatedactionBooking row updated
yatra_booking_status_changedactionArgs: ($booking, $new_status, $old_status)
yatra_booking_deletedactionBefore a booking is deleted
yatra_booking_email_variablesfilterAugment the merge-tag map for booking emails
yatra_booking_email_traveler_identity_field_keysfilterCustomize identity-table fields
yatra_payment_completedactionFired across multiple gateways after capture

Booking pricing pipeline

The price you see on the booking summary is the result of a chain of filters. Hooking these lets you adjust the math without touching gateway code.

FilterStage
yatra_before_calculation_paramsNormalize incoming traveler counts, picked date, etc.
yatra_booking_trip_pricePer-trip base price
yatra_calculate_subtotalAfter traveler categories, before extras
yatra_booking_additional_servicesPro Additional Services subtotal
yatra_calculate_payment_amountsCompute deposit / partial / total payable now
yatra_after_calculation_resultFinal adjustments
yatra_booking_email_variablesVariables passed to email templates

The implementation lives in app/Services/CalculationService.php. Each filter receives the partial result and the booking context.

Payments

HookTypePurpose
yatra_register_payment_gatewaysactionRegister a custom gateway class
yatra_payment_gateway_config_savedactionAfter a gateway's settings save
yatra_before_payment_processingactionBefore a payment intent is created
yatra_payment_completedactionAfter successful capture
yatra_payment_failedactionAfter failed capture
yatra_before_payment_refundactionBefore refund
yatra_payment_refundedactionAfter refund
yatra_after_payment_refundactionFinal hook for refund post-processing
yatra_paypal_payment_completedactionPayPal-specific success
yatra_paypal_payment_refundedactionPayPal-specific refund
yatra_paypal_payment_token_savedactionPayPal Advanced vault

Adding a custom gateway

The minimal recipe:

php
add_action( 'yatra_register_payment_gateways', function ( $registry ) {
    $registry->register( 'my_gw', \My\Gateway\MyGateway::class );
} );

Your MyGateway extends \Yatra\PaymentGateways\AbstractPaymentGateway and implements id, name, description, getConfigFields, processPayment, optionally processRefund and handleWebhook. See app/PaymentGateways/Gateways/PayPal/PayPalGateway.php for a complete reference.

Email

HookTypePurpose
yatra_send_transactional_emailfilterShort-circuit before sending; return false to suppress
yatra_pro_email_automation_owns_transactional_typefilterLet Pro Email Automation own a specific template type
yatra_send_*_email (e.g. yatra_send_booking_received_email)actionPer-event audit hook
yatra_email_template_replacementsfilterAdd or rewrite merge tags

Enquiries

HookTypePurpose
yatra_enquiry_createdactionAfter enquiry insert (carries the joined trip object since 3.0.3)
yatra_enquiry_updatedactionAfter enquiry edit (e.g. staff response)
yatra_send_enquiry_admin_emailactionSending the admin notification
yatra_send_enquiry_response_emailactionSending the customer response

Account / customer

HookTypePurpose
yatra_customer_createdactionNew customer record
yatra_customer_updatedactionAfter customer edit
yatra_user_registeredactionWhen customer registers a WP account
yatra_email_verifiedactionCustomer confirmed their email
yatra_password_reset_requestedactionReset requested (filter the URL via yatra_password_reset_url)

Front-end routing & templates

Yatra registers its own pretty URLs for the booking flow, account, email verification and remaining-balance checkout.

HookTypePurpose
yatra_pretty_route_matchfilterModify how a route resolves (final say on tab/template)
yatra_plain_route_matchfilterSame but for ?yatra_* query-string URLs
yatra_frontend_request_pathfilterNormalize the request path before matching
yatra_register_rewrite_rulesactionAdd additional rewrite rules
yatra_emit_canonical_metafilterDisable Yatra's <link rel=canonical> if your SEO plugin owns it

Shortcodes and listings

HookTypePurpose
yatra_trip_listing_filtersfilterModify the SQL filter array used by [yatra_trip] and the Trip block
yatra_destination_listing_filtersfilterSame for destination listings
yatra_activity_listing_filtersfilterSame for activity listings
yatra_trip_category_listing_filtersfilterSame for trip-category listings
yatra_trip_listing_card_htmlfilterReplace card markup wholesale
yatra_trip_listing_per_page_defaultfilterDefault per-page count
yatra_search_form_htmlfilterReplace search-form markup
yatra_classification_listing_card_htmlfilterCard markup for destination/activity/category cards

Admin / settings / modules

HookTypePurpose
yatra_admin_localized_datafilterInject extra props into window.yatraAdmin
yatra_module_activated / _deactivatedactionWhen a module's enabled/disabled state changes
yatra_module_capabilitiesfilterModule-required capabilities
yatra_module_settingsfilterModule settings schema
yatra_module_assetsfilterAssets enqueued for a module
yatra_setup_wizard_stepsfilterAdd or remove wizard steps
yatra_setup_wizard_completedactionAfter the wizard is finalized
yatra_clear_cacheactionInvalidate Yatra's internal cache

Pro license & updater

HookTypePurpose
yatra_is_pro_activefilterToggle Pro behavior (Pro returns true; you can short-circuit for testing)
yatra_pro_available_modulesfilterAdd or remove modules from the Modules screen
yatra_pro_license_store_urlfilterOverride the license store URL
yatra_pro_license_item_idfilterOverride the EDD product ID
yatra_pro_license_data_updatedactionAfter license data is saved
yatra_pro_module_activatedactionAfter a Pro module activates (creates tables, etc.)
yatra_pro_module_settings_updatedactionAfter a Pro module's settings save

Pro: Dynamic Pricing

HookTypePurpose
yatra_dynamic_pricing_enabledfilterWhether DP applies to a given trip
yatra_get_dynamic_pricing_display_settingsfilterDisplay settings for surcharge/discount badges
yatra_price_breakdownfilterThe breakdown shown on the booking summary
yatra_calculate_demand_scoresactionOverride / extend demand calculation

Pro: Flexible / Scheduled Payments

HookTypePurpose
yatra_flexible_payments_enabledfilterMaster toggle (per-trip or globally)
yatra_flexible_payment_settingfilterRead individual setting values
yatra_deposit_percentagefilterOverride deposit %
yatra_partial_payment_percentagefilterOverride partial-payment %
yatra_calculate_amount_duefilterFinal say on the payable-now amount
yatra_scheduled_payments_module_activefilterWhether scheduled payments processing should run
yatra_scheduled_payment_settingfilterPer-setting reads

Pro: Email Automation

HookTypePurpose
yatra_pro_email_automation_owns_transactional_typefilterWhen Pro should override a free transactional type
yatra_email_automation_event_payloadfilterMutate the variables passed to a sequence step
yatra_email_automation_should_sendfilterSuppress a step at runtime

Pro: Custom Landing Pages

HookTypePurpose
yatra_destination_permalinkfilterOverride the destination URL
yatra_activity_permalinkfilterOverride the activity URL
yatra_category_permalinkfilterOverride the trip-category URL
HookTypePurpose
yatra_consent_signedactionAfter a customer signs a consent form
yatra_consent_form_email_subjectfilterOverride the consent email subject

Pro: Additional Services

HookTypePurpose
yatra_booking_additional_servicesfilterMutate selected services on a booking
yatra_booking_save_servicesactionAfter services are persisted
yatra_booking_get_servicesfilterModify how services are fetched for display

Practical recipes

Send a Slack notification on every booking

php
add_action( 'yatra_booking_created', function ( $booking_id ) {
    $booking = yatra_get_booking( $booking_id );
    if ( ! $booking ) return;

    wp_remote_post( SLACK_WEBHOOK_URL, [
        'body'    => wp_json_encode( [
            'text' => sprintf(
                'New booking %s for %s · %d travelers · %s',
                $booking->reference,
                $booking->trip_title,
                $booking->traveler_count,
                yatra_price_html( $booking->total )
            ),
        ] ),
        'headers' => [ 'Content-Type' => 'application/json' ],
    ] );
}, 10, 1 );

Add 5% surcharge to all bookings on weekends

php
add_filter( 'yatra_booking_trip_price', function ( $price, $context ) {
    $departure = $context['departure_date'] ?? null;
    if ( ! $departure ) return $price;

    $day = (int) date( 'N', strtotime( $departure ) );
    if ( $day >= 6 ) {                  // Sat / Sun
        $price *= 1.05;
    }
    return $price;
}, 10, 2 );

Hide trips from a specific destination on a public listing

php
add_filter( 'yatra_trip_listing_filters', function ( $filters ) {
    if ( is_admin() || ! empty( $filters['private_view'] ) ) return $filters;

    $filters['exclude_destination'] = [ 99 ];   // hide destination ID 99 from public listings
    return $filters;
} );

Auto-tag Mailchimp subscribers based on the trip booked

php
add_action( 'yatra_booking_created', function ( $booking_id ) {
    $booking = yatra_get_booking( $booking_id );
    if ( ! $booking ) return;

    $tag = sprintf( 'trip-%s', sanitize_title( $booking->trip_title ) );
    do_action( 'yatra_mailchimp_add_tag', $booking->customer_email, $tag );
} );

Block weekend bookings of a specific trip

php
add_filter( 'yatra_resolve_availability_object', function ( $availability, $trip_id, $date ) {
    if ( $trip_id !== 42 ) return $availability;
    $day = (int) date( 'N', strtotime( $date ) );
    if ( $day >= 6 ) {
        $availability['available'] = false;
        $availability['message']   = 'This trip runs Mon–Fri only.';
    }
    return $availability;
}, 10, 3 );

Discovering more hooks

bash
cd wp-content/plugins/yatra
# All actions:
grep -rn "do_action\(\s*'yatra_" app/ | sort -t: -k1
# All filters:
grep -rn "apply_filters\(\s*'yatra_" app/ | sort -t: -k1

Most hooks have a short docblock explaining the arguments and intent. The cleanest summary lives at the call site rather than in a separate hook reference, so reading the source is the canonical move when you're stuck.