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/Repositories/DiscountRepository.php +8 -10 3.0.4 → 3.0.16 View file →
@@ -3,8 +3,9 @@
3 3 declare(strict_types=1);
4 4
5 5 namespace Yatra\Repositories;
6 6
7 +use Yatra\Database\Tables\BookingsTable;
7 8 use Yatra\Database\Tables\DiscountsTable;
8 9
9 10 /**
10 11 * Discount Repository
@@ -137,17 +138,14 @@
137 138 */
138 139 public function countUsage(string $code): int
139 140 {
140 141 global $wpdb;
141 -
142 - // Try new bookings table first, then fallback to old table
143 - $bookingsTable = $wpdb->prefix . 'yatra_new_bookings';
144 - $tableExists = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $bookingsTable));
145 -
146 - if (!$tableExists) {
147 - $bookingsTable = $wpdb->prefix . 'yatra_bookings';
148 - }
149 -
142 +
143 + // Canonical bookings table — post 3.0.5 rename. Previous code had
144 + // a fallback probe for `yatra_new_bookings`; that's no longer
145 + // needed since the migration guarantees the canonical name.
146 + $bookingsTable = BookingsTable::getTableName();
147 +
150 148 $count = $wpdb->get_var(
151 149 $wpdb->prepare(
152 150 "SELECT COUNT(*) FROM `{$bookingsTable}`
153 151 WHERE discount_code = %s
@@ -159,9 +157,9 @@
159 157 return (int) ($count ?? 0);
160 158 }
161 159
162 160 /**
163 - * Status counts for admin toolbar (matches wp_yatra_new_discounts.status values).
161 + * Status counts for admin toolbar (matches wp_yatra_discounts.status values).
164 162 *
165 163 * @return array{all: int, publish: int, draft: int, trash: int, expired: int}
166 164 */
167 165 public function getAdminStatusCounts(): array