| @@ -30,10 +30,20 @@ | ||
| 30 | 30 | if (!$booking) { |
| 31 | 31 | wp_die(__('Invalid checkout link.', 'yatra')); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - // Prevent 404 handling | |
| 35 | - $this->prevent404(); | |
| 34 | + // Configure $wp_query + virtual WP_Post so FSE block themes don't fall back to 404.html. | |
| 35 | + $this->setupPageEnvironment('singular', [ | |
| 36 | + 'title' => __('Checkout', 'yatra'), | |
| 37 | + // Keep the virtual post ID at 0 (like the account/login/booking | |
| 38 | + // handlers). Using the booking row id made get_queried_object_id() | |
| 39 | + // collide with a real wp_posts row of the same id, so SEO plugins / | |
| 40 | + // WordPress emitted THAT page's SEO on this page. The booking is read | |
| 41 | + // from the `yatra_booking` global, so no queried-object id is needed. | |
| 42 | + 'object_id' => 0, | |
| 43 | + 'post_type' => 'page', | |
| 44 | + 'post_name' => $token, | |
| 45 | + ]); | |
| 36 | 46 | |
| 37 | 47 | // Set up global booking object |
| 38 | 48 | $this->setGlobal('yatra_booking', $booking); |
| 39 | 49 | |
| @@ -42,18 +52,7 @@ | ||
| 42 | 52 | 'yatra_remaining_checkout' => $token, |
| 43 | 53 | 'yatra_booking' => $booking, |
| 44 | 54 | ]); |
| 45 | 55 | |
| 46 | - // Load the checkout template | |
| 47 | - $template_path = YATRA_PLUGIN_PATH . 'templates/checkout.php'; | |
| 48 | - | |
| 49 | - if (!file_exists($template_path)) { | |
| 50 | - $this->logError("Checkout template not found: {$template_path}"); | |
| 51 | - return false; | |
| 52 | - } | |
| 53 | - | |
| 54 | - include $template_path; | |
| 55 | - $this->exit(); | |
| 56 | - | |
| 57 | - return true; | |
| 56 | + return $this->selectTemplate('checkout', null, 'checkout'); | |
| 58 | 57 | } |
| 59 | 58 | } |