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/DynamicPricingService.php +16 -71 3.0.3 → 3.0.16 View file →
@@ -1,10 +1,21 @@
1 1 <?php
2 2 /**
3 - * Dynamic Pricing Service for Yatra Plugin
3 + * Dynamic Pricing — placeholder (Free plugin)
4 4 *
5 - * Handles dynamic pricing calculations and filters
5 + * This file used to ship a small example implementation that auto-enabled
6 + * dynamic pricing and applied hard-coded `*1.15` / `*0.9` math, which double-
7 + * applied or conflicted with the real engine in Yatra Pro
8 + * (`YatraPro\Modules\DynamicPricing`). It is now a no-op stub kept only to
9 + * preserve class-name back-compat.
6 10 *
11 + * The Free plugin's role is purely to expose pricing filters — actual rule
12 + * evaluation lives in the Pro module:
13 + * - yatra_dynamic_pricing_enabled
14 + * - yatra_availability_price
15 + * - yatra_trip_display_price
16 + * - yatra_booking_trip_price
17 + *
7 18 * @package Yatra\Services
8 19 */
9 20
10 21 namespace Yatra\Services;
@@ -11,78 +22,12 @@
11 22
12 23 class DynamicPricingService
13 24 {
14 25 /**
15 - * Initialize dynamic pricing hooks
26 + * Intentionally a no-op. The Pro DynamicPricing module owns all rule
27 + * registration, calculation, and the `yatra_dynamic_pricing_enabled` flag.
16 28 */
17 29 public static function init(): void
18 30 {
19 - // Enable dynamic pricing module
20 - add_filter('yatra_dynamic_pricing_enabled', '__return_true');
21 -
22 - // Register pricing filters
23 - add_filter('yatra_availability_price', [self::class, 'applyDynamicPricing'], 10, 3);
24 - add_filter('yatra_trip_display_price', [self::class, 'applyDisplayPricing'], 10, 3);
25 - add_filter('yatra_booking_trip_price', [self::class, 'applyBookingPricing'], 10, 3);
26 - }
27 -
28 - /**
29 - * Apply dynamic pricing logic
30 - *
31 - * @param float $price
32 - * @param int $trip_id
33 - * @param array $context
34 - * @return float
35 - */
36 - public static function applyDynamicPricing(float $price, int $trip_id, array $context): float
37 - {
38 - // Debug logging
39 - $original_price = $price;
40 -
41 - // Apply basic dynamic pricing logic
42 - $departure_date = $context['departure_date'] ?? null;
43 - $spots_remaining = $context['spots_remaining'] ?? null;
44 -
45 - // Example: Increase price if less than 5 spots remaining (high demand)
46 - if ($spots_remaining !== null && $spots_remaining <= 5 && $spots_remaining > 0) {
47 - $price = $price * 1.15; // 15% increase for high demand
48 - }
49 -
50 - // Example: Early bird discount (more than 30 days in advance)
51 - if ($departure_date) {
52 - $days_until = (strtotime($departure_date) - time()) / (60 * 60 * 24);
53 - if ($days_until > 30) {
54 - $price = $price * 0.9; // 10% early bird discount
55 - }
56 - }
57 -
58 - return $price;
59 - }
60 -
61 - /**
62 - * Apply dynamic pricing for trip display pages
63 - *
64 - * @param float $price
65 - * @param int $trip_id
66 - * @param array $context
67 - * @return float
68 - */
69 - public static function applyDisplayPricing(float $price, int $trip_id, array $context): float
70 - {
71 - // Apply same logic for trip display pages
72 - return apply_filters('yatra_availability_price', $price, $trip_id, $context);
73 - }
74 -
75 - /**
76 - * Apply dynamic pricing for booking calculations
77 - *
78 - * @param float $price
79 - * @param int $trip_id
80 - * @param array $context
81 - * @return float
82 - */
83 - public static function applyBookingPricing(float $price, int $trip_id, array $context): float
84 - {
85 - // Apply same logic for booking calculations
86 - return apply_filters('yatra_availability_price', $price, $trip_id, $context);
31 + // no-op
87 32 }
88 33 }