Plugin Directory

Changeset 2911748


Ignore:
Timestamp:
05/12/2023 05:52:47 PM (3 years ago)
Author:
sadowski
Message:

Tagging version 1.1.40

Location:
woocommerce-accommodation-bookings
Files:
26 added
4 deleted
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woocommerce-accommodation-bookings/tags/1.1.40/assets/css/frontend.scss

    r2179088 r2911748  
    1 .wc-bookings-date-picker {
    2         .ui-datepicker {
    3         td.partial_booked a {
    4             &:before {
    5                 display:none;
    6             }
     1.product-type-accommodation-booking {
     2    .wc-bookings-date-picker {
     3        position: relative;
     4        padding-top: 55px;
     5
     6        &::after {
     7            content: attr(data-content);
     8            position: absolute;
     9            background: #fff;
     10            margin: 10px 20px;
     11            font-size: 13px;
     12            left: 0;
     13            right: 0;
     14            top: 0;
     15            text-align: center;
     16            height: 35px;
     17            line-height: 35px;
    718        }
    8         td.fully_booked + td.partial_booked.partial_booked a {
    9             &:after {
    10                 border-bottom: none;
    11                 border-left: none;
    12                 border-top: 2.5em solid #C96259;
    13                 border-right: 2.5em solid transparent;
    14                 left: 0;
    15                 top: 0;
    16             }
     19
     20        .picker.hasDatepicker {
     21            margin: 0;
     22            position: static !important;
    1723        }
    1824    }
    1925}
     26
     27.wc-bookings-date-picker {
     28    fieldset {
     29        position: relative;
     30    }
     31
     32    &:not([data-selected-date-type="start"]) .ui-datepicker td.fully_booked_start_days:not(.selection-end-date),
     33    &[data-selected-date-type="start"] .ui-datepicker td.fully_booked_end_days:not(.selection-start-date) {
     34        opacity: 0.35;
     35    }
     36
     37    &:not([data-selected-date-type="start"]) .ui-datepicker td.fully_booked_start_days:not(.selection-end-date),
     38    &[data-selected-date-type="start"] .ui-datepicker td.fully_booked_end_days:not(.selection-start-date),
     39    .ui-datepicker td.fully_booked {
     40        span, a {
     41            background-color: #c0392b !important;
     42            background-image: none !important;
     43            border-color: rgba(0, 0, 0, 0.1) !important;
     44            color: #fff !important;
     45            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
     46            pointer-events: none;
     47        }
     48    }
     49
     50    .ui-datepicker {
     51        td.bookable-range.ui-state-disabled {
     52            opacity: 1;
     53        }
     54    }
     55}
  • woocommerce-accommodation-bookings/tags/1.1.40/assets/js/writepanel.js

    r2529660 r2911748  
    1 jQuery( function( $ ) {
     1/* globals jQuery */
    22
    3     $('#rates_rows').sortable({
    4         items:'tr',
    5         cursor:'move',
    6         axis:'y',
    7         handle: '.sort',
    8         scrollSensitivity:40,
    9         forcePlaceholderSize: true,
    10         helper: 'clone',
    11         opacity: 0.65,
    12         placeholder: 'wc-metabox-sortable-placeholder',
    13         start:function(event,ui){
    14             ui.item.css('background-color','#f6f6f6');
    15         },
    16         stop:function(event,ui){
    17             ui.item.removeAttr('style');
    18         }
    19     });
     3jQuery(function ($) {
     4    $('#rates_rows').sortable({
     5        items: 'tr',
     6        cursor: 'move',
     7        axis: 'y',
     8        handle: '.sort',
     9        scrollSensitivity: 40,
     10        forcePlaceholderSize: true,
     11        helper: 'clone',
     12        opacity: 0.65,
     13        placeholder: 'wc-metabox-sortable-placeholder',
     14        start(event, ui) {
     15            ui.item.css('background-color', '#f6f6f6');
     16        },
     17        stop(event, ui) {
     18            ui.item.removeAttr('style');
     19        },
     20    });
    2021
    21     function wc_accommodation_bookings_trigger_change_events() {
    22         $('#_wc_accommodation_booking_has_restricted_days').trigger( 'change' );
    23     }
     22    function wc_accommodation_bookings_trigger_change_events() {
     23        $('#_wc_accommodation_booking_has_restricted_days').trigger('change');
     24    }
    2425
    25     $('#_wc_accommodation_booking_has_restricted_days').on( 'change', function() {
    26         if ( $(this).is( ':checked' ) ) {
    27             $( '.booking-day-restriction' ).show();
    28         } else {
    29             $( '.booking-day-restriction' ).hide();
    30         }
    31     });
     26    $('#_wc_accommodation_booking_has_restricted_days').on(
     27        'change',
     28        function () {
     29            if ($(this).is(':checked')) {
     30                $('.booking-day-restriction').show();
     31            } else {
     32                $('.booking-day-restriction').hide();
     33            }
     34        }
     35    );
    3236
    33     wc_accommodation_bookings_trigger_change_events();
    34 
    35 } );
     37    wc_accommodation_bookings_trigger_change_events();
     38});
  • woocommerce-accommodation-bookings/tags/1.1.40/changelog.txt

    r2879445 r2911748  
    11*** Changelog ***
     2
     3= 1.1.40 - 2023-05-12 =
     4* Dev - Added a new filter, `woocommerce_accommodation_booking_get_check_times`, to change the check-in/out timings per product.
     5* Fix - Fully booked days show as partially booked - Day after booking shows partially booked.
    26
    37= 1.1.39 - 2023-03-14 =
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-booking-cart-manager.php

    r2815380 r2911748  
    3434    public function get_item_data( $other_data, $cart_item ) {
    3535        if ( 'accommodation-booking' === $cart_item['data']->get_type() && ! empty( $other_data ) ) {
    36             $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    37             $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     36            $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $cart_item['product_id'] );
     37            $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $cart_item['product_id'] );
    3838            $end_date  = date_i18n( get_option( 'date_format'), $cart_item['booking']['_end_date'] );
    3939
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-booking-date-picker.php

    r2337392 r2911748  
    1 <?php
     1<?php // phpcs:disable WordPress.DateTime.RestrictedFunctions.date_date,WordPress.PHP.StrictInArray.MissingTrueStrict
     2/**
     3 * This plugin handles the date picker related logic for Accommodation Bookings.
     4 *
     5 * @package WooCommerce Accommodation Bookings
     6 * @since   1.1.40
     7 */
     8
    29if ( ! defined( 'ABSPATH' ) ) {
    310    exit;
     
    1522        add_filter( 'woocommerce_bookings_date_picker_start_label', array( $this, 'start_label' ) );
    1623        add_filter( 'woocommerce_bookings_date_picker_end_label', array( $this, 'end_label' ) );
    17         add_filter( 'woocommerce_booking_form_get_posted_data', array( $this, 'add_accommodation_posted_data' ), 10 , 3 );
    18         add_filter( 'woocommerce_bookings_booked_day_blocks', array( $this, 'add_partially_booked_dates' ), 10 , 3 );
     24        add_filter( 'woocommerce_booking_form_get_posted_data', array( $this, 'add_accommodation_posted_data' ), 10, 3 );
     25        add_filter( 'woocommerce_bookings_booked_day_blocks', array( $this, 'update_fully_booked_dates' ), 10, 3 );
     26        add_filter( 'woocommerce_bookings_find_booked_day_blocks', array( $this, 'find_booked_day_blocks' ), 10, 2 );
    1927    }
    2028
    2129    /**
    2230     * Add custom start and end dat to booking data
     31     *
    2332     * @since 1.0.7
    2433     *
    25      * @param $data
    26      * @param $product
    27      * @param $total_duration
     34     * @param array               $data           Posted data.
     35     * @param \WC_Product_Booking $product        Booking product.
     36     * @param int                 $total_duration Total duration.
    2837     *
    2938     * @return mixed
    3039     */
    3140    public function add_accommodation_posted_data( $data, $product, $total_duration ) {
    32         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    33         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     41        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product->get_id() );
     42        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product->get_id() );
    3443
    3544        if ( 'night' === $product->get_duration_unit() ) {
     
    4049
    4150        if ( $product->has_resources() && ! $product->is_resource_assignment_type( 'customer' ) ) {
    42             // Assign an available resource automatically
     51            // Assign an available resource automatically.
    4352            $available_bookings = wc_bookings_get_total_available_bookings_for_range( $product, $data['_start_date'], $data['_end_date'], 0, $data['_qty'] );
    4453            if ( is_array( $available_bookings ) ) {
     
    5362    /**
    5463     * Changes the start label to "Check-in"
    55      * @param  string $label
     64     *
     65     * @param  string $label Label.
    5666     * @return string
    5767     */
     
    6272    /**
    6373     * Changes the end label to "Check-out"
     74     *
     75     * @param  string $label Label.
    6476     */
    6577    public function end_label( $label ) {
     
    8597     *    b. test if resources are available and if yes than move fully booked day to partially booked days
    8698     *
    87      * @param array                            $booked_data_array
    88      * @param WC_Product_Accommodation_Booking $product
     99     * @param array                            $booked_data_array Array of booked days.
     100     * @param WC_Product_Accommodation_Booking $product           Product.
    89101     */
    90102    public function add_partially_booked_dates( $booked_data_array, $product ) {
     
    107119                    }
    108120
     121                    $check_in_time = $product->get_check_times( 'in', $product->get_id() );
     122                    if ( 'in' === $which ) {
     123                        $check_time = strtotime( '-1 day ' . $check_in_time, $time );
     124                    } else {
     125                        $check_time = strtotime( $check_in_time, $time );
     126                    }
     127                    $check = date( 'F j, Y, g:i a', $check_time );
     128                    // Check available blocks for resource. If some are available that means that the day is not fully booked.
     129                    $not_fully_booked = $this->get_product_resource_available_blocks_on_time( $product, $resource_id, $check_time );
     130                    if ( $not_fully_booked ) {
     131                        $booked_data_array = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     132                    }
     133                }
     134            }
     135        }
     136
     137        return $booked_data_array;
     138    }
     139
     140    /**
     141     * Update the fully booked, fully booked start day, and fully booked end day accomodation bookings,
     142     *
     143     * @param array                            $booked_data_array Array of booked days.
     144     * @param WC_Product_Accommodation_Booking $product           Product.
     145     */
     146    public function update_fully_booked_dates( $booked_data_array, $product ) {
     147        // This function makes sense only for duration type: night.
     148        if ( 'night' !== $product->get_duration_unit() ) {
     149            return $booked_data_array;
     150        }
     151
     152        // Start and the end dates of all bookings.
     153        $check_in_out_times = $this->get_check_in_and_out_times( $product );
     154        $res_auto_assign    = $product->is_resource_assignment_type( 'automatic' );
     155
     156        // Go through each checkin and checkout days and mark them as fully booked.
     157        $made_partialy = array();
     158        foreach ( array( 'in', 'out' ) as $which ) {
     159            foreach ( $check_in_out_times[ $which ] as $resource_id => $times ) {
     160                foreach ( $times as $time ) {
     161                    $day = date( 'Y-n-j', $time );
     162
    109163                    $check_in_time = $product->get_check_times( 'in' );
    110164                    if ( 'in' === $which ) {
    111                         $check_time = strtotime( '-1 day ' . $check_in_time , $time );
     165                        $check_time = strtotime( $check_in_time, $time );
    112166                    } else {
    113                         $check_time = strtotime( $check_in_time, $time );
    114                     }
    115                     $check = date("F j, Y, g:i a", $check_time );
     167                        $check_time = strtotime( '-1 day' . $check_in_time, $time );
     168                    }
     169                    $check = date( 'F j, Y, g:i a', $check_time );
    116170                    // Check available blocks for resource. If some are available that means that the day is not fully booked.
    117                     $not_fully_booked = $this->get_product_resource_available_blocks_on_time( $product, $resource_id, $check_time );
    118                     if( $not_fully_booked ) {
    119                         $booked_data_array = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     171                    $resource_id_to_use = $res_auto_assign ? 0 : $resource_id;
     172                    $available_on_time  = $this->get_product_resource_available_blocks_on_time( $product, $resource_id_to_use, $check_time );
     173                    if ( 0 === $available_on_time ) {
     174                        $booked_data_array = $this->prepare_fully_booked_start_and_end_days( $booked_data_array, $resource_id, $day, $which );
     175                    } else {
     176                        $booked_data_array             = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     177                        $made_partialy[ $resource_id ] = $day;
    120178                    }
    121179                }
     
    123181        }
    124182
     183        // Later removing the days from `fully_booked_days` array that were moved to partially booked days.
     184        // We are doing this out of the above foreach because we want a condition in
     185        // `prepare_fully_booked_start_and_end_days()` to be true.
     186        foreach ( $made_partialy as $resource => $partial_day ) {
     187            if ( ! isset( $booked_data_array['fully_booked_days'][ $partial_day ][ $resource ] ) ) {
     188                continue;
     189            }
     190
     191            unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
     192
     193            if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
     194                unset( $booked_data_array['fully_booked_days'][ $day ] );
     195            }
     196        }
     197
    125198        return $booked_data_array;
    126199    }
    127200
    128201    /**
     202     * Should return find booked day blocks with additional data.
     203     *
     204     * @since 1.1.40
     205     *
     206     * @param array $result        Array of booked days.
     207     * @param array $booked_blocks Array of booked blocks.
     208     */
     209    public function find_booked_day_blocks( $result, $booked_blocks ): array {
     210        $result['fully_booked_start_days'] = $booked_blocks['fully_booked_start_days'] ?? array();
     211        $result['fully_booked_end_days']   = $booked_blocks['fully_booked_end_days'] ?? array();
     212
     213        return $result;
     214    }
     215
     216    /**
    129217     * Calculates array that contains the start and the end time of all bookings for given product.
    130      * @param $product
     218     *
     219     * @param \WC_Product_Booking $product Product.
    131220     */
    132221    private function get_check_in_and_out_times( $product ) {
    133222
    134         $check_in_out_times     = array(
    135             'in' => array(),
     223        $check_in_out_times = array(
     224            'in'  => array(),
    136225            'out' => array(),
    137226        );
     
    140229        // Those times will be considered for switching particular day from full to partially booked days.
    141230        if ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) {
    142             $existing_bookings  = WC_Bookings_Controller::get_all_existing_bookings( $product );
     231            $existing_bookings = WC_Bookings_Controller::get_all_existing_bookings( $product );
    143232        } else {
    144             $existing_bookings  = WC_Booking_Data_Store::get_all_existing_bookings( $product );
     233            $existing_bookings = WC_Booking_Data_Store::get_all_existing_bookings( $product );
    145234        }
    146235
    147236        foreach ( $existing_bookings as $booking ) {
    148237
    149             $resource   = $booking->get_resource_id();
     238            $resource = $booking->get_resource_id();
    150239            if ( ! array_key_exists( $resource, $check_in_out_times['in'] ) ) {
    151                 $check_in_out_times['in'][ $resource ] = array();
     240                $check_in_out_times['in'][ $resource ]  = array();
    152241                $check_in_out_times['out'][ $resource ] = array();
    153242            }
     
    167256    /**
    168257     * Get amount of available product resoureces on a specific timestamp
    169      * @param $product
    170      * @param $resource
    171      * @param $date
     258     *
     259     * @param \WC_Product_Booking $product  Product.
     260     * @param int                 $resource Resource ID.
     261     * @param string              $time     Timestamp.
     262     *
     263     * @return int|mixed
    172264     */
    173265    private function get_product_resource_available_blocks_on_time( $product, $resource, $time ) {
    174         $blocks = $product->get_blocks_in_range_for_day( $time, $time, $resource, array() );
    175         $available_blocks = wc_bookings_get_time_slots( $product, $blocks, array(), 0, $time, $time );
    176         return ! empty( $available_blocks[ $time ] ) ? $available_blocks[ $time ][ 'available'] : 0;
     266        $blocks           = $product->get_blocks_in_range_for_day( $time, $time, $resource, array() );
     267        $available_blocks = wc_bookings_get_time_slots( $product, $blocks, array(), $resource, $time, $time );
     268        return ! empty( $available_blocks[ $time ] ) ? $available_blocks[ $time ]['available'] : 0;
    177269    }
    178270
     
    180272     * Moves day from fully booked days array to partially booked days array and if the fully booked days is
    181273     * array for that day is empty ( no assigned resources ) removes that empty day entry
    182      * @param $booked_data_array
    183      * @param $resource
    184      * @param $day
     274     *
     275     * @param array  $booked_data_array Array of booked days.
     276     * @param int    $resource          Resource ID.
     277     * @param string $day               Day.
    185278     */
    186279    private function move_day_from_fully_to_partially_booked( $booked_data_array, $resource, $day ) {
     
    191284        $booked_data_array['partially_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
    192285
    193         unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
    194 
    195         if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
    196             unset( $booked_data_array['fully_booked_days'][ $day ] );
    197         }
    198 
    199286        return $booked_data_array;
    200287    }
    201288
     289    /**
     290     * Moves day from fully_booked_days array to the fully_booked_start_days or fully_booked_end_days
     291     * This is required because we want to showcase days availability as per the selection.
     292     * So by default, fully_booked_start_days will be colored red; not available for check-ins.
     293     * When start date is selected, fully_booked_end_days will be colored red; not available for check-outs.
     294     *
     295     * @param array  $booked_data_array Array of booked days.
     296     * @param int    $resource          Resource ID.
     297     * @param string $day               A Day.
     298     * @param string $which             In or Out.
     299     */
     300    private function prepare_fully_booked_start_and_end_days( $booked_data_array, $resource, $day, $which = 'in' ) {
     301        if ( isset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ) ) {
     302            if ( 'in' === $which ) {
     303                $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
     304            } else {
     305                $booked_data_array['fully_booked_end_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
     306            }
     307            unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
     308
     309            if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
     310                unset( $booked_data_array['fully_booked_days'][ $day ] );
     311            }
     312        } else {
     313            // If the day already exists fully_booked_start_days at this point,
     314            // it means it is also a fully booked end day, so reverting it
     315            // back to be in fully_booked_days.
     316            if ( isset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] ) ) {
     317                $booked_data_array['fully_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_start_days'][ $day ][ $resource ];
     318                unset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] );
     319
     320                if ( empty( $booked_data_array['fully_booked_start_days'][ $day ] ) ) {
     321                    unset( $booked_data_array['fully_booked_start_days'][ $day ] );
     322                }
     323            }
     324        }
     325
     326        // Also removing from partially booked array in case if it
     327        // was added there in `move_day_from_fully_to_partially_booked()`.
     328        if ( isset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] ) ) {
     329            unset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] );
     330        }
     331        if ( empty( $booked_data_array['partially_booked_days'][ $day ] ) ) {
     332            unset( $booked_data_array['partially_booked_days'][ $day ] );
     333        }
     334
     335        return $booked_data_array;
     336    }
    202337}
    203338
    204 new WC_Accommodation_Booking_Date_Picker;
     339new WC_Accommodation_Booking_Date_Picker();
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-booking-order-manager.php

    r2815380 r2911748  
    3434        }
    3535
    36         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    37         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     36        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $item['product_id'] );
     37        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $item['product_id'] );
    3838        ?>
    3939        <p>
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-booking-product-tabs.php

    r1714785 r2911748  
    1212
    1313    /**
     14     * Product ID.
     15     */
     16    public $product_id = 0;
     17
     18    /**
    1419     * Hook into WooCommerce..
    1520     */
     
    2328     */
    2429    public function are_time_fields_filled_out() {
    25         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    26         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     30        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $this->product_id );
     31        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $this->product_id );
    2732
    2833        if ( empty( $check_in ) ) {
     
    5762        }
    5863
     64        // Set the product ID.
     65        $this->product_id = $post->ID;
     66
    5967        if ( ! $this->are_time_fields_filled_out() ) {
    6068            return $tabs;
     
    7886            return;
    7987        }
    80         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    81         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     88        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $this->product_id );
     89        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $this->product_id );
    8290        ?>
    8391        <h2><?php echo esc_html( apply_filters( 'woocommerce_accommodation_booking_time_tab_heading', __( 'Arriving/leaving', 'woocommerce-accommodation-bookings' ) ) ); ?></h2>
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-booking.php

    r2390281 r2911748  
    110110        }
    111111
    112         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    113 
    114112        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() );
    115113        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() );
    116114
    117         return date_i18n( $date_format, $booking->start ) . date_i18n( $time_format, strtotime( "Today " . $check_in ) );
     115        return date_i18n( $date_format, $booking->start ) . date_i18n( $time_format, $booking->start );
    118116    }
    119117
     
    124122        }
    125123
    126         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
    127124        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() );
    128125        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() );
    129126
    130         return date_i18n( $date_format, $booking->end ) . date_i18n( $time_format, strtotime( "Today " . $check_out ) );
     127        return date_i18n( $date_format, $booking->end ) . date_i18n( $time_format, $booking->end );
    131128    }
    132129
     
    182179        }
    183180
    184         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    185         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     181        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product_id );
     182        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product_id );
    186183
    187184        $start = get_post_meta( $booking_id, '_booking_start', true );
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-accommodation-bookings-plugin.php

    r2815380 r2911748  
    11<?php
     2/**
     3 * This class is responsible for the plugin's initialization.
     4 *
     5 * @since 1.0.2
     6 * @package WooCommerce\AccommodationBookings
     7 */
     8
    29if ( ! defined( 'ABSPATH' ) ) {
    310    exit;
     
    3340     * Constructor.
    3441     *
    35      * @param string $plugin_file Path to main plugin's file
    36      * @param string $version     Plugin's version
     42     * @param string $plugin_file Path to main plugin's file.
     43     * @param string $version     Plugin's version.
    3744     */
    3845    public function __construct( $plugin_file, $version ) {
     
    8895     * @return void
    8996     */
     97    // phpcs:ignore
    9098    private function _define_constants() {
    9199        define( 'WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH', untrailingslashit( plugin_dir_path( $this->plugin_file ) ) . '/includes/' );
     
    100108     * @return void
    101109     */
     110    // phpcs:ignore
    102111    private function _register_hooks() {
    103112        register_activation_hook( $this->plugin_file, array( $this, 'check_dependencies' ) );
     
    111120        add_action( 'plugins_loaded', array( $this, 'includes' ), 20 );
    112121        add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
    113         add_action( 'wp_enqueue_scripts', array( $this, 'booking_form_styles' ) );
     122        add_action( 'wp_enqueue_scripts', array( $this, 'frontend_assets' ) );
    114123
    115124        if ( is_admin() ) {
     
    131140        }
    132141
    133         require_once( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-dependencies.php' );
     142        require_once WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-dependencies.php';
    134143        try {
    135144            WC_Accommodation_Dependencies::check_dependencies();
     
    164173     */
    165174    public function load_plugin_textdomain() {
     175        /**
     176         * Filter locale before loading the plugin's text domain.
     177         *
     178         * @since 1.0.2
     179         *
     180         * @param string $locale The plugin's current locale.
     181         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     182         */
    166183        $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-accommodation-bookings' );
    167184        $dir    = trailingslashit( WP_LANG_DIR );
     
    175192     */
    176193    public function includes() {
    177         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking.php' );
    178         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking-resource.php' );
    179         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking.php' );
    180         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-cart-manager.php' );
    181         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-date-picker.php' );
    182         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-product-tabs.php' );
    183         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-order-manager.php' );
    184         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'integrations/class-wc-accommodation-booking-addons.php' );
     194        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking.php';
     195        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking-resource.php';
     196        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking.php';
     197        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-cart-manager.php';
     198        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-date-picker.php';
     199        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-product-tabs.php';
     200        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-order-manager.php';
     201        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'integrations/class-wc-accommodation-booking-addons.php';
    185202    }
    186203
     
    189206     */
    190207    public function admin_includes() {
    191         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-panels.php' );
    192         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-product-settings.php' );
     208        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-panels.php';
     209        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-product-settings.php';
    193210    }
    194211
     
    196213     * Frontend booking form scripts
    197214     */
    198     public function booking_form_styles() {
    199         wp_enqueue_style( 'wc-accommodation-bookings-styles', WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/assets/css/frontend.css', null, WC_ACCOMMODATION_BOOKINGS_VERSION );
     215    public function frontend_assets() {
     216        $booking_style_asset_data  = $this->get_asset_data( 'frontend', 'css' );
     217        $booking_script_asset_data = $this->get_asset_data( 'booking-form', 'js/frontend' );
     218
     219        $booking_script_dependencies = array_merge(
     220            $booking_script_asset_data['dependencies'],
     221            array( 'wc-bookings-booking-form' )
     222        );
     223
     224        wp_enqueue_style(
     225            'wc-accommodation-bookings-styles',
     226            WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/dist/css/frontend.css',
     227            null,
     228            $booking_style_asset_data['version']
     229        );
     230
     231        wp_enqueue_script(
     232            'wc-accommodation-bookings-form',
     233            WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/dist/js/frontend/booking-form.js',
     234            $booking_script_dependencies,
     235            $booking_script_asset_data['version'],
     236            true
     237        );
     238
     239        wp_set_script_translations(
     240            'wc-accommodation-bookings-form',
     241            'woocommerce-accommodation-bookings',
     242            plugin_dir_path( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) . '/languages'
     243        );
    200244    }
    201245
     
    203247     * Show row meta on the plugin screen.
    204248     *
    205      * @access  public
    206      * @param   mixed $links Plugin Row Meta
    207      * @param   mixed $file  Plugin Base file
    208      * @return  array
     249     * @param array  $links Plugin Row Meta.
     250     * @param string $file  Plugin Base file.
     251     *
     252     * @return  array
    209253     */
    210254    public function plugin_row_meta( $links, $file ) {
    211         if ( $file == plugin_basename( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) ) {
     255        // phpcs:ignore
     256        if ( $file === plugin_basename( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) ) {
    212257            $row_meta = array(
    213                 'docs'      =>  '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_docs_url', 'https://docs.woocommerce.com/document/woocommerce-accommodation-bookings/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Docs', 'woocommerce-accommodation-bookings' ) . '</a>',
    214                 'support'   =>  '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_support_url', 'https://docs.woocommerce.com/' ) ) . '" title="' . esc_attr( __( 'Visit Premium Customer Support Forum', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Premium Support', 'woocommerce-accommodation-bookings' ) . '</a>',
     258                'docs'    => '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_docs_url', 'https://docs.woocommerce.com/document/woocommerce-accommodation-bookings/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Docs', 'woocommerce-accommodation-bookings' ) . '</a>', //phpcs:ignore
     259                'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_support_url', 'https://docs.woocommerce.com/' ) ) . '" title="' . esc_attr( __( 'Visit Premium Customer Support Forum', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Premium Support', 'woocommerce-accommodation-bookings' ) . '</a>', //phpcs:ignore
    215260            );
    216261
     
    227272        global $wpdb;
    228273
    229         $force_update = false;
     274        $force_update                   = false;
    230275        $accommodation_bookings_version = get_option( 'wc_accommodation_bookings_version' );
    231276
    232277        if ( ! $accommodation_bookings_version ) {
    233             $force_update = true;
     278            $force_update                   = true;
    234279            $accommodation_bookings_version = $this->version;
    235280        }
    236281
    237         // Data updates
     282        // Data updates.
    238283        if ( $force_update || version_compare( $accommodation_bookings_version, '1.1.3', '<' ) ) {
    239284            $accommodation_bookings = $wpdb->get_results( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = '_wc_booking_pricing' AND meta_value LIKE '%override_block%';" );
     
    242287
    243288                if ( ! is_a( $product, 'WC_Product' ) ) {
    244                     continue;               
    245                 }
    246 
    247                 if ( 'accommodation-booking' != $product->get_type() ) {
    248289                    continue;
    249290                }
    250291
    251                 $pricing = get_post_meta( $product->get_id(), '_wc_booking_pricing', true );
     292                if ( 'accommodation-booking' !== $product->get_type() ) {
     293                    continue;
     294                }
     295
     296                $pricing            = get_post_meta( $product->get_id(), '_wc_booking_pricing', true );
    252297                $original_base_cost = absint( get_post_meta( $product->get_id(), '_wc_booking_base_cost', true ) );
    253298
    254                 // Convert from the old to the new structure
     299                // Convert from the old to the new structure.
    255300                foreach ( $pricing as &$pricing_row ) {
    256                     $pricing_row['base_cost'] = $pricing_row['cost'] = 0;
    257                     $new_cost = $pricing_row['override_block'];
     301                    $pricing_row['base_cost'] = $pricing_row['cost'] = 0; //phpcs:ignore
     302                    $new_cost                 = $pricing_row['override_block'];
    258303                    unset( $pricing_row['override_block'] );
    259                     $pricing_row['base_modifier'] = $pricing_row['modifier'] = $new_cost > $original_base_cost ? 'plus' : 'minus';
    260                     $pricing_row['cost'] = absint( $new_cost - $original_base_cost );
     304                    $pricing_row['base_modifier'] = $pricing_row['modifier'] = $new_cost > $original_base_cost ? 'plus' : 'minus'; //phpcs:ignore
     305                    $pricing_row['cost']          = absint( $new_cost - $original_base_cost );
    261306                }
    262307
     
    265310        }
    266311
    267         // Update version
     312        // Update version.
    268313        update_option( 'wc_accommodation_bookings_version', $this->version );
    269314    }
     315
     316    /**
     317     * Should return data from the asset file.
     318     *
     319     * @param string $script_file_name Script file name.
     320     * @param string $location Script file location.
     321     *
     322     * @return array
     323     */
     324    private function get_asset_data( $script_file_name, $location ): array {
     325        $asset_path = dirname( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) . "/dist/$location/$script_file_name.asset.php";
     326
     327        return require $asset_path;
     328    }
    270329}
  • woocommerce-accommodation-bookings/tags/1.1.40/includes/class-wc-product-accommodation-booking.php

    r2815380 r2911748  
    196196        $bookable_product = $this;
    197197
    198         $transient_name               = 'book_ts_' . md5( http_build_query( array( $bookable_product->get_id(), $resource_id, $from, $to ) ) );
     198        $product_id                   = $bookable_product->get_id();
     199        $transient_name               = 'book_ts_' . md5( http_build_query( array( $product_id, $resource_id, $from, $to ) ) );
    199200        $available_slots              = get_transient( $transient_name );
    200201        $booking_slots_transient_keys = array_filter( (array) get_transient( 'booking_slots_transient_keys' ) );
    201202
    202         if ( ! isset( $booking_slots_transient_keys[ $bookable_product->get_id() ] ) ) {
    203             $booking_slots_transient_keys[ $bookable_product->get_id() ] = array();
    204         }
    205 
    206         $booking_slots_transient_keys[ $bookable_product->get_id() ][] = $transient_name;
     203        if ( ! isset( $booking_slots_transient_keys[ $product_id ] ) ) {
     204            $booking_slots_transient_keys[ $product_id ] = array();
     205        }
     206
     207        $booking_slots_transient_keys[ $product_id ][] = $transient_name;
    207208
    208209        // Give array of keys a long ttl because if it expires we won't be able to flush the keys when needed.
     
    230231
    231232            foreach ( $blocks as $block ) {
    232                 $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    233                 $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     233                $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product_id );
     234                $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product_id );
    234235                // Blocks for accommodation products are initially calculated as days but the actuall time blocks are shifted by check in and checkout times.
    235236                $block_start_time = strtotime( "{$check_in}", $block );
     
    329330     * Get checkin and checkout times.
    330331     *
    331      * @param string $type
    332      *
    333      * @return string Time, either from options or default
    334      */
    335     public static function get_check_times( $type ) {
    336         $option = get_option( 'woocommerce_accommodation_bookings_times_settings' );
     332     * @param string $type       The type, check_in or check_out.
     333     * @param int    $product_id The product ID.
     334     *
     335     * @return string The time, either from options or default or from the filtered value.
     336     */
     337    public static function get_check_times( $type, $product_id = 0 ) {
     338        $option     = get_option( 'woocommerce_accommodation_bookings_times_settings' );
     339        $check_time = '';
     340
    337341        switch ( $type ) {
    338342            case 'in':
    339                 return isset( $option['check_in'] ) ? $option['check_in'] : '14:00';
     343                $check_time = $option['check_in'] ?? '14:00';
     344                break;
    340345            case 'out':
    341                 return isset( $option['check_out'] ) ? $option['check_out'] : '14:00';
    342         }
    343 
    344         return '';
     346                $check_time = $option['check_out'] ?? '14:00';
     347                break;
     348        }
     349
     350        /**
     351         * Filter the check-in/out times for a specific product.
     352         *
     353         * @param string $check_time The check-in/out time stored in the database.
     354         * @param string $type       The type, check_in or check_out.
     355         * @param int    $product_id The product ID.
     356         *
     357         * @return string The filtered/original time.
     358         */
     359        return apply_filters( 'woocommerce_accommodation_booking_get_check_times', $check_time, $type, (int) $product_id );
    345360    }
    346361
  • woocommerce-accommodation-bookings/tags/1.1.40/languages/woocommerce-accommodation-bookings.pot

    r2879445 r2911748  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WooCommerce Accommodation Bookings 1.1.39\n"
    6 "Report-Msgid-Bugs-To: "
    7 "https://wordpress.org/support/plugin/woocommerce-accommodation-bookings\n"
    8 "POT-Creation-Date: 2023-03-14 00:20:22+00:00\n"
    9 "MIME-Version: 1.0\n"
    10 "Content-Type: text/plain; charset=utf-8\n"
    11 "Content-Transfer-Encoding: 8bit\n"
    12 "PO-Revision-Date: 2023-MO-DA HO:MI+ZONE\n"
     5"Project-Id-Version: WooCommerce Accommodation Bookings 1.1.40\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-accommodation-bookings\n"
    137"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    148"Language-Team: LANGUAGE <[email protected]>\n"
    15 "X-Generator: node-wp-i18n 1.2.6\n"
     9"MIME-Version: 1.0\n"
     10"Content-Type: text/plain; charset=UTF-8\n"
     11"Content-Transfer-Encoding: 8bit\n"
     12"POT-Creation-Date: 2023-05-12T17:52:26+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.7.1\n"
     15"X-Domain: woocommerce-accommodation-bookings\n"
     16
     17#. Plugin Name of the plugin
     18msgid "WooCommerce Accommodation Bookings"
     19msgstr ""
     20
     21#. Plugin URI of the plugin
     22msgid "https://woocommerce.com/products/woocommerce-accommodation-bookings/"
     23msgstr ""
     24
     25#. Description of the plugin
     26msgid "An accommodations add-on for the WooCommerce Bookings extension."
     27msgstr ""
     28
     29#. Author of the plugin
     30msgid "WooCommerce"
     31msgstr ""
     32
     33#. Author URI of the plugin
     34msgid "https://woocommerce.com"
     35msgstr ""
    1636
    1737#: includes/admin/class-wc-accommodation-booking-admin-panels.php:32
     
    1939msgstr ""
    2040
    21 #: includes/admin/class-wc-accommodation-booking-admin-panels.php:319
    22 msgid "Person Type #%d"
    23 msgstr ""
    24 
    25 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:84
    26 msgid "Accommodation"
    27 msgstr ""
    28 
    29 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:119
    30 msgid "Settings saved"
    31 msgstr ""
    32 
    3341#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:136
    34 #: includes/class-wc-accommodation-booking-product-tabs.php:85
     42#: includes/class-wc-accommodation-booking-product-tabs.php:93
    3543msgid "Check-in time"
    3644msgstr ""
     
    4149
    4250#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:142
    43 #: includes/class-wc-accommodation-booking-product-tabs.php:86
     51#: includes/class-wc-accommodation-booking-product-tabs.php:94
    4452msgid "Check-out time"
    4553msgstr ""
     
    4755#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:143
    4856msgid "Check-out time for reservations."
    49 msgstr ""
    50 
    51 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:172
    52 msgid "Save Changes"
    5357msgstr ""
    5458
     
    114118
    115119#: includes/admin/views/html-accommodation-booking-availability-fields.php:20
    116 #: includes/admin/views/html-accommodation-booking-availability.php:64
    117120#: includes/admin/views/html-accommodation-booking-rates-fields.php:20
    118121msgid "Monday"
     
    120123
    121124#: includes/admin/views/html-accommodation-booking-availability-fields.php:21
    122 #: includes/admin/views/html-accommodation-booking-availability.php:65
    123125#: includes/admin/views/html-accommodation-booking-rates-fields.php:21
    124126msgid "Tuesday"
     
    126128
    127129#: includes/admin/views/html-accommodation-booking-availability-fields.php:22
    128 #: includes/admin/views/html-accommodation-booking-availability.php:66
    129130#: includes/admin/views/html-accommodation-booking-rates-fields.php:22
    130131msgid "Wednesday"
     
    132133
    133134#: includes/admin/views/html-accommodation-booking-availability-fields.php:23
    134 #: includes/admin/views/html-accommodation-booking-availability.php:67
    135135#: includes/admin/views/html-accommodation-booking-rates-fields.php:23
    136136msgid "Thursday"
     
    138138
    139139#: includes/admin/views/html-accommodation-booking-availability-fields.php:24
    140 #: includes/admin/views/html-accommodation-booking-availability.php:68
    141140#: includes/admin/views/html-accommodation-booking-rates-fields.php:24
    142141msgid "Friday"
     
    144143
    145144#: includes/admin/views/html-accommodation-booking-availability-fields.php:25
    146 #: includes/admin/views/html-accommodation-booking-availability.php:69
    147145#: includes/admin/views/html-accommodation-booking-rates-fields.php:25
    148146msgid "Saturday"
     
    150148
    151149#: includes/admin/views/html-accommodation-booking-availability-fields.php:26
    152 #: includes/admin/views/html-accommodation-booking-availability.php:63
    153150#: includes/admin/views/html-accommodation-booking-rates-fields.php:26
    154151msgid "Sunday"
     
    229226
    230227#: includes/admin/views/html-accommodation-booking-availability.php:50
    231 msgid ""
    232 "Restrict the days of the week that are able to be selected on the calendar; "
    233 "this will not affect your availability."
     228msgid "Restrict the days of the week that are able to be selected on the calendar; this will not affect your availability."
    234229msgstr ""
    235230
     
    260255
    261256#: includes/admin/views/html-accommodation-booking-availability.php:100
    262 msgid ""
    263 "The lower the priority number, the earlier this rule gets applied. By "
    264 "default, global rules take priority over product rules which take priority "
    265 "over resource rules. By using priority numbers you can execute rules in "
    266 "different orders."
     257msgid "The lower the priority number, the earlier this rule gets applied. By default, global rules take priority over product rules which take priority over resource rules. By using priority numbers you can execute rules in different orders."
    267258msgstr ""
    268259
     
    273264
    274265#: includes/admin/views/html-accommodation-booking-availability.php:113
    275 msgid ""
    276 "Rules with lower numbers will execute first. Rules further down this table "
    277 "with the same priority will also execute first."
     266msgid "Rules with lower numbers will execute first. Rules further down this table with the same priority will also execute first."
    278267msgstr ""
    279268
     
    315304
    316305#: includes/admin/views/html-accommodation-booking-data.php:50
    317 msgid ""
    318 "Check this box if the booking requires admin approval/confirmation. Payment "
    319 "will not be taken during checkout."
     306msgid "Check this box if the booking requires admin approval/confirmation. Payment will not be taken during checkout."
    320307msgstr ""
    321308
     
    325312
    326313#: includes/admin/views/html-accommodation-booking-data.php:57
    327 msgid ""
    328 "Check this box if the booking can be cancelled by the customer after it has "
    329 "been purchased. A refund will not be sent automatically."
     314msgid "Check this box if the booking can be cancelled by the customer after it has been purchased. A refund will not be sent automatically."
    330315msgstr ""
    331316
     
    367352
    368353#: includes/admin/views/html-accommodation-booking-rates.php:9
    369 msgid ""
    370 "The cost is displayed to the user on the frontend. Leave blank to have it "
    371 "calculated for you. If a booking has varying costs, this will be prefixed "
    372 "with the word \"from:\"."
     354msgid "The cost is displayed to the user on the frontend. Leave blank to have it calculated for you. If a booking has varying costs, this will be prefixed with the word \"from:\"."
    373355msgstr ""
    374356
     
    402384
    403385#: includes/class-wc-accommodation-booking-cart-manager.php:42
    404 #: includes/class-wc-accommodation-booking-date-picker.php:59
     386#: includes/class-wc-accommodation-booking-date-picker.php:69
    405387#: includes/class-wc-accommodation-booking-order-manager.php:40
    406388msgid "Check-in"
     
    415397
    416398#: includes/class-wc-accommodation-booking-cart-manager.php:50
    417 #: includes/class-wc-accommodation-booking-date-picker.php:66
     399#: includes/class-wc-accommodation-booking-date-picker.php:78
    418400#: includes/class-wc-accommodation-booking-order-manager.php:57
    419401msgid "Check-out"
     
    428410msgstr ""
    429411
    430 #: includes/class-wc-accommodation-booking-product-tabs.php:63
    431 #: includes/class-wc-accommodation-booking-product-tabs.php:83
     412#: includes/class-wc-accommodation-booking-product-tabs.php:71
     413#: includes/class-wc-accommodation-booking-product-tabs.php:91
    432414msgid "Arriving/leaving"
    433415msgstr ""
    434416
    435 #: includes/class-wc-accommodation-booking.php:209
     417#: includes/class-wc-accommodation-booking.php:206
    436418msgid "night"
    437419msgstr ""
    438420
    439 #: includes/class-wc-accommodation-bookings-plugin.php:213
     421#: includes/class-wc-accommodation-bookings-plugin.php:258
    440422msgid "View Documentation"
    441423msgstr ""
    442424
    443 #: includes/class-wc-accommodation-bookings-plugin.php:213
     425#: includes/class-wc-accommodation-bookings-plugin.php:258
    444426msgid "Docs"
    445427msgstr ""
    446428
    447 #: includes/class-wc-accommodation-bookings-plugin.php:214
     429#: includes/class-wc-accommodation-bookings-plugin.php:259
    448430msgid "Visit Premium Customer Support Forum"
    449431msgstr ""
    450432
    451 #: includes/class-wc-accommodation-bookings-plugin.php:214
     433#: includes/class-wc-accommodation-bookings-plugin.php:259
    452434msgid "Premium Support"
    453435msgstr ""
     
    477459msgstr ""
    478460
    479 #: includes/integrations/class-wc-accommodation-booking-addons.php:57
    480461#: includes/integrations/class-wc-accommodation-booking-addons.php:71
    481462msgid "Bookings: Multiply cost by person count"
    482 msgstr ""
    483 
    484 #: includes/integrations/class-wc-accommodation-booking-addons.php:61
    485 msgid "Bookings: Multiply cost by block count"
    486463msgstr ""
    487464
     
    495472msgstr ""
    496473
    497 #. Plugin Name of the plugin/theme
    498 msgid "WooCommerce Accommodation Bookings"
    499 msgstr ""
    500 
    501 #. Plugin URI of the plugin/theme
    502 msgid "https://woocommerce.com/products/woocommerce-accommodation-bookings/"
    503 msgstr ""
    504 
    505 #. Description of the plugin/theme
    506 msgid "An accommodations add-on for the WooCommerce Bookings extension."
    507 msgstr ""
    508 
    509 #. Author of the plugin/theme
    510 msgid "WooCommerce"
    511 msgstr ""
    512 
    513 #. Author URI of the plugin/theme
    514 msgid "https://woocommerce.com"
    515 msgstr ""
     474#: dist/js/frontend/booking-form.js:1
     475msgid "Available for check-out only."
     476msgstr ""
     477
     478#: dist/js/frontend/booking-form.js:1
     479msgid "Available for check-in only."
     480msgstr ""
     481
     482#: dist/js/frontend/booking-form.js:1
     483msgid "Select check-in"
     484msgstr ""
     485
     486#: dist/js/frontend/booking-form.js:1
     487msgid "Selected! Re-select to change your check-in date."
     488msgstr ""
     489
     490#: dist/js/frontend/booking-form.js:1
     491msgid "Select check-out"
     492msgstr ""
  • woocommerce-accommodation-bookings/tags/1.1.40/readme.txt

    r2879445 r2911748  
    44Requires at least: 5.6
    55Tested up to: 6.1
    6 Stable tag: 1.1.39
     6Stable tag: 1.1.40
    77License: GNU General Public License v3.0
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    3636
    3737== Changelog ==
     38
     39= 1.1.40 - 2023-05-12 =
     40* Dev - Added a new filter, `woocommerce_accommodation_booking_get_check_times`, to change the check-in/out timings per product.
     41* Fix - Fully booked days show as partially booked - Day after booking shows partially booked.
    3842
    3943= 1.1.39 - 2023-03-14 =
  • woocommerce-accommodation-bookings/tags/1.1.40/woocommerce-accommodation-bookings.php

    r2879445 r2911748  
    44 * Plugin URI: https://woocommerce.com/products/woocommerce-accommodation-bookings/
    55 * Description: An accommodations add-on for the WooCommerce Bookings extension.
    6  * Version: 1.1.39
     6 * Version: 1.1.40
    77 * Author: WooCommerce
    88 * Author URI: https://woocommerce.com
     
    2424}
    2525
    26 define( 'WC_ACCOMMODATION_BOOKINGS_VERSION', '1.1.39' ); // WRCS: DEFINED_VERSION.
     26define( 'WC_ACCOMMODATION_BOOKINGS_VERSION', '1.1.40' ); // WRCS: DEFINED_VERSION.
    2727
    2828require_once( 'includes/class-wc-accommodation-bookings-plugin.php' );
  • woocommerce-accommodation-bookings/trunk/assets/css/frontend.scss

    r2179088 r2911748  
    1 .wc-bookings-date-picker {
    2         .ui-datepicker {
    3         td.partial_booked a {
    4             &:before {
    5                 display:none;
    6             }
     1.product-type-accommodation-booking {
     2    .wc-bookings-date-picker {
     3        position: relative;
     4        padding-top: 55px;
     5
     6        &::after {
     7            content: attr(data-content);
     8            position: absolute;
     9            background: #fff;
     10            margin: 10px 20px;
     11            font-size: 13px;
     12            left: 0;
     13            right: 0;
     14            top: 0;
     15            text-align: center;
     16            height: 35px;
     17            line-height: 35px;
    718        }
    8         td.fully_booked + td.partial_booked.partial_booked a {
    9             &:after {
    10                 border-bottom: none;
    11                 border-left: none;
    12                 border-top: 2.5em solid #C96259;
    13                 border-right: 2.5em solid transparent;
    14                 left: 0;
    15                 top: 0;
    16             }
     19
     20        .picker.hasDatepicker {
     21            margin: 0;
     22            position: static !important;
    1723        }
    1824    }
    1925}
     26
     27.wc-bookings-date-picker {
     28    fieldset {
     29        position: relative;
     30    }
     31
     32    &:not([data-selected-date-type="start"]) .ui-datepicker td.fully_booked_start_days:not(.selection-end-date),
     33    &[data-selected-date-type="start"] .ui-datepicker td.fully_booked_end_days:not(.selection-start-date) {
     34        opacity: 0.35;
     35    }
     36
     37    &:not([data-selected-date-type="start"]) .ui-datepicker td.fully_booked_start_days:not(.selection-end-date),
     38    &[data-selected-date-type="start"] .ui-datepicker td.fully_booked_end_days:not(.selection-start-date),
     39    .ui-datepicker td.fully_booked {
     40        span, a {
     41            background-color: #c0392b !important;
     42            background-image: none !important;
     43            border-color: rgba(0, 0, 0, 0.1) !important;
     44            color: #fff !important;
     45            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
     46            pointer-events: none;
     47        }
     48    }
     49
     50    .ui-datepicker {
     51        td.bookable-range.ui-state-disabled {
     52            opacity: 1;
     53        }
     54    }
     55}
  • woocommerce-accommodation-bookings/trunk/assets/js/writepanel.js

    r2529660 r2911748  
    1 jQuery( function( $ ) {
     1/* globals jQuery */
    22
    3     $('#rates_rows').sortable({
    4         items:'tr',
    5         cursor:'move',
    6         axis:'y',
    7         handle: '.sort',
    8         scrollSensitivity:40,
    9         forcePlaceholderSize: true,
    10         helper: 'clone',
    11         opacity: 0.65,
    12         placeholder: 'wc-metabox-sortable-placeholder',
    13         start:function(event,ui){
    14             ui.item.css('background-color','#f6f6f6');
    15         },
    16         stop:function(event,ui){
    17             ui.item.removeAttr('style');
    18         }
    19     });
     3jQuery(function ($) {
     4    $('#rates_rows').sortable({
     5        items: 'tr',
     6        cursor: 'move',
     7        axis: 'y',
     8        handle: '.sort',
     9        scrollSensitivity: 40,
     10        forcePlaceholderSize: true,
     11        helper: 'clone',
     12        opacity: 0.65,
     13        placeholder: 'wc-metabox-sortable-placeholder',
     14        start(event, ui) {
     15            ui.item.css('background-color', '#f6f6f6');
     16        },
     17        stop(event, ui) {
     18            ui.item.removeAttr('style');
     19        },
     20    });
    2021
    21     function wc_accommodation_bookings_trigger_change_events() {
    22         $('#_wc_accommodation_booking_has_restricted_days').trigger( 'change' );
    23     }
     22    function wc_accommodation_bookings_trigger_change_events() {
     23        $('#_wc_accommodation_booking_has_restricted_days').trigger('change');
     24    }
    2425
    25     $('#_wc_accommodation_booking_has_restricted_days').on( 'change', function() {
    26         if ( $(this).is( ':checked' ) ) {
    27             $( '.booking-day-restriction' ).show();
    28         } else {
    29             $( '.booking-day-restriction' ).hide();
    30         }
    31     });
     26    $('#_wc_accommodation_booking_has_restricted_days').on(
     27        'change',
     28        function () {
     29            if ($(this).is(':checked')) {
     30                $('.booking-day-restriction').show();
     31            } else {
     32                $('.booking-day-restriction').hide();
     33            }
     34        }
     35    );
    3236
    33     wc_accommodation_bookings_trigger_change_events();
    34 
    35 } );
     37    wc_accommodation_bookings_trigger_change_events();
     38});
  • woocommerce-accommodation-bookings/trunk/changelog.txt

    r2879445 r2911748  
    11*** Changelog ***
     2
     3= 1.1.40 - 2023-05-12 =
     4* Dev - Added a new filter, `woocommerce_accommodation_booking_get_check_times`, to change the check-in/out timings per product.
     5* Fix - Fully booked days show as partially booked - Day after booking shows partially booked.
    26
    37= 1.1.39 - 2023-03-14 =
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-cart-manager.php

    r2815380 r2911748  
    3434    public function get_item_data( $other_data, $cart_item ) {
    3535        if ( 'accommodation-booking' === $cart_item['data']->get_type() && ! empty( $other_data ) ) {
    36             $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    37             $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     36            $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $cart_item['product_id'] );
     37            $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $cart_item['product_id'] );
    3838            $end_date  = date_i18n( get_option( 'date_format'), $cart_item['booking']['_end_date'] );
    3939
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-date-picker.php

    r2337392 r2911748  
    1 <?php
     1<?php // phpcs:disable WordPress.DateTime.RestrictedFunctions.date_date,WordPress.PHP.StrictInArray.MissingTrueStrict
     2/**
     3 * This plugin handles the date picker related logic for Accommodation Bookings.
     4 *
     5 * @package WooCommerce Accommodation Bookings
     6 * @since   1.1.40
     7 */
     8
    29if ( ! defined( 'ABSPATH' ) ) {
    310    exit;
     
    1522        add_filter( 'woocommerce_bookings_date_picker_start_label', array( $this, 'start_label' ) );
    1623        add_filter( 'woocommerce_bookings_date_picker_end_label', array( $this, 'end_label' ) );
    17         add_filter( 'woocommerce_booking_form_get_posted_data', array( $this, 'add_accommodation_posted_data' ), 10 , 3 );
    18         add_filter( 'woocommerce_bookings_booked_day_blocks', array( $this, 'add_partially_booked_dates' ), 10 , 3 );
     24        add_filter( 'woocommerce_booking_form_get_posted_data', array( $this, 'add_accommodation_posted_data' ), 10, 3 );
     25        add_filter( 'woocommerce_bookings_booked_day_blocks', array( $this, 'update_fully_booked_dates' ), 10, 3 );
     26        add_filter( 'woocommerce_bookings_find_booked_day_blocks', array( $this, 'find_booked_day_blocks' ), 10, 2 );
    1927    }
    2028
    2129    /**
    2230     * Add custom start and end dat to booking data
     31     *
    2332     * @since 1.0.7
    2433     *
    25      * @param $data
    26      * @param $product
    27      * @param $total_duration
     34     * @param array               $data           Posted data.
     35     * @param \WC_Product_Booking $product        Booking product.
     36     * @param int                 $total_duration Total duration.
    2837     *
    2938     * @return mixed
    3039     */
    3140    public function add_accommodation_posted_data( $data, $product, $total_duration ) {
    32         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    33         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     41        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product->get_id() );
     42        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product->get_id() );
    3443
    3544        if ( 'night' === $product->get_duration_unit() ) {
     
    4049
    4150        if ( $product->has_resources() && ! $product->is_resource_assignment_type( 'customer' ) ) {
    42             // Assign an available resource automatically
     51            // Assign an available resource automatically.
    4352            $available_bookings = wc_bookings_get_total_available_bookings_for_range( $product, $data['_start_date'], $data['_end_date'], 0, $data['_qty'] );
    4453            if ( is_array( $available_bookings ) ) {
     
    5362    /**
    5463     * Changes the start label to "Check-in"
    55      * @param  string $label
     64     *
     65     * @param  string $label Label.
    5666     * @return string
    5767     */
     
    6272    /**
    6373     * Changes the end label to "Check-out"
     74     *
     75     * @param  string $label Label.
    6476     */
    6577    public function end_label( $label ) {
     
    8597     *    b. test if resources are available and if yes than move fully booked day to partially booked days
    8698     *
    87      * @param array                            $booked_data_array
    88      * @param WC_Product_Accommodation_Booking $product
     99     * @param array                            $booked_data_array Array of booked days.
     100     * @param WC_Product_Accommodation_Booking $product           Product.
    89101     */
    90102    public function add_partially_booked_dates( $booked_data_array, $product ) {
     
    107119                    }
    108120
     121                    $check_in_time = $product->get_check_times( 'in', $product->get_id() );
     122                    if ( 'in' === $which ) {
     123                        $check_time = strtotime( '-1 day ' . $check_in_time, $time );
     124                    } else {
     125                        $check_time = strtotime( $check_in_time, $time );
     126                    }
     127                    $check = date( 'F j, Y, g:i a', $check_time );
     128                    // Check available blocks for resource. If some are available that means that the day is not fully booked.
     129                    $not_fully_booked = $this->get_product_resource_available_blocks_on_time( $product, $resource_id, $check_time );
     130                    if ( $not_fully_booked ) {
     131                        $booked_data_array = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     132                    }
     133                }
     134            }
     135        }
     136
     137        return $booked_data_array;
     138    }
     139
     140    /**
     141     * Update the fully booked, fully booked start day, and fully booked end day accomodation bookings,
     142     *
     143     * @param array                            $booked_data_array Array of booked days.
     144     * @param WC_Product_Accommodation_Booking $product           Product.
     145     */
     146    public function update_fully_booked_dates( $booked_data_array, $product ) {
     147        // This function makes sense only for duration type: night.
     148        if ( 'night' !== $product->get_duration_unit() ) {
     149            return $booked_data_array;
     150        }
     151
     152        // Start and the end dates of all bookings.
     153        $check_in_out_times = $this->get_check_in_and_out_times( $product );
     154        $res_auto_assign    = $product->is_resource_assignment_type( 'automatic' );
     155
     156        // Go through each checkin and checkout days and mark them as fully booked.
     157        $made_partialy = array();
     158        foreach ( array( 'in', 'out' ) as $which ) {
     159            foreach ( $check_in_out_times[ $which ] as $resource_id => $times ) {
     160                foreach ( $times as $time ) {
     161                    $day = date( 'Y-n-j', $time );
     162
    109163                    $check_in_time = $product->get_check_times( 'in' );
    110164                    if ( 'in' === $which ) {
    111                         $check_time = strtotime( '-1 day ' . $check_in_time , $time );
     165                        $check_time = strtotime( $check_in_time, $time );
    112166                    } else {
    113                         $check_time = strtotime( $check_in_time, $time );
    114                     }
    115                     $check = date("F j, Y, g:i a", $check_time );
     167                        $check_time = strtotime( '-1 day' . $check_in_time, $time );
     168                    }
     169                    $check = date( 'F j, Y, g:i a', $check_time );
    116170                    // Check available blocks for resource. If some are available that means that the day is not fully booked.
    117                     $not_fully_booked = $this->get_product_resource_available_blocks_on_time( $product, $resource_id, $check_time );
    118                     if( $not_fully_booked ) {
    119                         $booked_data_array = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     171                    $resource_id_to_use = $res_auto_assign ? 0 : $resource_id;
     172                    $available_on_time  = $this->get_product_resource_available_blocks_on_time( $product, $resource_id_to_use, $check_time );
     173                    if ( 0 === $available_on_time ) {
     174                        $booked_data_array = $this->prepare_fully_booked_start_and_end_days( $booked_data_array, $resource_id, $day, $which );
     175                    } else {
     176                        $booked_data_array             = $this->move_day_from_fully_to_partially_booked( $booked_data_array, $resource_id, $day );
     177                        $made_partialy[ $resource_id ] = $day;
    120178                    }
    121179                }
     
    123181        }
    124182
     183        // Later removing the days from `fully_booked_days` array that were moved to partially booked days.
     184        // We are doing this out of the above foreach because we want a condition in
     185        // `prepare_fully_booked_start_and_end_days()` to be true.
     186        foreach ( $made_partialy as $resource => $partial_day ) {
     187            if ( ! isset( $booked_data_array['fully_booked_days'][ $partial_day ][ $resource ] ) ) {
     188                continue;
     189            }
     190
     191            unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
     192
     193            if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
     194                unset( $booked_data_array['fully_booked_days'][ $day ] );
     195            }
     196        }
     197
    125198        return $booked_data_array;
    126199    }
    127200
    128201    /**
     202     * Should return find booked day blocks with additional data.
     203     *
     204     * @since 1.1.40
     205     *
     206     * @param array $result        Array of booked days.
     207     * @param array $booked_blocks Array of booked blocks.
     208     */
     209    public function find_booked_day_blocks( $result, $booked_blocks ): array {
     210        $result['fully_booked_start_days'] = $booked_blocks['fully_booked_start_days'] ?? array();
     211        $result['fully_booked_end_days']   = $booked_blocks['fully_booked_end_days'] ?? array();
     212
     213        return $result;
     214    }
     215
     216    /**
    129217     * Calculates array that contains the start and the end time of all bookings for given product.
    130      * @param $product
     218     *
     219     * @param \WC_Product_Booking $product Product.
    131220     */
    132221    private function get_check_in_and_out_times( $product ) {
    133222
    134         $check_in_out_times     = array(
    135             'in' => array(),
     223        $check_in_out_times = array(
     224            'in'  => array(),
    136225            'out' => array(),
    137226        );
     
    140229        // Those times will be considered for switching particular day from full to partially booked days.
    141230        if ( version_compare( WC_BOOKINGS_VERSION, '1.15.0', '<' ) ) {
    142             $existing_bookings  = WC_Bookings_Controller::get_all_existing_bookings( $product );
     231            $existing_bookings = WC_Bookings_Controller::get_all_existing_bookings( $product );
    143232        } else {
    144             $existing_bookings  = WC_Booking_Data_Store::get_all_existing_bookings( $product );
     233            $existing_bookings = WC_Booking_Data_Store::get_all_existing_bookings( $product );
    145234        }
    146235
    147236        foreach ( $existing_bookings as $booking ) {
    148237
    149             $resource   = $booking->get_resource_id();
     238            $resource = $booking->get_resource_id();
    150239            if ( ! array_key_exists( $resource, $check_in_out_times['in'] ) ) {
    151                 $check_in_out_times['in'][ $resource ] = array();
     240                $check_in_out_times['in'][ $resource ]  = array();
    152241                $check_in_out_times['out'][ $resource ] = array();
    153242            }
     
    167256    /**
    168257     * Get amount of available product resoureces on a specific timestamp
    169      * @param $product
    170      * @param $resource
    171      * @param $date
     258     *
     259     * @param \WC_Product_Booking $product  Product.
     260     * @param int                 $resource Resource ID.
     261     * @param string              $time     Timestamp.
     262     *
     263     * @return int|mixed
    172264     */
    173265    private function get_product_resource_available_blocks_on_time( $product, $resource, $time ) {
    174         $blocks = $product->get_blocks_in_range_for_day( $time, $time, $resource, array() );
    175         $available_blocks = wc_bookings_get_time_slots( $product, $blocks, array(), 0, $time, $time );
    176         return ! empty( $available_blocks[ $time ] ) ? $available_blocks[ $time ][ 'available'] : 0;
     266        $blocks           = $product->get_blocks_in_range_for_day( $time, $time, $resource, array() );
     267        $available_blocks = wc_bookings_get_time_slots( $product, $blocks, array(), $resource, $time, $time );
     268        return ! empty( $available_blocks[ $time ] ) ? $available_blocks[ $time ]['available'] : 0;
    177269    }
    178270
     
    180272     * Moves day from fully booked days array to partially booked days array and if the fully booked days is
    181273     * array for that day is empty ( no assigned resources ) removes that empty day entry
    182      * @param $booked_data_array
    183      * @param $resource
    184      * @param $day
     274     *
     275     * @param array  $booked_data_array Array of booked days.
     276     * @param int    $resource          Resource ID.
     277     * @param string $day               Day.
    185278     */
    186279    private function move_day_from_fully_to_partially_booked( $booked_data_array, $resource, $day ) {
     
    191284        $booked_data_array['partially_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
    192285
    193         unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
    194 
    195         if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
    196             unset( $booked_data_array['fully_booked_days'][ $day ] );
    197         }
    198 
    199286        return $booked_data_array;
    200287    }
    201288
     289    /**
     290     * Moves day from fully_booked_days array to the fully_booked_start_days or fully_booked_end_days
     291     * This is required because we want to showcase days availability as per the selection.
     292     * So by default, fully_booked_start_days will be colored red; not available for check-ins.
     293     * When start date is selected, fully_booked_end_days will be colored red; not available for check-outs.
     294     *
     295     * @param array  $booked_data_array Array of booked days.
     296     * @param int    $resource          Resource ID.
     297     * @param string $day               A Day.
     298     * @param string $which             In or Out.
     299     */
     300    private function prepare_fully_booked_start_and_end_days( $booked_data_array, $resource, $day, $which = 'in' ) {
     301        if ( isset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ) ) {
     302            if ( 'in' === $which ) {
     303                $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
     304            } else {
     305                $booked_data_array['fully_booked_end_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
     306            }
     307            unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] );
     308
     309            if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) {
     310                unset( $booked_data_array['fully_booked_days'][ $day ] );
     311            }
     312        } else {
     313            // If the day already exists fully_booked_start_days at this point,
     314            // it means it is also a fully booked end day, so reverting it
     315            // back to be in fully_booked_days.
     316            if ( isset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] ) ) {
     317                $booked_data_array['fully_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_start_days'][ $day ][ $resource ];
     318                unset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] );
     319
     320                if ( empty( $booked_data_array['fully_booked_start_days'][ $day ] ) ) {
     321                    unset( $booked_data_array['fully_booked_start_days'][ $day ] );
     322                }
     323            }
     324        }
     325
     326        // Also removing from partially booked array in case if it
     327        // was added there in `move_day_from_fully_to_partially_booked()`.
     328        if ( isset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] ) ) {
     329            unset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] );
     330        }
     331        if ( empty( $booked_data_array['partially_booked_days'][ $day ] ) ) {
     332            unset( $booked_data_array['partially_booked_days'][ $day ] );
     333        }
     334
     335        return $booked_data_array;
     336    }
    202337}
    203338
    204 new WC_Accommodation_Booking_Date_Picker;
     339new WC_Accommodation_Booking_Date_Picker();
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-order-manager.php

    r2815380 r2911748  
    3434        }
    3535
    36         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    37         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     36        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $item['product_id'] );
     37        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $item['product_id'] );
    3838        ?>
    3939        <p>
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-product-tabs.php

    r1714785 r2911748  
    1212
    1313    /**
     14     * Product ID.
     15     */
     16    public $product_id = 0;
     17
     18    /**
    1419     * Hook into WooCommerce..
    1520     */
     
    2328     */
    2429    public function are_time_fields_filled_out() {
    25         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    26         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     30        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $this->product_id );
     31        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $this->product_id );
    2732
    2833        if ( empty( $check_in ) ) {
     
    5762        }
    5863
     64        // Set the product ID.
     65        $this->product_id = $post->ID;
     66
    5967        if ( ! $this->are_time_fields_filled_out() ) {
    6068            return $tabs;
     
    7886            return;
    7987        }
    80         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    81         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     88        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $this->product_id );
     89        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $this->product_id );
    8290        ?>
    8391        <h2><?php echo esc_html( apply_filters( 'woocommerce_accommodation_booking_time_tab_heading', __( 'Arriving/leaving', 'woocommerce-accommodation-bookings' ) ) ); ?></h2>
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking.php

    r2390281 r2911748  
    110110        }
    111111
    112         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    113 
    114112        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() );
    115113        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() );
    116114
    117         return date_i18n( $date_format, $booking->start ) . date_i18n( $time_format, strtotime( "Today " . $check_in ) );
     115        return date_i18n( $date_format, $booking->start ) . date_i18n( $time_format, $booking->start );
    118116    }
    119117
     
    124122        }
    125123
    126         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
    127124        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() );
    128125        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() );
    129126
    130         return date_i18n( $date_format, $booking->end ) . date_i18n( $time_format, strtotime( "Today " . $check_out ) );
     127        return date_i18n( $date_format, $booking->end ) . date_i18n( $time_format, $booking->end );
    131128    }
    132129
     
    182179        }
    183180
    184         $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    185         $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     181        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product_id );
     182        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product_id );
    186183
    187184        $start = get_post_meta( $booking_id, '_booking_start', true );
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-bookings-plugin.php

    r2815380 r2911748  
    11<?php
     2/**
     3 * This class is responsible for the plugin's initialization.
     4 *
     5 * @since 1.0.2
     6 * @package WooCommerce\AccommodationBookings
     7 */
     8
    29if ( ! defined( 'ABSPATH' ) ) {
    310    exit;
     
    3340     * Constructor.
    3441     *
    35      * @param string $plugin_file Path to main plugin's file
    36      * @param string $version     Plugin's version
     42     * @param string $plugin_file Path to main plugin's file.
     43     * @param string $version     Plugin's version.
    3744     */
    3845    public function __construct( $plugin_file, $version ) {
     
    8895     * @return void
    8996     */
     97    // phpcs:ignore
    9098    private function _define_constants() {
    9199        define( 'WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH', untrailingslashit( plugin_dir_path( $this->plugin_file ) ) . '/includes/' );
     
    100108     * @return void
    101109     */
     110    // phpcs:ignore
    102111    private function _register_hooks() {
    103112        register_activation_hook( $this->plugin_file, array( $this, 'check_dependencies' ) );
     
    111120        add_action( 'plugins_loaded', array( $this, 'includes' ), 20 );
    112121        add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
    113         add_action( 'wp_enqueue_scripts', array( $this, 'booking_form_styles' ) );
     122        add_action( 'wp_enqueue_scripts', array( $this, 'frontend_assets' ) );
    114123
    115124        if ( is_admin() ) {
     
    131140        }
    132141
    133         require_once( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-dependencies.php' );
     142        require_once WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-dependencies.php';
    134143        try {
    135144            WC_Accommodation_Dependencies::check_dependencies();
     
    164173     */
    165174    public function load_plugin_textdomain() {
     175        /**
     176         * Filter locale before loading the plugin's text domain.
     177         *
     178         * @since 1.0.2
     179         *
     180         * @param string $locale The plugin's current locale.
     181         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     182         */
    166183        $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-accommodation-bookings' );
    167184        $dir    = trailingslashit( WP_LANG_DIR );
     
    175192     */
    176193    public function includes() {
    177         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking.php' );
    178         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking-resource.php' );
    179         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking.php' );
    180         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-cart-manager.php' );
    181         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-date-picker.php' );
    182         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-product-tabs.php' );
    183         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-order-manager.php' );
    184         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'integrations/class-wc-accommodation-booking-addons.php' );
     194        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking.php';
     195        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-product-accommodation-booking-resource.php';
     196        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking.php';
     197        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-cart-manager.php';
     198        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-date-picker.php';
     199        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-product-tabs.php';
     200        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'class-wc-accommodation-booking-order-manager.php';
     201        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'integrations/class-wc-accommodation-booking-addons.php';
    185202    }
    186203
     
    189206     */
    190207    public function admin_includes() {
    191         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-panels.php' );
    192         include( WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-product-settings.php' );
     208        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-panels.php';
     209        include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-product-settings.php';
    193210    }
    194211
     
    196213     * Frontend booking form scripts
    197214     */
    198     public function booking_form_styles() {
    199         wp_enqueue_style( 'wc-accommodation-bookings-styles', WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/assets/css/frontend.css', null, WC_ACCOMMODATION_BOOKINGS_VERSION );
     215    public function frontend_assets() {
     216        $booking_style_asset_data  = $this->get_asset_data( 'frontend', 'css' );
     217        $booking_script_asset_data = $this->get_asset_data( 'booking-form', 'js/frontend' );
     218
     219        $booking_script_dependencies = array_merge(
     220            $booking_script_asset_data['dependencies'],
     221            array( 'wc-bookings-booking-form' )
     222        );
     223
     224        wp_enqueue_style(
     225            'wc-accommodation-bookings-styles',
     226            WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/dist/css/frontend.css',
     227            null,
     228            $booking_style_asset_data['version']
     229        );
     230
     231        wp_enqueue_script(
     232            'wc-accommodation-bookings-form',
     233            WC_ACCOMMODATION_BOOKINGS_PLUGIN_URL . '/dist/js/frontend/booking-form.js',
     234            $booking_script_dependencies,
     235            $booking_script_asset_data['version'],
     236            true
     237        );
     238
     239        wp_set_script_translations(
     240            'wc-accommodation-bookings-form',
     241            'woocommerce-accommodation-bookings',
     242            plugin_dir_path( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) . '/languages'
     243        );
    200244    }
    201245
     
    203247     * Show row meta on the plugin screen.
    204248     *
    205      * @access  public
    206      * @param   mixed $links Plugin Row Meta
    207      * @param   mixed $file  Plugin Base file
    208      * @return  array
     249     * @param array  $links Plugin Row Meta.
     250     * @param string $file  Plugin Base file.
     251     *
     252     * @return  array
    209253     */
    210254    public function plugin_row_meta( $links, $file ) {
    211         if ( $file == plugin_basename( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) ) {
     255        // phpcs:ignore
     256        if ( $file === plugin_basename( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) ) {
    212257            $row_meta = array(
    213                 'docs'      =>  '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_docs_url', 'https://docs.woocommerce.com/document/woocommerce-accommodation-bookings/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Docs', 'woocommerce-accommodation-bookings' ) . '</a>',
    214                 'support'   =>  '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_support_url', 'https://docs.woocommerce.com/' ) ) . '" title="' . esc_attr( __( 'Visit Premium Customer Support Forum', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Premium Support', 'woocommerce-accommodation-bookings' ) . '</a>',
     258                'docs'    => '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_docs_url', 'https://docs.woocommerce.com/document/woocommerce-accommodation-bookings/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Docs', 'woocommerce-accommodation-bookings' ) . '</a>', //phpcs:ignore
     259                'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_accommodation_bookings_support_url', 'https://docs.woocommerce.com/' ) ) . '" title="' . esc_attr( __( 'Visit Premium Customer Support Forum', 'woocommerce-accommodation-bookings' ) ) . '">' . __( 'Premium Support', 'woocommerce-accommodation-bookings' ) . '</a>', //phpcs:ignore
    215260            );
    216261
     
    227272        global $wpdb;
    228273
    229         $force_update = false;
     274        $force_update                   = false;
    230275        $accommodation_bookings_version = get_option( 'wc_accommodation_bookings_version' );
    231276
    232277        if ( ! $accommodation_bookings_version ) {
    233             $force_update = true;
     278            $force_update                   = true;
    234279            $accommodation_bookings_version = $this->version;
    235280        }
    236281
    237         // Data updates
     282        // Data updates.
    238283        if ( $force_update || version_compare( $accommodation_bookings_version, '1.1.3', '<' ) ) {
    239284            $accommodation_bookings = $wpdb->get_results( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = '_wc_booking_pricing' AND meta_value LIKE '%override_block%';" );
     
    242287
    243288                if ( ! is_a( $product, 'WC_Product' ) ) {
    244                     continue;               
    245                 }
    246 
    247                 if ( 'accommodation-booking' != $product->get_type() ) {
    248289                    continue;
    249290                }
    250291
    251                 $pricing = get_post_meta( $product->get_id(), '_wc_booking_pricing', true );
     292                if ( 'accommodation-booking' !== $product->get_type() ) {
     293                    continue;
     294                }
     295
     296                $pricing            = get_post_meta( $product->get_id(), '_wc_booking_pricing', true );
    252297                $original_base_cost = absint( get_post_meta( $product->get_id(), '_wc_booking_base_cost', true ) );
    253298
    254                 // Convert from the old to the new structure
     299                // Convert from the old to the new structure.
    255300                foreach ( $pricing as &$pricing_row ) {
    256                     $pricing_row['base_cost'] = $pricing_row['cost'] = 0;
    257                     $new_cost = $pricing_row['override_block'];
     301                    $pricing_row['base_cost'] = $pricing_row['cost'] = 0; //phpcs:ignore
     302                    $new_cost                 = $pricing_row['override_block'];
    258303                    unset( $pricing_row['override_block'] );
    259                     $pricing_row['base_modifier'] = $pricing_row['modifier'] = $new_cost > $original_base_cost ? 'plus' : 'minus';
    260                     $pricing_row['cost'] = absint( $new_cost - $original_base_cost );
     304                    $pricing_row['base_modifier'] = $pricing_row['modifier'] = $new_cost > $original_base_cost ? 'plus' : 'minus'; //phpcs:ignore
     305                    $pricing_row['cost']          = absint( $new_cost - $original_base_cost );
    261306                }
    262307
     
    265310        }
    266311
    267         // Update version
     312        // Update version.
    268313        update_option( 'wc_accommodation_bookings_version', $this->version );
    269314    }
     315
     316    /**
     317     * Should return data from the asset file.
     318     *
     319     * @param string $script_file_name Script file name.
     320     * @param string $location Script file location.
     321     *
     322     * @return array
     323     */
     324    private function get_asset_data( $script_file_name, $location ): array {
     325        $asset_path = dirname( WC_ACCOMMODATION_BOOKINGS_MAIN_FILE ) . "/dist/$location/$script_file_name.asset.php";
     326
     327        return require $asset_path;
     328    }
    270329}
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-product-accommodation-booking.php

    r2815380 r2911748  
    196196        $bookable_product = $this;
    197197
    198         $transient_name               = 'book_ts_' . md5( http_build_query( array( $bookable_product->get_id(), $resource_id, $from, $to ) ) );
     198        $product_id                   = $bookable_product->get_id();
     199        $transient_name               = 'book_ts_' . md5( http_build_query( array( $product_id, $resource_id, $from, $to ) ) );
    199200        $available_slots              = get_transient( $transient_name );
    200201        $booking_slots_transient_keys = array_filter( (array) get_transient( 'booking_slots_transient_keys' ) );
    201202
    202         if ( ! isset( $booking_slots_transient_keys[ $bookable_product->get_id() ] ) ) {
    203             $booking_slots_transient_keys[ $bookable_product->get_id() ] = array();
    204         }
    205 
    206         $booking_slots_transient_keys[ $bookable_product->get_id() ][] = $transient_name;
     203        if ( ! isset( $booking_slots_transient_keys[ $product_id ] ) ) {
     204            $booking_slots_transient_keys[ $product_id ] = array();
     205        }
     206
     207        $booking_slots_transient_keys[ $product_id ][] = $transient_name;
    207208
    208209        // Give array of keys a long ttl because if it expires we won't be able to flush the keys when needed.
     
    230231
    231232            foreach ( $blocks as $block ) {
    232                 $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' );
    233                 $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' );
     233                $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in', $product_id );
     234                $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out', $product_id );
    234235                // Blocks for accommodation products are initially calculated as days but the actuall time blocks are shifted by check in and checkout times.
    235236                $block_start_time = strtotime( "{$check_in}", $block );
     
    329330     * Get checkin and checkout times.
    330331     *
    331      * @param string $type
    332      *
    333      * @return string Time, either from options or default
    334      */
    335     public static function get_check_times( $type ) {
    336         $option = get_option( 'woocommerce_accommodation_bookings_times_settings' );
     332     * @param string $type       The type, check_in or check_out.
     333     * @param int    $product_id The product ID.
     334     *
     335     * @return string The time, either from options or default or from the filtered value.
     336     */
     337    public static function get_check_times( $type, $product_id = 0 ) {
     338        $option     = get_option( 'woocommerce_accommodation_bookings_times_settings' );
     339        $check_time = '';
     340
    337341        switch ( $type ) {
    338342            case 'in':
    339                 return isset( $option['check_in'] ) ? $option['check_in'] : '14:00';
     343                $check_time = $option['check_in'] ?? '14:00';
     344                break;
    340345            case 'out':
    341                 return isset( $option['check_out'] ) ? $option['check_out'] : '14:00';
    342         }
    343 
    344         return '';
     346                $check_time = $option['check_out'] ?? '14:00';
     347                break;
     348        }
     349
     350        /**
     351         * Filter the check-in/out times for a specific product.
     352         *
     353         * @param string $check_time The check-in/out time stored in the database.
     354         * @param string $type       The type, check_in or check_out.
     355         * @param int    $product_id The product ID.
     356         *
     357         * @return string The filtered/original time.
     358         */
     359        return apply_filters( 'woocommerce_accommodation_booking_get_check_times', $check_time, $type, (int) $product_id );
    345360    }
    346361
  • woocommerce-accommodation-bookings/trunk/languages/woocommerce-accommodation-bookings.pot

    r2879445 r2911748  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WooCommerce Accommodation Bookings 1.1.39\n"
    6 "Report-Msgid-Bugs-To: "
    7 "https://wordpress.org/support/plugin/woocommerce-accommodation-bookings\n"
    8 "POT-Creation-Date: 2023-03-14 00:20:22+00:00\n"
    9 "MIME-Version: 1.0\n"
    10 "Content-Type: text/plain; charset=utf-8\n"
    11 "Content-Transfer-Encoding: 8bit\n"
    12 "PO-Revision-Date: 2023-MO-DA HO:MI+ZONE\n"
     5"Project-Id-Version: WooCommerce Accommodation Bookings 1.1.40\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-accommodation-bookings\n"
    137"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    148"Language-Team: LANGUAGE <[email protected]>\n"
    15 "X-Generator: node-wp-i18n 1.2.6\n"
     9"MIME-Version: 1.0\n"
     10"Content-Type: text/plain; charset=UTF-8\n"
     11"Content-Transfer-Encoding: 8bit\n"
     12"POT-Creation-Date: 2023-05-12T17:52:26+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.7.1\n"
     15"X-Domain: woocommerce-accommodation-bookings\n"
     16
     17#. Plugin Name of the plugin
     18msgid "WooCommerce Accommodation Bookings"
     19msgstr ""
     20
     21#. Plugin URI of the plugin
     22msgid "https://woocommerce.com/products/woocommerce-accommodation-bookings/"
     23msgstr ""
     24
     25#. Description of the plugin
     26msgid "An accommodations add-on for the WooCommerce Bookings extension."
     27msgstr ""
     28
     29#. Author of the plugin
     30msgid "WooCommerce"
     31msgstr ""
     32
     33#. Author URI of the plugin
     34msgid "https://woocommerce.com"
     35msgstr ""
    1636
    1737#: includes/admin/class-wc-accommodation-booking-admin-panels.php:32
     
    1939msgstr ""
    2040
    21 #: includes/admin/class-wc-accommodation-booking-admin-panels.php:319
    22 msgid "Person Type #%d"
    23 msgstr ""
    24 
    25 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:84
    26 msgid "Accommodation"
    27 msgstr ""
    28 
    29 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:119
    30 msgid "Settings saved"
    31 msgstr ""
    32 
    3341#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:136
    34 #: includes/class-wc-accommodation-booking-product-tabs.php:85
     42#: includes/class-wc-accommodation-booking-product-tabs.php:93
    3543msgid "Check-in time"
    3644msgstr ""
     
    4149
    4250#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:142
    43 #: includes/class-wc-accommodation-booking-product-tabs.php:86
     51#: includes/class-wc-accommodation-booking-product-tabs.php:94
    4452msgid "Check-out time"
    4553msgstr ""
     
    4755#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:143
    4856msgid "Check-out time for reservations."
    49 msgstr ""
    50 
    51 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:172
    52 msgid "Save Changes"
    5357msgstr ""
    5458
     
    114118
    115119#: includes/admin/views/html-accommodation-booking-availability-fields.php:20
    116 #: includes/admin/views/html-accommodation-booking-availability.php:64
    117120#: includes/admin/views/html-accommodation-booking-rates-fields.php:20
    118121msgid "Monday"
     
    120123
    121124#: includes/admin/views/html-accommodation-booking-availability-fields.php:21
    122 #: includes/admin/views/html-accommodation-booking-availability.php:65
    123125#: includes/admin/views/html-accommodation-booking-rates-fields.php:21
    124126msgid "Tuesday"
     
    126128
    127129#: includes/admin/views/html-accommodation-booking-availability-fields.php:22
    128 #: includes/admin/views/html-accommodation-booking-availability.php:66
    129130#: includes/admin/views/html-accommodation-booking-rates-fields.php:22
    130131msgid "Wednesday"
     
    132133
    133134#: includes/admin/views/html-accommodation-booking-availability-fields.php:23
    134 #: includes/admin/views/html-accommodation-booking-availability.php:67
    135135#: includes/admin/views/html-accommodation-booking-rates-fields.php:23
    136136msgid "Thursday"
     
    138138
    139139#: includes/admin/views/html-accommodation-booking-availability-fields.php:24
    140 #: includes/admin/views/html-accommodation-booking-availability.php:68
    141140#: includes/admin/views/html-accommodation-booking-rates-fields.php:24
    142141msgid "Friday"
     
    144143
    145144#: includes/admin/views/html-accommodation-booking-availability-fields.php:25
    146 #: includes/admin/views/html-accommodation-booking-availability.php:69
    147145#: includes/admin/views/html-accommodation-booking-rates-fields.php:25
    148146msgid "Saturday"
     
    150148
    151149#: includes/admin/views/html-accommodation-booking-availability-fields.php:26
    152 #: includes/admin/views/html-accommodation-booking-availability.php:63
    153150#: includes/admin/views/html-accommodation-booking-rates-fields.php:26
    154151msgid "Sunday"
     
    229226
    230227#: includes/admin/views/html-accommodation-booking-availability.php:50
    231 msgid ""
    232 "Restrict the days of the week that are able to be selected on the calendar; "
    233 "this will not affect your availability."
     228msgid "Restrict the days of the week that are able to be selected on the calendar; this will not affect your availability."
    234229msgstr ""
    235230
     
    260255
    261256#: includes/admin/views/html-accommodation-booking-availability.php:100
    262 msgid ""
    263 "The lower the priority number, the earlier this rule gets applied. By "
    264 "default, global rules take priority over product rules which take priority "
    265 "over resource rules. By using priority numbers you can execute rules in "
    266 "different orders."
     257msgid "The lower the priority number, the earlier this rule gets applied. By default, global rules take priority over product rules which take priority over resource rules. By using priority numbers you can execute rules in different orders."
    267258msgstr ""
    268259
     
    273264
    274265#: includes/admin/views/html-accommodation-booking-availability.php:113
    275 msgid ""
    276 "Rules with lower numbers will execute first. Rules further down this table "
    277 "with the same priority will also execute first."
     266msgid "Rules with lower numbers will execute first. Rules further down this table with the same priority will also execute first."
    278267msgstr ""
    279268
     
    315304
    316305#: includes/admin/views/html-accommodation-booking-data.php:50
    317 msgid ""
    318 "Check this box if the booking requires admin approval/confirmation. Payment "
    319 "will not be taken during checkout."
     306msgid "Check this box if the booking requires admin approval/confirmation. Payment will not be taken during checkout."
    320307msgstr ""
    321308
     
    325312
    326313#: includes/admin/views/html-accommodation-booking-data.php:57
    327 msgid ""
    328 "Check this box if the booking can be cancelled by the customer after it has "
    329 "been purchased. A refund will not be sent automatically."
     314msgid "Check this box if the booking can be cancelled by the customer after it has been purchased. A refund will not be sent automatically."
    330315msgstr ""
    331316
     
    367352
    368353#: includes/admin/views/html-accommodation-booking-rates.php:9
    369 msgid ""
    370 "The cost is displayed to the user on the frontend. Leave blank to have it "
    371 "calculated for you. If a booking has varying costs, this will be prefixed "
    372 "with the word \"from:\"."
     354msgid "The cost is displayed to the user on the frontend. Leave blank to have it calculated for you. If a booking has varying costs, this will be prefixed with the word \"from:\"."
    373355msgstr ""
    374356
     
    402384
    403385#: includes/class-wc-accommodation-booking-cart-manager.php:42
    404 #: includes/class-wc-accommodation-booking-date-picker.php:59
     386#: includes/class-wc-accommodation-booking-date-picker.php:69
    405387#: includes/class-wc-accommodation-booking-order-manager.php:40
    406388msgid "Check-in"
     
    415397
    416398#: includes/class-wc-accommodation-booking-cart-manager.php:50
    417 #: includes/class-wc-accommodation-booking-date-picker.php:66
     399#: includes/class-wc-accommodation-booking-date-picker.php:78
    418400#: includes/class-wc-accommodation-booking-order-manager.php:57
    419401msgid "Check-out"
     
    428410msgstr ""
    429411
    430 #: includes/class-wc-accommodation-booking-product-tabs.php:63
    431 #: includes/class-wc-accommodation-booking-product-tabs.php:83
     412#: includes/class-wc-accommodation-booking-product-tabs.php:71
     413#: includes/class-wc-accommodation-booking-product-tabs.php:91
    432414msgid "Arriving/leaving"
    433415msgstr ""
    434416
    435 #: includes/class-wc-accommodation-booking.php:209
     417#: includes/class-wc-accommodation-booking.php:206
    436418msgid "night"
    437419msgstr ""
    438420
    439 #: includes/class-wc-accommodation-bookings-plugin.php:213
     421#: includes/class-wc-accommodation-bookings-plugin.php:258
    440422msgid "View Documentation"
    441423msgstr ""
    442424
    443 #: includes/class-wc-accommodation-bookings-plugin.php:213
     425#: includes/class-wc-accommodation-bookings-plugin.php:258
    444426msgid "Docs"
    445427msgstr ""
    446428
    447 #: includes/class-wc-accommodation-bookings-plugin.php:214
     429#: includes/class-wc-accommodation-bookings-plugin.php:259
    448430msgid "Visit Premium Customer Support Forum"
    449431msgstr ""
    450432
    451 #: includes/class-wc-accommodation-bookings-plugin.php:214
     433#: includes/class-wc-accommodation-bookings-plugin.php:259
    452434msgid "Premium Support"
    453435msgstr ""
     
    477459msgstr ""
    478460
    479 #: includes/integrations/class-wc-accommodation-booking-addons.php:57
    480461#: includes/integrations/class-wc-accommodation-booking-addons.php:71
    481462msgid "Bookings: Multiply cost by person count"
    482 msgstr ""
    483 
    484 #: includes/integrations/class-wc-accommodation-booking-addons.php:61
    485 msgid "Bookings: Multiply cost by block count"
    486463msgstr ""
    487464
     
    495472msgstr ""
    496473
    497 #. Plugin Name of the plugin/theme
    498 msgid "WooCommerce Accommodation Bookings"
    499 msgstr ""
    500 
    501 #. Plugin URI of the plugin/theme
    502 msgid "https://woocommerce.com/products/woocommerce-accommodation-bookings/"
    503 msgstr ""
    504 
    505 #. Description of the plugin/theme
    506 msgid "An accommodations add-on for the WooCommerce Bookings extension."
    507 msgstr ""
    508 
    509 #. Author of the plugin/theme
    510 msgid "WooCommerce"
    511 msgstr ""
    512 
    513 #. Author URI of the plugin/theme
    514 msgid "https://woocommerce.com"
    515 msgstr ""
     474#: dist/js/frontend/booking-form.js:1
     475msgid "Available for check-out only."
     476msgstr ""
     477
     478#: dist/js/frontend/booking-form.js:1
     479msgid "Available for check-in only."
     480msgstr ""
     481
     482#: dist/js/frontend/booking-form.js:1
     483msgid "Select check-in"
     484msgstr ""
     485
     486#: dist/js/frontend/booking-form.js:1
     487msgid "Selected! Re-select to change your check-in date."
     488msgstr ""
     489
     490#: dist/js/frontend/booking-form.js:1
     491msgid "Select check-out"
     492msgstr ""
  • woocommerce-accommodation-bookings/trunk/readme.txt

    r2879445 r2911748  
    44Requires at least: 5.6
    55Tested up to: 6.1
    6 Stable tag: 1.1.39
     6Stable tag: 1.1.40
    77License: GNU General Public License v3.0
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    3636
    3737== Changelog ==
     38
     39= 1.1.40 - 2023-05-12 =
     40* Dev - Added a new filter, `woocommerce_accommodation_booking_get_check_times`, to change the check-in/out timings per product.
     41* Fix - Fully booked days show as partially booked - Day after booking shows partially booked.
    3842
    3943= 1.1.39 - 2023-03-14 =
  • woocommerce-accommodation-bookings/trunk/woocommerce-accommodation-bookings.php

    r2879445 r2911748  
    44 * Plugin URI: https://woocommerce.com/products/woocommerce-accommodation-bookings/
    55 * Description: An accommodations add-on for the WooCommerce Bookings extension.
    6  * Version: 1.1.39
     6 * Version: 1.1.40
    77 * Author: WooCommerce
    88 * Author URI: https://woocommerce.com
     
    2424}
    2525
    26 define( 'WC_ACCOMMODATION_BOOKINGS_VERSION', '1.1.39' ); // WRCS: DEFINED_VERSION.
     26define( 'WC_ACCOMMODATION_BOOKINGS_VERSION', '1.1.40' ); // WRCS: DEFINED_VERSION.
    2727
    2828require_once( 'includes/class-wc-accommodation-bookings-plugin.php' );
Note: See TracChangeset for help on using the changeset viewer.