/var/www/html_uk/wp-content/plugins/automatewoo/includes/Variables/AbstractBookingTime.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

namespace AutomateWoo\Variables;

use 
AutomateWoo\DateTime;
use 
WC_Booking;

defined'ABSPATH' ) || exit;

/**
 * Class AbstractBookingTime
 *
 * @since 5.4.0
 */
abstract class AbstractBookingTime extends AbstractTime {

    
/**
     * Get the target booking datetime value for the variable.
     *
     * @param WC_Booking $booking
     *
     * @return DateTime|null The variable's target datetime value in the site's local timezone.
     */
    
abstract protected function get_target_datetime_valueWC_Booking $booking );

    
/**
     * Get the variable value.
     *
     * If booking is "all-day" no time will be returned.
     *
     * @param WC_Booking $booking
     * @param array      $parameters
     *
     * @return string
     */
    
public function get_value$booking$parameters ) {
        if ( 
$booking->is_all_day() ) {
            
// All-day bookings have no time.
            // Returning '' here lets users use the 'fallback' parameter for all-day bookings.
            
return '';
        }

        
$datetime $this->get_target_datetime_value$booking );
        if ( ! 
$datetime ) {
            return 
'';
        }

        return 
$this->format_value_from_local_tz$datetime );
    }
}