WordPress.org

Plugin Directory

Changeset 1714785


Ignore:
Timestamp:
08/17/17 15:22:53 (5 weeks ago)
Author:
bor0
Message:

Update trunk for 1.1.0

Location:
woocommerce-accommodation-bookings/trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-accommodation-bookings/trunk/assets/js/writepanel.js

    r1487396 r1714785  
    1919    }); 
    2020 
     21    function wc_accommodation_bookings_trigger_change_events() { 
     22        $('#_wc_accommodation_booking_has_restricted_days').change(); 
     23    } 
     24 
     25    $('#_wc_accommodation_booking_has_restricted_days').change(function() { 
     26        if ( $(this).is( ':checked' ) ) { 
     27            $( '.booking-day-restriction' ).show(); 
     28        } else { 
     29            $( '.booking-day-restriction' ).hide(); 
     30        } 
     31    }); 
     32 
     33    wc_accommodation_bookings_trigger_change_events(); 
     34 
    2135} ); 
  • woocommerce-accommodation-bookings/trunk/assets/js/writepanel.min.js

    r1530426 r1714785  
    1 jQuery(function(a){a("#rates_rows").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")}})}); 
     1jQuery(function(a){function b(){a("#_wc_accommodation_booking_has_restricted_days").change()}a("#rates_rows").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")}}),a("#_wc_accommodation_booking_has_restricted_days").change(function(){a(this).is(":checked")?a(".booking-day-restriction").show():a(".booking-day-restriction").hide()}),b()}); 
  • woocommerce-accommodation-bookings/trunk/includes/admin/class-wc-accommodation-booking-admin-panels.php

    r1634742 r1714785  
    6565    /** 
    6666     * Loads our panels related to accommodation bookings 
     67     * @version  1.0.11 
    6768     */ 
    6869    public function panels() { 
    69         global $post; 
     70        global $post, $bookable_product; 
    7071        $post_id = $post->ID; 
     72 
     73        /** 
     74         * Day restrictions added to Bookings 1.10.7 
     75         * @todo  Remove version compare ~Aug 2018 
     76         */ 
     77        if ( version_compare( WC_BOOKINGS_VERSION, '1.10.7', '>=' ) ) { 
     78 
     79            if ( empty( $bookable_product ) || $bookable_product->get_id() !== $post->ID ) { 
     80                $bookable_product = new WC_Product_Booking( $post->ID ); 
     81            } 
     82 
     83            $restricted_meta = $bookable_product->get_restricted_days(); 
     84 
     85            for ( $i=0; $i < 7; $i++) { 
     86 
     87                if ( $restricted_meta && in_array( $i, $restricted_meta ) ) { 
     88                    $restricted_days[ $i ] = $i; 
     89                } else { 
     90                    $restricted_days[ $i ] = false; 
     91                } 
     92            } 
     93        } 
    7194 
    7295        include( 'views/html-accommodation-booking-rates.php' ); 
     
    105128     * Saves booking / accommodation data for a product 
    106129     * 
    107      * @param int $post_id 
     130     * @version  1.0.11 
     131     * @param    int $post_id 
    108132     */ 
    109133    public function save_product_data( $post_id ) { 
     
    205229        update_post_meta( $post_id, '_wc_booking_availability', $availability ); 
    206230 
     231        // Restricted days. 
     232        update_post_meta( $post_id, '_wc_booking_has_restricted_days', isset( $_POST['_wc_accommodation_booking_has_restricted_days'] ) ); 
     233        $restricted_days = isset( $_POST['_wc_accommodation_booking_restricted_days'] ) ? wc_clean( $_POST['_wc_accommodation_booking_restricted_days'] ) : ''; 
     234        update_post_meta( $post_id, '_wc_booking_restricted_days', $restricted_days ); 
     235 
    207236        // Resources 
    208237        if ( isset( $_POST['resource_id'] ) && isset( $_POST['_wc_booking_has_resources'] ) ) { 
  • woocommerce-accommodation-bookings/trunk/includes/admin/class-wc-accommodation-booking-admin-product-settings.php

    r1322455 r1714785  
    3838                'type'      => 'accommodation_time', 
    3939                'class'     => 'time-picker', 
     40                'default'       => '14:00 PM', 
    4041            ), 
    4142 
     
    4647                'type'      => 'accommodation_time', 
    4748                'class'     => 'time-picker', 
     49                'default'       => '12:00 PM', 
    4850            ), 
    4951 
  • woocommerce-accommodation-bookings/trunk/includes/admin/views/html-accommodation-booking-availability.php

    r1322455 r1714785  
    3535                </select> <?php _e( 'into the future', 'woocommerce-accommodation-bookings' ); ?> 
    3636        </p> 
     37 
     38        <?php 
     39            /** 
     40             * Day restrictions added to Bookings 1.10.7 
     41             * @todo  Remove version compare ~Aug 2018 
     42             */ 
     43            if ( version_compare( WC_BOOKINGS_VERSION, '1.10.7', '>=' ) ) : 
     44 
     45                woocommerce_wp_checkbox( 
     46                    array( 
     47                        'id'          => '_wc_accommodation_booking_has_restricted_days', 
     48                        'value'       => $bookable_product->has_restricted_days( 'edit' ) ? 'yes' : 'no', 
     49                        'label'       => __( 'Restrict start days?', 'woocommerce-bookings' ), 
     50                        'description' => __( 'Restrict bookings so that they can only start on certain days of the week. Does not affect availability.', 'woocommerce-bookings' ), 
     51                    ) 
     52                ); 
     53        ?> 
     54 
     55            <div class="booking-day-restriction"> 
     56                <table class="widefat"> 
     57                    <tbody> 
     58                        <tr> 
     59                            <td>&nbsp;</td> 
     60 
     61                <?php 
     62                    $weekdays = array( 
     63                        __( 'Sunday', 'woocommerce-bookings' ), 
     64                        __( 'Monday', 'woocommerce-bookings' ), 
     65                        __( 'Tuesday', 'woocommerce-bookings' ), 
     66                        __( 'Wednesday', 'woocommerce-bookings' ), 
     67                        __( 'Thursday', 'woocommerce-bookings' ), 
     68                        __( 'Friday', 'woocommerce-bookings' ), 
     69                        __( 'Saturday', 'woocommerce-bookings' ), 
     70                        ); 
     71 
     72                    for ( $i=0;  $i < 7;  $i++) {  
     73                        ?> 
     74                            <td> 
     75                                <label class="checkbox" for="_wc_accommodation_booking_restricted_days[<?php echo $i; ?>]"><?php echo $weekdays[ $i ]; ?>&nbsp;</label> 
     76                                <input type="checkbox" class="checkbox" name="_wc_accommodation_booking_restricted_days[<?php echo $i; ?>]" id="_wc_accommodation_booking_restricted_days[<?php echo $i; ?>]" value="<?php echo $i; ?>" <?php checked( $restricted_days[ $i ], $i ); ?>> 
     77                            </td> 
     78                        <?php 
     79                    } 
     80                ?> 
     81                            <td>&nbsp;</td> 
     82                        </tr> 
     83                    </tbody> 
     84                </table> 
     85            </div> 
     86 
     87        <?php endif; ?> 
    3788 
    3889    </div> 
  • woocommerce-accommodation-bookings/trunk/includes/admin/views/html-accommodation-booking-data.php

    r1458646 r1714785  
    7575 
    7676    <script type="text/javascript"> 
    77         jQuery( '._tax_status_field' ).closest( '.show_if_simple' ).addClass( 'show_if_accommodation_booking' ); 
     77        jQuery( '._tax_status_field' ).closest( '.show_if_simple' ).addClass( 'show_if_accommodation-booking' ); 
    7878    </script> 
    7979</div> 
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-cart-manager.php

    r1634742 r1714785  
    3434    public function get_item_data( $other_data, $cart_item ) { 
    3535        if ( 'accommodation-booking' === $cart_item['data']->get_type() ) { 
    36             $check_in = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    37             $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     36            $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     37            $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    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

    r1644960 r1714785  
    3030     */ 
    3131    public function add_accommodation_posted_data( $data, $product, $total_duration ) { 
    32  
    33         $check_in = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    34         $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     32        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     33        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    3534 
    3635        if ( 'night' === $product->get_duration_unit() ) { 
     
    3837            $data['_end_date']   = strtotime( "+{$total_duration} day $check_out", $data['_start_date'] ); 
    3938            $data['_all_day']    = 0; 
     39        } 
     40 
     41        if ( $product->has_resources() && ! $product->is_resource_assignment_type( 'customer' ) ) { 
     42            // Assign an available resource automatically 
     43            $available_bookings = wc_bookings_get_total_available_bookings_for_range( $product, $data['_start_date'], $data['_end_date'], 0, $data['_qty'] ); 
     44            if ( is_array( $available_bookings ) ) { 
     45                $data['_resource_id'] = current( array_keys( $available_bookings ) ); 
     46                $data['type']         = get_the_title( current( array_keys( $available_bookings ) ) ); 
     47            } 
    4048        } 
    4149 
     
    6169    /** 
    6270     * Add partially booked accomodation bookings 
    63      * @param array $booked_data_array 
     71     * If a calendar date has check-in ( a booking starts on that date ) if it is feasible we want it marked as 
     72     * partially booked because some other booking could end on that date. 
     73     * If a calendar date has check-out ( a booking ends on that date ) if it is feasible we want it marked as 
     74     * partially booked because some other booking could start on that date. 
     75     * When it is feasible to mark a date partially booked: 
     76     *  - for a check-in date we check if a day before that date has any available resources. Only if a day before 
     77     *    check-in has any avaialble resources it is possible that some booking could end ( had its check-out ) on the 
     78     *    check-in date we are testing. 
     79     *  - for a check-out date we chack if that date has any available resources. If it does it means that some other 
     80     *    booking can start ( can have its check-in ) on the check-out date that we are testing. 
     81     * Function works in followin steps: 
     82     *  1. gather all check-in and checko-out dates for product 
     83     *  2. loop over all dates from (1): 
     84     *    a. get all available resources for: day before for check-in and current for check-out 
     85     *    b. test if resources are available and if yes than move fully booked day to partially booked days 
     86     * 
     87     * @param array                            $booked_data_array 
     88     * @param WC_Product_Accommodation_Booking $product 
    6489     */ 
    6590    public function add_partially_booked_dates( $booked_data_array, $product ) { 
    66         // this array will contain the start and the end of all bookings 
    67         $check_in_out_days     = array( 
    68             'in' => array(), 
    69             'out' => array(), 
    70         ); 
    71  
     91        // This function makes sesne only for duration type: night. 
    7292        if ( 'night' !== $product->get_duration_unit() ) { 
    7393            return $booked_data_array; 
    7494        } 
    7595 
    76         $existing_bookings = WC_Bookings_Controller::get_bookings_for_objects( array( $product->get_id() ) ); 
    77         $available_quantity = $product->get_available_quantity( null ); 
    78         // Use the existing bookings to find days which are partially booked 
    79         foreach ( $existing_bookings as $booking ) { 
     96        // Start and the end dates of all bookings. 
     97        $check_in_out_times = $this->get_check_in_and_out_times( $product ); 
    8098 
    81             $check_date  = $booking->start; 
    82             $resource = $booking->get_resource_id(); 
     99        // Go through each checkin and checkout days and mark them as partially booked. 
     100        foreach ( array( 'in', 'out' ) as $which ) { 
     101            foreach ( $check_in_out_times[ $which ] as $resource_id => $times ) { 
     102                foreach ( $times as $time ) { 
     103                    $day = date( 'Y-n-j', $time ); 
     104                    if ( ! empty( $booked_data_array['partially_booked_days'][ $day ][ $resource_id ] ) ) { 
     105                        // The day is already partially booked so lets skipp to the next day. 
     106                        continue; 
     107                    } 
    83108 
    84             // if we have automatic assignment attempt to automatically assign a resource 
    85             if ( $product->has_resources() && $product->is_resource_assignment_type( 'automatic' ) ) { 
    86                 // if the resource is not set, attempt to assign one 
    87                 if ( empty( $resource ) ) { 
    88                     $resources = $booking->get_product()->get_all_resources_availability( $booking->start, $booking->end, 1 ); 
    89                     $resources = is_array( $resources ) ? array_keys( $resources ) : array(); 
    90  
    91                     // found an available resource, automatically assign it 
    92                     if ( count( $resources ) > 0 ) { 
    93                         $resource = $resources[0]; 
    94                         update_post_meta( $booking->get_id(), '_booking_resource_id', $resource ); 
     109                    $check_in_time = $product->get_check_times( 'in' ); 
     110                    if( 'in' === $which ){ 
     111                        $check_time = strtotime( '-1 day ' . $check_in_time , $time ); 
     112                    } else { 
     113                        $check_time = strtotime( $check_in_time, $time ); 
    95114                    } 
    96                 } 
    97             } 
    98  
    99             $check_in_out_days['in'][ $resource ][] = date( 'Y-n-j', $check_date ); 
    100  
    101             // Loop over all booked days in this booking and mark them as fully booked (the last one will be filtered by check out filter) 
    102             while ( $check_date < $booking->end ) { 
    103  
    104                 $js_date = date( 'Y-n-j', $check_date ); 
    105  
    106                 $check_date = strtotime( '+1 day', $check_date ); 
    107                 $booked_data_array['fully_booked_days'][ date( 'Y-n-j', $check_date ) ][ $resource ] = true; 
    108             } 
    109  
    110             $check_in_out_days['out'][ $resource ][] = date( 'Y-n-j', $check_date ); 
    111         } 
    112  
    113         // if it has resources, remove resource id 0 from the fully and partially booked list (comes from Bookings itself) 
    114         if ( $product->has_resources() ) { 
    115             foreach ( array( 'partially_booked_days', 'fully_booked_days' ) as $which ) { 
    116                 foreach ( $booked_data_array[ $which ] as $day => $resource ) { 
    117                     $booked_data_array[ $which ][ $day ] = array_filter( 
    118                         $booked_data_array[ $which ][ $day ], 
    119                         function( $key ) { 
    120                             return 0 !== $key; 
    121                         }, 
    122                         ARRAY_FILTER_USE_KEY 
    123                     ); 
    124                 } 
    125             } 
    126         } 
    127  
    128         // get all resources that have a checkin and a checkout date 
    129         $resources = array_intersect( array_keys( $check_in_out_days['in'] ), array_keys( $check_in_out_days['out'] ) ); 
    130  
    131         foreach ( $resources as $resource ) { 
    132             // mark as fully booked all days that intersect the check in and check out date 
    133             // e.g. booking A starts from X to Y, and booking B starts from Y to Z. 
    134             // X and Z will be partially booked, but Y will be fully booked. 
    135             $fully_booked = array_intersect( $check_in_out_days['in'][ $resource ], $check_in_out_days['out'][ $resource ] ); 
    136  
    137             if ( ! empty( $fully_booked ) ) { 
    138                 foreach ( $fully_booked as $day ) { 
    139                     $booked_data_array['fully_booked_days'][ $day ][ $resource ] = true; 
    140                 } 
    141  
    142                 // since we're marking the fully booked checkin days as partially booked, we will exclude the intersection (fully booked ones) 
    143                 $check_in_out_days['in'][ $resource ] = array_diff( $check_in_out_days['in'][ $resource ], $fully_booked ); 
    144  
    145                 // since we're marking the checkout days as partially booked, we will exclude the intersection (fully booked ones) 
    146                 $check_in_out_days['out'][ $resource ] = array_diff( $check_in_out_days['out'][ $resource ], $fully_booked ); 
    147             } 
    148         } 
    149  
    150         // go through each checkin and checkout days and mark them as partially booked 
    151         foreach ( array( 'in', 'out' ) as $which ) { 
    152             foreach ( $check_in_out_days[ $which ] as $resource => $days ) { 
    153                 $full_days = array(); 
    154  
    155                 // if all resources were used, set the id to 0 (date-picker.js depends on that) 
    156                 if ( $product->has_resources() && count( $product->get_resources() ) === count( array_keys( $check_in_out_days[ $which ] ) ) && $product->is_resource_assignment_type( 'automatic' ) ) { 
    157                     $full_days = call_user_func_array( 'array_intersect', $check_in_out_days[ $which ] ); 
    158                 } 
    159  
    160                 foreach ( $days as $day ) { 
    161                     // if the first or the last checkout day for a booking was marked as fully booked, move to partially booked 
    162                     if ( ! empty( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ) ) { 
    163                         $booked_data_array['partially_booked_days'][ $day ][ in_array( $day, $full_days ) ? 0 : $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ]; 
    164                         unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ); 
     115                    $check = date("F j, Y, g:i a", $check_time ); 
     116                    // Check freele 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 ); 
    165120                    } 
    166121                } 
     
    170125        return $booked_data_array; 
    171126    } 
     127 
     128    /** 
     129     * Calculates array that contains the start and the end time of all bookings for given product. 
     130     * *@param $product 
     131     */ 
     132    private function get_check_in_and_out_times( $product ) { 
     133 
     134        $check_in_out_times     = array( 
     135            'in' => array(), 
     136            'out' => array(), 
     137        ); 
     138 
     139        // Using all existing bookings we will calculate start and end time for each booking. 
     140        // Those times will be considered for switching particular day from full to partially booked days. 
     141        $existing_bookings  = WC_Bookings_Controller::get_bookings_for_objects( array( $product->get_id() ) ); 
     142        foreach ( $existing_bookings as $booking ) { 
     143 
     144            $resource   = $booking->get_resource_id(); 
     145            if( ! array_key_exists( $resource, $check_in_out_times['in'] ) ) { 
     146                $check_in_out_times['in'][ $resource ] = array(); 
     147                $check_in_out_times['out'][ $resource ] = array(); 
     148            } 
     149 
     150            if ( ! in_array( $booking->start, $check_in_out_times['in'][ $resource ] ) ) { 
     151                $check_in_out_times['in'][ $resource ][] = $booking->start; 
     152            } 
     153 
     154            if ( ! in_array( $booking->end, $check_in_out_times['out'][ $resource ] ) ) { 
     155                $check_in_out_times['out'][ $resource ][] = $booking->end; 
     156            } 
     157        } 
     158 
     159        return $check_in_out_times; 
     160    } 
     161 
     162    /** 
     163     * Get amount of available product resoureces on a specific timestamp 
     164     * *@param $product 
     165     * *@param $resource 
     166     * *@param $date 
     167     */ 
     168    private function get_product_resource_available_blocks_on_time( $product, $resource, $time ) { 
     169        $blocks = $product->get_blocks_in_range_for_day( $time, $time, $resource, array() ); 
     170        $available_blocks = wc_bookings_get_time_slots( $product, $blocks, array(), 0, $time, $time ); 
     171        return ! empty( $available_blocks[ $time ] ) ? $available_blocks[ $time ][ 'available'] : 0; 
     172    } 
     173 
     174    /** 
     175     * Moves day from fully booked days array to partially booked days array and if the fully booked days is 
     176     * array for that day is empty ( no assigned resources ) removes that empty day entry 
     177     * *@param $booked_data_array 
     178     * *@param $resource 
     179     * *@param $day 
     180     */ 
     181    private function move_day_from_fully_to_partially_booked( $booked_data_array, $resource, $day ) { 
     182        $booked_data_array['partially_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ]; 
     183        unset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ); 
     184        if ( empty( $booked_data_array['fully_booked_days'][ $day ] ) ) { 
     185            unset( $booked_data_array['fully_booked_days'][ $day ] ); 
     186        } 
     187        return $booked_data_array; 
     188    } 
     189 
    172190} 
    173191 
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-order-info.php

    r1634742 r1714785  
    3333        } 
    3434 
    35         $check_in  = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    36         $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     35        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     36        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    3737        ?> 
    3838        <p> 
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-accommodation-booking-product-tabs.php

    r1634742 r1714785  
    2323     */ 
    2424    public function are_time_fields_filled_out() { 
    25         $check_in = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    26         $check_out = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
     25        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     26        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    2727 
    2828        if ( empty( $check_in ) ) { 
     
    7878            return; 
    7979        } 
    80         $check_in = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    81         $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     80        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     81        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    8282        ?> 
    8383        <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

    r1644960 r1714785  
    4949        } 
    5050 
    51         $check_in = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
     51        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     52 
    5253        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() ); 
    5354        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() ); 
     
    6263        } 
    6364 
    64         $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     65        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    6566        $date_format = apply_filters( 'woocommerce_bookings_date_format', wc_date_format() ); 
    6667        $time_format = apply_filters( 'woocommerce_bookings_time_format', ', ' . wc_time_format() ); 
     
    120121        } 
    121122 
    122         $check_in  = get_option( 'woocommerce_accommodation_bookings_check_in', '' ); 
    123         $check_out = get_option( 'woocommerce_accommodation_bookings_check_out', '' ); 
     123        $check_in  = WC_Product_Accommodation_Booking::get_check_times( 'in' ); 
     124        $check_out = WC_Product_Accommodation_Booking::get_check_times( 'out' ); 
    124125 
    125126        $start = get_post_meta( $booking_id, '_booking_start', true ); 
  • woocommerce-accommodation-bookings/trunk/includes/class-wc-product-accommodation-booking.php

    r1644960 r1714785  
    9090     */ 
    9191    public function is_range_picker_enabled() { 
    92         return true; 
     92        return apply_filters( 'woocommerce_accommodation_bookings_range_picker_enabled', true ); 
    9393    } 
    9494 
     
    142142     */ 
    143143    public function get_price_html( $price = '' ) { 
    144         $tax_display_mode = get_option( 'woocommerce_tax_display_shop' ); 
    145         if ( version_compare( WC_VERSION, '3.0', '<' ) ) { 
    146             $display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_price() ) : $this->get_price_excluding_tax( 1, $this->get_price() ); 
    147         } else { 
    148             $display_price = $tax_display_mode == 'incl' ? wc_get_price_including_tax( $this, array( 'qty' => 1, 'price' => $this->get_price() ) ) : wc_get_price_excluding_tax( $this, array( 'qty' => 1, 'price' => $this->get_price() ) ); 
    149  
    150         } 
    151  
    152         $min_duration = absint( get_post_meta( $this->get_id(), '_wc_booking_min_duration', true ) ); 
    153  
    154         if ( $min_duration > 1 ) { 
    155             $display_price = $display_price / $min_duration; 
     144 
     145        // If displau cost is set - user wants that to be displayed 
     146        $display_price = $this->get_display_cost(); 
     147        if ( ! $display_price ) { 
     148            $tax_display_mode = get_option( 'woocommerce_tax_display_shop' ); 
     149            if ( version_compare( WC_VERSION, '3.0', '<' ) ) { 
     150                $display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_price() ) : $this->get_price_excluding_tax( 1, $this->get_price() ); 
     151            } else { 
     152                $display_price = $tax_display_mode == 'incl' ? wc_get_price_including_tax( $this, array( 'qty' => 1, 'price' => $this->get_price() ) ) : wc_get_price_excluding_tax( $this, array( 'qty' => 1, 'price' => $this->get_price() ) ); 
     153            } 
    156154        } 
    157155 
    158156        if ( $display_price ) { 
    159             if ( $this->has_additional_costs() ) { 
     157            if ( $this->has_additional_costs() || $this->get_display_cost() ) { 
    160158                $price_html = sprintf( __( 'From %s per night', 'woocommerce-accommodation-bookings' ), wc_price( $display_price ) ) . $this->get_price_suffix(); 
    161159            } else { 
     
    190188        return array_unique( $blocks_in_range ); 
    191189    } 
     190 
     191    /** 
     192     * Get checkin and checkout times. 
     193     * 
     194     * @param string $type 
     195     * @return string Time, either from options or default 
     196     */ 
     197    public static function get_check_times( $type ) { 
     198        switch ( $type ) { 
     199            case 'in': 
     200                return get_option( 'woocommerce_accommodation_bookings_check_in' ) ?: '14:00'; 
     201            case 'out': 
     202                return get_option( 'woocommerce_accommodation_bookings_check_out' ) ?: '12:00'; 
     203        } 
     204 
     205        return ''; 
     206    } 
    192207} 
    193208 
  • woocommerce-accommodation-bookings/trunk/languages/woocommerce-accommodation-bookings.pot

    r1487396 r1714785  
    1 # Copyright (C) 2016 WooThemes 
     1# Copyright (C) 2017 WooCommerce 
    22# This file is distributed under the GNU General Public License v3.0. 
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: WooCommerce Accommodation Bookings 1.0.3\n" 
     5"Project-Id-Version: WooCommerce Accommodation Bookings 1.1.0\n" 
    66"Report-Msgid-Bugs-To: https://support.woothemes.com/hc/\n" 
    7 "POT-Creation-Date: 2016-05-04 11:05:52+00:00\n" 
     7"POT-Creation-Date: 2017-08-17 15:21:05+00:00\n" 
    88"MIME-Version: 1.0\n" 
    99"Content-Type: text/plain; charset=utf-8\n" 
    1010"Content-Transfer-Encoding: 8bit\n" 
    11 "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n" 
     11"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n" 
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
    1313"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n" 
    14 "X-Generator: grunt-wp-i18n 0.5.3\n" 
    15  
    16 #: includes/admin/class-wc-accommodation-booking-admin-panels.php:33 
     14"X-Generator: grunt-wp-i18n 0.5.4\n" 
     15 
     16#: includes/admin/class-wc-accommodation-booking-admin-panels.php:38 
    1717msgid "Accommodation product" 
     18msgstr "" 
     19 
     20#: includes/admin/class-wc-accommodation-booking-admin-panels.php:326 
     21msgid "Person Type #%d" 
    1822msgstr "" 
    1923 
     
    2327 
    2428#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:35 
    25 #: includes/class-wc-accommodation-booking-product-tabs.php:79 
     29#: includes/class-wc-accommodation-booking-product-tabs.php:85 
    2630msgid "Check-in time" 
    2731msgstr "" 
     
    3135msgstr "" 
    3236 
    33 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:43 
    34 #: includes/class-wc-accommodation-booking-product-tabs.php:80 
     37#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:44 
     38#: includes/class-wc-accommodation-booking-product-tabs.php:86 
    3539msgid "Check-out time" 
    3640msgstr "" 
    3741 
    38 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:44 
     42#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:45 
    3943msgid "Check-out time for reservations." 
    4044msgstr "" 
    4145 
    42 #: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:60 
     46#: includes/admin/class-wc-accommodation-booking-admin-product-settings.php:62 
    4347msgid "Accommodations" 
    4448msgstr "" 
     
    105109 
    106110#: includes/admin/views/html-accommodation-booking-availability-fields.php:20 
     111#: includes/admin/views/html-accommodation-booking-availability.php:64 
    107112#: includes/admin/views/html-accommodation-booking-rates-fields.php:20 
    108113msgid "Monday" 
     
    110115 
    111116#: includes/admin/views/html-accommodation-booking-availability-fields.php:21 
     117#: includes/admin/views/html-accommodation-booking-availability.php:65 
    112118#: includes/admin/views/html-accommodation-booking-rates-fields.php:21 
    113119msgid "Tuesday" 
     
    115121 
    116122#: includes/admin/views/html-accommodation-booking-availability-fields.php:22 
     123#: includes/admin/views/html-accommodation-booking-availability.php:66 
    117124#: includes/admin/views/html-accommodation-booking-rates-fields.php:22 
    118125msgid "Wednesday" 
     
    120127 
    121128#: includes/admin/views/html-accommodation-booking-availability-fields.php:23 
     129#: includes/admin/views/html-accommodation-booking-availability.php:67 
    122130#: includes/admin/views/html-accommodation-booking-rates-fields.php:23 
    123131msgid "Thursday" 
     
    125133 
    126134#: includes/admin/views/html-accommodation-booking-availability-fields.php:24 
     135#: includes/admin/views/html-accommodation-booking-availability.php:68 
    127136#: includes/admin/views/html-accommodation-booking-rates-fields.php:24 
    128137msgid "Friday" 
     
    130139 
    131140#: includes/admin/views/html-accommodation-booking-availability-fields.php:25 
     141#: includes/admin/views/html-accommodation-booking-availability.php:69 
    132142#: includes/admin/views/html-accommodation-booking-rates-fields.php:25 
    133143msgid "Saturday" 
     
    135145 
    136146#: includes/admin/views/html-accommodation-booking-availability-fields.php:26 
     147#: includes/admin/views/html-accommodation-booking-availability.php:63 
    137148#: includes/admin/views/html-accommodation-booking-rates-fields.php:26 
    138149msgid "Sunday" 
     
    208219msgstr "" 
    209220 
    210 #: includes/admin/views/html-accommodation-booking-availability.php:45 
    211 #: includes/admin/views/html-accommodation-booking-rates.php:15 
     221#: includes/admin/views/html-accommodation-booking-availability.php:49 
     222msgid "Restrict start days?" 
     223msgstr "" 
     224 
     225#: includes/admin/views/html-accommodation-booking-availability.php:50 
     226msgid "" 
     227"Restrict bookings so that they can only start on certain days of the week. " 
     228"Does not affect availability." 
     229msgstr "" 
     230 
     231#: includes/admin/views/html-accommodation-booking-availability.php:96 
     232#: includes/admin/views/html-accommodation-booking-rates.php:22 
    212233msgid "Range type" 
    213234msgstr "" 
    214235 
    215 #: includes/admin/views/html-accommodation-booking-availability.php:46 
     236#: includes/admin/views/html-accommodation-booking-availability.php:97 
    216237msgid "From" 
    217238msgstr "" 
    218239 
    219 #: includes/admin/views/html-accommodation-booking-availability.php:47 
     240#: includes/admin/views/html-accommodation-booking-availability.php:98 
    220241msgid "To" 
    221242msgstr "" 
    222243 
    223 #: includes/admin/views/html-accommodation-booking-availability.php:48 
     244#: includes/admin/views/html-accommodation-booking-availability.php:99 
    224245msgid "Bookable" 
    225246msgstr "" 
    226247 
    227 #: includes/admin/views/html-accommodation-booking-availability.php:48 
     248#: includes/admin/views/html-accommodation-booking-availability.php:99 
    228249msgid "If not bookable, users won't be able to choose this room." 
    229250msgstr "" 
    230251 
    231 #: includes/admin/views/html-accommodation-booking-availability.php:49 
     252#: includes/admin/views/html-accommodation-booking-availability.php:100 
    232253msgid "Priority" 
    233254msgstr "" 
    234255 
    235 #: includes/admin/views/html-accommodation-booking-availability.php:49 
     256#: includes/admin/views/html-accommodation-booking-availability.php:100 
    236257msgid "" 
    237258"The lower the priority number, the earlier this rule gets applied. By " 
     
    241262msgstr "" 
    242263 
    243 #: includes/admin/views/html-accommodation-booking-availability.php:61 
    244 #: includes/admin/views/html-accommodation-booking-rates.php:30 
     264#: includes/admin/views/html-accommodation-booking-availability.php:112 
     265#: includes/admin/views/html-accommodation-booking-rates.php:37 
    245266msgid "Add Range" 
    246267msgstr "" 
    247268 
    248 #: includes/admin/views/html-accommodation-booking-availability.php:62 
     269#: includes/admin/views/html-accommodation-booking-availability.php:113 
    249270msgid "" 
    250271"Rules with lower numbers will execute first. Rules further down this table " 
     
    336357msgstr "" 
    337358 
    338 #: includes/admin/views/html-accommodation-booking-rates.php:16 
     359#: includes/admin/views/html-accommodation-booking-rates.php:9 
     360msgid "Display cost" 
     361msgstr "" 
     362 
     363#: includes/admin/views/html-accommodation-booking-rates.php:9 
     364msgid "" 
     365"The cost is displayed to the user on the frontend. Leave blank to have it " 
     366"calculated for you. If a booking has varying costs, this will be prefixed " 
     367"with the word \"from:\"." 
     368msgstr "" 
     369 
     370#: includes/admin/views/html-accommodation-booking-rates.php:23 
    339371msgid "Starting" 
    340372msgstr "" 
    341373 
    342 #: includes/admin/views/html-accommodation-booking-rates.php:17 
     374#: includes/admin/views/html-accommodation-booking-rates.php:24 
    343375msgid "Ending" 
    344376msgstr "" 
    345377 
    346 #: includes/admin/views/html-accommodation-booking-rates.php:17 
     378#: includes/admin/views/html-accommodation-booking-rates.php:24 
    347379msgid "Includes this date/night." 
    348380msgstr "" 
    349381 
    350 #: includes/admin/views/html-accommodation-booking-rates.php:18 
     382#: includes/admin/views/html-accommodation-booking-rates.php:25 
    351383msgid "Cost" 
    352384msgstr "" 
    353385 
    354 #: includes/admin/views/html-accommodation-booking-rates.php:18 
     386#: includes/admin/views/html-accommodation-booking-rates.php:25 
    355387msgid "Cost for this time period." 
    356388msgstr "" 
     
    364396msgstr "" 
    365397 
    366 #: includes/class-wc-accommodation-booking-cart-manager.php:43 
    367 #: includes/class-wc-accommodation-booking-date-picker.php:25 
     398#: includes/class-wc-accommodation-booking-cart-manager.php:42 
     399#: includes/class-wc-accommodation-booking-date-picker.php:59 
    368400#: includes/class-wc-accommodation-booking-order-info.php:39 
    369401msgid "Check-in" 
    370402msgstr "" 
    371403 
    372 #: includes/class-wc-accommodation-booking-cart-manager.php:44 
    373 #: includes/class-wc-accommodation-booking-cart-manager.php:52 
     404#: includes/class-wc-accommodation-booking-cart-manager.php:43 
     405#: includes/class-wc-accommodation-booking-cart-manager.php:51 
    374406#: includes/class-wc-accommodation-booking-order-info.php:42 
    375407#: includes/class-wc-accommodation-booking-order-info.php:61 
     
    377409msgstr "" 
    378410 
    379 #: includes/class-wc-accommodation-booking-cart-manager.php:51 
    380 #: includes/class-wc-accommodation-booking-date-picker.php:32 
     411#: includes/class-wc-accommodation-booking-cart-manager.php:50 
     412#: includes/class-wc-accommodation-booking-date-picker.php:66 
    381413#: includes/class-wc-accommodation-booking-order-info.php:56 
    382414msgid "Check-out" 
     
    391423msgstr "" 
    392424 
    393 #: includes/class-wc-accommodation-booking-product-tabs.php:57 
    394 #: includes/class-wc-accommodation-booking-product-tabs.php:77 
     425#: includes/class-wc-accommodation-booking-product-tabs.php:63 
     426#: includes/class-wc-accommodation-booking-product-tabs.php:83 
    395427msgid "Arriving/leaving" 
    396428msgstr "" 
    397429 
    398 #: includes/class-wc-accommodation-bookings-plugin.php:175 
     430#: includes/class-wc-accommodation-bookings-plugin.php:177 
    399431msgid "View Documentation" 
    400432msgstr "" 
    401433 
    402 #: includes/class-wc-accommodation-bookings-plugin.php:175 
     434#: includes/class-wc-accommodation-bookings-plugin.php:177 
    403435msgid "Docs" 
    404436msgstr "" 
    405437 
    406 #: includes/class-wc-accommodation-bookings-plugin.php:176 
     438#: includes/class-wc-accommodation-bookings-plugin.php:178 
    407439msgid "Visit Premium Customer Support Forum" 
    408440msgstr "" 
    409441 
    410 #: includes/class-wc-accommodation-bookings-plugin.php:176 
     442#: includes/class-wc-accommodation-bookings-plugin.php:178 
    411443msgid "Premium Support" 
    412444msgstr "" 
    413445 
    414 #: includes/class-wc-accommodation-dependencies.php:54 
     446#: includes/class-wc-accommodation-dependencies.php:69 
    415447msgid "Accommodation Bookings requires Bookings plugin activated." 
    416448msgstr "" 
    417449 
    418 #: includes/class-wc-accommodation-dependencies.php:58 
     450#: includes/class-wc-accommodation-dependencies.php:73 
    419451msgid "Accommodation Bookings requires Bookings version 1.9+." 
    420452msgstr "" 
    421453 
    422 #: includes/class-wc-accommodation-dependencies.php:62 
     454#: includes/class-wc-accommodation-dependencies.php:77 
    423455msgid "Accommodation Bookings requires PHP version 5.3+." 
    424456msgstr "" 
    425457 
    426 #: includes/class-wc-product-accommodation-booking.php:37 
     458#: includes/class-wc-product-accommodation-booking.php:84 
    427459msgid "Accommodation booking" 
    428460msgstr "" 
    429461 
    430 #: includes/class-wc-product-accommodation-booking.php:136 
     462#: includes/class-wc-product-accommodation-booking.php:158 
    431463msgid "From %s per night" 
    432464msgstr "" 
    433465 
    434 #: includes/class-wc-product-accommodation-booking.php:141 
     466#: includes/class-wc-product-accommodation-booking.php:163 
    435467msgid "Free" 
     468msgstr "" 
     469 
     470#: includes/integrations/class-wc-accommodation-booking-addons.php:49 
     471msgid "Bookings: Multiply cost by person count" 
     472msgstr "" 
     473 
     474#: includes/integrations/class-wc-accommodation-booking-addons.php:53 
     475msgid "Bookings: Multiply cost by number of nights" 
    436476msgstr "" 
    437477 
     
    441481 
    442482#. Plugin URI of the plugin/theme 
    443 msgid "http://www.woothemes.com/products/woocommerce-accommodation-bookings/" 
     483msgid "https://woocommerce.com/products/woocommerce-accommodation-bookings/" 
    444484msgstr "" 
    445485 
     
    449489 
    450490#. Author of the plugin/theme 
    451 msgid "WooThemes" 
     491msgid "WooCommerce" 
    452492msgstr "" 
    453493 
    454494#. Author URI of the plugin/theme 
    455 msgid "http://woothemes.com" 
    456 msgstr "" 
     495msgid "https://woocommerce.com" 
     496msgstr "" 
  • woocommerce-accommodation-bookings/trunk/readme.txt

    r1644960 r1714785  
    33Tags: woocommerce, bookings, accommodations 
    44Requires at least: 4.1 
    5 Tested up to: 4.6 
    6 Stable tag: 1.0.9 
     5Tested up to: 4.8.1 
     6Stable tag: 1.1.0 
    77License: GNU General Public License v3.0 
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html 
     
    3030 
    3131== Changelog == 
     32 
     33= 1.1.0 = 
     34* Fix - Display cost not used when presenting price to the client. 
     35* Add - Add woocommerce_accommodation_bookings_range_picker_enabled to disable range picker. 
     36* Fix - Fallback to default checkin/checkout time values if none are set. 
     37* Fix - Fully booked days not showing correctly when persons are used. 
     38* Fix - Resource availability calculated incorrectly. 
     39* Add - New functionality to restrict the day a booking can start on.  
     40* Fix - Tax fields missing. 
     41* Fix - Display price is showing incorrectly. 
     42* Fix - Availability rules being ignored. 
     43* Fix - Today should be shown as booked if it has check out available only 
    3244 
    3345= 1.0.9 = 
  • woocommerce-accommodation-bookings/trunk/woocommerce-accommodation-bookings.php

    r1644960 r1714785  
    44Plugin URI: https://woocommerce.com/products/woocommerce-accommodation-bookings/ 
    55Description: An accommodations add-on for the WooCommerce Bookings extension. 
    6 Version: 1.0.9 
     6Version: 1.1.0 
    77Author: WooCommerce 
    88Author URI: https://woocommerce.com 
     
    2020 
    2121require_once( 'includes/class-wc-accommodation-bookings-plugin.php' ); 
    22 $plugin = new WC_Accommodation_Bookings_Plugin( __FILE__, '1.0.9' ); 
     22$plugin = new WC_Accommodation_Bookings_Plugin( __FILE__, '1.1.0' ); 
    2323$plugin->run(); 
Note: See TracChangeset for help on using the changeset viewer.