← All changes
|
app/Services/Integrations/FluentBooking/FluentBookingService.php
+14
-28
2.4.0
→
2.4.5
View file →
| @@ -10,10 +10,8 @@ | ||
| 10 | 10 | class FluentBookingService |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Registers WordPress hooks for the booking-scheduled and agent-response events. | |
| 15 | - * | |
| 16 | 14 | * @return void |
| 17 | 15 | */ |
| 18 | 16 | public function init() |
| 19 | 17 | { |
| @@ -21,12 +19,10 @@ | ||
| 21 | 19 | add_action('fluent_support/response_added_by_agent', [$this, 'promoteGeneratedBookingLinksFromResponse'], 20, 3); |
| 22 | 20 | } |
| 23 | 21 | |
| 24 | 22 | /** |
| 25 | - * Returns the plugin's active/configured state. | |
| 23 | + * Pass $eventTypes if already loaded to skip the query. | |
| 26 | 24 | * |
| 27 | - * Pass $eventTypes from a prior getEventTypes() call to avoid a redundant DB query. | |
| 28 | - * | |
| 29 | 25 | * @param array|null $eventTypes |
| 30 | 26 | * @return array |
| 31 | 27 | */ |
| 32 | 28 | public function getStatus($eventTypes = null) |
| @@ -44,9 +40,9 @@ | ||
| 44 | 40 | ]; |
| 45 | 41 | } |
| 46 | 42 | |
| 47 | 43 | /** |
| 48 | - * Returns all active, publicly-accessible event types the current user can read, shaped for the frontend selector. | |
| 44 | + * Active event types whose landing page is public, for the frontend selector. | |
| 49 | 45 | * |
| 50 | 46 | * @return array |
| 51 | 47 | */ |
| 52 | 48 | public function getEventTypes() |
| @@ -79,12 +75,11 @@ | ||
| 79 | 75 | return $eventTypes; |
| 80 | 76 | } |
| 81 | 77 | |
| 82 | 78 | /** |
| 83 | - * Generates a tokenised booking URL and both HTML and plain-text email content. | |
| 79 | + * Build the reply content (HTML and plain text) with a tokenised booking link. | |
| 80 | + * Selected slots are re-checked against live availability. | |
| 84 | 81 | * |
| 85 | - * Each selected slot is validated against live availability before being embedded. | |
| 86 | - * | |
| 87 | 82 | * @param Ticket $ticket |
| 88 | 83 | * @param int $eventId |
| 89 | 84 | * @param string $message |
| 90 | 85 | * @param array $selectedSlots |
| @@ -131,9 +126,9 @@ | ||
| 131 | 126 | ]; |
| 132 | 127 | } |
| 133 | 128 | |
| 134 | 129 | /** |
| 135 | - * Fetches and formats available time slots for the given event and date range, grouped by day for the UI preview. | |
| 130 | + * Available slots for the event in the given range, grouped by day. | |
| 136 | 131 | * |
| 137 | 132 | * @param int $eventId |
| 138 | 133 | * @param string $range |
| 139 | 134 | * @param string $timezone |
| @@ -179,12 +174,11 @@ | ||
| 179 | 174 | ]; |
| 180 | 175 | } |
| 181 | 176 | |
| 182 | 177 | /** |
| 183 | - * Returns upcoming and past bookings for the ticket's customer. | |
| 178 | + * Upcoming and past bookings for the ticket's customer, scoped to the | |
| 179 | + * events and dates of the ticket's stored links when there are any. | |
| 184 | 180 | * |
| 185 | - * When stored link tokens exist the query is scoped to those event types and date range. | |
| 186 | - * | |
| 187 | 181 | * @param Ticket $ticket |
| 188 | 182 | * @return array |
| 189 | 183 | */ |
| 190 | 184 | public function getTicketMeetings(Ticket $ticket) |
| @@ -244,12 +238,10 @@ | ||
| 244 | 238 | return $meetings; |
| 245 | 239 | } |
| 246 | 240 | |
| 247 | 241 | /** |
| 248 | - * Hook: fluent_booking/after_booking_scheduled. | |
| 242 | + * Add a timeline note when the customer books through a link sent from the ticket. | |
| 249 | 243 | * |
| 250 | - * Appends an internal timeline note when a customer books via a link sent from this ticket. | |
| 251 | - * | |
| 252 | 244 | * @param object $booking |
| 253 | 245 | * @param object $calendarSlot |
| 254 | 246 | * @param array $bookingData |
| 255 | 247 | * @return void |
| @@ -292,12 +284,10 @@ | ||
| 292 | 284 | ]); |
| 293 | 285 | } |
| 294 | 286 | |
| 295 | 287 | /** |
| 296 | - * Hook: fluent_support/response_added_by_agent. | |
| 288 | + * Store any tokenised booking links found in an agent response. | |
| 297 | 289 | * |
| 298 | - * Scans outgoing response content for tokenised booking URLs and persists any found as ticket meta. | |
| 299 | - * | |
| 300 | 290 | * @param object $response |
| 301 | 291 | * @param Ticket $ticket |
| 302 | 292 | * @param object $person |
| 303 | 293 | * @return void |
| @@ -320,9 +310,9 @@ | ||
| 320 | 310 | } |
| 321 | 311 | } |
| 322 | 312 | |
| 323 | 313 | /** |
| 324 | - * Returns true when FluentBooking is installed. | |
| 314 | + * FluentBooking is installed and the integration is enabled. | |
| 325 | 315 | * |
| 326 | 316 | * @return bool |
| 327 | 317 | */ |
| 328 | 318 | public function isActive() |
| @@ -333,9 +323,9 @@ | ||
| 333 | 323 | return Helper::getBusinessSettings('enable_fluent_booking_integration', 'yes') === 'yes'; |
| 334 | 324 | } |
| 335 | 325 | |
| 336 | 326 | /** |
| 337 | - * Returns true when the event's landing-page sharing is enabled and includes this slot. | |
| 327 | + * The calendar's public landing page is enabled and includes this event. | |
| 338 | 328 | * |
| 339 | 329 | * @param object $event |
| 340 | 330 | * @return bool |
| 341 | 331 | */ |
| @@ -354,15 +344,11 @@ | ||
| 354 | 344 | return in_array((int) $event->id, array_map('intval', Arr::get($settings, 'enabled_slots', [])), true); |
| 355 | 345 | } |
| 356 | 346 | |
| 357 | 347 | /** |
| 358 | - * Builds the booking landing-page URL for an event. | |
| 348 | + * Landing-page URL for an event, prefilled with the customer and ticket ID when given. | |
| 349 | + * Forces getLandingPageUrl() because callers have already checked canUseEvent(). | |
| 359 | 350 | * |
| 360 | - * Uses Calendar::getLandingPageUrl() so FluentBooking owns its URL format (pretty-slug vs query-string). | |
| 361 | - * canUseEvent() has already confirmed the landing page is enabled, so $isForce = true skips the | |
| 362 | - * redundant settings re-check inside getLandingPageUrl(). | |
| 363 | - * Appends customer name, email, and ticket ID when a ticket is provided. | |
| 364 | - * | |
| 365 | 351 | * @param object $event |
| 366 | 352 | * @param Ticket|null $ticket |
| 367 | 353 | * @return string |
| 368 | 354 | */ |
| @@ -391,9 +377,9 @@ | ||
| 391 | 377 | ]), $url)); |
| 392 | 378 | } |
| 393 | 379 | |
| 394 | 380 | /** |
| 395 | - * Appends fs_booking_link_token to a URL so a completed booking can be traced back to the originating ticket link. | |
| 381 | + * Add fs_booking_link_token so a booking can be traced back to the link that was sent. | |
| 396 | 382 | * |
| 397 | 383 | * @param string $url |
| 398 | 384 | * @param string $linkToken |
| 399 | 385 | * @return string |