Plugin Directory

Changeset 2358899


Ignore:
Timestamp:
08/12/2020 01:13:19 PM (6 years ago)
Author:
themewinter
Message:

Adding Version 1.0.6

Location:
wp-cafe
Files:
3 deleted
22 edited
45 copied

Legend:

Unmodified
Added
Removed
  • wp-cafe/tags/1.0.6/assets/css/wpc-public.css

    r2343218 r2358899  
    341341  margin-left: auto;
    342342}
    343 
     343.ui-timepicker-standard a{
     344  padding: 0 !important;
     345}
    344346@media (min-width: 576px) {
    345347  .wpc-container {
    … …  
    51145116  background: #5D78FF;
    51155117  padding: 8px 10px;
    5116   margin-right: 5px;
     5118  margin-right: 2px;
    51175119  color: #fff;
    51185120}
  • wp-cafe/tags/1.0.6/assets/js/wpc-admin-menu.js

    r2335589 r2358899  
    11(function ($) {
     2    "use strict";
    23    $(document).ready(function () {
    34        $('.toplevel_page_cafe_menu')
  • wp-cafe/tags/1.0.6/assets/js/wpc-admin.js

    r2335589 r2358899  
    11(function($) {
     2    "use strict";
    23    $(document).ready(function() {
    3 
    44     // load color picker   
    55     $("#wpc_primary_color").wpColorPicker();
    … …  
    1212         });
    1313     });
    14 
    15      // Shcedule dynamically increase decrease
     14     // Exceptional Shcedule dynamically increase decrease
    1615     var countExceptionBlock = $('.exception_block').length;
    1716     var increase=countExceptionBlock;
    … …  
    2322                 '<input type="text" name="wpc_exception_start_time[]" class="wpc_exception_start_time_'+increase+' wpc-settings-input attr-form-control" id="exception_start_time_'+increase+'" placeholder="Start time" />'+
    2423                 '<input type="text" name="wpc_exception_end_time[]" class="wpc_exception_end_time_'+increase+' wpc-settings-input attr-form-control" id="exception_end_time_'+increase+'" placeholder="End time"/>'+
    25                  '<div class="exception_time_clear exception_time_clear_'+increase+'" id="'+ increase +'" >clear</div>'+
    2624                 '<span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>'+
    2725             '</div>');
    2826             $('.wpc_exception_start_time_'+increase+', .wpc_exception_end_time_'+increase+' ').
    29              flatpickr({
    30                 enableTime: true,
    31                 noCalendar: true,
    32                 dateFormat: "h:i K",
    33                 time_24hr : false,
    34              });
     27             timepicker({
     28                timeFormat: 'h:mm p',
     29                interval: 30,
     30                dynamic: true,
     31                dropdown: true,
     32                scrollbar: true
     33            })
    3534     });
    36  
    37      $(".exception_main_block").on( 'click' ,'.remove_exception_block', function(e) {
    38          e.preventDefault();
    39          $(this).parent('div').remove();
    40          increase--;
    41      });
    42  
    43      // Shcedule dynamically increase decrease
     35
     36     // Weekly shcedule dynamically increase decrease
    4437     var countScheduleBox = $('.schedule_block').length;
    4538     var i           = countScheduleBox;
    4639     var createField = 7 - i ;
     40     // add shcedule block
    4741     $(document).on( 'click' , '.add_schedule_block' , function() {
    4842         if( i <= createField ){
    … …  
    6155                        '<input type="text" name="wpc_weekly_schedule_start_time[]" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_'+i+' wpc_mt_two wpc-mr-one wpc-settings-input attr-form-control" placeholder="Start time" />'+
    6256                        '<input type="text" name="wpc_weekly_schedule_end_time[]" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_'+i+'  wpc-settings-input attr-form-control" placeholder="End time"/>'+
    63                         '<div class="wpc_weekly_clear" id="'+i+'" >clear</div>'+
    6457                     '</div>'+
    6558                     '<span class="dashicons dashicons-no-alt remove_schedule_block wpc-btn"></span>'+
    … …  
    6962         }
    7063     });
    71      time_class = ['.wpc_weekly_schedule_start_time','.wpc_weekly_schedule_end_time','.wpc_exception_start_time',
     64
     65    // remove shcedule block
     66    $(".schedule_main_block").on( 'click' ,'.remove_schedule_block', function(e) {
     67        e.preventDefault();
     68        $(this).parent('.schedule_block').remove();
     69        increase--;
     70    });
     71    $(".exception_main_block").on( 'click' ,'.remove_exception_block', function(e) {
     72        e.preventDefault();
     73        $(this).parent('div').remove();
     74        increase--;
     75    });
     76
     77     var time_class = ['.wpc_weekly_schedule_start_time','.wpc_weekly_schedule_end_time','.wpc_exception_start_time',
    7278    '.wpc_exception_end_time'];
    73      // date flatpicker 
     79     // date timepicker 
    7480     $.map(time_class,function(value,index){
    7581        $(document).on('focus', value , function(){
    76             $(this).flatpickr({
    77                     enableTime: true,
    78                     noCalendar: true,
    79                     dateFormat: "h:i K",
    80                     time_24hr : false,
     82            $(this).timepicker({
     83                timeFormat: 'h:mm p',
     84                interval: 30,
     85                dynamic: true,
     86                dropdown: true,
     87                scrollbar: true
    8188            });
    8289        });
    8390    });
    84      $(".schedule_main_block").on( 'click' ,'.remove_schedule_block', function(e) {
    85          e.preventDefault();
    86          $(this).parent('.schedule_block').remove();
    87          increase--;
    88      });
    89      //clear action
    90      $(document).on('click','.wpc_weekly_clear',function(){
    91         var id = $(this).attr('id');
    92         $('.wpc_weekly_schedule_start_time_'+id+', .wpc_weekly_schedule_end_time_'+id+' ').flatpickr();
    93      });
    94     $(document).on('click','.exception_time_clear',function(){
    95         var id = $(this).attr('id');
    96         $('.wpc_exception_start_time_'+id+', .wpc_exception_end_time_'+id+' ').flatpickr();
    97      });
    98      $(document).on('click','.wpc_all_day_clear',function() {
    99         $('.wpc_all_day_start, .wpc_all_day_end ').flatpickr({
    100             errorHandler: (error) => {
    101               }
    102         });
    103     });
     91    var clear_class = ['.wpc_weekly_clear','.wpc_all_day_clear','.exception_time_clear'];
     92
     93    $.each(clear_class,function(ind,val){
     94        $(document).on('click', val ,function(){
     95            if ( ind === 0 ) {
     96                $('input[name="wpc_weekly_schedule_start_time[]"]').val('');
     97                $('input[name="wpc_weekly_schedule_end_time[]"]').val('');
     98            }
     99            else if(ind === 1) {
     100                $('input[name="wpc_all_day_start_time"]').val('');
     101                $('input[name="wpc_all_day_end_time"]').val('');
     102            }
     103            else if(ind === 2) {
     104                $('input[name="wpc_exception_start_time[]"]').val('');
     105                $('input[name="wpc_exception_end_time[]"]').val('');
     106            }
     107        })
     108    })
    104109
    105110     // weekly schedule select
    … …  
    141146     });
    142147    // all day shcedule
    143     $(document).on('focus',".wpc_all_day_start , .wpc_all_day_end ", function(){
     148    $(document).on('focus',".wpc_all_day_start , .wpc_all_day_end", function(){
    144149        if( selected_values.length == 0 ){
    145150            $('input.wpc_all_day_start,input.wpc_all_day_end').removeAttr("disabled");
    146             $(this).flatpickr({
    147                 enableTime: true,
    148                 noCalendar: true,
    149                 dateFormat: "h:i K",
    150                 time_24hr : false,
     151            $(this).timepicker({
     152                timeFormat: 'h:mm p',
     153                interval: 30,
     154                dynamic: true,
     155                dropdown: true,
     156                scrollbar: true
    151157            });
    152158        }else{
    … …  
    163169  (function($){
    164170    $(document).ready(function() {
    165         // get object   
    166         var wpc_booking_form_data = JSON.parse(wpc_client_booking_form_data);
     171        // get data from enqueue
     172        var wpc_booking_form_data;   
     173        if ( typeof wpc_form_data !=="undefined") {
     174            wpc_booking_form_data = wpc_form_data;
     175        }
    167176        // set location in local storage
    168177        $(document).on( 'click' , '.wpc-select-location' ,function(){
    … …  
    229238        }
    230239        // time format
    231         wpc_flat_time_format = true ;
    232         // time format
    233         if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
    234             wpc_time_format = 'H:i';
    235             wpc_flat_time_format = true;
    236         } else {
    237             wpc_time_format = 'h:i K';
    238             wpc_flat_time_format = false ;
    239         }
    240         // date format
    241         if( wpc_booking_form_data.wpc_date_format != "" ){
    242             wpc_date_format = wpc_booking_form_data.wpc_date_format;
    243         }else{
     240       var wpc_time_format; var wpc_date_format;
     241
     242        if ( typeof wpc_booking_form_data === "undefined" ){
     243            wpc_time_format = 'HH:mm';
    244244            wpc_date_format = 'yyyy-mm-dd'
     245        }
     246        else{
     247            if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
     248                wpc_time_format = 'HH:mm';
     249            } else {
     250                wpc_time_format = 'h:mm p';
     251            }
     252            // date format
     253            if( wpc_booking_form_data.wpc_date_format != "" ){
     254                wpc_date_format = wpc_booking_form_data.wpc_date_format;
     255            }else{
     256                wpc_date_format = 'yyyy-mm-dd'
     257            }
    245258        }
    246259        // check weekly and all day schedule
    … …  
    312325            }
    313326        }
    314         // change date format to expected format in flas
     327        // change date format to expected format
    315328        const wpc_flatpicker_date_change =(selectedDates,format)=>{
    316329            const wpc_date_ar         = selectedDates.map(date => flatpickr.formatDate(date, format));
    … …  
    319332        }
    320333        //  from time 
    321         var time_picker_from = $('#wpc_from_time').flatpickr({
    322             enableTime  : true,
    323             noCalendar  : true,
    324             dateFormat  : wpc_time_format,
    325             time_24hr   : wpc_flat_time_format,
    326             onChange  : function(selectedDates, dateStr, instance) {
    327                 var selected_time     = wpc_flatpicker_date_change( selectedDates , 'H:i');
    328                 var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
    329                 // late bookings
    330                 if ( wpc_time_format != 'H:i' &&  typeof wpc_end_time !== 'undefined' ){
    331                     wpc_end_time  = convertTime12to24( wpc_end_time );
    332                     selected_time = convertTime12to24( selected_time );
    333                 }
    334 
    335                 if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
    336                     var last_booking_time = time_diff(wpc_end_time, "00:14");
    337                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    338                         wpc_check_late_booking(selected_time,last_booking_time,15);
     334        $('#wpc_from_time').timepicker({
     335            timeFormat  : wpc_time_format,
     336            dynamic     : true,
     337            change      : function( time ) {
     338                if (time !== null) {
     339                    // the input field
     340                    var element = $(this), text;
     341                    // get access to this Timepicker instance
     342                    var timepicker = element.timepicker();
     343                    var selected_time     = timepicker.format(time);
     344
     345                    if ( typeof wpc_booking_form_data !=="undefined" ) {
     346                        var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
     347                        // late bookings
     348                        if ( wpc_time_format != 'HH:mm' &&  typeof wpc_end_time !== 'undefined' ){
     349                            wpc_end_time  = convertTime12to24( wpc_end_time );
     350                            selected_time = convertTime12to24( selected_time );
     351                        }
     352       
     353                        if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
     354                            var last_booking_time = time_diff(wpc_end_time, "00:14");
     355                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     356                                wpc_check_late_booking(selected_time,last_booking_time,15);
     357                            }
     358                        }
     359                        else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
     360                            var last_booking_time = time_diff(wpc_end_time, "00:29");
     361                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     362                                wpc_check_late_booking(selected_time,last_booking_time,30);
     363                            }
     364                        }
     365                        else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
     366                            var last_booking_time = time_diff(wpc_end_time, "00:44");
     367                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     368                                wpc_check_late_booking(selected_time,last_booking_time,45);
     369                            }
     370                        }
    339371                    }
    340372                }
    341                 else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
    342                     var last_booking_time = time_diff(wpc_end_time, "00:29");
    343                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    344                         wpc_check_late_booking(selected_time,last_booking_time,30);
    345                     }
    346                 }
    347                 else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
    348                     var last_booking_time = time_diff(wpc_end_time, "00:44");
    349                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    350                         wpc_check_late_booking(selected_time,last_booking_time,45);
    351                     }
    352                 }
    353373            }
    354374        });
    355375
    356376        //  To
    357         time_picker_to  =   $('#wpc_to_time').flatpickr({
    358             enableTime: true,
    359             noCalendar: true,
    360             dateFormat: wpc_time_format,
    361             time_24hr : wpc_flat_time_format
     377         $('#wpc_to_time').timepicker({
     378            timeFormat  : wpc_time_format,
     379            dynamic     : true,
    362380        });
    363381
    … …  
    365383        $(document).on('focus','#wpc_booking_date', function( e ){
    366384            e.preventDefault();
    367             var wpc_early_bookings    = wpc_booking_form_data.wpc_early_bookings;
    368             var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
    369             var wpc_one_week          = wpc_booking_form_data.wpc_one_week;
    370             var wpc_one_month         = wpc_booking_form_data.wpc_one_month;
    371             var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
    372             var wpc_max_day ='';
    373 
    374             // early bookings
    375             if (typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1day') {
    376                 wpc_max_day = new Date(wpc_one_day);
    377             }
    378             else if(typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1week' )
    379             {
    380                 wpc_max_day = new Date(wpc_one_week);
    381             }
    382             else if( typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1month' )
    383             {
    384                 wpc_max_day = new Date(wpc_one_month);
    385             }
    386             else{
    387                 wpc_max_day = false;
    388             }
    389             $(this).flatpickr({
    390                 dateFormat: wpc_date_format,
    391                 minDate   : "today",
    392                 maxDate   : wpc_max_day,
    393                 position  : "below",
    394                 onChange  : function(selectedDates, dateStr, instance) {
    395                     var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"Y-m-d");
    396                     var exception_date        = wpc_booking_form_data.wpc_exception_date;
    397                     $("#wpc_booking_date").val('');
    398                     $("#wpc_booking_date").val(dateStr);
    399 
    400                     if ( typeof exception_date === "undefined" )
    401                     {
    402                         var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
    403                         wpc_weekly_daily_schedule( wpc_new_selected_date ); 
    404                     }
    405                     else{
    406    
    407                         if (exception_date.length > 0 && exception_date[0] !== '') {
    408                             if ( $.inArray( wpc_new_selected_date,exception_date) !== -1)
    409                             {
    410                                 var index = exception_date.indexOf(wpc_new_selected_date);
    411                                 wpc_start_time = wpc_booking_form_data.wpc_exception_start_time[index];
    412                                 wpc_end_time   = wpc_booking_form_data.wpc_exception_end_time[index];
    413                             }
     385            if ( typeof wpc_booking_form_data !=="undefined") {
     386                var wpc_early_bookings    = wpc_booking_form_data.wpc_early_bookings;
     387                var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
     388                var wpc_one_week          = wpc_booking_form_data.wpc_one_week;
     389                var wpc_one_month         = wpc_booking_form_data.wpc_one_month;
     390                var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
     391                var wpc_max_day ='';
     392
     393                // early bookings
     394                if (typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1day') {
     395                    wpc_max_day = new Date(wpc_one_day);
     396                }
     397                else if(typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1week' )
     398                {
     399                    wpc_max_day = new Date(wpc_one_week);
     400                }
     401                else if( typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1month' )
     402                {
     403                    wpc_max_day = new Date(wpc_one_month);
     404                }
     405                else{
     406                    wpc_max_day = false;
     407                }
     408                $(this).flatpickr({
     409                    dateFormat: wpc_date_format,
     410                    minDate   : "today",
     411                    maxDate   : wpc_max_day,
     412                    position  : "below",
     413                    onChange  : function(selectedDates, dateStr, instance) {
     414                        var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"Y-m-d");
     415                        var exception_date        = wpc_booking_form_data.wpc_exception_date;
     416                        $("#wpc_booking_date").val('');
     417                        $("#wpc_booking_date").val(dateStr);
     418
     419                        if ( typeof exception_date === "undefined" )
     420                        {
     421                            var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
     422                            wpc_weekly_daily_schedule( wpc_new_selected_date ); 
     423                        }
     424                        else{
     425       
     426                            if (exception_date.length > 0 && exception_date[0] !== '') {
     427                                if ( $.inArray( wpc_new_selected_date,exception_date) !== -1)
     428                                {
     429                                    var index = exception_date.indexOf(wpc_new_selected_date);
     430                                    wpc_start_time = wpc_booking_form_data.wpc_exception_start_time[index];
     431                                    wpc_end_time   = wpc_booking_form_data.wpc_exception_end_time[index];
     432                                }
     433                                else
     434                                {
     435                                    var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
     436                                    wpc_weekly_daily_schedule( wpc_new_selected_date );
     437                                }
     438                            }
    414439                            else
    415440                            {
    … …  
    418443                            }
    419444                        }
    420                         else
    421                         {
    422                             var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
    423                             wpc_weekly_daily_schedule( wpc_new_selected_date );
    424                         }
     445                        if( wpc_booking_form_data.length == 0 ){
     446                            $("#wpc-booking-date").val(' ');
     447                            alert("No schedule set.");
     448                            $("#wpc_from_time").prop('disabled',true);
     449                            $("#wpc_to_time").prop('disabled',true);
     450       
     451                        }else{
     452                            $("#wpc_from_time").prop('disabled',false);
     453                            $("#wpc_to_time").prop('disabled',false);
     454
     455                            if (wpc_time_format == "h:mm p") {       
     456                                wpc_start_time = convertTime12to24(wpc_start_time);
     457                                wpc_end_time   = convertTime12to24(wpc_end_time);
     458                            }
     459
     460                            $('#wpc_from_time').timepicker('option','minTime', wpc_start_time);
     461                            $('#wpc_from_time').timepicker('option','maxTime', wpc_end_time);
     462
     463                            $('#wpc_to_time').timepicker('option','minTime', wpc_start_time);
     464                            $('#wpc_to_time').timepicker('option','maxTime', wpc_end_time);
     465                        }
    425466                    }
    426                     if( wpc_booking_form_data.length == 0 ){
    427                         $("#wpc-booking-date").val(' ');
    428                         alert("No schedule set.");
    429                         $("#wpc_from_time").prop('disabled',true);
    430                         $("#wpc_to_time").prop('disabled',true);
    431    
    432                     }else{
    433                         $("#wpc_from_time").prop('disabled',false);
    434                         $("#wpc_to_time").prop('disabled',false);
    435 
    436                         if (wpc_flat_time_format === false) {       
    437                             wpc_start_time = convertTime12to24(wpc_start_time);
    438                             wpc_end_time   = convertTime12to24(wpc_end_time);
    439                         }
    440                         wpc_start_arr = wpc_start_time.split(":");
    441                         time_picker_to.set({ defaultHour: wpc_start_arr[0] , defaultMinute: wpc_start_arr[1] , minTime: wpc_start_time, maxTime: wpc_end_time });
    442                         time_picker_from.set({ defaultHour: wpc_start_arr[0] ,defaultMinute: wpc_start_arr[1], minTime: wpc_start_time, maxTime: wpc_end_time });
    443                     }
    444                 }
    445                 // onset function end
    446             });
    447             // flatpicker date end
     467                    // onset function end
     468                });
     469                // flatpicker date end
     470            }
    448471        });
    449472
  • wp-cafe/tags/1.0.6/assets/js/wpc-public.js

    r2343218 r2358899  
     1"use strict";
    12// get object key name
    23const objectKeyName = (obj) => {
    … …  
    4041        }
    4142        return response;
    42     }
    43     (function ($) {
    44         var local_storage_value = localStorage.getItem('wpc_location');
    45         $("#wpc_location_name option[value='" + local_storage_value + "']").attr("selected", true);
    46 
    47         $(document).ready(function () {
    48             // get object   
    49             var wpc_form_data = JSON.parse(wpc_client_booking_form_data);
    50             var wpc_booking_form_data = wpc_form_data.settings;
    51 
    52             // set location in local storage and cancell modal
    53             $(document).on('click', '.wpc-select-location', function () {
    54                 wpc_location = $('.wpc-location option:selected').val();
    55 
    56                 var local_storage_value = localStorage.getItem('wpc_location');
    57                 if (local_storage_value === null) {
    58                     localStorage.setItem('wpc_location', wpc_location);
    59                 } else {
    60                     localStorage.removeItem('wpc_location');
    61                     localStorage.setItem('wpc_location', wpc_location);
    62                 }
    63                 $(".wpc_modal").fadeOut();
    64                 $('body').removeClass('wpc_location_popup');
    65 
    66             });
    67             wpc_date_format = "";
    68             wpc_start_time = "";
    69             wpc_end_time = "";
    70             wpc_all_day_start_time = "";
    71             wpc_all_day_end_time = "";
    72 
    73             // convert time 12 to 24
    74             const convertTime12to24 = (time12h) => {
    75                 const [time, modifier] = time12h.split(' ');
    76 
    77                 let [hours, minutes] = time.split(':');
    78 
    79                 if (hours === '12') {
    80                     hours = '00';
    81                 }
    82 
    83                 if (modifier === 'PM') {
    84                     hours = parseInt(hours, 10) + 12;
    85                 }
    86                 time_arr = [];
    87                 return `${hours}:${minutes}`;
    88             }
    89             // calculate time difference
    90             const time_diff = (wpc_end_time, last_time) => {
    91                 wpc_end_time = wpc_end_time.replace(',', ':');
    92                 var startTime = moment(wpc_end_time, "HH:mm");
    93                 var endTime = moment(last_time, "HH:mm");
    94                 var duration = moment.duration(startTime.diff(endTime));
    95                 var hours = parseInt(duration.asHours());
    96                 var minutes = parseInt(duration.asMinutes()) - hours * 60;
    97                 return hours + ':' + minutes;
    98             }
    99             // check late booking
    100             const time_diff_for_before_after_equal = (select_time, last_booking_time) => {
    101                 var startTime = moment(select_time, "HH:mm");
    102                 var endTime = moment(last_booking_time, "HH:mm");
    103 
    104                 if (startTime.isBefore(endTime)) {
    105                     data = "early";
    106                 } else if (startTime.isSame(endTime)) {
    107                     data = "equal";
    108                 } else if (startTime.isAfter(endTime)) {
    109                     data = "late";
    110                 } else {
    111                     data = "unknown";
    112                 }
    113                 return data;
    114             }
    115             wpc_flat_time_format = true;
    116             // time format
     43}
     44(function ($) {
     45    var local_storage_value = localStorage.getItem('wpc_location');
     46    $("#wpc_location_name option[value='" + local_storage_value + "']").attr("selected", true);
     47
     48    $(document).ready(function () {
     49
     50        // get data from enqueue
     51        var wpc_booking_form_data;   
     52        if ( typeof wpc_form_client_data !=="undefined") {
     53            var wpc_form_data =JSON.parse(wpc_form_client_data);
     54            wpc_booking_form_data = wpc_form_data.settings;
     55        }
     56        // set location in local storage and cancell modal
     57        $(document).on('click', '.wpc-select-location', function () {
     58            var wpc_location = $('.wpc-location option:selected').val();
     59
     60            var local_storage_value = localStorage.getItem('wpc_location');
     61            if (local_storage_value === null) {
     62                localStorage.setItem('wpc_location', wpc_location);
     63            } else {
     64                localStorage.removeItem('wpc_location');
     65                localStorage.setItem('wpc_location', wpc_location);
     66            }
     67            $(".wpc_modal").fadeOut();
     68            $('body').removeClass('wpc_location_popup');
     69
     70        });
     71        var wpc_date_format = "";
     72        var wpc_start_time = "";
     73        var wpc_end_time = "";
     74        var wpc_all_day_start_time = "";
     75        var wpc_all_day_end_time = "";
     76
     77        // convert time 12 to 24
     78        const convertTime12to24 = (time12h) => {
     79            const [time, modifier] = time12h.split(' ');
     80
     81            let [hours, minutes] = time.split(':');
     82
     83            if (hours === '12') {
     84                hours = '00';
     85            }
     86
     87            if (modifier === 'PM') {
     88                hours = parseInt(hours, 10) + 12;
     89            }
     90            return `${hours}:${minutes}`;
     91        }
     92        // calculate time difference
     93        const time_diff = (wpc_end_time, last_time) => {
     94            wpc_end_time = wpc_end_time.replace(',', ':');
     95            var startTime = moment(wpc_end_time, "HH:mm");
     96            var endTime = moment(last_time, "HH:mm");
     97            var duration = moment.duration(startTime.diff(endTime));
     98            var hours = parseInt(duration.asHours());
     99            var minutes = parseInt(duration.asMinutes()) - hours * 60;
     100            return hours + ':' + minutes;
     101        }
     102        // check late booking
     103        const time_diff_for_before_after_equal = (select_time, last_booking_time) => {
     104            var startTime = moment(select_time, "HH:mm");
     105            var endTime = moment(last_booking_time, "HH:mm");
     106            var data;
     107            if (startTime.isBefore(endTime)) {
     108                data = "early";
     109            } else if (startTime.isSame(endTime)) {
     110                data = "equal";
     111            } else if (startTime.isAfter(endTime)) {
     112                data = "late";
     113            } else {
     114                data = "unknown";
     115            }
     116            return data;
     117        }
     118         var wpc_time_format; var wpc_date_format;
     119        // time format
     120        if ( typeof wpc_booking_form_data === "undefined" ){
     121            wpc_time_format = 'HH:mm';
     122            wpc_date_format = 'yyyy-mm-dd'
     123        }
     124        else{
    117125            if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
    118                 wpc_time_format = 'H:i';
    119                 wpc_flat_time_format = true;
     126                wpc_time_format = 'HH:mm';
    120127            } else {
    121                 wpc_time_format = 'h:i K';
    122                 wpc_flat_time_format = false;
     128                wpc_time_format = 'h:mm p';
    123129            }
    124130            // date format
    125             if (wpc_booking_form_data.wpc_date_format != "") {
     131            if ( wpc_booking_form_data.wpc_date_format != "") {
    126132                wpc_date_format = wpc_booking_form_data.wpc_date_format;
    127133            } else {
    128134                wpc_date_format = 'yyyy-mm-dd'
    129135            }
    130             // check weekly and all day schedule
    131             const wpc_weekly_daily_schedule = (selected_day) => {
    132                 // time range for all day
    133                 if (wpc_booking_form_data.wpc_all_day_start_time != "" && wpc_booking_form_data.wpc_all_day_end_time != "") {
    134                     wpc_all_day_start_time = wpc_booking_form_data.wpc_all_day_start_time;
    135                     wpc_all_day_end_time = wpc_booking_form_data.wpc_all_day_end_time;
    136 
     136        }
     137        // check weekly and all day schedule
     138        const wpc_weekly_daily_schedule = (selected_day) => {
     139            // time range for all day
     140            if (wpc_booking_form_data.wpc_all_day_start_time != "" && wpc_booking_form_data.wpc_all_day_end_time != "") {
     141                wpc_all_day_start_time = wpc_booking_form_data.wpc_all_day_start_time;
     142                wpc_all_day_end_time = wpc_booking_form_data.wpc_all_day_end_time;
     143
     144                if (wpc_booking_form_data.wpc_time_format == '24') {
     145                    wpc_start_time = convertTime12to24(wpc_all_day_start_time);
     146                    wpc_end_time = convertTime12to24(wpc_all_day_end_time);
     147                } else {
     148                    wpc_start_time = wpc_all_day_start_time;
     149                    wpc_end_time = wpc_all_day_end_time;
     150                }
     151                $('#wpc-booking-date').removeClass("wpc_booking_error");
     152                button_disable();
     153            }
     154             else {
     155                var weekly_schedule_arr = wpc_booking_form_data.wpc_weekly_schedule;
     156                var weekly_start_time = wpc_booking_form_data.wpc_weekly_schedule_start_time;
     157                var weekly_end_time = wpc_booking_form_data.wpc_weekly_schedule_end_time;
     158                var response = wpc_weekly_schedule_time(weekly_schedule_arr, selected_day, weekly_start_time, weekly_end_time);
     159                if (response.success == true) {
     160                    $("#wpc-from-time").prop('disabled', false);
     161                    $("#wpc-to-time").prop('disabled', false);
    137162                    if (wpc_booking_form_data.wpc_time_format == '24') {
    138                         wpc_start_time = convertTime12to24(wpc_all_day_start_time);
    139                         wpc_end_time = convertTime12to24(wpc_all_day_end_time);
     163                        wpc_start_time = convertTime12to24(response.wpc_start_time);
     164                        wpc_end_time = convertTime12to24(response.wpc_end_time);
    140165                    } else {
    141                         wpc_start_time = wpc_all_day_start_time;
    142                         wpc_end_time = wpc_all_day_end_time;
     166                        wpc_start_time = response.wpc_start_time;
     167                        wpc_end_time = response.wpc_end_time;
    143168                    }
    144169                    $('#wpc-booking-date').removeClass("wpc_booking_error");
    145170                    button_disable();
    146171                } else {
    147                     var weekly_schedule_arr = wpc_booking_form_data.wpc_weekly_schedule;
    148                     var weekly_start_time = wpc_booking_form_data.wpc_weekly_schedule_start_time;
    149                     var weekly_end_time = wpc_booking_form_data.wpc_weekly_schedule_end_time;
    150                     var response = wpc_weekly_schedule_time(weekly_schedule_arr, selected_day, weekly_start_time, weekly_end_time);
    151                     if (response.success == true) {
    152                         $("#wpc-from-time").prop('disabled', false);
    153                         $("#wpc-to-time").prop('disabled', false);
    154                         if (wpc_booking_form_data.wpc_time_format == '24') {
    155                             wpc_start_time = convertTime12to24(response.wpc_start_time);
    156                             wpc_end_time = convertTime12to24(response.wpc_end_time);
     172                    $("#wpc-booking-date").val(" ");
     173                    $('#wpc-booking-date').addClass("wpc_booking_error");
     174                    if (selected_day !== '') {
     175                        alert("No schedule set for the day .");
     176                    }
     177                    $("#wpc-from-time").prop('disabled', true);
     178                    $("#wpc-to-time").prop('disabled', true);
     179                    return "clear_date";
     180                }
     181            }
     182        }
     183        if (typeof wpc_date_format === 'undefined') {
     184            wpc_date_format = 'yyyy-mm-dd';
     185        }
     186
     187        // check late booking
     188        const wpc_check_late_booking = (selected_time, last_booking_time, min) => {
     189            var time_diff_latebooked = time_diff_for_before_after_equal(selected_time, last_booking_time);
     190            if (time_diff_latebooked == 'late') {
     191                $('#wpc-from-time').val(' ');
     192                $('.wpc_error_message').html("");
     193                $('.wpc_error_message').css("display","block");
     194                $('.wpc_error_message').html("You can boook before  " + min + " minutes of closing time .");
     195            } else {
     196                $('.wpc_error_message').html("");
     197                $('.wpc_error_message').css("display","none");
     198                $('#wpc-from-time').removeClass("wpc_booking_error");
     199                button_disable();
     200            }
     201        }
     202        //  from time 
     203        $('#wpc-from-time').timepicker({
     204            timeFormat  : wpc_time_format,
     205            dynamic     : true,
     206            change      : function (time) {
     207                if (time !== null) {
     208                    // the input field
     209                    var element = $(this);
     210                    // get access to this Timepicker instance
     211                    var timepicker = element.timepicker();
     212                    var selected_time     = timepicker.format(time);
     213
     214                    if ( typeof wpc_booking_form_data !== "undefined") {
     215                        var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
     216                        // late bookings
     217                        if (wpc_time_format != 'HH:mm' && typeof wpc_end_time !== 'undefined') {
     218                            wpc_end_time = convertTime12to24(wpc_end_time);
     219                            selected_time = convertTime12to24(selected_time);
     220                        }
     221                        if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
     222                            var last_booking_time = time_diff(wpc_end_time, "00:14");
     223                            if (selected_time !== '' && selected_time !== ',undefined') {
     224                                wpc_check_late_booking(selected_time, last_booking_time, 15);
     225                            }
     226                        } else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
     227                            var last_booking_time = time_diff(wpc_end_time, "00:29");
     228                            if (selected_time !== '' && selected_time !== ',undefined') {
     229                                wpc_check_late_booking(selected_time, last_booking_time, 30);
     230                                return;
     231                            }
     232                        } else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
     233                            var last_booking_time = time_diff(wpc_end_time, "00:44");
     234                            if (selected_time !== '' && selected_time !== ',undefined') {
     235                                wpc_check_late_booking(selected_time, last_booking_time, 45);
     236                            }
    157237                        } else {
    158                             wpc_start_time = response.wpc_start_time;
    159                             wpc_end_time = response.wpc_end_time;
    160                         }
    161                         $('#wpc-booking-date').removeClass("wpc_booking_error");
    162                         button_disable();
    163                     } else {
    164                         $("#wpc-booking-date").val(" ");
    165                         $('#wpc-booking-date').addClass("wpc_booking_error");
    166                         if (selected_day !== '') {
    167                             alert("No schedule set for the day .");
    168                         }
    169                         $("#wpc-from-time").prop('disabled', true);
    170                         $("#wpc-to-time").prop('disabled', true);
    171                         return "clear_date";
    172                     }
    173                 }
    174             }
    175             if (typeof wpc_date_format === 'undefined') {
    176                 wpc_date_format = 'yyyy-mm-dd';
    177             }
    178 
    179             // check late booking
    180             const wpc_check_late_booking = (selected_time, last_booking_time, min) => {
    181                 time_diff_latebooked = time_diff_for_before_after_equal(selected_time, last_booking_time);
    182                 if (time_diff_latebooked == 'late') {
    183                     $('#wpc-from-time').val(' ');
    184                     $('.wpc_error_message').html("");
    185                     $('.wpc_error_message').html("You can boook before  " + min + " minutes of closing time .");
    186                 } else {
    187                     $('.wpc_error_message').html("");
    188                     $('#wpc-from-time').removeClass("wpc_booking_error");
    189                     button_disable();
    190                 }
    191             }
    192             //  from time 
    193             var time_picker_from = $('#wpc-from-time').flatpickr({
    194                 enableTime: true,
    195                 noCalendar: true,
    196                 dateFormat: wpc_time_format,
    197                 time_24hr: wpc_flat_time_format,
    198                 onChange: function (selectedDates, dateStr, instance) {
    199                     var selected_time = wpc_flatpicker_date_change(selectedDates, 'H:i');
    200                     var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
    201                     // late bookings
    202                     if (wpc_time_format != 'H:i' && typeof wpc_end_time !== 'undefined') {
    203                         wpc_end_time = convertTime12to24(wpc_end_time);
    204                         selected_time = convertTime12to24(selected_time);
    205                     }
    206                     if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
    207                         var last_booking_time = time_diff(wpc_end_time, "00:14");
    208                         if (selected_time !== '' && selected_time !== ',undefined') {
    209                             wpc_check_late_booking(selected_time, last_booking_time, 15);
    210                         }
    211                     } else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
    212                         var last_booking_time = time_diff(wpc_end_time, "00:29");
    213                         if (selected_time !== '' && selected_time !== ',undefined') {
    214                             wpc_late_check = wpc_check_late_booking(selected_time, last_booking_time, 30);
    215                             return;
    216                         }
    217                     } else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
    218                         var last_booking_time = time_diff(wpc_end_time, "00:44");
    219                         if (selected_time !== '' && selected_time !== ',undefined') {
    220                             wpc_check_late_booking(selected_time, last_booking_time, 45);
    221                         }
    222                     } else {
     238                            $('#wpc-from-time').removeClass("wpc_booking_error");
     239                            button_disable();
     240                        }
     241                    }
     242                    else{
    223243                        $('#wpc-from-time').removeClass("wpc_booking_error");
    224                         button_disable();
    225                     }
    226                 }
    227             });
    228             //  To
    229             var time_picker_to = $("#wpc-to-time").flatpickr({
    230                 enableTime: true,
    231                 noCalendar: true,
    232                 dateFormat: wpc_time_format,
    233                 time_24hr: wpc_flat_time_format,
    234                 onChange: function (selectedDates, dateStr, instance) {
    235                     var selected_time = wpc_flatpicker_date_change(selectedDates, 'H:i');
    236                     if (selected_time) {
     244                    }
     245                }
     246            }
     247        });
     248        //  To
     249        $("#wpc-to-time").timepicker({
     250            timeFormat  : wpc_time_format,
     251            dynamic     : true,
     252            change      : function( time ) {
     253                if (time !== null) {
     254                    if (time) {
    237255                        $('#wpc-to-time').removeClass("wpc_booking_error");
    238256                        button_disable();
    239257                    }
    240258                }
    241             });
     259            }
     260        });
     261        if ( typeof wpc_booking_form_data !== "undefined") {
    242262            var wpc_early_bookings = wpc_booking_form_data.wpc_early_bookings;
    243263            var wpc_one_day = wpc_booking_form_data.wpc_one_day;
    … …  
    257277                wpc_max_day = false;
    258278            }
    259             var wpc_pro_form_data = $(".wpc-calender-view").html()
    260             inline_value = true;
    261             if (typeof wpc_pro_form_data !== 'undefined' && wpc_pro_form_data == 'no') {
    262                 inline_value = false;
    263             }
    264             // inline flat picker date
    265             if ($('#wpc-booking-date').length > 0) {
    266                 document.getElementById('wpc-booking-date').flatpickr({
    267                     dateFormat: wpc_date_format,
    268                     minDate: "today",
    269                     maxDate: wpc_max_day,
    270                     position: "below",
    271                     inline: inline_value,
    272                     onChange: function (selectedDates, dateStr, instance) {
     279        }
     280        var wpc_pro_form_data = $(".wpc-calender-view").html()
     281        var inline_value = true;
     282        if (typeof wpc_pro_form_data !== 'undefined' && wpc_pro_form_data == 'no') {
     283            inline_value = false;
     284        }
     285        // inline flat picker date
     286        if ($('#wpc-booking-date').length > 0) {
     287            document.getElementById('wpc-booking-date').flatpickr({
     288                dateFormat: wpc_date_format,
     289                minDate: "today",
     290                maxDate: wpc_max_day,
     291                position: "below",
     292                inline: inline_value,
     293                onChange: function (selectedDates, dateStr, instance) {
     294                    if (typeof wpc_booking_form_data !== "undefined") {
    273295                        var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "Y-m-d");
     296                       
    274297                        var exception_date = wpc_booking_form_data.wpc_exception_date;
    275 
    276298                        if (typeof exception_date === "undefined") {
    277299                            var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "D");
    … …  
    302324                            $("#wpc-from-time").prop('disabled', false);
    303325                            $("#wpc-to-time").prop('disabled', false);
    304                             if (wpc_flat_time_format === false) {
     326
     327                            if (wpc_time_format == "h:mm p") {       
    305328                                wpc_start_time = convertTime12to24(wpc_start_time);
    306                                 wpc_end_time = convertTime12to24(wpc_end_time);
     329                                wpc_end_time   = convertTime12to24(wpc_end_time);
    307330                            }
    308                             wpc_start_arr = wpc_start_time.split(":");
    309                             time_picker_to.set({
    310                                 defaultHour: wpc_start_arr[0],
    311                                 defaultMinute: wpc_start_arr[1],
    312                                 minTime: wpc_start_time,
    313                                 maxTime: wpc_end_time
    314                             });
    315                             time_picker_from.set({
    316                                 defaultHour: wpc_start_arr[0],
    317                                 defaultMinute: wpc_start_arr[1],
    318                                 minTime: wpc_start_time,
    319                                 maxTime: wpc_end_time
    320                             });
    321                         }
    322                     }
    323                 });
    324             }
    325             // Food menu tab js
    326             $('.schedule-tab').on('click', openScheduleTab);
    327 
    328             function openScheduleTab() {
    329                 var title = $(this).data('title');
    330                 var i, tabcontent, tablinks;
    331                 tabcontent = document.getElementsByClassName("tabcontent");
    332                 for (i = 0; i < tabcontent.length; i++) {
    333                     tabcontent[i].style.display = "none";
    334                 }
    335                 tablinks = document.getElementsByClassName("tablinks");
    336                 for (i = 0; i < tablinks.length; i++) {
    337                     tablinks[i].className = tablinks[i].className.replace(" active", "");
    338                 }
    339                 document.getElementById(title).style.display = "block";
    340             }
    341 
    342             $('.schedule-tab-shortcode').on('click', openScheduleTabShortCode);
    343 
    344             function openScheduleTabShortCode() {
    345                 var title = $(this).data('title');
    346                 var i, tabcontent, tablinks;
    347                 tabcontent = document.getElementsByClassName("tabcontent-shortcode");
    348                 for (i = 0; i < tabcontent.length; i++) {
    349                     tabcontent[i].style.display = "none";
    350                 }
    351                 tablinks = document.getElementsByClassName("tablinks-shortcode");
    352                 for (i = 0; i < tablinks.length; i++) {
    353                     tablinks[i].className = tablinks[i].className.replace(" active", "");
    354                 }
    355                 let single_title = "shortcode_" + title;
    356                 document.getElementById(single_title).style.display = "block";
    357             }
    358             // reservation form validation
    359             function button_disable() {
    360                 var length = $(".wpc_booking_error").length;
    361                 if (length == 0) {
    362                     $('.reservation_form_submit').prop('disabled', false);
    363                     $('.reservation_form_submit').removeClass('wpc_reservation_form_disabled');
    364                 } else {
    365                     $('.reservation_form_submit').prop('disabled', true);
    366                     $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
    367                 }
    368             }
    369             $(document).on("keyup", "input[name='wpc_name']", function () {
    370                 $(this).removeClass("wpc_booking_error");
     331                            $('#wpc-from-time').timepicker('option','minTime', wpc_start_time);
     332                            $('#wpc-from-time').timepicker('option','maxTime', wpc_end_time);
     333
     334                            $('#wpc-to-time').timepicker('option','minTime', wpc_start_time);
     335                            $('#wpc-to-time').timepicker('option','maxTime', wpc_end_time);
     336                        }
     337                    }
     338                    else{
     339                        $('#wpc-booking-date').removeClass("wpc_booking_error");
     340                    }
     341                }
     342            });
     343        }
     344        // Food menu tab js
     345        $('.schedule-tab').on('click', openScheduleTab);
     346
     347        function openScheduleTab() {
     348            var title = $(this).data('title');
     349            var i, tabcontent, tablinks;
     350            tabcontent = document.getElementsByClassName("tabcontent");
     351            for (i = 0; i < tabcontent.length; i++) {
     352                tabcontent[i].style.display = "none";
     353            }
     354            tablinks = document.getElementsByClassName("tablinks");
     355            for (i = 0; i < tablinks.length; i++) {
     356                tablinks[i].className = tablinks[i].className.replace(" active", "");
     357            }
     358            document.getElementById(title).style.display = "block";
     359        }
     360
     361        $('.schedule-tab-shortcode').on('click', openScheduleTabShortCode);
     362
     363        function openScheduleTabShortCode() {
     364            var title = $(this).data('title');
     365            var i, tabcontent, tablinks;
     366            tabcontent = document.getElementsByClassName("tabcontent-shortcode");
     367            for (i = 0; i < tabcontent.length; i++) {
     368                tabcontent[i].style.display = "none";
     369            }
     370            tablinks = document.getElementsByClassName("tablinks-shortcode");
     371            for (i = 0; i < tablinks.length; i++) {
     372                tablinks[i].className = tablinks[i].className.replace(" active", "");
     373            }
     374            let single_title = "shortcode_" + title;
     375            document.getElementById(single_title).style.display = "block";
     376        }
     377        // reservation form validation
     378        function button_disable() {
     379            var length = $(".wpc_booking_error").length;
     380            if (length == 0) {
     381                $('.reservation_form_submit').prop('disabled', false);
     382                $('.reservation_form_submit').removeClass('wpc_reservation_form_disabled');
     383            } else {
     384                $('.reservation_form_submit').prop('disabled', true);
     385                $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
     386            }
     387        }
     388        var check_selected_val = $("#wpc-party option:selected").val();
     389       
     390        if (check_selected_val =='' ) {
     391            $("#wpc-party").addClass('wpc_booking_error');
     392        }
     393
     394        var booking_field = [ "input[name='wpc_name']", "input[name='wpc_email']" ];
     395
     396        $("input").not(':button').each(function () {
     397            if ( $(this).attr('name') == 'wpc_phone' && $(this).prop('required') ) {
     398                $(this).addClass("wpc_booking_error");
     399                booking_field.push( "input[name='wpc_phone']" );
     400            }
     401            if ($(this).attr('name') == 'wpc_booking_date' || $(this).attr('name') == 'wpc_from_time' ||
     402                $(this).attr('name') == 'wpc_to_time' || $(this).attr('name') == 'wpc_name' ||
     403                $(this).attr('name') == 'wpc_email'
     404            ) {
     405                $(this).addClass("wpc_booking_error");
     406            }
     407            if ($(this).attr('name') == 'wpc_reservation_invoice' || $(this).attr('name') == 'wpc_cancell_email') {
     408                $(this).addClass("wpc_cancell_error");
     409            }
     410        });
     411
     412        $.each(booking_field, function( index, value ) {
     413            $(document).on("keyup", value , function () {
     414                if ( $(this).val().length == 0 ) {
     415                    $(this).addClass("wpc_booking_error");
     416                   
     417                }else{
     418                    $(this).removeClass("wpc_booking_error");
     419                }
    371420                button_disable();
    372421            });
    373             $(document).on("keyup", "input[name='wpc_email']", function () {
    374                 $(this).removeClass("wpc_booking_error");
    375                 button_disable();
    376             });
    377             $("input").not(':button').each(function () {
    378                 if ($(this).attr('name') == 'wpc_booking_date' || $(this).attr('name') == 'wpc_from_time' ||
    379                     $(this).attr('name') == 'wpc_to_time' || $(this).attr('name') == 'wpc_name' ||
    380                     $(this).attr('name') == 'wpc_email'
    381                 ) {
    382                     $(this).addClass("wpc_booking_error");
    383                 }
    384                 if ($(this).attr('name') == 'wpc_reservation_invoice' || $(this).attr('name') == 'wpc_cancell_email' ||
    385                     $(this).attr('name') == 'wpc_cancell_phone'
    386                 ) {
    387                     $(this).addClass("wpc_cancell_error");
    388                 }
    389 
    390             });
    391 
    392             var booking_length = $(".wpc_booking_error").length;
    393             if (booking_length > 0) {
    394                 $('.reservation_form_submit').prop('disabled', true);
    395                 $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
    396             }
    397             // reservation cancell
    398             function cancell_button_disable() {
    399                 var length = $(".wpc_cancell_error").length;
    400                 if (length == 0) {
    401                     $('.cancell_form_submit').prop('disabled', false);
    402                     $('.cancell_form_submit').removeClass('wpc_cancell_form_submit_disabled');
    403 
    404                 } else {
    405                     $('.cancell_form_submit').prop('disabled', true);
    406                     $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
    407 
    408                 }
    409             }
    410             var cancell_length = $(".wpc_cancell_error").length;
    411             if (cancell_length > 0) {
     422          });
     423
     424        $(document).on("change", "#wpc-party", function () {
     425            if ( $(this).val() == "" ) {
     426                $(this).addClass( "wpc_booking_error" );
     427            }
     428            else{
     429                $(this).removeClass( "wpc_booking_error" );
     430            }
     431            button_disable();
     432        });
     433
     434        var booking_length = $(".wpc_booking_error").length;
     435        if (booking_length > 0) {
     436            $('.reservation_form_submit').prop('disabled', true);
     437            $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
     438        }
     439        // reservation cancell
     440        function cancell_button_disable() {
     441            var length = $(".wpc_cancell_error").length;
     442            if (length == 0) {
     443                $('.cancell_form_submit').prop('disabled', false);
     444                $('.cancell_form_submit').removeClass('wpc_cancell_form_submit_disabled');
     445
     446            } else {
    412447                $('.cancell_form_submit').prop('disabled', true);
    413448                $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
    414449
    415450            }
    416             $(document).on("keyup", "input[name='wpc_reservation_invoice']", function () {
    417                 $(this).removeClass("wpc_cancell_error");
     451        }
     452        var cancell_length = $(".wpc_cancell_error").length;
     453        if (cancell_length > 0) {
     454            $('.cancell_form_submit').prop('disabled', true);
     455            $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
     456
     457        }
     458        var cancell_form_field = ["input[name='wpc_reservation_invoice']","input[name='wpc_cancell_email']"];
     459       
     460        $.each( cancell_form_field , function( index , value ){
     461            $(document).on( "keyup", value , function () {
     462                if ($(this).val().length === 0 ) {
     463                    $(this).addClass("wpc_cancell_error");
     464                }else{
     465                    $(this).removeClass("wpc_cancell_error");
     466                }
    418467                cancell_button_disable();
    419468            });
    420             $(document).on("keyup", "input[name='wpc_cancell_email']", function () {
    421                 $(this).removeClass("wpc_cancell_error");
    422                 cancell_button_disable();
    423             });
    424             $(document).on("keyup", "input[name='wpc_cancell_phone']", function () {
    425                 $(this).removeClass("wpc_cancell_error");
    426                 cancell_button_disable();
    427             });
    428 
    429             // modal on tab
    430             if (document.querySelector('.wpc_modal') !== null) {
    431                 $(".wpc_modal").fadeIn();
    432                 $('body').addClass("wpc_location_popup");
    433 
    434             }
    435             $(document).on('click', '.wpc-close', function () {
     469        })
     470
     471        // modal on tab
     472        if (document.querySelector('.wpc_modal') !== null) {
     473            $(".wpc_modal").fadeIn();
     474            $('body').addClass("wpc_location_popup");
     475
     476        }
     477        $(document).on('click', '.wpc-close', function () {
     478            $(".wpc_modal").fadeOut();
     479            $('body').removeClass("wpc_location_popup");
     480        });
     481
     482        $(document).on('mouseup', function (e) {
     483            var container = $("#wpc_location_modal");
     484            if (!container.is(e.target) && container.has(e.target).length === 0) {
    436485                $(".wpc_modal").fadeOut();
    437486                $('body').removeClass("wpc_location_popup");
    438             });
    439 
    440             $(document).on('mouseup', function (e) {
    441                 var container = $("#wpc_location_modal");
    442                 if (!container.is(e.target) && container.has(e.target).length === 0) {
    443                     $(".wpc_modal").fadeOut();
    444                     $('body').removeClass("wpc_location_popup");
    445                 }
    446             });
    447 
    448             // reservation from show /hide
    449             $(document).on('click', '#wpc_cancel_request', function () {
    450                 $('.wpc-reservation-form .wpc_reservation_table').slideUp();
    451                 $('.wpc-reservation-form .wpc_reservation_cancel_form').slideDown();
    452             });
    453             $(document).on('click', '#wpc_book_table', function () {
    454                 $('.wpc-reservation-form .wpc_reservation_cancel_form').slideUp();
    455                 $('.wpc-reservation-form .wpc_reservation_table').slideDown();
    456             });
    457 
    458             // cart icon open
    459             $(document).on('click', '.wpc_cart_icon', function (event) {
    460                 event.preventDefault();
    461 
    462                 $('.wpc_cart_block').toggleClass('cart_icon_active');
    463             });
    464 
    465             $(document).on('mouseup', function (e) {
    466                 var container = $(".wpc_cart_block");
    467                 if (!container.is(e.target) && container.has(e.target).length === 0) {
    468                     container.removeClass('cart_icon_active');
    469                 }
    470             });
    471 
    472             //   custom tabs
    473             $(document).on('click', '.wpc-tab-a', function (event) {
    474                 event.preventDefault();
    475                 $(this).parent().parent().parent().find(".wpc-tab").removeClass('tab-active');
    476                 $(".wpc-tab[data-id='" + $(this).attr('data-id') + "']").addClass("tab-active");
    477                 $(".wpc-tab-a").removeClass('wpc-active');
    478                 $(this).parent().find(".wpc-tab-a").addClass('wpc-active');
    479             });
    480 
     487            }
     488        });
     489
     490        // reservation from show /hide
     491        $(document).on('click', '#wpc_cancel_request', function () {
     492            $('.wpc-reservation-form .wpc_reservation_table').slideUp();
     493            $('.wpc-reservation-form .wpc_reservation_cancel_form').slideDown();
     494        });
     495        $(document).on('click', '#wpc_book_table', function () {
     496            $('.wpc-reservation-form .wpc_reservation_cancel_form').slideUp();
     497            $('.wpc-reservation-form .wpc_reservation_table').slideDown();
     498        });
     499
     500        // cart icon open
     501        $(document).on('click', '.wpc_cart_icon', function (event) {
     502            event.preventDefault();
     503
     504            $('.wpc_cart_block').toggleClass('cart_icon_active');
     505        });
     506
     507        $(document).on('mouseup', function (e) {
     508            var container = $(".wpc_cart_block");
     509            if (!container.is(e.target) && container.has(e.target).length === 0) {
     510                container.removeClass('cart_icon_active');
     511            }
     512        });
     513
     514        //   custom tabs
     515        $(document).on('click', '.wpc-tab-a', function (event) {
     516            event.preventDefault();
     517            $(this).parent().parent().parent().find(".wpc-tab").removeClass('tab-active');
     518            $(".wpc-tab[data-id='" + $(this).attr('data-id') + "']").addClass("tab-active");
     519            $(".wpc-tab-a").removeClass('wpc-active');
     520            $(this).parent().find(".wpc-tab-a").addClass('wpc-active');
     521        });
     522        if (typeof wpc_form_data !=='undefined') {
    481523            // reservation form submit
    482524            var wpc_ajax_url = wpc_form_data.wpc_ajax_url;
    483525            var wpc_reservation_form_nonce = wpc_form_data.wpc_reservation_form_nonce;
    484526            $(".reservation_form_submit").on('click', function (e) {
    485                 e.preventDefault();
    486                 wpc_reservation_first = $(".reservation_form_first_step").val();
     527                e.preventDefault(); var wpc_diff_data="";
     528                var wpc_reservation_first = $(".reservation_form_first_step").val();
    487529                if (typeof wpc_reservation_first !== 'undefined' && wpc_reservation_first == 'reservation_form_first_step') {
    488                     wpc_name = $("#wpc-name").val();
    489                     wpc_email = $("#wpc-email").val();
    490                     wpc_phone = $("#wpc-phone").val();
    491                     wpc_booking_date = $("#wpc-booking-date").val();
    492                     wpc_from_time = $("#wpc-from-time").val();
    493                     wpc_to_time = $("#wpc-to-time").val();
    494                     wpc_guest_count = $("#wpc-party option:selected").val();
    495                     wpc_message = $("#wpc-message").val();
     530                    var wpc_name            = $("#wpc-name").val();
     531                    var wpc_email          = $("#wpc-email").val();
     532                    var wpc_phone          = $("#wpc-phone").val();
     533                    var wpc_booking_date    = $("#wpc-booking-date").val();
     534                    var wpc_from_time      = $("#wpc-from-time").val();
     535                    var wpc_to_time        = $("#wpc-to-time").val();
     536                    var wpc_guest_count    = $("#wpc-party option:selected").val();
     537                    var wpc_message        = $("#wpc-message").val();
    496538
    497539                    if (wpc_booking_form_data.wpc_time_format == '12') {
    … …  
    507549                        $('.wpc_log_message').html('');
    508550                        $('.wpc_error_message').fadeIn('slow');
    509                         $('.wpc_error_message').html("End time must be after start time.");
     551                        $('.wpc_error_message').html("Booking end time must be before start time.");
    510552                    } else {
    511553                        $('.wpc_error_message').html('');
    … …  
    527569            $(".cancell_form_submit,.confirm_booking_btn").on('click', function (e) {
    528570                e.preventDefault();
    529                 wpc_invoice = $(".wpc-invoice").val();
    530                 if (wpc_invoice !== '' && typeof wpc_invoice !== "undefined") {
    531                     wpc_email = $(".wpc_cancell_email").val();
    532                     wpc_phone = $(".wpc_cancell_phone").val();
    533                     wpc_message = $(".wpc_cancell_message").val();
     571
     572                var wpc_invoice = $(".wpc-invoice").val();
     573                var wpc_email = $(".wpc_cancell_email").val();
     574                if ( typeof wpc_invoice !== "undefined" && ( wpc_invoice !== '' && wpc_email !=='' ) ) {
     575                   
     576                    var wpc_phone = $(".wpc_cancell_phone").val();
     577                    var wpc_message = $(".wpc_cancell_message").val();
    534578                    var data = {
    535579                        action: 'wpc_check_for_submission',
    … …  
    541585                        wpc_action: 'wpc_cancellation',
    542586                    }
    543                 } else {
    544                     reservation_form_second_step = $(this).data('id');
     587                }
     588                 else {
     589                    var reservation_form_second_step = $(this).data('id');
    545590                    if (typeof reservation_form_second_step !== 'undefined' && reservation_form_second_step == 'reservation_form_second_step') {
    546                         wpc_name = $(".wpc_check_name").text();
    547                         wpc_email = $(".wpc_check_email").text();
    548                         wpc_phone = $(".wpc_check_phone").text();
    549                         wpc_guest_count = $(".wpc_check_guest").text();
    550                         wpc_from_time = $(".wpc_check_start_time").text();
    551                         wpc_to_time = $(".wpc_check_end_time").text();
    552                         wpc_booking_date = $(".wpc_check_booking_date").text();
    553                         wpc_message = $(".wpc_check_message").text();
     591                        var wpc_name            = $(".wpc_check_name").text();
     592                        var wpc_email          = $(".wpc_check_email").text();
     593                        var wpc_phone          = $(".wpc_check_phone").text();
     594                        var wpc_guest_count    = $(".wpc_check_guest").text();
     595                        var wpc_from_time      = $(".wpc_check_start_time").text();
     596                        var wpc_to_time        = $(".wpc_check_end_time").text();
     597                        var wpc_booking_date    = $(".wpc_check_booking_date").text();
     598                        var wpc_message        = $(".wpc_check_message").text();
    554599                        var data = {
    555600                            action: 'wpc_check_for_submission',
    … …  
    597642                        else if (response.data.data.form_type == 'wpc_reservation_cancell' &&
    598643                        ($.isArray(response.data.message) && response.data.message.length>0) ) {
     644                            // console.log(response.data);
    599645                            $('.wpc_error_message').css('display', 'none');
    600646                            $('.wpc_error_message').html('');
    … …  
    605651                            $(".wpc_cancell_message").val("");
    606652                            $(".wpc-invoice").val("");
    607                             $(".cancell_form_submit").fadeOut('slow');
     653                            if (response.data.status_code === 200) {
     654                                $(".cancell_form_submit").fadeOut('slow');
     655                            }
     656                           
    608657                        }
    609658                        else if (response.data.data.form_type == 'wpc_reservation_cancell_field_missing' &&
    610659                            ($.isArray(response.data.message) && response.data.message.length>0) ) {
     660                            console.log("else");
    611661                            $('.wpc_error_message').css('display', 'block');
    612662                            $('.wpc_cancell_log_message').css('display', 'none');
    … …  
    620670            $('.single_add_to_cart_button').click(function (e) {
    621671                e.preventDefault();
    622                 $thisbutton = $(this)
     672                var $thisbutton = $(this)
    623673                var product_id = $(this).val();
    624674                var quantity = $('input[name="quantity"]').val();
    625675                var variation_id = $('input[name="variation_id"]').val();
    626676                var id_arr = [];
    627                 quantity_arr = [];
     677                var quantity_arr = [];
    628678                if (typeof quantity === 'undefined') {
    629679                    $('input[name^="quantity"]').each(function () {
    … …  
    679729                    success: function (results) {
    680730                        $( document.body ).trigger( 'wc_fragment_refresh' );
    681                         $('#wpc-mini-cart-count').html("");
    682                         $('#wpc-mini-cart-count').html(results.data.wpc_count);
    683                         $('.widget_shopping_cart_content').html("");
    684                         $('.widget_shopping_cart_content').html(results.data.wpc_cart_content);
    685                         $('.single_add_to_cart_button').removeClass('adding-cart');
    686731                    }
    687732                });
    688733            });
    689         });
     734        }
     735        // back to edit form
    690736        $(".edit_booking_btn").on('click', function (e) {
    691737            e.preventDefault();
    … …  
    694740            $(".wpc_reservation_form_one").fadeIn('slow');
    695741        });
    696 
    697     })(jQuery);
     742    });
     743})(jQuery);
  • wp-cafe/tags/1.0.6/assets/scss/wpc-admin.scss

    r2335589 r2358899  
    109109                }
    110110        }
    111 
    112         .wpc_weekly_clear,
    113         .wpc_all_day_clear,
    114           .wpc_delivery_weekly_clear,
    115           .exception_time_clear,
    116         .wpc_pickup_weekly_clear {
    117                 line-height: 40px;
    118                 cursor     : pointer;
    119                 color      : $secondary-color;
    120                 font-size  : 14px;
    121         }
    122 
    123111        //   checkbox style
    124112        .wpc-weekly-schedule-list {
  • wp-cafe/tags/1.0.6/core/action/wpc-action.php

    r2335589 r2358899  
    3232     */
    3333    public function wpc_store( $form_id, $form_setting ) {
    34 
    3534        if ( !current_user_can( 'manage_options' ) ) {
    3635            return;
  • wp-cafe/tags/1.0.6/core/action/wpc-ajax-action.php

    r2343218 r2358899  
    176176            //check if all required fields are given
    177177            //else show a message
    178             if ( $invoice_no && $wpc_phone && $wpc_email ) {
     178            if ( $invoice_no && $wpc_email ) {
    179179                $args = [
    180180                    'post_type'      => 'wpc_reservation',
    … …  
    188188                            'key'   => 'wpc_email',
    189189                            'value' => $wpc_email,
    190                         ],
    191                         [
    192                             'key'   => 'wpc_phone',
    193                             'value' => $wpc_phone,
    194                         ],
     190                        ]
    195191                    ],
    196192                ];
    … …  
    244240
    245241            }
    246            
    247             // mini cart content
    248             $wpc_cart_content = '';
    249             $items            = WC()->cart->get_cart();
    250             global $woocommerce;
    251             $item_count = $woocommerce->cart->cart_contents_count;
    252             foreach ( $items as $item => $values ) {
    253                 $variation = $values['variation_id'];
    254                 if ( $variation ) {
    255                     $wpc_thumbnail = get_the_post_thumbnail( $values['variation_id'], 'thumbnail' );
    256                     $product_id    = $values['variation_id'];
    257                     $get_data      = $values['data']->get_data();
    258                     $product_title = $get_data['name'];
    259                 } else {
    260                     $wpc_thumbnail = get_the_post_thumbnail( $values['product_id'], 'thumbnail' );
    261                     $product_id    = $values['product_id'];
    262                     $product_title = $values['data']->get_title();
    263                 }
    264 
    265                 $currency     = get_woocommerce_currency_symbol();
    266 
    267                 $_woo_product = wc_get_product( $product_id );
    268 
    269                 $price_div    = '';
    270                 if ( wc_get_price_including_tax( $_woo_product ) ) {
    271                     $price_div .= '× ' . $currency . ' ' . wc_get_price_including_tax( $_woo_product );
    272                 }
    273                 else {
    274                     $price_div .= ' × ' . $currency . ' ' . wc_get_price_excluding_tax( $_woo_product );
    275                 }
    276 
    277                 $wpc_cart_content .= '
    278                         <ul class="woocommerce-mini-cart cart_list product_list_widget ">
    279                             <li class="woocommerce-mini-cart-item mini_cart_item">
    280                                 ' . $wpc_thumbnail . '
    281                                 <a>' . $product_title . '</a>
    282                                 ' .
    283                 sprintf(
    284                     '<a href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-product_sku="%s" data-cart_item_key="%s">&times;</a>',
    285                     esc_url( wc_get_cart_remove_url( $item ) ),
    286                     esc_html__( 'Remove this item', 'woocommerce' ),
    287                     esc_attr( $values['product_id'] ),
    288                     esc_attr( $_woo_product->get_sku() ),
    289                     esc_attr( $item )
    290                 )
    291                     . '
    292                                 <span class="quantity">' . $values['quantity'] . '
    293                                     <span class="woocommerce-Price-amount amount">' . $price_div . '</span>
    294                                 </span>
    295                             </li>
    296                         </ul>';
    297             }
    298 
    299             $wpc_cart_content .= '
    300                     <p class="woocommerce-mini-cart__total total">
    301                         <strong>Subtotal</strong>
    302                         <span class="woocommerce-Price-amount amount">
    303                             ' . WC()->cart->get_cart_total() . '
    304                         </span>
    305                     </p> ';
    306             $cart_url     = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : $woocommerce->cart->get_cart_url();
    307             $checkout_url = function_exists( 'get_checkout_url' ) ? $woocommerce->cart->get_checkout_url() : $woocommerce->cart->wc_get_checkout_url;
    308             $wpc_cart_content .= '
    309                     <p class="woocommerce-mini-cart__buttons buttons">
    310                         <a href="' . $cart_url . '" class="button wc-forward">View Cart</a>
    311                         <a href="' . $checkout_url . '" class="button checkout wc-forward">Checkout</a>
    312                     </p>';
    313242            wp_send_json_success( [
    314                 'wpc_count' => $item_count, 'wpc_cart_content' => $wpc_cart_content] );
     243                'message' => ['success'], 'data' => [] ] );
    315244        }
    316245        die();
  • wp-cafe/tags/1.0.6/core/base/wpc-settings-field.php

    r2335589 r2358899  
    77
    88class Wpc_Settings_Field {
     9
    910    use Wpc_Singleton;
    1011
    1112    private $key_settings_option;
    12     public $response_message;
    1313
    1414    /**
    … …  
    2929    }
    3030
     31    public function compare_time( $start_arr , $end_arr ){
     32        $time_checking_error = false;
     33        if ( ( is_array( $start_arr ) && count( $start_arr  )>0 && $start_arr [0] !== "" ) && ( is_array($end_arr) && count( $end_arr )>0 && $end_arr[0] !== ""  ) ) {
     34            for ($i=0; $i < count( $start_arr ); $i++) {
     35                if ( $start_arr[$i] >= $end_arr[$i] ) {
     36                    $time_checking_error = true;
     37                }
     38            }
     39        }
     40        return $time_checking_error;
     41    }
     42    public function check_validation( $request ){
     43        // weekly schedule time checking
     44        $weekly_time_error = $this->compare_time( $request['wpc_weekly_schedule_start_time'] ,$request['wpc_weekly_schedule_end_time'] );
     45        // exce schedule time checking
     46        $exception_time_error = $this->compare_time( $request['wpc_exception_start_time'] ,$request['wpc_exception_end_time'] );
     47       
     48        apply_filters("wpcafe/settings/validation",$request);
     49
     50       switch ($request) {
     51           case $request['wpc_min_guest_no'] >= $request['wpc_max_guest_no']:
     52                add_settings_error( "validation_error", 701 , esc_html__( "Minimum guest no. can't be grater than or equal maximum guest no." , "wpcafe"), "error" );
     53                 return false;
     54            break;
     55
     56            case ( ! ( $request['wpc_min_guest_no'] <= $request['wpc_default_gest_no'] ) || ! ( $request['wpc_default_gest_no'] <= $request['wpc_max_guest_no'] ) ) :
     57                add_settings_error( "validation_error", 701 , esc_html__( "Default guest no. must be in between minimum and  maximum guest no." , "wpcafe"), "error" );
     58                 return false;
     59            break;
     60
     61            case  ( ( ( isset($request['wpc_all_day_start_time']) && isset($request['wpc_all_day_end_time']) && $request['wpc_all_day_start_time']!== "" && $request['wpc_all_day_end_time']!== "") && $request['wpc_all_day_start_time'] >= $request['wpc_all_day_end_time'] ) || $exception_time_error == true || $weekly_time_error == true ) :
     62                add_settings_error( "validation_error", 701 , esc_html__( "Schedule start time can't be grater than or equal end time" , "wpcafe"), "error" );
     63                 return false;
     64            break;
     65
     66           default:
     67                return true;
     68            break;
     69       }
     70    }
    3171    public function form_handler() {
    3272
    … …  
    3878            }
    3979
    40             $status = \WpCafe\Core\Action\Wpc_Action::instance()->wpc_store( -1, $request );
    41             return $status;
     80            $data = $this->check_validation( $request );
     81           
     82            if ($data == false) {
     83                return false;
     84            }
     85            return \WpCafe\Core\Action\Wpc_Action::instance()->wpc_store( -1, $request );
    4286        }
    4387    }
  • wp-cafe/tags/1.0.6/core/enqueue/wpc-enqueue.php

    r2335589 r2358899  
    4343                'deps'    => ['jquery'],
    4444            ],
     45            'wpc-jquery-timepicker' => [
     46                'src'     => WPC_ASSETS . 'js/jquery.timepicker.min.js',
     47                'version' => WPC_VERSION,
     48                'deps'    => ['jquery'],
     49            ],
    4550            'wpc-ui-js'      => [
    4651                'src'     => WPC_ASSETS . 'js/wpc-ui.min.js',
    … …  
    6570            'wpc-flatpicker' => [
    6671                'src'     => WPC_ASSETS . 'css/flatpickr.min.css',
     72                'version' => WPC_VERSION,
     73            ],
     74            'wpc-jquery-timepicker' => [
     75                'src'     => WPC_ASSETS . 'css/jquery.timepicker.min.css',
    6776                'version' => WPC_VERSION,
    6877            ],
    … …  
    111120        // locallize for admin
    112121        $form_data = $this->wpc_settings_obj();
    113         wp_localize_script( 'wpc-admin-js', 'wpc_client_booking_form_data', json_encode( $form_data ) );
     122        wp_localize_script( 'wpc-admin-js', 'wpc_form_data', $form_data );
    114123    }
    115124
    … …  
    183192                'deps'    => ['jquery'],
    184193            ],
     194            'wpc-jquery-timepicker' => [
     195                'src'     => WPC_ASSETS . 'js/jquery.timepicker.min.js',
     196                'version' => WPC_VERSION,
     197                'deps'    => ['jquery'],
     198            ],
    185199            'wpc-public'     => [
    186200                'src'     => WPC_ASSETS . 'js/wpc-public.js',
    … …  
    200214            'wpc-flatpicker' => [
    201215                'src'     => WPC_ASSETS . 'css/flatpickr.min.css',
     216                'version' => WPC_VERSION,
     217            ],
     218            'wpc-jquery-timepicker' => [
     219                'src'     => WPC_ASSETS . 'css/jquery.timepicker.min.css',
    202220                'version' => WPC_VERSION,
    203221            ],
    … …  
    244262        $form_data['wpc_reservation_form_nonce']        = wp_create_nonce( 'wpc_reservation_form_nonce' );
    245263        $form_data['wpc_single_add_to_cart_form_nonce'] = wp_create_nonce( 'wpc_single_add_to_cart_form_nonce' );
    246 
    247         wp_localize_script( 'wpc-public', 'wpc_client_booking_form_data', json_encode( $form_data ) );
     264        wp_localize_script( 'wpc-public', 'wpc_form_client_data', json_encode( $form_data ) );
    248265    }
    249266
  • wp-cafe/tags/1.0.6/core/report/wpc-reservation-report.php

    r2335589 r2358899  
    1717        add_action( "manage_wpc_reservation_posts_custom_column",
    1818            [$this, 'wpc_reservation_custom_column'], 10, 2 );
     19        // search by invoice
     20        add_filter('pre_get_posts', [$this, 'reservation_filter_request_query']);
     21        add_filter('search-submit', 'reservation_search_form_text');
    1922    }
    2023
    … …  
    4750     * @return void
    4851     */
    49     function wpc_reservation_custom_column( $column, $post_id ) {
     52    public function wpc_reservation_custom_column( $column, $post_id ) {
    5053
    5154        switch ( $column ) {
    … …  
    7780        }
    7881    }
     82
     83    /**
     84     * search button text
     85     */
     86    public function reservation_search_form_text( $text ){
     87        return esc_attr("test");
     88    }
     89
     90    /**
     91     * Search by invoice function
     92     *
     93     */
     94    public function reservation_filter_request_query($query){
     95        if (!(is_admin()) && $query->is_main_query()) {
     96            return $query;
     97        }
     98        $search_value = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
     99        if (!isset($query->query['post_type']) || ('wpc_reservation' !== $query->query['post_type']) || !isset($search_value)) {
     100            return $query;
     101        }
     102        // var_dump(get_query_var( 's' ));die;
     103        // if (!isset($query->query_vars['meta_query'])) {
     104        //     $query->query_vars['meta_query'] = array();
     105        //     $query->set('meta_key', 'wpc_reservation_invoice');
     106        //     $query->set('meta_value', $search_value);
     107        // }
     108        // setup this functions meta values
     109        // $meta = array(
     110        //     'key'       =>   'wpc_reservation_invoice',
     111        //     'value'     =>   $search_value,
     112        //     'compare'   =>  '=',
     113        // );
     114        // append to meta_query array
     115        // $query->query_vars['meta_query'][]= $meta;
     116        // echo "<pre>";
     117        // var_dump($query);die;
     118        if ( get_query_var( 's' ) && $query->is_main_query() ) {
     119            $query->set( 'post_type', 'wpc_reservation' );
     120            $query->set( 'post_status', 'publish' );
     121            $meta_query[] =
     122            //  array(
     123                array(
     124                    'key'       => 'wpc_reservation_invoice',
     125                    'value'     => $search_value,
     126                    'compare'   => 'LIKE'
     127                );
     128            // );
     129   
     130            $query->set( 'meta_query', $meta_query );
     131        }
     132        // echo "<pre>";
     133        // var_dump($query);die;
     134
     135        return $query;
     136    }
    79137}
  • wp-cafe/tags/1.0.6/core/template/wpc-key-options.php

    r2341364 r2358899  
    9292                            $check_wpc_user_notification_for_cancel_req   =  (isset($settings['wpc_user_notification_for_cancel_req']) ? 'checked' : '');
    9393                           
    94                             $wpc_booking_confirmed =  __('Thank you for  booking. Your booking is confirmed.Please check your email to get invoice no.','wpcafe');
     94                            $wpc_booking_confirmed =  esc_html__('Thank you for  booking. Your booking is confirmed.Please check your email to get invoice no.','wpcafe');
    9595                            $wpc_booking_confirmed_message = $wpc_booking_confirmed;
    96                             $wpc_pending = __('Thank you for  booking. Your booking is pending. Please check your email to get invoice no.','wpcafe');
     96                            $wpc_pending = esc_html__('Thank you for  booking. Your booking is pending. Please check your email to get invoice no.','wpcafe');
    9797                            $wpc_pending_message = $wpc_pending;
    9898
    … …  
    121121                                <div id='<?php echo esc_attr( $item );?>' data-id='tab_<?php echo esc_attr( $item ); ?>' class='tab-pane <?php echo esc_attr( $active_class );?>'>
    122122                                <?php
    123                                     if ( isset( $wpc_doc_link[$item] ) ) {
    124                                         ?>
     123                                    if ( isset( $wpc_doc_link[$item] ) ) { ?>
    125124                                         <!-- documentation link -->
    126                                         <div class="mb-2"><?php echo Wpc_Utilities::wpc_kses( $wpc_doc_link[$item]); ?></div>
     125                                        <div class="mb-2"><?php echo Wpc_Utilities::wpc_kses( $wpc_doc_link[$item] ); ?></div>
    127126                                        <?php
    128127                                    }
    … …  
    162161                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Wed]" class="wed" id="wed<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_wed ); ?> /> <label for="wed<?php echo esc_html($index); ?>"><?php echo esc_html__('Wed', $this->textdomain); ?></label>
    163162                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Thu]" class="thu" id="thu<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_thu ); ?> /> <label for="thu<?php echo esc_html($index); ?>"><?php echo esc_html__('Thu', $this->textdomain); ?></label>
    164                                                                         <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Fri]" class="fri" id="fri<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_fri ); ?> /> <label for="fri<?php  echo esc_html($index); ?>"><?php echo esc_html__('Fri', $this->textdomain); ?></label> 
     163                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Fri]" class="fri" id="fri<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_fri ); ?> /> <label for="fri<?php  echo esc_html($index); ?>"><?php echo esc_html__('Fri', $this->textdomain); ?></label>
    165164                                                                    </div>
    166165                                                                    <div class="wpc-schedule-field">
    167166                                                                        <input type="text"  name="wpc_weekly_schedule_start_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_schedule['wpc_weekly_schedule_start_time'][ $index ] ); ?>" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_<?php echo Wpc_Utilities::wpc_numeric($index) ?> ml-2 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    168167                                                                        <input type="text"  name="wpc_weekly_schedule_end_time[]"   value="<?php echo Wpc_Utilities::wpc_render( $wpc_schedule['wpc_weekly_schedule_end_time'][ $index ] ); ?>" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_<?php echo Wpc_Utilities::wpc_numeric($index) ?> ml-2 wpc-settings-input attr-form-control" placeholder="End time"/>
    169                                                                         <div class="wpc_weekly_clear wpc_weekly_clear_0" id="<?php echo Wpc_Utilities::wpc_numeric($index) ?>" >clear</div>                                                                     
     168                                                                        <div class="wpc_weekly_clear" id="<?php echo Wpc_Utilities::wpc_numeric($index) ?>" >clear</div>                                                                     
    170169                                                                    </div>
    171170                                                                    <?php if( $index != 0 ) { ?>
    … …  
    192191                                                                    <input type="text" name="wpc_weekly_schedule_start_time[]" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_0 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    193192                                                                    <input type="text" name="wpc_weekly_schedule_end_time[]" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_0 wpc-settings-input attr-form-control"  placeholder="End time"/>
    194                                                                     <div class="wpc_weekly_clear" id="0" >clear</div>                                                                     
     193                                                                    <div class="wpc_weekly_clear" id="0" >clear</div> 
    195194                                                                </div>
    196195                                                            </div>
    … …  
    209208                                                            <input type="text" name="wpc_all_day_start_time" value="<?php echo esc_attr( isset($settings['wpc_all_day_start_time'] ) ? $settings['wpc_all_day_start_time'] : ''); ?>"
    210209                                                            class="wpc_all_day_start mb-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    211 
    212210                                                            <input type="text" name="wpc_all_day_end_time" value="<?php echo esc_attr( isset($settings['wpc_all_day_end_time'] ) ? $settings['wpc_all_day_end_time'] : ''); ?>"
    213211                                                            class="wpc_all_day_end wpc-settings-input attr-form-control" placeholder="End time"/>
    214                                                             <div class="wpc_all_day_clear">clear</div>                                                        </div>
     212                                                            <div class="wpc_all_day_clear">clear</div>
     213                                                        </div>
    215214                                                    </div>
    216215                                                </div>
    … …  
    235234                                                                    <input type="text" name="wpc_exception_start_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_exception['wpc_exception_start_time'][ $index ] ); ?>" class="wpc_exception_start_time wpc_exception_start_time_<?php echo Wpc_Utilities::wpc_render( $index )?> mr-1 wpc-settings-input attr-form-control" id="exception_start_time_<?php echo Wpc_Utilities::wpc_render( $index ) ?>"  placeholder="Start time" />
    236235                                                                    <input type="text"  name="wpc_exception_end_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_exception['wpc_exception_end_time'][ $index ] ); ?>" class="wpc_exception_end_time wpc_exception_end_time_<?php echo Wpc_Utilities::wpc_render( $index )?> wpc-settings-input attr-form-control" id="exception_end_time_<?php echo Wpc_Utilities::wpc_render( $index ) ?>"  placeholder="End time"/>
    237                                                                     <div class="exception_time_clear exception_time_clear_0" id="0" >clear</div>
     236                                                                    <div class="exception_time_clear" id="0" >clear</div>
    238237                                                                    <?php if( $index != 0 ) { ?>
    239238                                                                        <span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>
    … …  
    249248                                                                <input type="text" name="wpc_exception_start_time[]" value="" class="wpc_exception_start_time wpc_exception_start_time_0 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    250249                                                                <input type="text" name="wpc_exception_end_time[]" value="" class="wpc_exception_end_time wpc_exception_end_time_0 wpc-settings-input attr-form-control" placeholder="End time"/>
    251                                                                 <div class="exception_time_clear exception_time_clear_0" id="0" >clear</div>
     250                                                                <div class="exception_time_clear" id="0" >clear</div>
    252251                                                            </div>
    253252                                                        <?php
    … …  
    336335                                                <div class="wpc-meta">
    337336                                                    <select id="wpc_default_gest_no" class="wpc-settings-input" name="wpc_default_gest_no">
     337                                                        <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    338338                                                        <?php
    339339                                                        $wpc_no_range = 101;
    … …  
    352352                                                <div class="wpc-meta">
    353353                                                    <select id="wpc_min_guest_no" class="wpc-settings-input" name="wpc_min_guest_no">
     354                                                        <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    354355                                                        <?php
    355356                                                        $wpc_no_range = 101;
    … …  
    368369                                                <div class="wpc-meta">
    369370                                                    <select id="wpc_max_guest_no" class="wpc-settings-input" name="wpc_max_guest_no">
     371                                                    <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    370372                                                        <?php
    371373                                                        for( $i = 1 ; $i <= $wpc_no_range ; $i++ ) { ?>
    … …  
    744746                                            <div class="wpc-label">
    745747                                                <label for="wpcafe_food_location"><?php esc_html_e('Allow location', $this->textdomain ); ?></label>
    746                                                 <div class="wpc-desc"> <?php esc_html_e("Show location dropdown on front-end menu and checkout", 'wpcafe'); ?> </div>
     748                                                <div class="wpc-desc"> <?php esc_html_e("Show location dropdown on front-end menu (only in front page) and checkout", 'wpcafe'); ?> </div>
    747749                                            </div>
    748750                                            <div class="wpc-meta">
  • wp-cafe/tags/1.0.6/core/widgets/cancellation-form-template.php

    r2335589 r2358899  
    1 <?php
    2  if (!is_admin()) {
    3 ?>
     1<?php if (!is_admin()) { ?>
    42 <div class='wpc-reservation-form '>
    53     <form method='post' class='wpc_reservation_form wpc_reservation_cancel_form' action=''>
    … …  
    2018                </div>
    2119                <div class='wpc-reservation-field phone'>
    22                     <label for='wpc-phone'><?php echo esc_html__('Phone','wpcafe')?><small class='wpc_required'>*</small></label>
    23                     <input type='tel' name='wpc_cancell_phone' class='wpc_cancell_phone wpc-form-control' id='wpc-cancell-phone' value='' required>
     20                    <label for='wpc-phone'><?php echo esc_html__('Phone', 'wpcafe'); ?></label>
     21                    <input type='tel' name='wpc_cancell_phone' class='wpc_cancell_phone wpc-form-control' id='wpc-cancell-phone' value=''>
    2422                </div>
    2523                <div class='wpc-reservation-field area message'>
  • wp-cafe/tags/1.0.6/core/widgets/hook.php

    r2343218 r2358899  
    3131        add_shortcode('wpc_food_menu_list', [$this, 'wpc_food_menu_list']);
    3232        add_shortcode('wpc_reservation_form', [$this, 'wpc_booking_form_shortcode']);
     33
    3334        // add minicart to header
    3435        add_action('wp_head', [$this, 'wpc_custom_mini_cart']);
    … …  
    4041            add_action('woocommerce_checkout_create_order', [$this, 'wpc_location_update_meta'], 10, 2);
    4142        }
     43
    4244        // menu order action
    4345        add_action('product_cat_add_form_fields', [$this, 'wpc_product_cat_taxonomy_add_new_meta_field'], 10, 1);
    … …  
    4547        add_action('edited_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1);
    4648        add_action('create_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1);
     49       
    4750        //Displaying Additional Columns
    4851        add_filter('manage_edit-product_cat_columns', [$this, 'wpc_custom_fields_list_title']);
    4952        add_action('manage_product_cat_custom_column', [$this, 'wpc_custom_fields_list_diplay'], 10, 3);
     53       
    5054        // update cart counter
    5155        add_filter('woocommerce_add_to_cart_fragments', [$this, 'wpc_add_to_cart_count_fragment_refresh'], 30, 1);
    … …  
    6266        $settings = $this->settings_obj;
    6367        include_once 'reservation-form-template.php';
     68
    6469        if (isset($settings['wpc_allow_cancellation'])) {
    6570            include_once 'cancellation-form-template.php';
    6671        }
     72
    6773        $content = ob_get_clean();
     74
    6875        return $content;
    6976    }
    … …  
    7481     * @param [type] $id
    7582     */
    76     public function wpc_tag($id)
    77     {
    78 ?>
    79         <?php
     83    public function wpc_tag($id , $stock_status ){
    8084        $current_tags = get_the_terms($id, 'product_tag');
    81 
    82         //only start if we have some tags
    83         if ($current_tags && !is_wp_error($current_tags)) {
    8485            //create a list to hold our tags
    85         ?>
     86            ?>
    8687            <ul class="wpc-menu-tag">
    8788                <?php
    88 
    89                 //for each tag we create a list item
    90                 foreach ($current_tags as $tag) {
    91                     $tag_title = $tag->name;
    92                 ?>
    93                     <li><?php echo esc_html($tag_title); ?></li>
    94                 <?php
     89                if ($stock_status == true || ( $current_tags && !is_wp_error($current_tags) ) ) {
     90                    //for each tag we create a list item
     91                    if ( is_array( $current_tags ) && count( $current_tags )>0 ) {
     92                        foreach ($current_tags as $tag) {
     93                            $tag_title = $tag->name;
     94                            ?>
     95                            <li>
     96                                <?php echo esc_html__($tag_title,'wpcafe'); ?>
     97                            </li>
     98                            <?php
     99                        }
     100                    }
     101                }
     102                else{
     103                   ?><li><?php echo esc_html__('Out of stock','wpcafe'); ?></li><?php
    95104                }
    96105                ?>
    97106            </ul>
    98         <?php }
    99     }
    100 
    101     /**
    102      * Location feature function
    103      *
    104      */
    105     public function wpc_location()
    106     {
    107         // show location
    108         $settings = $this->settings_obj;
    109         if (isset($settings['wpcafe_food_location']) && $settings['wpcafe_food_location'] == 'on') {
    110         ?>
    111             <div id="wpc_location_modal" class="wpc_modal">
    112                 <!-- Modal content -->
    113                 <div class="modal-content">
    114                     <select name="wpc-location" class="wpc-location">
    115                         <option value=""><?php echo esc_html('Select a location', 'wpcafe') ?></option>
    116                         <?php
    117                         // get wpcafe locations
    118                         $wpc_loctaion = get_terms('wpcafe_location', ['taxonomy' => 'wpcafe_location', 'hide_empty' => 0, 'orderby' => 'DESC', 'parent' => 0]);
    119                         if (count($wpc_loctaion) > 0) {
    120                             foreach ($wpc_loctaion as $value) {
    121                         ?>
    122                                 <option value="<?php echo esc_html($value->slug); ?>"><?php echo esc_html__($value->name, 'wpcafe') ?></option>
    123                             <?php
    124                             }
    125                         } else {
    126                             ?>
    127                             <option value=""><?php echo esc_html__('No location set', 'wpcafe') ?></option>
    128                         <?php
    129                         }
    130                         ?>
    131                     </select>
    132                     <button class="wpc-select-location wpc-btn wpc-btn-primary">Ok</button>
    133                     <button class="wpc-close wpc-btn"> <i class="dashicons dashicons-no-alt"></i> </button>
    134                 </div>
    135             </div>
    136         <?php
    137         }
     107            <?php
    138108    }
    139109
    … …  
    144114     * @param $content
    145115     */
    146     public function wpc_food_menu_tab($atts, $content)
    147     {
     116    public function wpc_food_menu_tab($atts, $content){
    148117        if (!class_exists('Woocommerce')) {
    149118            return;
    … …  
    152121        // show location
    153122        if (is_front_page()) {
    154             $this->wpc_location();
    155         }
    156         $atts = extract(shortcode_atts(
    157             [
    158                 'wpc_food_catgeries' => '21', 'no_of_product' => 5, 'product_thumnail' => "on", 'wpc_cart_button' => 'on'
     123            Utils::get_location_details();
     124        }
     125        $atts = extract(shortcode_atts([
     126                'wpc_food_catgeries' => '21',
     127                'no_of_product' => 5,
     128                'product_thumbnail' => "on",
     129                'wpc_cart_button' => 'on'
    159130            ],
    160131            $atts
    … …  
    167138        foreach ($wpc_cat_arr as $value) {
    168139            $i++;
    169 
    170140            if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
    171141                $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
    … …  
    187157                        $current      = $wpc_cat->name;
    188158                        $active_class = (($key == array_keys($wpc_cat_sort_arr)[0]) ? 'wpc-active' : ' ');
    189                 ?>
     159                        ?>
    190160                        <li>
    191161                            <a href="#" data-id="tab_<?php echo Utils::wpc_render(Utils::wpc_cat_name_lower($current)); ?>" class="wpc-tab-a <?php echo esc_attr($active_class); ?>" data-toggle="tab" aria-expanded="true">
    … …  
    193163                            </a>
    194164                        </li>
    195                 <?php
     165                        <?php
    196166                    }
    197167                }
    … …  
    210180                    $wpc_cat_id   = Utils::wpc_cat_name_lower($wpc_cat->name);
    211181                    $products = wc_get_products($args);
    212                 ?>
     182                    ?>
    213183                    <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo esc_attr($wpc_cat_id); ?>'>
    214184                        <div class='wpc-row'>
    … …  
    218188                                        <?php
    219189                                        // show tag
    220                                         if ($product_thumnail == "on") {
    221                                         ?>
     190                                        if ( $product_thumbnail == "on" ) {
     191                                            ?>
    222192                                            <div class="wpc-col-md-3">
    223193                                                <div class="wpc-food-menu-thumb">
    224                                                     <a href="<?php echo esc_url(get_permalink($product->get_id())); ?>">
    225                                                         <?php echo Wpc_Utilities::wpc_kses($product->get_image()); ?>
     194                                                    <a href="<?php echo esc_url( get_permalink( $product->get_id() ) ); ?>">
     195                                                        <?php  echo Wpc_Utilities::wpc_kses( $product->get_image() )?>
    226196                                                    </a>
    227197                                                </div>
    228198                                            </div>
    229                                         <?php } ?>
     199                                            <?php
     200                                        }
     201                                        ?>
    230202                                        <div class="wpc-col-md-9">
    231203                                            <div class="wpc-food-inner-content">
    232204                                                <div class="wpc-menu-tag-wrap">
    233205                                                    <?php
    234                                                     $this->wpc_tag($product->get_id());
     206                                                    $this->wpc_tag( $product->get_id() , $product->is_in_stock() );
    235207                                                    $price = '';
    236208                                                    if (wc_get_price_including_tax($product)) {
    … …  
    256228                                                        <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    257229                                                </h3>
    258                                                 <?php echo Wpc_Utilities::wpc_kses(esc_html__(get_the_excerpt($product->get_id(), 'wpcafe')));
     230                                                <?php echo Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) );
    259231                                                // show cart button
    260                                                 if ($wpc_cart_button == 'on') {
    261                                                 ?>
     232                                                if ($wpc_cart_button == 'on' && $product->is_in_stock() == true ) {
     233                                                    ?>
    262234                                                    <div class="wpc-add-to-cart">
    263235                                                        <a href="?add-to-cart<?php echo Wpc_Utilities::wpc_numeric($product->get_id()); ?>" data-product_id="<?php echo Wpc_Utilities::wpc_numeric($product->get_id()); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    … …  
    265237                                                        </a>
    266238                                                    </div>
    267                                                 <?php
     239                                                    <?php
    268240                                                }
    269241                                                ?>
    … …  
    280252            </div>
    281253        </div>
    282     <?php
    283         $contents = ob_get_clean();
    284         return $contents;
     254        <?php
     255        return ob_get_clean();
    285256    }
    286257
    … …  
    290261     * @param Type $var
    291262     */
    292     public function wpc_food_menu_list($atts, $content)
    293     {
     263    public function wpc_food_menu_list($atts, $content){
    294264        if (!class_exists('Woocommerce')) {
    295265            return;
    … …  
    298268        // show location
    299269        if (is_front_page()) {
    300             $this->wpc_location();
     270            Utils::get_location_details();
    301271        }
    302272
    303273        $atts = extract(shortcode_atts(
    304             ['wpc_food_catgeries' => '21', 'no_of_product' => 5, 'wpc_cart_button' => 'on'],
     274            ['wpc_food_catgeries' => '21',
     275            'no_of_product' => 5,
     276            'wpc_cart_button' => 'on'],
    305277            $atts
    306278        ));
    … …  
    330302        };
    331303        $products = wc_get_products($args);
    332     ?>
     304        ?>
    333305        <div class='wpc-food-wrapper'>
    334306            <?php foreach ($products as $product) { ?>
    … …  
    339311                            <div class="wpc-food-menu-thumb">
    340312                                <a href="<?php echo esc_url(get_permalink($product->get_id())); ?>">
    341                                     <?php echo Wpc_Utilities::wpc_kses($product->get_image()); ?>
     313                                    <?php echo Wpc_Utilities::wpc_kses( $product->get_image() ) ?>
    342314                                </a>
    343315                            </div>
    … …  
    349321                            <div class="wpc-menu-tag-wrap">
    350322                                <?php
    351                                 $this->wpc_tag($product->get_id());
     323                                $this->wpc_tag( $product->get_id() , $product->is_in_stock() );
    352324                                $price = '';
    353325                                if (wc_get_price_including_tax($product)) {
    … …  
    373345                            </h3>
    374346                            <?php
    375                             echo esc_html__(get_the_excerpt($product->get_id()), 'wpcafe');
     347                            echo  Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) );
    376348                            // show cart button
    377                             if ($wpc_cart_button == 'on') {
     349                            if ($wpc_cart_button == 'on' && $product->is_in_stock() == true) {
    378350                            ?>
    379351                                <div class="wpc-add-to-cart">
    … …  
    391363        </div>
    392364        <?php
    393 
    394         $contents = ob_get_clean();
    395         return $contents;
     365        return ob_get_clean();
    396366    }
    397367
    … …  
    400370     *
    401371     */
    402     public function wpc_custom_mini_cart()
    403     {
     372    public function wpc_custom_mini_cart(){
    404373        if (!class_exists('WooCommerce')) {
    405374            return;
  • wp-cafe/tags/1.0.6/core/widgets/reservation-form-template.php

    r2335589 r2358899  
    33$wpc_min_guest_no    = isset($settings['wpc_min_guest_no']) ? $settings['wpc_min_guest_no'] : 1;
    44$wpc_max_guest_no    = isset($settings['wpc_max_guest_no']) ? $settings['wpc_max_guest_no'] : 10;
    5 $wpc_default_gest_no = isset($settings['wpc_default_gest_no']) ? $settings['wpc_default_gest_no'] : 1;
     5$wpc_default_gest_no = isset($settings['wpc_default_gest_no']) ? $settings['wpc_default_gest_no'] : '';
    66$phone_required      = isset($settings['wpc_require_phone']) ? "required" : "";
     7
    78$cancellation_option = '';
    89if (isset($settings['wpc_allow_cancellation']) &&  $settings['wpc_allow_cancellation'] !== '') {
    … …  
    114115                                <div class='wpc-reservation-field phone'>
    115116                                    <label for='wpc-phone'><?php echo esc_html__('Phone', 'wpcafe');
    116                                                             $phone_required === "required" ? "<small class='wpc_required'>*</small>" : ""
    117                                                             ?>
     117                                        echo $phone_required == "required" ? "<small class='wpc_required'>*</small>" : "" ?>
    118118                                    </label>
    119                                     <input type='tel' <?php echo esc_attr($phone_required === "required" ? "required" : ""); ?> name='wpc_phone' class='wpc-form-control' id='wpc-phone' value=''>
     119                                    <input type='tel' <?php echo esc_attr($phone_required == "required" ? "required" : ""); ?> name='wpc_phone' class='wpc-form-control' id='wpc-phone' value=''>
    120120                                </div>
    121121                            </div>
    … …  
    147147                            <label for='wpc-total-guest'><?php echo esc_html__('Total Guest ', 'wpcafe'); ?><small class='wpc_required'>*</small></label>
    148148                            <select name='wpc_guest_count' id='wpc-party' class='wpc-form-control' required aria-required='true'>
     149                                <option value=""><?php echo esc_html__("Select no of geuests","wpcafe")?></option>
    149150                                <?php
    150151                                for ($i = $wpc_min_guest_no; $i <= $wpc_max_guest_no; $i++) {
  • wp-cafe/tags/1.0.6/plugin.php

    r2343218 r2358899  
    1414final class Plugin{
    1515   
    16     const version = '1.0.5';
     16    const version = '1.0.0';
    1717
    1818    private static $instance;
  • wp-cafe/tags/1.0.6/readme.txt

    r2343218 r2358899  
    44Requires at least: 5.2
    55Tested up to: 5.4
    6 Stable tag: 1.0.5
     6Stable tag: 1.0.6
    77Requires PHP: 5.6
    88License: GPLv2 or later
    … …  
    3030* Restaurant Menu System
    3131* Restaurant Ordering System for Takeaway / Delivery
     32* Ajax Mini cart
     33* Option to Customize mini-cart icon, color
     34* Food menu based on Location
     35* Customizable e-mail notifications can be sent to customers to provide confirmation, or cancellation
     36* Show reservation list on admin dashboard
     37* Make reservation from front-end
     38* Cancel a reservation from front-end
    3239
    3340####WP Cafe Plugin Integrated with Elementor builder.####
    3441
    35 ####Shortcodes / Elements:####
     42####Shortcodes / Elementor Widgets:####
    3643
    3744* Reservation Form
    … …  
    5057
    5158== Changelog ==
     59
     60= 1.0.6 =
     61
     62Fix    : Food menu stock status checking
     63Fix    : Remove html tag from product description
     64Fix    : Phone required field bug fixed
     65Fix    : Food menu thumbnail enable / disable bug fixed
     66Tweak  : Update reservation booking time validation
     67Tweak  : Update reservation time picker
     68Tweak  : Optimization and performance update for shortcodes and Elementor widgets
     69Tweak  : More validation added in reservation party size settings.
    5270
    5371= 1.0.5 =
  • wp-cafe/tags/1.0.6/utils/wpc-utilities.php

    r2335589 r2358899  
    142142            'label'                         => [
    143143                'class' => [],
    144             ]
     144            ],
    145145        ];
    146146
    … …  
    216216        $from      = $mail_from;
    217217        $from_name = $mail_from_name;
    218         $headers   = [ 'Content-Type: text/html; charset=UTF-8', 'From: ' . $from_name . ' <' . $from . '>' ];
     218        $headers   = ['Content-Type: text/html; charset=UTF-8', 'From: ' . $from_name . ' <' . $from . '>'];
    219219        wp_mail( $to, $subject, $body, $headers );
    220220    }
    … …  
    251251        }
    252252
    253                 // Is notice dismissible?
     253        // Is notice dismissible?
    254254        if ( true === $notice['dismissible'] ) {
    255255            $classes[] = 'is-dismissible';
    … …  
    281281        }
    282282
    283                 // Notice visible after transient expire.
     283        // Notice visible after transient expire.
    284284        if ( isset( $notice['show_if'] ) ) {
    285285            if ( true === $notice['show_if'] ) {
    286                                 // Is transient expired?
     286
     287                // Is transient expired?
    287288                if ( false === $expired || empty( $expired ) ) {
    288289                    self::markup( $notice );
    289290                }
     291
    290292            }
     293
    291294        } else {
    292295            self::markup( $notice );
    293296        }
     297
    294298    }
    295299
    … …  
    314318                        <?php endif;?>
    315319                </div>
    316       <?php
    317 }
     320        <?php
     321    }
    318322
    319323    public static function wpc_render( $content ) {
    … …  
    321325            return "";
    322326        }
     327
    323328        return $content;
    324329    }
    … …  
    328333            return $content;
    329334        }
     335
    330336        return $content;
    331337    }
    … …  
    389395     * @return void
    390396     */
    391     public static function wpcafe_trim_words( $content, $count = 10, $readmore = null ) {
     397    public static function wpcafe_trim_words( $content, $count = 150, $readmore = null ) {
    392398        return wp_trim_words( $content, $count, $readmore );
    393399    }
     400   
     401        /**
     402         * Post query to get data for widget and shortcode
     403         */
     404    public static function post_data_query( $post_type , $count = null, $order = null ,
     405                                            $term_arr = null, $taxonomy_slug = null, $post__in = null ) {
     406                $data = [];
     407                $args = array(
     408                    'orderby'             => 'post_date',
     409                        'post_type'           => $post_type ,
     410                        'post_status'         => 'publish',
     411                        'suppress_filters'    => false,
     412                );
     413
     414                if( $count != null ){
     415                        $args['posts_per_page']  = $count;
     416                }
     417                if( $order != null ){
     418                        $args['order']                   = $order;
     419                }
     420                if( $post__in != null ){
     421                        $args['post__in']                = $post__in;
     422                }
     423
     424                if ( is_array( $term_arr ) && !empty( $term_arr )) {
     425                        $args['tax_query'] = array(
     426                                array(
     427                                        'taxonomy'      => $taxonomy_slug,
     428                                        'terms'         => $term_arr,
     429                                        'field'         => 'id',
     430                                        'include_children' => true,
     431                                        'operator'      => 'IN'
     432                                ),
     433                        );
     434                };
     435                $data   = get_posts($args);
     436                return $data;
     437    }
     438   
     439   
     440
     441    /**
     442     * Location feature function
     443     *
     444     */
     445    public static function get_location_details(){
     446        $settings =  \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     447        // show location
     448        if (isset($settings['wpcafe_food_location']) && $settings['wpcafe_food_location'] == 'on') {
     449            ?>
     450            <div id="wpc_location_modal" class="wpc_modal">
     451                <!-- Modal content -->
     452                <div class="modal-content">
     453                    <select name="wpc-location" class="wpc-location">
     454                        <option value=""><?php echo esc_html('Select a location', 'wpcafe') ?></option>
     455                        <?php
     456                        // get wpcafe locations
     457                        $wpc_loctaion = get_terms('wpcafe_location', ['taxonomy' => 'wpcafe_location', 'hide_empty' => 0, 'orderby' => 'DESC', 'parent' => 0]);
     458                        if ( !empty($wpc_loctaion) ) {
     459                            foreach ($wpc_loctaion as $value) {
     460                                ?>
     461                                <option value="<?php echo esc_html( $value->slug ); ?>"><?php echo esc_html__($value->name, 'wpcafe') ?></option>
     462                                <?php
     463                            }
     464                        } else {
     465                            ?>
     466                            <option value=""><?php echo esc_html__('No location set', 'wpcafe') ?></option>
     467                        <?php
     468                        }
     469                        ?>
     470                    </select>
     471                    <button class="wpc-select-location wpc-btn wpc-btn-primary">Ok</button>
     472                    <button class="wpc-close wpc-btn"> <i class="dashicons dashicons-no-alt"></i> </button>
     473                </div>
     474            </div>
     475            <?php
     476        }
     477    }
    394478
    395479}
  • wp-cafe/tags/1.0.6/widgets/wpc-food-menu-tab/style/style-1.php

    r2343218 r2358899  
    11<?php
     2if (!class_exists('Woocommerce')) {
     3    return;
     4}
    25
    3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;
     6use \WpCafe\Utils\Wpc_Utilities as Utilities;
    47
    58$show_thumbnail      = $settings["show_thumbnail"];
    … …  
    811$col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12';
    912
    10 
     13if (is_front_page()) {
     14    Utilities::get_location_details();
     15}
    1116?>
    1217<div class="wpc-food-tab-wrapper">
    1318    <ul class="wpc-nav">
    1419        <?php
    15         foreach ($food_menu_tabs as $tab_key => $value) {
    16             $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
    17         ?>
    18             <li>
    19                 <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
    20                     <span><?php echo esc_html($value['tab_title']); ?></span>
    21                 </a>
    22             </li>
    23 
    24         <?php
     20        if( is_array( $food_menu_tabs ) ){
     21            foreach ($food_menu_tabs as $tab_key => $value) {
     22                $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
     23                ?>
     24                <li>
     25                    <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
     26                        <span><?php echo esc_html($value['tab_title']); ?></span>
     27                    </a>
     28                </li>
     29                <?php
     30            }
    2531        }
    2632        ?>
    … …  
    2834    <div class="wpc-tab-content">
    2935        <?php
    30         foreach ($food_menu_tabs as $content_key => $value) {
    31             $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    32         ?>
    33             <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
    34                 <?php
    35                 $arg = array(
    36                     'post_type'   =>  'product',
    37                     'post_status' => 'publish',
    38                     'posts_per_page' => $wpc_menu_count,
    39                     'order' => $wpc_menu_order,
    40                     'orderby' => 'publish_date',
    41                     'suppress_filters' => false,
    42                 );
    43                 if (is_array($value['post_cats']) && count($value['post_cats'])) {
    44                     $arg['tax_query'] = array(
    45                         array(
    46                             'taxonomy' => 'product_cat',
    47                             'terms'    => $value['post_cats'],
    48                             'field' => 'id',
    49                             'include_children' => true,
    50                             'operator' => 'IN'
    51                         ),
    52                     );
    53                 };
    54                 global  $woocommerce;
    55                 $queryd = new \WP_Query($arg);
     36        if( is_array( $food_menu_tabs ) ){
     37            foreach ($food_menu_tabs as $content_key => $value) {
     38                $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    5639                ?>
    57                 <?php if ($queryd->have_posts()) : ?>
    58                     <div class="wpc-food-block-tab-item">
    59                         <div class="wpc-row">
    60                             <?php while ($queryd->have_posts()) : $queryd->the_post();
    61                                 $product = wc_get_product(get_the_ID());
    62                                 $price = $product->get_price();
    63                                 $current_tags = get_the_terms(get_the_ID(), 'product_tag');
    64                                 $permalink = (($addtocart_link_show == 'yes') ? get_the_permalink() : '');
    65                                 $class = (($addtocart_link_show == 'yes') ? '' : 'wpc-no-link');
    66                             ?>
    67                                 <div class="wpc-col-lg-6">
    68                                     <div class="wpc-food-menu-item wpc-row">
    69                                         <?php if ($show_thumbnail == 'yes') : ?>
    70                                             <div class="wpc-col-md-4">
    71                                                 <!-- thumbnail -->
    72                                                 <?php if (has_post_thumbnail()) { ?>
    73                                                     <div class="wpc-food-menu-thumb">
    74                                                         <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>">
    75                                                             <?php the_post_thumbnail(); ?>
    76                                                         </a>
    77                                                     </div>
    78                                                 <?php } ?>
    79                                             </div>
    80                                         <?php endif; ?>
    81                                         <div class="<?php echo esc_attr($col); ?>">
    82                                             <div class="wpc-food-inner-content">
    83                                                 <!-- product tag and tax -->
    84                                                 <?php if ($current_tags || $product->get_price_suffix()) { ?>
    85                                                     <ul class="wpc-menu-tag">
     40                <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
     41                    <?php
     42                    global  $woocommerce;
     43                    $post_type = "product";
     44                    $data = Utilities::post_data_query( $post_type , $wpc_menu_count, $wpc_menu_order, $value['post_cats'], 'product_cat'  );
     45                    ?>
     46                    <?php
     47                    if ( !empty( $data ) ) {
     48                        ?>
     49                        <div class="wpc-food-block-tab-item">
     50                            <div class="wpc-row">
     51                                <?php
     52                                foreach( $data as $value ) {
     53                                    $product = wc_get_product( $value->ID );
     54                                    $price = $product->get_price();
     55                                    $current_tags = get_the_terms( $value->ID, 'product_tag');
     56                                    $permalink = ( ($addtocart_link_show == 'yes') ? get_the_permalink( $value->ID ) : '');
     57                                    $class = ( ($addtocart_link_show == 'yes') ? '' : 'wpc-no-link' );
     58                                    ?>
     59                                    <div class="wpc-col-lg-6">
     60                                        <div class="wpc-food-menu-item wpc-row">
     61                                            <?php
     62                                            if ($show_thumbnail == 'yes') {
     63                                                ?>
     64                                                <div class="wpc-col-md-4">
     65                                                    <!-- thumbnail -->
     66                                                    <?php
     67                                                    if( get_the_post_thumbnail_url($value->ID) ) {
     68                                                        ?>
     69                                                        <div class="wpc-food-menu-thumb">
     70                                                            <a href="<?php echo esc_url( $permalink ) ; ?>" class="<?php echo esc_attr($class); ?>">
     71                                                                <img src="<?php echo get_the_post_thumbnail_url($value->ID); ?>">
     72                                                            </a>
     73                                                        </div>
     74                                                        <?php
     75                                                    }
     76                                                    ?>
     77                                                </div>
     78                                                <?php
     79                                            }
     80                                            ?>
     81                                            <div class="<?php echo esc_attr($col); ?>">
     82                                                <div class="wpc-food-inner-content">
     83                                                    <!-- product tag and tax -->
     84                                                    <?php
     85                                                    if ($current_tags || $product->get_price_suffix()) {
     86                                                        ?>
     87                                                        <ul class="wpc-menu-tag">
     88                                                            <?php
     89                                                            if ($show_item_status == 'yes' && $current_tags && !is_wp_error($current_tags)) {
     90                                                                //for each tag we create a list item
     91                                                                foreach ($current_tags as $tag) {
     92                                                                    $tag_title = $tag->name;
     93                                                                    ?>
     94                                                                    <li>
     95                                                                        <?php echo esc_html($tag_title); ?>
     96                                                                    </li>
     97                                                                    <?php
     98                                                                }
     99                                                            }
     100                                                            ?>
     101                                                            <!-- product tax -->
     102                                                            <?php if ($product->get_price_suffix() != '') { ?>
     103                                                                <li>
     104                                                                    <?php
     105                                                                    if ( wc_get_price_including_tax( $product ) ) {
     106                                                                        $price      = wc_get_price_including_tax($product);
     107                                                                        // get percentage tax
     108                                                                        echo Utilities::wpc_kses($product->get_price_suffix());
     109                                                                    } else {
     110                                                                        $price = wc_get_price_excluding_tax($product);
     111                                                                    }
     112                                                                    ?>
     113                                                                </li>
     114                                                            <?php } ?>
     115                                                        </ul>
     116                                                        <?php
     117                                                    }
     118                                                    ?>
     119   
     120                                                    <h3 class="wpc-post-title wpc-title-with-border">
     121                                                        <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title( $value->ID ));  ?> </a>
     122                                                        <span class="wpc-title-border"></span>
     123                                                        <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
     124                                                    </h3>
     125                                                    <p>
    86126                                                        <?php
    87                                                         if ($show_item_status == 'yes' && $current_tags && !is_wp_error($current_tags)) {
    88                                                             //for each tag we create a list item
    89                                                             foreach ($current_tags as $tag) {
    90                                                                 $tag_title = $tag->name;
     127                                                        if ($wpc_show_desc == 'yes') {
     128                                                            echo  Utilities::wpcafe_trim_words( get_the_excerpt( $value->ID ) , $wpc_desc_limit);
     129                                                        }
    91130                                                        ?>
    92                                                                 <li><?php echo esc_html($tag_title); ?></li>
    93                                                         <?php }
    94                                                         } ?>
    95                                                         <!-- product tax -->
    96                                                         <?php if ($product->get_price_suffix() != '') { ?>
    97                                                             <li>
    98                                                                 <?php
    99                                                                 if (wc_get_price_including_tax($product)) {
    100                                                                     $price      = wc_get_price_including_tax($product);
    101                                                                     // get percentage tax
    102                                                                     echo Wpc_Utilities::wpc_kses($product->get_price_suffix());
    103                                                                 } else {
    104                                                                     $price = wc_get_price_excluding_tax($product);
    105                                                                 }
    106                                                                 ?>
    107                                                             </li>
    108                                                         <?php } ?>
    109                                                     </ul>
    110                                                 <?php } ?>
    111 
    112                                                 <h3 class="wpc-post-title wpc-title-with-border">
    113                                                     <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title());  ?> </a>
    114                                                     <span class="wpc-title-border"></span>
    115                                                     <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    116 
    117                                                 </h3>
    118                                                 <p>
     131                                                    </p>
    119132                                                    <?php
    120                                                     if ($wpc_show_desc == 'yes') {
    121                                                         echo  WPC_Utilities::wpcafe_trim_words(get_the_excerpt(), $wpc_desc_limit);
     133                                                    // show cart button
     134                                                    if ($wpc_cart_button_show == 'yes' && $product->is_in_stock() == true) {
     135                                                        ?>
     136                                                        <div class="wpc-add-to-cart">
     137                                                            <a href="?add-to-cart<?php echo $value->ID; ?>" data-product_id="<?php echo $value->ID; ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
     138                                                                <i class="wpcafe-cart_icon"></i>
     139                                                            </a>
     140                                                        </div>
     141                                                        <?php
    122142                                                    }
    123143                                                    ?>
    124                                                 </p>
    125                                                 <?php
    126                                                 // show cart button
    127                                                 if ($wpc_cart_button_show == 'yes') {
    128                                                 ?>
    129                                                     <div class="wpc-add-to-cart">
    130                                                         <a href="?add-to-cart<?php echo get_the_id(); ?>" data-product_id="<?php echo get_the_id(); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    131                                                             <i class="wpcafe-cart_icon"></i>
    132                                                         </a>
    133                                                     </div>
    134                                                 <?php
    135                                                 }
    136                                                 ?>
    137 
     144                                                </div>
    138145                                            </div>
    139146                                        </div>
    140147                                    </div>
    141                                 </div>
    142                             <?php
    143                             endwhile; ?>
    144                         </div>
    145                     </div><!-- block-item6 -->
    146                     <?php wp_reset_postdata(); ?>
    147                 <?php endif; ?>
    148             </div><!-- Tab pane 1 end -->
    149         <?php } ?>
     148                                    <?php
     149                                }
     150                                ?>
     151                            </div>
     152                        </div><!-- block-item6 -->
     153                        <?php wp_reset_postdata(); ?>
     154                        <?php
     155                    }
     156                    ?>
     157                </div><!-- Tab pane 1 end -->
     158                <?php
     159            }
     160        }
     161        ?>
    150162    </div><!-- Tab content-->
    151163</div>
  • wp-cafe/tags/1.0.6/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php

    r2335589 r2358899  
    662662        $wpc_desc_limit = $settings["wpc_desc_limit"];
    663663
    664         ?>
    665         <?php
    666         include WPC_DIR . "/widgets/wpc-food-menu-tab/style/{$style}.php";
     664            include WPC_DIR . "/widgets/wpc-food-menu-tab/style/{$style}.php";
    667665    }
    668666
  • wp-cafe/tags/1.0.6/widgets/wpc-menus-list/style/style-1.php

    r2343218 r2358899  
    11<?php
    22
    3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;
    4 
     3use \WpCafe\Utils\Wpc_Utilities as Utilities;
     4if (!class_exists('Woocommerce')) {
     5    return;
     6}
    57$wpc_menu_cat      = $settings["wpc_menu_cat"];
    68$wpc_menu_count      = $settings["wpc_menu_count"];
    … …  
    810$show_thumbnail      = $settings["show_thumbnail"];
    911$col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12';
    10 $args = array(
    11     'posts_per_page'   => $wpc_menu_count,
    12     'orderby'          => 'post_date',
    13     'order'            => $wpc_menu_order,
    14     'post_type'        => 'product',
    15     'post_status'      => 'publish',
    16     'suppress_filters' => false,
     12$post_type = 'product';
     13$data = Utilities::post_data_query( $post_type , $wpc_menu_count, $wpc_menu_order, $settings['wpc_menu_cat'], 'product_cat' );                 
    1714
    18 );
    19 
    20 if (is_array($settings['wpc_menu_cat']) && count($settings['wpc_menu_cat'])) {
    21     $args['tax_query'] = array(
    22         array(
    23             'taxonomy' => 'product_cat',
    24             'terms'    => $settings['wpc_menu_cat'],
    25             'field' => 'id',
    26             'include_children' => true,
    27             'operator' => 'IN'
    28         ),
    29     );
    30 };
    31 
    32 $f_query = new \WP_Query($args);
    33 
     15// show location
     16if (is_front_page()) {
     17    Utilities::get_location_details();
     18}
    3419?>
    3520
    … …  
    3722    <?php
    3823    global  $woocommerce;
    39     if ($f_query->have_posts()) {
    40         while ($f_query->have_posts()) {
    41             $f_query->the_post();
    42             $product = wc_get_product(get_the_ID());
     24    if ( !empty( $data ) ) {
     25        foreach( $data as $value ) {
     26            $product = wc_get_product( $value->ID );
    4327            $price = $product->get_price();
    44             $current_tags = get_the_terms(get_the_ID(), 'product_tag');
    45             $permalink = (($addtocart_link_show == 'yes') ? get_the_permalink() : '');
    46             $class = (($addtocart_link_show == 'yes') ? '' : 'wpc-no-link');
    47 
    48     ?>
     28            $current_tags = get_the_terms( $value->ID, 'product_tag');
     29            $permalink = ( ( $addtocart_link_show == 'yes' ) ? get_the_permalink( $value->ID ) : '');
     30            $class = ( ( $addtocart_link_show == 'yes' ) ? '' : 'wpc-no-link');
     31            ?>
    4932            <div class="wpc-food-menu-item wpc-row">
    50                 <?php if ($show_thumbnail == 'yes') : ?>
     33                <?php
     34                if ( $show_thumbnail == 'yes' ) {
     35                ?>
    5136                    <div class="wpc-col-md-4">
    5237                        <!-- thumbnail -->
    53                         <?php if (has_post_thumbnail()) { ?>
     38                        <?php
     39                        if( get_the_post_thumbnail_url( $value->ID ) ) {
     40                            ?>
    5441                            <div class="wpc-food-menu-thumb">
    55                                 <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>">
    56                                     <?php the_post_thumbnail(); ?>
     42                                <a href="<?php echo esc_url( $permalink ); ?>" class="<?php echo esc_attr($class); ?>">
     43                                    <img src="<?php echo get_the_post_thumbnail_url( $value->ID ); ?>">
    5744                                </a>
    5845                            </div>
    59                         <?php } ?>
     46                            <?php
     47                        }
     48                        ?>
    6049                    </div>
    61                 <?php endif; ?>
    62                 <div class="<?php echo esc_attr($col); ?>">
     50                    <?php
     51                }
     52                ?>
     53                <div class="<?php echo esc_attr( $col ); ?>">
    6354                    <div class="wpc-food-inner-content">
    6455                        <!-- product tag and tax -->
    65                         <?php if ($current_tags || $product->get_price_suffix()) { ?>
    66 
     56                        <?php
     57                        if ($current_tags || $product->get_price_suffix()) {
     58                            ?>
    6759                            <ul class="wpc-menu-tag">
    6860                                <?php
    … …  
    7264                                    foreach ($current_tags as $tag) {
    7365                                        $tag_title = $tag->name;
     66                                        ?>
     67                                        <li>
     68                                            <?php echo esc_html( $tag_title ); ?>
     69                                        </li>
     70                                        <?php
     71                                    }
     72                                }
    7473                                ?>
    75                                         <li><?php echo esc_html($tag_title); ?></li>
    76                                 <?php }
    77                                 } ?>
    7874                                <!-- product tax -->
    79                                 <?php if ($product->get_price_suffix() != '') {  ?>
     75                                <?php
     76                                if ( $product->get_price_suffix() != '' ) { 
     77                                    ?>
    8078                                    <li>
    8179                                        <?php
    82                                         if (wc_get_price_including_tax($product)) {
    83                                             $price      = wc_get_price_including_tax($product);
     80                                        if ( wc_get_price_including_tax( $product ) ) {
     81                                            $price      = wc_get_price_including_tax( $product );
    8482                                            // get percentage tax
    85                                             echo Wpc_Utilities::wpc_kses($product->get_price_suffix());
     83                                            echo Utilities::wpc_kses( $product->get_price_suffix() );
    8684                                        } else {
    87                                             $price = wc_get_price_excluding_tax($product);
     85                                            $price = wc_get_price_excluding_tax( $product );
    8886                                        }
    8987                                        ?>
    9088                                    </li>
    91                                 <?php } ?>
     89                                    <?php
     90                                }
     91                                ?>
    9292                            </ul>
    93                         <?php } ?>
    94 
     93                            <?php
     94                        }
     95                        ?>
    9596                        <h3 class="wpc-post-title wpc-title-with-border">
    96                             <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title());  ?> </a>
     97                            <a href="<?php echo esc_url( $permalink ); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html( get_the_title( $value->ID ) );  ?> </a>
    9798                            <span class="wpc-title-border"></span>
    98                             <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    99 
     99                            <span class="wpc-menu-currency">
     100                                <?php echo get_woocommerce_currency_symbol(); ?>
     101                                <span class="wpc-menu-price"><?php echo esc_html($price); ?>
     102                                </span>
     103                            </span>
    100104                        </h3>
    101105                        <p>
    102106                            <?php
    103                             if ($wpc_show_desc == 'yes') {
    104                                 echo  WPC_Utilities::wpcafe_trim_words(get_the_excerpt(), $wpc_desc_limit);
     107                            if ( $wpc_show_desc == 'yes' ) {
     108                                echo  Utilities::wpcafe_trim_words( get_the_excerpt( $value->ID ), $wpc_desc_limit);
    105109                            }
    106110                            ?>
    … …  
    108112                        <?php
    109113                        // show cart button
    110                         if ($wpc_cart_button == 'yes') {
    111                         ?>
     114                        if ($wpc_cart_button == 'yes' && $product->is_in_stock() == true) {
     115                            ?>
    112116                            <div class="wpc-add-to-cart">
    113                                 <a href="?add-to-cart<?php echo get_the_id(); ?>" data-product_id="<?php echo get_the_id(); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
     117                                <a href="?add-to-cart<?php echo $value->ID; ?>" data-product_id="<?php echo $value->ID; ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    114118                                    <i class="wpcafe-cart_icon"></i>
    115119                                </a>
    116120                            </div>
    117                         <?php
     121                            <?php
    118122                        }
    119123                        ?>
    … …  
    121125                </div>
    122126            </div>
    123     <?php
     127            <?php
    124128        }
    125129    }
    126     wp_reset_query();
     130    wp_reset_postdata();
    127131    ?>
    128132</div>
  • wp-cafe/tags/1.0.6/wpcafe.php

    r2343218 r2358899  
    99 * Plugin URI:         https://product.themewinter.com/wpcafe
    1010 * Description:        WordPress Restaurant solution plugin to launch Restaurant Websites.
    11  * Version:            1.0.5
     11 * Version:            1.0.6
    1212 * Author:             Themewinter
    1313 * Author URI:         http://themewinter.com/
  • wp-cafe/trunk/assets/css/wpc-public.css

    r2343218 r2358899  
    341341  margin-left: auto;
    342342}
    343 
     343.ui-timepicker-standard a{
     344  padding: 0 !important;
     345}
    344346@media (min-width: 576px) {
    345347  .wpc-container {
    … …  
    51145116  background: #5D78FF;
    51155117  padding: 8px 10px;
    5116   margin-right: 5px;
     5118  margin-right: 2px;
    51175119  color: #fff;
    51185120}
  • wp-cafe/trunk/assets/js/wpc-admin-menu.js

    r2335589 r2358899  
    11(function ($) {
     2    "use strict";
    23    $(document).ready(function () {
    34        $('.toplevel_page_cafe_menu')
  • wp-cafe/trunk/assets/js/wpc-admin.js

    r2335589 r2358899  
    11(function($) {
     2    "use strict";
    23    $(document).ready(function() {
    3 
    44     // load color picker   
    55     $("#wpc_primary_color").wpColorPicker();
    … …  
    1212         });
    1313     });
    14 
    15      // Shcedule dynamically increase decrease
     14     // Exceptional Shcedule dynamically increase decrease
    1615     var countExceptionBlock = $('.exception_block').length;
    1716     var increase=countExceptionBlock;
    … …  
    2322                 '<input type="text" name="wpc_exception_start_time[]" class="wpc_exception_start_time_'+increase+' wpc-settings-input attr-form-control" id="exception_start_time_'+increase+'" placeholder="Start time" />'+
    2423                 '<input type="text" name="wpc_exception_end_time[]" class="wpc_exception_end_time_'+increase+' wpc-settings-input attr-form-control" id="exception_end_time_'+increase+'" placeholder="End time"/>'+
    25                  '<div class="exception_time_clear exception_time_clear_'+increase+'" id="'+ increase +'" >clear</div>'+
    2624                 '<span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>'+
    2725             '</div>');
    2826             $('.wpc_exception_start_time_'+increase+', .wpc_exception_end_time_'+increase+' ').
    29              flatpickr({
    30                 enableTime: true,
    31                 noCalendar: true,
    32                 dateFormat: "h:i K",
    33                 time_24hr : false,
    34              });
     27             timepicker({
     28                timeFormat: 'h:mm p',
     29                interval: 30,
     30                dynamic: true,
     31                dropdown: true,
     32                scrollbar: true
     33            })
    3534     });
    36  
    37      $(".exception_main_block").on( 'click' ,'.remove_exception_block', function(e) {
    38          e.preventDefault();
    39          $(this).parent('div').remove();
    40          increase--;
    41      });
    42  
    43      // Shcedule dynamically increase decrease
     35
     36     // Weekly shcedule dynamically increase decrease
    4437     var countScheduleBox = $('.schedule_block').length;
    4538     var i           = countScheduleBox;
    4639     var createField = 7 - i ;
     40     // add shcedule block
    4741     $(document).on( 'click' , '.add_schedule_block' , function() {
    4842         if( i <= createField ){
    … …  
    6155                        '<input type="text" name="wpc_weekly_schedule_start_time[]" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_'+i+' wpc_mt_two wpc-mr-one wpc-settings-input attr-form-control" placeholder="Start time" />'+
    6256                        '<input type="text" name="wpc_weekly_schedule_end_time[]" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_'+i+'  wpc-settings-input attr-form-control" placeholder="End time"/>'+
    63                         '<div class="wpc_weekly_clear" id="'+i+'" >clear</div>'+
    6457                     '</div>'+
    6558                     '<span class="dashicons dashicons-no-alt remove_schedule_block wpc-btn"></span>'+
    … …  
    6962         }
    7063     });
    71      time_class = ['.wpc_weekly_schedule_start_time','.wpc_weekly_schedule_end_time','.wpc_exception_start_time',
     64
     65    // remove shcedule block
     66    $(".schedule_main_block").on( 'click' ,'.remove_schedule_block', function(e) {
     67        e.preventDefault();
     68        $(this).parent('.schedule_block').remove();
     69        increase--;
     70    });
     71    $(".exception_main_block").on( 'click' ,'.remove_exception_block', function(e) {
     72        e.preventDefault();
     73        $(this).parent('div').remove();
     74        increase--;
     75    });
     76
     77     var time_class = ['.wpc_weekly_schedule_start_time','.wpc_weekly_schedule_end_time','.wpc_exception_start_time',
    7278    '.wpc_exception_end_time'];
    73      // date flatpicker 
     79     // date timepicker 
    7480     $.map(time_class,function(value,index){
    7581        $(document).on('focus', value , function(){
    76             $(this).flatpickr({
    77                     enableTime: true,
    78                     noCalendar: true,
    79                     dateFormat: "h:i K",
    80                     time_24hr : false,
     82            $(this).timepicker({
     83                timeFormat: 'h:mm p',
     84                interval: 30,
     85                dynamic: true,
     86                dropdown: true,
     87                scrollbar: true
    8188            });
    8289        });
    8390    });
    84      $(".schedule_main_block").on( 'click' ,'.remove_schedule_block', function(e) {
    85          e.preventDefault();
    86          $(this).parent('.schedule_block').remove();
    87          increase--;
    88      });
    89      //clear action
    90      $(document).on('click','.wpc_weekly_clear',function(){
    91         var id = $(this).attr('id');
    92         $('.wpc_weekly_schedule_start_time_'+id+', .wpc_weekly_schedule_end_time_'+id+' ').flatpickr();
    93      });
    94     $(document).on('click','.exception_time_clear',function(){
    95         var id = $(this).attr('id');
    96         $('.wpc_exception_start_time_'+id+', .wpc_exception_end_time_'+id+' ').flatpickr();
    97      });
    98      $(document).on('click','.wpc_all_day_clear',function() {
    99         $('.wpc_all_day_start, .wpc_all_day_end ').flatpickr({
    100             errorHandler: (error) => {
    101               }
    102         });
    103     });
     91    var clear_class = ['.wpc_weekly_clear','.wpc_all_day_clear','.exception_time_clear'];
     92
     93    $.each(clear_class,function(ind,val){
     94        $(document).on('click', val ,function(){
     95            if ( ind === 0 ) {
     96                $('input[name="wpc_weekly_schedule_start_time[]"]').val('');
     97                $('input[name="wpc_weekly_schedule_end_time[]"]').val('');
     98            }
     99            else if(ind === 1) {
     100                $('input[name="wpc_all_day_start_time"]').val('');
     101                $('input[name="wpc_all_day_end_time"]').val('');
     102            }
     103            else if(ind === 2) {
     104                $('input[name="wpc_exception_start_time[]"]').val('');
     105                $('input[name="wpc_exception_end_time[]"]').val('');
     106            }
     107        })
     108    })
    104109
    105110     // weekly schedule select
    … …  
    141146     });
    142147    // all day shcedule
    143     $(document).on('focus',".wpc_all_day_start , .wpc_all_day_end ", function(){
     148    $(document).on('focus',".wpc_all_day_start , .wpc_all_day_end", function(){
    144149        if( selected_values.length == 0 ){
    145150            $('input.wpc_all_day_start,input.wpc_all_day_end').removeAttr("disabled");
    146             $(this).flatpickr({
    147                 enableTime: true,
    148                 noCalendar: true,
    149                 dateFormat: "h:i K",
    150                 time_24hr : false,
     151            $(this).timepicker({
     152                timeFormat: 'h:mm p',
     153                interval: 30,
     154                dynamic: true,
     155                dropdown: true,
     156                scrollbar: true
    151157            });
    152158        }else{
    … …  
    163169  (function($){
    164170    $(document).ready(function() {
    165         // get object   
    166         var wpc_booking_form_data = JSON.parse(wpc_client_booking_form_data);
     171        // get data from enqueue
     172        var wpc_booking_form_data;   
     173        if ( typeof wpc_form_data !=="undefined") {
     174            wpc_booking_form_data = wpc_form_data;
     175        }
    167176        // set location in local storage
    168177        $(document).on( 'click' , '.wpc-select-location' ,function(){
    … …  
    229238        }
    230239        // time format
    231         wpc_flat_time_format = true ;
    232         // time format
    233         if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
    234             wpc_time_format = 'H:i';
    235             wpc_flat_time_format = true;
    236         } else {
    237             wpc_time_format = 'h:i K';
    238             wpc_flat_time_format = false ;
    239         }
    240         // date format
    241         if( wpc_booking_form_data.wpc_date_format != "" ){
    242             wpc_date_format = wpc_booking_form_data.wpc_date_format;
    243         }else{
     240       var wpc_time_format; var wpc_date_format;
     241
     242        if ( typeof wpc_booking_form_data === "undefined" ){
     243            wpc_time_format = 'HH:mm';
    244244            wpc_date_format = 'yyyy-mm-dd'
     245        }
     246        else{
     247            if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
     248                wpc_time_format = 'HH:mm';
     249            } else {
     250                wpc_time_format = 'h:mm p';
     251            }
     252            // date format
     253            if( wpc_booking_form_data.wpc_date_format != "" ){
     254                wpc_date_format = wpc_booking_form_data.wpc_date_format;
     255            }else{
     256                wpc_date_format = 'yyyy-mm-dd'
     257            }
    245258        }
    246259        // check weekly and all day schedule
    … …  
    312325            }
    313326        }
    314         // change date format to expected format in flas
     327        // change date format to expected format
    315328        const wpc_flatpicker_date_change =(selectedDates,format)=>{
    316329            const wpc_date_ar         = selectedDates.map(date => flatpickr.formatDate(date, format));
    … …  
    319332        }
    320333        //  from time 
    321         var time_picker_from = $('#wpc_from_time').flatpickr({
    322             enableTime  : true,
    323             noCalendar  : true,
    324             dateFormat  : wpc_time_format,
    325             time_24hr   : wpc_flat_time_format,
    326             onChange  : function(selectedDates, dateStr, instance) {
    327                 var selected_time     = wpc_flatpicker_date_change( selectedDates , 'H:i');
    328                 var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
    329                 // late bookings
    330                 if ( wpc_time_format != 'H:i' &&  typeof wpc_end_time !== 'undefined' ){
    331                     wpc_end_time  = convertTime12to24( wpc_end_time );
    332                     selected_time = convertTime12to24( selected_time );
    333                 }
    334 
    335                 if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
    336                     var last_booking_time = time_diff(wpc_end_time, "00:14");
    337                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    338                         wpc_check_late_booking(selected_time,last_booking_time,15);
     334        $('#wpc_from_time').timepicker({
     335            timeFormat  : wpc_time_format,
     336            dynamic     : true,
     337            change      : function( time ) {
     338                if (time !== null) {
     339                    // the input field
     340                    var element = $(this), text;
     341                    // get access to this Timepicker instance
     342                    var timepicker = element.timepicker();
     343                    var selected_time     = timepicker.format(time);
     344
     345                    if ( typeof wpc_booking_form_data !=="undefined" ) {
     346                        var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
     347                        // late bookings
     348                        if ( wpc_time_format != 'HH:mm' &&  typeof wpc_end_time !== 'undefined' ){
     349                            wpc_end_time  = convertTime12to24( wpc_end_time );
     350                            selected_time = convertTime12to24( selected_time );
     351                        }
     352       
     353                        if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
     354                            var last_booking_time = time_diff(wpc_end_time, "00:14");
     355                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     356                                wpc_check_late_booking(selected_time,last_booking_time,15);
     357                            }
     358                        }
     359                        else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
     360                            var last_booking_time = time_diff(wpc_end_time, "00:29");
     361                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     362                                wpc_check_late_booking(selected_time,last_booking_time,30);
     363                            }
     364                        }
     365                        else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
     366                            var last_booking_time = time_diff(wpc_end_time, "00:44");
     367                            if (selected_time !== '' && selected_time !== ',undefined' ) {
     368                                wpc_check_late_booking(selected_time,last_booking_time,45);
     369                            }
     370                        }
    339371                    }
    340372                }
    341                 else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
    342                     var last_booking_time = time_diff(wpc_end_time, "00:29");
    343                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    344                         wpc_check_late_booking(selected_time,last_booking_time,30);
    345                     }
    346                 }
    347                 else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
    348                     var last_booking_time = time_diff(wpc_end_time, "00:44");
    349                     if (selected_time !== '' && selected_time !== ',undefined' ) {
    350                         wpc_check_late_booking(selected_time,last_booking_time,45);
    351                     }
    352                 }
    353373            }
    354374        });
    355375
    356376        //  To
    357         time_picker_to  =   $('#wpc_to_time').flatpickr({
    358             enableTime: true,
    359             noCalendar: true,
    360             dateFormat: wpc_time_format,
    361             time_24hr : wpc_flat_time_format
     377         $('#wpc_to_time').timepicker({
     378            timeFormat  : wpc_time_format,
     379            dynamic     : true,
    362380        });
    363381
    … …  
    365383        $(document).on('focus','#wpc_booking_date', function( e ){
    366384            e.preventDefault();
    367             var wpc_early_bookings    = wpc_booking_form_data.wpc_early_bookings;
    368             var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
    369             var wpc_one_week          = wpc_booking_form_data.wpc_one_week;
    370             var wpc_one_month         = wpc_booking_form_data.wpc_one_month;
    371             var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
    372             var wpc_max_day ='';
    373 
    374             // early bookings
    375             if (typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1day') {
    376                 wpc_max_day = new Date(wpc_one_day);
    377             }
    378             else if(typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1week' )
    379             {
    380                 wpc_max_day = new Date(wpc_one_week);
    381             }
    382             else if( typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1month' )
    383             {
    384                 wpc_max_day = new Date(wpc_one_month);
    385             }
    386             else{
    387                 wpc_max_day = false;
    388             }
    389             $(this).flatpickr({
    390                 dateFormat: wpc_date_format,
    391                 minDate   : "today",
    392                 maxDate   : wpc_max_day,
    393                 position  : "below",
    394                 onChange  : function(selectedDates, dateStr, instance) {
    395                     var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"Y-m-d");
    396                     var exception_date        = wpc_booking_form_data.wpc_exception_date;
    397                     $("#wpc_booking_date").val('');
    398                     $("#wpc_booking_date").val(dateStr);
    399 
    400                     if ( typeof exception_date === "undefined" )
    401                     {
    402                         var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
    403                         wpc_weekly_daily_schedule( wpc_new_selected_date ); 
    404                     }
    405                     else{
    406    
    407                         if (exception_date.length > 0 && exception_date[0] !== '') {
    408                             if ( $.inArray( wpc_new_selected_date,exception_date) !== -1)
    409                             {
    410                                 var index = exception_date.indexOf(wpc_new_selected_date);
    411                                 wpc_start_time = wpc_booking_form_data.wpc_exception_start_time[index];
    412                                 wpc_end_time   = wpc_booking_form_data.wpc_exception_end_time[index];
    413                             }
     385            if ( typeof wpc_booking_form_data !=="undefined") {
     386                var wpc_early_bookings    = wpc_booking_form_data.wpc_early_bookings;
     387                var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
     388                var wpc_one_week          = wpc_booking_form_data.wpc_one_week;
     389                var wpc_one_month         = wpc_booking_form_data.wpc_one_month;
     390                var wpc_one_day           = wpc_booking_form_data.wpc_one_day;
     391                var wpc_max_day ='';
     392
     393                // early bookings
     394                if (typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1day') {
     395                    wpc_max_day = new Date(wpc_one_day);
     396                }
     397                else if(typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1week' )
     398                {
     399                    wpc_max_day = new Date(wpc_one_week);
     400                }
     401                else if( typeof wpc_early_bookings !== 'undefinded' && wpc_early_bookings == '1month' )
     402                {
     403                    wpc_max_day = new Date(wpc_one_month);
     404                }
     405                else{
     406                    wpc_max_day = false;
     407                }
     408                $(this).flatpickr({
     409                    dateFormat: wpc_date_format,
     410                    minDate   : "today",
     411                    maxDate   : wpc_max_day,
     412                    position  : "below",
     413                    onChange  : function(selectedDates, dateStr, instance) {
     414                        var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"Y-m-d");
     415                        var exception_date        = wpc_booking_form_data.wpc_exception_date;
     416                        $("#wpc_booking_date").val('');
     417                        $("#wpc_booking_date").val(dateStr);
     418
     419                        if ( typeof exception_date === "undefined" )
     420                        {
     421                            var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
     422                            wpc_weekly_daily_schedule( wpc_new_selected_date ); 
     423                        }
     424                        else{
     425       
     426                            if (exception_date.length > 0 && exception_date[0] !== '') {
     427                                if ( $.inArray( wpc_new_selected_date,exception_date) !== -1)
     428                                {
     429                                    var index = exception_date.indexOf(wpc_new_selected_date);
     430                                    wpc_start_time = wpc_booking_form_data.wpc_exception_start_time[index];
     431                                    wpc_end_time   = wpc_booking_form_data.wpc_exception_end_time[index];
     432                                }
     433                                else
     434                                {
     435                                    var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
     436                                    wpc_weekly_daily_schedule( wpc_new_selected_date );
     437                                }
     438                            }
    414439                            else
    415440                            {
    … …  
    418443                            }
    419444                        }
    420                         else
    421                         {
    422                             var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates,"D");
    423                             wpc_weekly_daily_schedule( wpc_new_selected_date );
    424                         }
     445                        if( wpc_booking_form_data.length == 0 ){
     446                            $("#wpc-booking-date").val(' ');
     447                            alert("No schedule set.");
     448                            $("#wpc_from_time").prop('disabled',true);
     449                            $("#wpc_to_time").prop('disabled',true);
     450       
     451                        }else{
     452                            $("#wpc_from_time").prop('disabled',false);
     453                            $("#wpc_to_time").prop('disabled',false);
     454
     455                            if (wpc_time_format == "h:mm p") {       
     456                                wpc_start_time = convertTime12to24(wpc_start_time);
     457                                wpc_end_time   = convertTime12to24(wpc_end_time);
     458                            }
     459
     460                            $('#wpc_from_time').timepicker('option','minTime', wpc_start_time);
     461                            $('#wpc_from_time').timepicker('option','maxTime', wpc_end_time);
     462
     463                            $('#wpc_to_time').timepicker('option','minTime', wpc_start_time);
     464                            $('#wpc_to_time').timepicker('option','maxTime', wpc_end_time);
     465                        }
    425466                    }
    426                     if( wpc_booking_form_data.length == 0 ){
    427                         $("#wpc-booking-date").val(' ');
    428                         alert("No schedule set.");
    429                         $("#wpc_from_time").prop('disabled',true);
    430                         $("#wpc_to_time").prop('disabled',true);
    431    
    432                     }else{
    433                         $("#wpc_from_time").prop('disabled',false);
    434                         $("#wpc_to_time").prop('disabled',false);
    435 
    436                         if (wpc_flat_time_format === false) {       
    437                             wpc_start_time = convertTime12to24(wpc_start_time);
    438                             wpc_end_time   = convertTime12to24(wpc_end_time);
    439                         }
    440                         wpc_start_arr = wpc_start_time.split(":");
    441                         time_picker_to.set({ defaultHour: wpc_start_arr[0] , defaultMinute: wpc_start_arr[1] , minTime: wpc_start_time, maxTime: wpc_end_time });
    442                         time_picker_from.set({ defaultHour: wpc_start_arr[0] ,defaultMinute: wpc_start_arr[1], minTime: wpc_start_time, maxTime: wpc_end_time });
    443                     }
    444                 }
    445                 // onset function end
    446             });
    447             // flatpicker date end
     467                    // onset function end
     468                });
     469                // flatpicker date end
     470            }
    448471        });
    449472
  • wp-cafe/trunk/assets/js/wpc-public.js

    r2343218 r2358899  
     1"use strict";
    12// get object key name
    23const objectKeyName = (obj) => {
    … …  
    4041        }
    4142        return response;
    42     }
    43     (function ($) {
    44         var local_storage_value = localStorage.getItem('wpc_location');
    45         $("#wpc_location_name option[value='" + local_storage_value + "']").attr("selected", true);
    46 
    47         $(document).ready(function () {
    48             // get object   
    49             var wpc_form_data = JSON.parse(wpc_client_booking_form_data);
    50             var wpc_booking_form_data = wpc_form_data.settings;
    51 
    52             // set location in local storage and cancell modal
    53             $(document).on('click', '.wpc-select-location', function () {
    54                 wpc_location = $('.wpc-location option:selected').val();
    55 
    56                 var local_storage_value = localStorage.getItem('wpc_location');
    57                 if (local_storage_value === null) {
    58                     localStorage.setItem('wpc_location', wpc_location);
    59                 } else {
    60                     localStorage.removeItem('wpc_location');
    61                     localStorage.setItem('wpc_location', wpc_location);
    62                 }
    63                 $(".wpc_modal").fadeOut();
    64                 $('body').removeClass('wpc_location_popup');
    65 
    66             });
    67             wpc_date_format = "";
    68             wpc_start_time = "";
    69             wpc_end_time = "";
    70             wpc_all_day_start_time = "";
    71             wpc_all_day_end_time = "";
    72 
    73             // convert time 12 to 24
    74             const convertTime12to24 = (time12h) => {
    75                 const [time, modifier] = time12h.split(' ');
    76 
    77                 let [hours, minutes] = time.split(':');
    78 
    79                 if (hours === '12') {
    80                     hours = '00';
    81                 }
    82 
    83                 if (modifier === 'PM') {
    84                     hours = parseInt(hours, 10) + 12;
    85                 }
    86                 time_arr = [];
    87                 return `${hours}:${minutes}`;
    88             }
    89             // calculate time difference
    90             const time_diff = (wpc_end_time, last_time) => {
    91                 wpc_end_time = wpc_end_time.replace(',', ':');
    92                 var startTime = moment(wpc_end_time, "HH:mm");
    93                 var endTime = moment(last_time, "HH:mm");
    94                 var duration = moment.duration(startTime.diff(endTime));
    95                 var hours = parseInt(duration.asHours());
    96                 var minutes = parseInt(duration.asMinutes()) - hours * 60;
    97                 return hours + ':' + minutes;
    98             }
    99             // check late booking
    100             const time_diff_for_before_after_equal = (select_time, last_booking_time) => {
    101                 var startTime = moment(select_time, "HH:mm");
    102                 var endTime = moment(last_booking_time, "HH:mm");
    103 
    104                 if (startTime.isBefore(endTime)) {
    105                     data = "early";
    106                 } else if (startTime.isSame(endTime)) {
    107                     data = "equal";
    108                 } else if (startTime.isAfter(endTime)) {
    109                     data = "late";
    110                 } else {
    111                     data = "unknown";
    112                 }
    113                 return data;
    114             }
    115             wpc_flat_time_format = true;
    116             // time format
     43}
     44(function ($) {
     45    var local_storage_value = localStorage.getItem('wpc_location');
     46    $("#wpc_location_name option[value='" + local_storage_value + "']").attr("selected", true);
     47
     48    $(document).ready(function () {
     49
     50        // get data from enqueue
     51        var wpc_booking_form_data;   
     52        if ( typeof wpc_form_client_data !=="undefined") {
     53            var wpc_form_data =JSON.parse(wpc_form_client_data);
     54            wpc_booking_form_data = wpc_form_data.settings;
     55        }
     56        // set location in local storage and cancell modal
     57        $(document).on('click', '.wpc-select-location', function () {
     58            var wpc_location = $('.wpc-location option:selected').val();
     59
     60            var local_storage_value = localStorage.getItem('wpc_location');
     61            if (local_storage_value === null) {
     62                localStorage.setItem('wpc_location', wpc_location);
     63            } else {
     64                localStorage.removeItem('wpc_location');
     65                localStorage.setItem('wpc_location', wpc_location);
     66            }
     67            $(".wpc_modal").fadeOut();
     68            $('body').removeClass('wpc_location_popup');
     69
     70        });
     71        var wpc_date_format = "";
     72        var wpc_start_time = "";
     73        var wpc_end_time = "";
     74        var wpc_all_day_start_time = "";
     75        var wpc_all_day_end_time = "";
     76
     77        // convert time 12 to 24
     78        const convertTime12to24 = (time12h) => {
     79            const [time, modifier] = time12h.split(' ');
     80
     81            let [hours, minutes] = time.split(':');
     82
     83            if (hours === '12') {
     84                hours = '00';
     85            }
     86
     87            if (modifier === 'PM') {
     88                hours = parseInt(hours, 10) + 12;
     89            }
     90            return `${hours}:${minutes}`;
     91        }
     92        // calculate time difference
     93        const time_diff = (wpc_end_time, last_time) => {
     94            wpc_end_time = wpc_end_time.replace(',', ':');
     95            var startTime = moment(wpc_end_time, "HH:mm");
     96            var endTime = moment(last_time, "HH:mm");
     97            var duration = moment.duration(startTime.diff(endTime));
     98            var hours = parseInt(duration.asHours());
     99            var minutes = parseInt(duration.asMinutes()) - hours * 60;
     100            return hours + ':' + minutes;
     101        }
     102        // check late booking
     103        const time_diff_for_before_after_equal = (select_time, last_booking_time) => {
     104            var startTime = moment(select_time, "HH:mm");
     105            var endTime = moment(last_booking_time, "HH:mm");
     106            var data;
     107            if (startTime.isBefore(endTime)) {
     108                data = "early";
     109            } else if (startTime.isSame(endTime)) {
     110                data = "equal";
     111            } else if (startTime.isAfter(endTime)) {
     112                data = "late";
     113            } else {
     114                data = "unknown";
     115            }
     116            return data;
     117        }
     118         var wpc_time_format; var wpc_date_format;
     119        // time format
     120        if ( typeof wpc_booking_form_data === "undefined" ){
     121            wpc_time_format = 'HH:mm';
     122            wpc_date_format = 'yyyy-mm-dd'
     123        }
     124        else{
    117125            if (wpc_booking_form_data.wpc_time_format == "24" || wpc_booking_form_data.wpc_time_format == "") {
    118                 wpc_time_format = 'H:i';
    119                 wpc_flat_time_format = true;
     126                wpc_time_format = 'HH:mm';
    120127            } else {
    121                 wpc_time_format = 'h:i K';
    122                 wpc_flat_time_format = false;
     128                wpc_time_format = 'h:mm p';
    123129            }
    124130            // date format
    125             if (wpc_booking_form_data.wpc_date_format != "") {
     131            if ( wpc_booking_form_data.wpc_date_format != "") {
    126132                wpc_date_format = wpc_booking_form_data.wpc_date_format;
    127133            } else {
    128134                wpc_date_format = 'yyyy-mm-dd'
    129135            }
    130             // check weekly and all day schedule
    131             const wpc_weekly_daily_schedule = (selected_day) => {
    132                 // time range for all day
    133                 if (wpc_booking_form_data.wpc_all_day_start_time != "" && wpc_booking_form_data.wpc_all_day_end_time != "") {
    134                     wpc_all_day_start_time = wpc_booking_form_data.wpc_all_day_start_time;
    135                     wpc_all_day_end_time = wpc_booking_form_data.wpc_all_day_end_time;
    136 
     136        }
     137        // check weekly and all day schedule
     138        const wpc_weekly_daily_schedule = (selected_day) => {
     139            // time range for all day
     140            if (wpc_booking_form_data.wpc_all_day_start_time != "" && wpc_booking_form_data.wpc_all_day_end_time != "") {
     141                wpc_all_day_start_time = wpc_booking_form_data.wpc_all_day_start_time;
     142                wpc_all_day_end_time = wpc_booking_form_data.wpc_all_day_end_time;
     143
     144                if (wpc_booking_form_data.wpc_time_format == '24') {
     145                    wpc_start_time = convertTime12to24(wpc_all_day_start_time);
     146                    wpc_end_time = convertTime12to24(wpc_all_day_end_time);
     147                } else {
     148                    wpc_start_time = wpc_all_day_start_time;
     149                    wpc_end_time = wpc_all_day_end_time;
     150                }
     151                $('#wpc-booking-date').removeClass("wpc_booking_error");
     152                button_disable();
     153            }
     154             else {
     155                var weekly_schedule_arr = wpc_booking_form_data.wpc_weekly_schedule;
     156                var weekly_start_time = wpc_booking_form_data.wpc_weekly_schedule_start_time;
     157                var weekly_end_time = wpc_booking_form_data.wpc_weekly_schedule_end_time;
     158                var response = wpc_weekly_schedule_time(weekly_schedule_arr, selected_day, weekly_start_time, weekly_end_time);
     159                if (response.success == true) {
     160                    $("#wpc-from-time").prop('disabled', false);
     161                    $("#wpc-to-time").prop('disabled', false);
    137162                    if (wpc_booking_form_data.wpc_time_format == '24') {
    138                         wpc_start_time = convertTime12to24(wpc_all_day_start_time);
    139                         wpc_end_time = convertTime12to24(wpc_all_day_end_time);
     163                        wpc_start_time = convertTime12to24(response.wpc_start_time);
     164                        wpc_end_time = convertTime12to24(response.wpc_end_time);
    140165                    } else {
    141                         wpc_start_time = wpc_all_day_start_time;
    142                         wpc_end_time = wpc_all_day_end_time;
     166                        wpc_start_time = response.wpc_start_time;
     167                        wpc_end_time = response.wpc_end_time;
    143168                    }
    144169                    $('#wpc-booking-date').removeClass("wpc_booking_error");
    145170                    button_disable();
    146171                } else {
    147                     var weekly_schedule_arr = wpc_booking_form_data.wpc_weekly_schedule;
    148                     var weekly_start_time = wpc_booking_form_data.wpc_weekly_schedule_start_time;
    149                     var weekly_end_time = wpc_booking_form_data.wpc_weekly_schedule_end_time;
    150                     var response = wpc_weekly_schedule_time(weekly_schedule_arr, selected_day, weekly_start_time, weekly_end_time);
    151                     if (response.success == true) {
    152                         $("#wpc-from-time").prop('disabled', false);
    153                         $("#wpc-to-time").prop('disabled', false);
    154                         if (wpc_booking_form_data.wpc_time_format == '24') {
    155                             wpc_start_time = convertTime12to24(response.wpc_start_time);
    156                             wpc_end_time = convertTime12to24(response.wpc_end_time);
     172                    $("#wpc-booking-date").val(" ");
     173                    $('#wpc-booking-date').addClass("wpc_booking_error");
     174                    if (selected_day !== '') {
     175                        alert("No schedule set for the day .");
     176                    }
     177                    $("#wpc-from-time").prop('disabled', true);
     178                    $("#wpc-to-time").prop('disabled', true);
     179                    return "clear_date";
     180                }
     181            }
     182        }
     183        if (typeof wpc_date_format === 'undefined') {
     184            wpc_date_format = 'yyyy-mm-dd';
     185        }
     186
     187        // check late booking
     188        const wpc_check_late_booking = (selected_time, last_booking_time, min) => {
     189            var time_diff_latebooked = time_diff_for_before_after_equal(selected_time, last_booking_time);
     190            if (time_diff_latebooked == 'late') {
     191                $('#wpc-from-time').val(' ');
     192                $('.wpc_error_message').html("");
     193                $('.wpc_error_message').css("display","block");
     194                $('.wpc_error_message').html("You can boook before  " + min + " minutes of closing time .");
     195            } else {
     196                $('.wpc_error_message').html("");
     197                $('.wpc_error_message').css("display","none");
     198                $('#wpc-from-time').removeClass("wpc_booking_error");
     199                button_disable();
     200            }
     201        }
     202        //  from time 
     203        $('#wpc-from-time').timepicker({
     204            timeFormat  : wpc_time_format,
     205            dynamic     : true,
     206            change      : function (time) {
     207                if (time !== null) {
     208                    // the input field
     209                    var element = $(this);
     210                    // get access to this Timepicker instance
     211                    var timepicker = element.timepicker();
     212                    var selected_time     = timepicker.format(time);
     213
     214                    if ( typeof wpc_booking_form_data !== "undefined") {
     215                        var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
     216                        // late bookings
     217                        if (wpc_time_format != 'HH:mm' && typeof wpc_end_time !== 'undefined') {
     218                            wpc_end_time = convertTime12to24(wpc_end_time);
     219                            selected_time = convertTime12to24(selected_time);
     220                        }
     221                        if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
     222                            var last_booking_time = time_diff(wpc_end_time, "00:14");
     223                            if (selected_time !== '' && selected_time !== ',undefined') {
     224                                wpc_check_late_booking(selected_time, last_booking_time, 15);
     225                            }
     226                        } else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
     227                            var last_booking_time = time_diff(wpc_end_time, "00:29");
     228                            if (selected_time !== '' && selected_time !== ',undefined') {
     229                                wpc_check_late_booking(selected_time, last_booking_time, 30);
     230                                return;
     231                            }
     232                        } else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
     233                            var last_booking_time = time_diff(wpc_end_time, "00:44");
     234                            if (selected_time !== '' && selected_time !== ',undefined') {
     235                                wpc_check_late_booking(selected_time, last_booking_time, 45);
     236                            }
    157237                        } else {
    158                             wpc_start_time = response.wpc_start_time;
    159                             wpc_end_time = response.wpc_end_time;
    160                         }
    161                         $('#wpc-booking-date').removeClass("wpc_booking_error");
    162                         button_disable();
    163                     } else {
    164                         $("#wpc-booking-date").val(" ");
    165                         $('#wpc-booking-date').addClass("wpc_booking_error");
    166                         if (selected_day !== '') {
    167                             alert("No schedule set for the day .");
    168                         }
    169                         $("#wpc-from-time").prop('disabled', true);
    170                         $("#wpc-to-time").prop('disabled', true);
    171                         return "clear_date";
    172                     }
    173                 }
    174             }
    175             if (typeof wpc_date_format === 'undefined') {
    176                 wpc_date_format = 'yyyy-mm-dd';
    177             }
    178 
    179             // check late booking
    180             const wpc_check_late_booking = (selected_time, last_booking_time, min) => {
    181                 time_diff_latebooked = time_diff_for_before_after_equal(selected_time, last_booking_time);
    182                 if (time_diff_latebooked == 'late') {
    183                     $('#wpc-from-time').val(' ');
    184                     $('.wpc_error_message').html("");
    185                     $('.wpc_error_message').html("You can boook before  " + min + " minutes of closing time .");
    186                 } else {
    187                     $('.wpc_error_message').html("");
    188                     $('#wpc-from-time').removeClass("wpc_booking_error");
    189                     button_disable();
    190                 }
    191             }
    192             //  from time 
    193             var time_picker_from = $('#wpc-from-time').flatpickr({
    194                 enableTime: true,
    195                 noCalendar: true,
    196                 dateFormat: wpc_time_format,
    197                 time_24hr: wpc_flat_time_format,
    198                 onChange: function (selectedDates, dateStr, instance) {
    199                     var selected_time = wpc_flatpicker_date_change(selectedDates, 'H:i');
    200                     var wpc_late_bookings = wpc_booking_form_data.wpc_late_bookings;
    201                     // late bookings
    202                     if (wpc_time_format != 'H:i' && typeof wpc_end_time !== 'undefined') {
    203                         wpc_end_time = convertTime12to24(wpc_end_time);
    204                         selected_time = convertTime12to24(selected_time);
    205                     }
    206                     if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '15') {
    207                         var last_booking_time = time_diff(wpc_end_time, "00:14");
    208                         if (selected_time !== '' && selected_time !== ',undefined') {
    209                             wpc_check_late_booking(selected_time, last_booking_time, 15);
    210                         }
    211                     } else if (typeof wpc_late_bookings !== 'undefinded' && wpc_late_bookings == '30') {
    212                         var last_booking_time = time_diff(wpc_end_time, "00:29");
    213                         if (selected_time !== '' && selected_time !== ',undefined') {
    214                             wpc_late_check = wpc_check_late_booking(selected_time, last_booking_time, 30);
    215                             return;
    216                         }
    217                     } else if (wpc_late_bookings != 'undefinded' && wpc_late_bookings == '45') {
    218                         var last_booking_time = time_diff(wpc_end_time, "00:44");
    219                         if (selected_time !== '' && selected_time !== ',undefined') {
    220                             wpc_check_late_booking(selected_time, last_booking_time, 45);
    221                         }
    222                     } else {
     238                            $('#wpc-from-time').removeClass("wpc_booking_error");
     239                            button_disable();
     240                        }
     241                    }
     242                    else{
    223243                        $('#wpc-from-time').removeClass("wpc_booking_error");
    224                         button_disable();
    225                     }
    226                 }
    227             });
    228             //  To
    229             var time_picker_to = $("#wpc-to-time").flatpickr({
    230                 enableTime: true,
    231                 noCalendar: true,
    232                 dateFormat: wpc_time_format,
    233                 time_24hr: wpc_flat_time_format,
    234                 onChange: function (selectedDates, dateStr, instance) {
    235                     var selected_time = wpc_flatpicker_date_change(selectedDates, 'H:i');
    236                     if (selected_time) {
     244                    }
     245                }
     246            }
     247        });
     248        //  To
     249        $("#wpc-to-time").timepicker({
     250            timeFormat  : wpc_time_format,
     251            dynamic     : true,
     252            change      : function( time ) {
     253                if (time !== null) {
     254                    if (time) {
    237255                        $('#wpc-to-time').removeClass("wpc_booking_error");
    238256                        button_disable();
    239257                    }
    240258                }
    241             });
     259            }
     260        });
     261        if ( typeof wpc_booking_form_data !== "undefined") {
    242262            var wpc_early_bookings = wpc_booking_form_data.wpc_early_bookings;
    243263            var wpc_one_day = wpc_booking_form_data.wpc_one_day;
    … …  
    257277                wpc_max_day = false;
    258278            }
    259             var wpc_pro_form_data = $(".wpc-calender-view").html()
    260             inline_value = true;
    261             if (typeof wpc_pro_form_data !== 'undefined' && wpc_pro_form_data == 'no') {
    262                 inline_value = false;
    263             }
    264             // inline flat picker date
    265             if ($('#wpc-booking-date').length > 0) {
    266                 document.getElementById('wpc-booking-date').flatpickr({
    267                     dateFormat: wpc_date_format,
    268                     minDate: "today",
    269                     maxDate: wpc_max_day,
    270                     position: "below",
    271                     inline: inline_value,
    272                     onChange: function (selectedDates, dateStr, instance) {
     279        }
     280        var wpc_pro_form_data = $(".wpc-calender-view").html()
     281        var inline_value = true;
     282        if (typeof wpc_pro_form_data !== 'undefined' && wpc_pro_form_data == 'no') {
     283            inline_value = false;
     284        }
     285        // inline flat picker date
     286        if ($('#wpc-booking-date').length > 0) {
     287            document.getElementById('wpc-booking-date').flatpickr({
     288                dateFormat: wpc_date_format,
     289                minDate: "today",
     290                maxDate: wpc_max_day,
     291                position: "below",
     292                inline: inline_value,
     293                onChange: function (selectedDates, dateStr, instance) {
     294                    if (typeof wpc_booking_form_data !== "undefined") {
    273295                        var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "Y-m-d");
     296                       
    274297                        var exception_date = wpc_booking_form_data.wpc_exception_date;
    275 
    276298                        if (typeof exception_date === "undefined") {
    277299                            var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "D");
    … …  
    302324                            $("#wpc-from-time").prop('disabled', false);
    303325                            $("#wpc-to-time").prop('disabled', false);
    304                             if (wpc_flat_time_format === false) {
     326
     327                            if (wpc_time_format == "h:mm p") {       
    305328                                wpc_start_time = convertTime12to24(wpc_start_time);
    306                                 wpc_end_time = convertTime12to24(wpc_end_time);
     329                                wpc_end_time   = convertTime12to24(wpc_end_time);
    307330                            }
    308                             wpc_start_arr = wpc_start_time.split(":");
    309                             time_picker_to.set({
    310                                 defaultHour: wpc_start_arr[0],
    311                                 defaultMinute: wpc_start_arr[1],
    312                                 minTime: wpc_start_time,
    313                                 maxTime: wpc_end_time
    314                             });
    315                             time_picker_from.set({
    316                                 defaultHour: wpc_start_arr[0],
    317                                 defaultMinute: wpc_start_arr[1],
    318                                 minTime: wpc_start_time,
    319                                 maxTime: wpc_end_time
    320                             });
    321                         }
    322                     }
    323                 });
    324             }
    325             // Food menu tab js
    326             $('.schedule-tab').on('click', openScheduleTab);
    327 
    328             function openScheduleTab() {
    329                 var title = $(this).data('title');
    330                 var i, tabcontent, tablinks;
    331                 tabcontent = document.getElementsByClassName("tabcontent");
    332                 for (i = 0; i < tabcontent.length; i++) {
    333                     tabcontent[i].style.display = "none";
    334                 }
    335                 tablinks = document.getElementsByClassName("tablinks");
    336                 for (i = 0; i < tablinks.length; i++) {
    337                     tablinks[i].className = tablinks[i].className.replace(" active", "");
    338                 }
    339                 document.getElementById(title).style.display = "block";
    340             }
    341 
    342             $('.schedule-tab-shortcode').on('click', openScheduleTabShortCode);
    343 
    344             function openScheduleTabShortCode() {
    345                 var title = $(this).data('title');
    346                 var i, tabcontent, tablinks;
    347                 tabcontent = document.getElementsByClassName("tabcontent-shortcode");
    348                 for (i = 0; i < tabcontent.length; i++) {
    349                     tabcontent[i].style.display = "none";
    350                 }
    351                 tablinks = document.getElementsByClassName("tablinks-shortcode");
    352                 for (i = 0; i < tablinks.length; i++) {
    353                     tablinks[i].className = tablinks[i].className.replace(" active", "");
    354                 }
    355                 let single_title = "shortcode_" + title;
    356                 document.getElementById(single_title).style.display = "block";
    357             }
    358             // reservation form validation
    359             function button_disable() {
    360                 var length = $(".wpc_booking_error").length;
    361                 if (length == 0) {
    362                     $('.reservation_form_submit').prop('disabled', false);
    363                     $('.reservation_form_submit').removeClass('wpc_reservation_form_disabled');
    364                 } else {
    365                     $('.reservation_form_submit').prop('disabled', true);
    366                     $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
    367                 }
    368             }
    369             $(document).on("keyup", "input[name='wpc_name']", function () {
    370                 $(this).removeClass("wpc_booking_error");
     331                            $('#wpc-from-time').timepicker('option','minTime', wpc_start_time);
     332                            $('#wpc-from-time').timepicker('option','maxTime', wpc_end_time);
     333
     334                            $('#wpc-to-time').timepicker('option','minTime', wpc_start_time);
     335                            $('#wpc-to-time').timepicker('option','maxTime', wpc_end_time);
     336                        }
     337                    }
     338                    else{
     339                        $('#wpc-booking-date').removeClass("wpc_booking_error");
     340                    }
     341                }
     342            });
     343        }
     344        // Food menu tab js
     345        $('.schedule-tab').on('click', openScheduleTab);
     346
     347        function openScheduleTab() {
     348            var title = $(this).data('title');
     349            var i, tabcontent, tablinks;
     350            tabcontent = document.getElementsByClassName("tabcontent");
     351            for (i = 0; i < tabcontent.length; i++) {
     352                tabcontent[i].style.display = "none";
     353            }
     354            tablinks = document.getElementsByClassName("tablinks");
     355            for (i = 0; i < tablinks.length; i++) {
     356                tablinks[i].className = tablinks[i].className.replace(" active", "");
     357            }
     358            document.getElementById(title).style.display = "block";
     359        }
     360
     361        $('.schedule-tab-shortcode').on('click', openScheduleTabShortCode);
     362
     363        function openScheduleTabShortCode() {
     364            var title = $(this).data('title');
     365            var i, tabcontent, tablinks;
     366            tabcontent = document.getElementsByClassName("tabcontent-shortcode");
     367            for (i = 0; i < tabcontent.length; i++) {
     368                tabcontent[i].style.display = "none";
     369            }
     370            tablinks = document.getElementsByClassName("tablinks-shortcode");
     371            for (i = 0; i < tablinks.length; i++) {
     372                tablinks[i].className = tablinks[i].className.replace(" active", "");
     373            }
     374            let single_title = "shortcode_" + title;
     375            document.getElementById(single_title).style.display = "block";
     376        }
     377        // reservation form validation
     378        function button_disable() {
     379            var length = $(".wpc_booking_error").length;
     380            if (length == 0) {
     381                $('.reservation_form_submit').prop('disabled', false);
     382                $('.reservation_form_submit').removeClass('wpc_reservation_form_disabled');
     383            } else {
     384                $('.reservation_form_submit').prop('disabled', true);
     385                $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
     386            }
     387        }
     388        var check_selected_val = $("#wpc-party option:selected").val();
     389       
     390        if (check_selected_val =='' ) {
     391            $("#wpc-party").addClass('wpc_booking_error');
     392        }
     393
     394        var booking_field = [ "input[name='wpc_name']", "input[name='wpc_email']" ];
     395
     396        $("input").not(':button').each(function () {
     397            if ( $(this).attr('name') == 'wpc_phone' && $(this).prop('required') ) {
     398                $(this).addClass("wpc_booking_error");
     399                booking_field.push( "input[name='wpc_phone']" );
     400            }
     401            if ($(this).attr('name') == 'wpc_booking_date' || $(this).attr('name') == 'wpc_from_time' ||
     402                $(this).attr('name') == 'wpc_to_time' || $(this).attr('name') == 'wpc_name' ||
     403                $(this).attr('name') == 'wpc_email'
     404            ) {
     405                $(this).addClass("wpc_booking_error");
     406            }
     407            if ($(this).attr('name') == 'wpc_reservation_invoice' || $(this).attr('name') == 'wpc_cancell_email') {
     408                $(this).addClass("wpc_cancell_error");
     409            }
     410        });
     411
     412        $.each(booking_field, function( index, value ) {
     413            $(document).on("keyup", value , function () {
     414                if ( $(this).val().length == 0 ) {
     415                    $(this).addClass("wpc_booking_error");
     416                   
     417                }else{
     418                    $(this).removeClass("wpc_booking_error");
     419                }
    371420                button_disable();
    372421            });
    373             $(document).on("keyup", "input[name='wpc_email']", function () {
    374                 $(this).removeClass("wpc_booking_error");
    375                 button_disable();
    376             });
    377             $("input").not(':button').each(function () {
    378                 if ($(this).attr('name') == 'wpc_booking_date' || $(this).attr('name') == 'wpc_from_time' ||
    379                     $(this).attr('name') == 'wpc_to_time' || $(this).attr('name') == 'wpc_name' ||
    380                     $(this).attr('name') == 'wpc_email'
    381                 ) {
    382                     $(this).addClass("wpc_booking_error");
    383                 }
    384                 if ($(this).attr('name') == 'wpc_reservation_invoice' || $(this).attr('name') == 'wpc_cancell_email' ||
    385                     $(this).attr('name') == 'wpc_cancell_phone'
    386                 ) {
    387                     $(this).addClass("wpc_cancell_error");
    388                 }
    389 
    390             });
    391 
    392             var booking_length = $(".wpc_booking_error").length;
    393             if (booking_length > 0) {
    394                 $('.reservation_form_submit').prop('disabled', true);
    395                 $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
    396             }
    397             // reservation cancell
    398             function cancell_button_disable() {
    399                 var length = $(".wpc_cancell_error").length;
    400                 if (length == 0) {
    401                     $('.cancell_form_submit').prop('disabled', false);
    402                     $('.cancell_form_submit').removeClass('wpc_cancell_form_submit_disabled');
    403 
    404                 } else {
    405                     $('.cancell_form_submit').prop('disabled', true);
    406                     $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
    407 
    408                 }
    409             }
    410             var cancell_length = $(".wpc_cancell_error").length;
    411             if (cancell_length > 0) {
     422          });
     423
     424        $(document).on("change", "#wpc-party", function () {
     425            if ( $(this).val() == "" ) {
     426                $(this).addClass( "wpc_booking_error" );
     427            }
     428            else{
     429                $(this).removeClass( "wpc_booking_error" );
     430            }
     431            button_disable();
     432        });
     433
     434        var booking_length = $(".wpc_booking_error").length;
     435        if (booking_length > 0) {
     436            $('.reservation_form_submit').prop('disabled', true);
     437            $('.reservation_form_submit').addClass('wpc_reservation_form_disabled');
     438        }
     439        // reservation cancell
     440        function cancell_button_disable() {
     441            var length = $(".wpc_cancell_error").length;
     442            if (length == 0) {
     443                $('.cancell_form_submit').prop('disabled', false);
     444                $('.cancell_form_submit').removeClass('wpc_cancell_form_submit_disabled');
     445
     446            } else {
    412447                $('.cancell_form_submit').prop('disabled', true);
    413448                $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
    414449
    415450            }
    416             $(document).on("keyup", "input[name='wpc_reservation_invoice']", function () {
    417                 $(this).removeClass("wpc_cancell_error");
     451        }
     452        var cancell_length = $(".wpc_cancell_error").length;
     453        if (cancell_length > 0) {
     454            $('.cancell_form_submit').prop('disabled', true);
     455            $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled');
     456
     457        }
     458        var cancell_form_field = ["input[name='wpc_reservation_invoice']","input[name='wpc_cancell_email']"];
     459       
     460        $.each( cancell_form_field , function( index , value ){
     461            $(document).on( "keyup", value , function () {
     462                if ($(this).val().length === 0 ) {
     463                    $(this).addClass("wpc_cancell_error");
     464                }else{
     465                    $(this).removeClass("wpc_cancell_error");
     466                }
    418467                cancell_button_disable();
    419468            });
    420             $(document).on("keyup", "input[name='wpc_cancell_email']", function () {
    421                 $(this).removeClass("wpc_cancell_error");
    422                 cancell_button_disable();
    423             });
    424             $(document).on("keyup", "input[name='wpc_cancell_phone']", function () {
    425                 $(this).removeClass("wpc_cancell_error");
    426                 cancell_button_disable();
    427             });
    428 
    429             // modal on tab
    430             if (document.querySelector('.wpc_modal') !== null) {
    431                 $(".wpc_modal").fadeIn();
    432                 $('body').addClass("wpc_location_popup");
    433 
    434             }
    435             $(document).on('click', '.wpc-close', function () {
     469        })
     470
     471        // modal on tab
     472        if (document.querySelector('.wpc_modal') !== null) {
     473            $(".wpc_modal").fadeIn();
     474            $('body').addClass("wpc_location_popup");
     475
     476        }
     477        $(document).on('click', '.wpc-close', function () {
     478            $(".wpc_modal").fadeOut();
     479            $('body').removeClass("wpc_location_popup");
     480        });
     481
     482        $(document).on('mouseup', function (e) {
     483            var container = $("#wpc_location_modal");
     484            if (!container.is(e.target) && container.has(e.target).length === 0) {
    436485                $(".wpc_modal").fadeOut();
    437486                $('body').removeClass("wpc_location_popup");
    438             });
    439 
    440             $(document).on('mouseup', function (e) {
    441                 var container = $("#wpc_location_modal");
    442                 if (!container.is(e.target) && container.has(e.target).length === 0) {
    443                     $(".wpc_modal").fadeOut();
    444                     $('body').removeClass("wpc_location_popup");
    445                 }
    446             });
    447 
    448             // reservation from show /hide
    449             $(document).on('click', '#wpc_cancel_request', function () {
    450                 $('.wpc-reservation-form .wpc_reservation_table').slideUp();
    451                 $('.wpc-reservation-form .wpc_reservation_cancel_form').slideDown();
    452             });
    453             $(document).on('click', '#wpc_book_table', function () {
    454                 $('.wpc-reservation-form .wpc_reservation_cancel_form').slideUp();
    455                 $('.wpc-reservation-form .wpc_reservation_table').slideDown();
    456             });
    457 
    458             // cart icon open
    459             $(document).on('click', '.wpc_cart_icon', function (event) {
    460                 event.preventDefault();
    461 
    462                 $('.wpc_cart_block').toggleClass('cart_icon_active');
    463             });
    464 
    465             $(document).on('mouseup', function (e) {
    466                 var container = $(".wpc_cart_block");
    467                 if (!container.is(e.target) && container.has(e.target).length === 0) {
    468                     container.removeClass('cart_icon_active');
    469                 }
    470             });
    471 
    472             //   custom tabs
    473             $(document).on('click', '.wpc-tab-a', function (event) {
    474                 event.preventDefault();
    475                 $(this).parent().parent().parent().find(".wpc-tab").removeClass('tab-active');
    476                 $(".wpc-tab[data-id='" + $(this).attr('data-id') + "']").addClass("tab-active");
    477                 $(".wpc-tab-a").removeClass('wpc-active');
    478                 $(this).parent().find(".wpc-tab-a").addClass('wpc-active');
    479             });
    480 
     487            }
     488        });
     489
     490        // reservation from show /hide
     491        $(document).on('click', '#wpc_cancel_request', function () {
     492            $('.wpc-reservation-form .wpc_reservation_table').slideUp();
     493            $('.wpc-reservation-form .wpc_reservation_cancel_form').slideDown();
     494        });
     495        $(document).on('click', '#wpc_book_table', function () {
     496            $('.wpc-reservation-form .wpc_reservation_cancel_form').slideUp();
     497            $('.wpc-reservation-form .wpc_reservation_table').slideDown();
     498        });
     499
     500        // cart icon open
     501        $(document).on('click', '.wpc_cart_icon', function (event) {
     502            event.preventDefault();
     503
     504            $('.wpc_cart_block').toggleClass('cart_icon_active');
     505        });
     506
     507        $(document).on('mouseup', function (e) {
     508            var container = $(".wpc_cart_block");
     509            if (!container.is(e.target) && container.has(e.target).length === 0) {
     510                container.removeClass('cart_icon_active');
     511            }
     512        });
     513
     514        //   custom tabs
     515        $(document).on('click', '.wpc-tab-a', function (event) {
     516            event.preventDefault();
     517            $(this).parent().parent().parent().find(".wpc-tab").removeClass('tab-active');
     518            $(".wpc-tab[data-id='" + $(this).attr('data-id') + "']").addClass("tab-active");
     519            $(".wpc-tab-a").removeClass('wpc-active');
     520            $(this).parent().find(".wpc-tab-a").addClass('wpc-active');
     521        });
     522        if (typeof wpc_form_data !=='undefined') {
    481523            // reservation form submit
    482524            var wpc_ajax_url = wpc_form_data.wpc_ajax_url;
    483525            var wpc_reservation_form_nonce = wpc_form_data.wpc_reservation_form_nonce;
    484526            $(".reservation_form_submit").on('click', function (e) {
    485                 e.preventDefault();
    486                 wpc_reservation_first = $(".reservation_form_first_step").val();
     527                e.preventDefault(); var wpc_diff_data="";
     528                var wpc_reservation_first = $(".reservation_form_first_step").val();
    487529                if (typeof wpc_reservation_first !== 'undefined' && wpc_reservation_first == 'reservation_form_first_step') {
    488                     wpc_name = $("#wpc-name").val();
    489                     wpc_email = $("#wpc-email").val();
    490                     wpc_phone = $("#wpc-phone").val();
    491                     wpc_booking_date = $("#wpc-booking-date").val();
    492                     wpc_from_time = $("#wpc-from-time").val();
    493                     wpc_to_time = $("#wpc-to-time").val();
    494                     wpc_guest_count = $("#wpc-party option:selected").val();
    495                     wpc_message = $("#wpc-message").val();
     530                    var wpc_name            = $("#wpc-name").val();
     531                    var wpc_email          = $("#wpc-email").val();
     532                    var wpc_phone          = $("#wpc-phone").val();
     533                    var wpc_booking_date    = $("#wpc-booking-date").val();
     534                    var wpc_from_time      = $("#wpc-from-time").val();
     535                    var wpc_to_time        = $("#wpc-to-time").val();
     536                    var wpc_guest_count    = $("#wpc-party option:selected").val();
     537                    var wpc_message        = $("#wpc-message").val();
    496538
    497539                    if (wpc_booking_form_data.wpc_time_format == '12') {
    … …  
    507549                        $('.wpc_log_message').html('');
    508550                        $('.wpc_error_message').fadeIn('slow');
    509                         $('.wpc_error_message').html("End time must be after start time.");
     551                        $('.wpc_error_message').html("Booking end time must be before start time.");
    510552                    } else {
    511553                        $('.wpc_error_message').html('');
    … …  
    527569            $(".cancell_form_submit,.confirm_booking_btn").on('click', function (e) {
    528570                e.preventDefault();
    529                 wpc_invoice = $(".wpc-invoice").val();
    530                 if (wpc_invoice !== '' && typeof wpc_invoice !== "undefined") {
    531                     wpc_email = $(".wpc_cancell_email").val();
    532                     wpc_phone = $(".wpc_cancell_phone").val();
    533                     wpc_message = $(".wpc_cancell_message").val();
     571
     572                var wpc_invoice = $(".wpc-invoice").val();
     573                var wpc_email = $(".wpc_cancell_email").val();
     574                if ( typeof wpc_invoice !== "undefined" && ( wpc_invoice !== '' && wpc_email !=='' ) ) {
     575                   
     576                    var wpc_phone = $(".wpc_cancell_phone").val();
     577                    var wpc_message = $(".wpc_cancell_message").val();
    534578                    var data = {
    535579                        action: 'wpc_check_for_submission',
    … …  
    541585                        wpc_action: 'wpc_cancellation',
    542586                    }
    543                 } else {
    544                     reservation_form_second_step = $(this).data('id');
     587                }
     588                 else {
     589                    var reservation_form_second_step = $(this).data('id');
    545590                    if (typeof reservation_form_second_step !== 'undefined' && reservation_form_second_step == 'reservation_form_second_step') {
    546                         wpc_name = $(".wpc_check_name").text();
    547                         wpc_email = $(".wpc_check_email").text();
    548                         wpc_phone = $(".wpc_check_phone").text();
    549                         wpc_guest_count = $(".wpc_check_guest").text();
    550                         wpc_from_time = $(".wpc_check_start_time").text();
    551                         wpc_to_time = $(".wpc_check_end_time").text();
    552                         wpc_booking_date = $(".wpc_check_booking_date").text();
    553                         wpc_message = $(".wpc_check_message").text();
     591                        var wpc_name            = $(".wpc_check_name").text();
     592                        var wpc_email          = $(".wpc_check_email").text();
     593                        var wpc_phone          = $(".wpc_check_phone").text();
     594                        var wpc_guest_count    = $(".wpc_check_guest").text();
     595                        var wpc_from_time      = $(".wpc_check_start_time").text();
     596                        var wpc_to_time        = $(".wpc_check_end_time").text();
     597                        var wpc_booking_date    = $(".wpc_check_booking_date").text();
     598                        var wpc_message        = $(".wpc_check_message").text();
    554599                        var data = {
    555600                            action: 'wpc_check_for_submission',
    … …  
    597642                        else if (response.data.data.form_type == 'wpc_reservation_cancell' &&
    598643                        ($.isArray(response.data.message) && response.data.message.length>0) ) {
     644                            // console.log(response.data);
    599645                            $('.wpc_error_message').css('display', 'none');
    600646                            $('.wpc_error_message').html('');
    … …  
    605651                            $(".wpc_cancell_message").val("");
    606652                            $(".wpc-invoice").val("");
    607                             $(".cancell_form_submit").fadeOut('slow');
     653                            if (response.data.status_code === 200) {
     654                                $(".cancell_form_submit").fadeOut('slow');
     655                            }
     656                           
    608657                        }
    609658                        else if (response.data.data.form_type == 'wpc_reservation_cancell_field_missing' &&
    610659                            ($.isArray(response.data.message) && response.data.message.length>0) ) {
     660                            console.log("else");
    611661                            $('.wpc_error_message').css('display', 'block');
    612662                            $('.wpc_cancell_log_message').css('display', 'none');
    … …  
    620670            $('.single_add_to_cart_button').click(function (e) {
    621671                e.preventDefault();
    622                 $thisbutton = $(this)
     672                var $thisbutton = $(this)
    623673                var product_id = $(this).val();
    624674                var quantity = $('input[name="quantity"]').val();
    625675                var variation_id = $('input[name="variation_id"]').val();
    626676                var id_arr = [];
    627                 quantity_arr = [];
     677                var quantity_arr = [];
    628678                if (typeof quantity === 'undefined') {
    629679                    $('input[name^="quantity"]').each(function () {
    … …  
    679729                    success: function (results) {
    680730                        $( document.body ).trigger( 'wc_fragment_refresh' );
    681                         $('#wpc-mini-cart-count').html("");
    682                         $('#wpc-mini-cart-count').html(results.data.wpc_count);
    683                         $('.widget_shopping_cart_content').html("");
    684                         $('.widget_shopping_cart_content').html(results.data.wpc_cart_content);
    685                         $('.single_add_to_cart_button').removeClass('adding-cart');
    686731                    }
    687732                });
    688733            });
    689         });
     734        }
     735        // back to edit form
    690736        $(".edit_booking_btn").on('click', function (e) {
    691737            e.preventDefault();
    … …  
    694740            $(".wpc_reservation_form_one").fadeIn('slow');
    695741        });
    696 
    697     })(jQuery);
     742    });
     743})(jQuery);
  • wp-cafe/trunk/assets/scss/wpc-admin.scss

    r2335589 r2358899  
    109109                }
    110110        }
    111 
    112         .wpc_weekly_clear,
    113         .wpc_all_day_clear,
    114           .wpc_delivery_weekly_clear,
    115           .exception_time_clear,
    116         .wpc_pickup_weekly_clear {
    117                 line-height: 40px;
    118                 cursor     : pointer;
    119                 color      : $secondary-color;
    120                 font-size  : 14px;
    121         }
    122 
    123111        //   checkbox style
    124112        .wpc-weekly-schedule-list {
  • wp-cafe/trunk/core/action/wpc-action.php

    r2335589 r2358899  
    3232     */
    3333    public function wpc_store( $form_id, $form_setting ) {
    34 
    3534        if ( !current_user_can( 'manage_options' ) ) {
    3635            return;
  • wp-cafe/trunk/core/action/wpc-ajax-action.php

    r2343218 r2358899  
    176176            //check if all required fields are given
    177177            //else show a message
    178             if ( $invoice_no && $wpc_phone && $wpc_email ) {
     178            if ( $invoice_no && $wpc_email ) {
    179179                $args = [
    180180                    'post_type'      => 'wpc_reservation',
    … …  
    188188                            'key'   => 'wpc_email',
    189189                            'value' => $wpc_email,
    190                         ],
    191                         [
    192                             'key'   => 'wpc_phone',
    193                             'value' => $wpc_phone,
    194                         ],
     190                        ]
    195191                    ],
    196192                ];
    … …  
    244240
    245241            }
    246            
    247             // mini cart content
    248             $wpc_cart_content = '';
    249             $items            = WC()->cart->get_cart();
    250             global $woocommerce;
    251             $item_count = $woocommerce->cart->cart_contents_count;
    252             foreach ( $items as $item => $values ) {
    253                 $variation = $values['variation_id'];
    254                 if ( $variation ) {
    255                     $wpc_thumbnail = get_the_post_thumbnail( $values['variation_id'], 'thumbnail' );
    256                     $product_id    = $values['variation_id'];
    257                     $get_data      = $values['data']->get_data();
    258                     $product_title = $get_data['name'];
    259                 } else {
    260                     $wpc_thumbnail = get_the_post_thumbnail( $values['product_id'], 'thumbnail' );
    261                     $product_id    = $values['product_id'];
    262                     $product_title = $values['data']->get_title();
    263                 }
    264 
    265                 $currency     = get_woocommerce_currency_symbol();
    266 
    267                 $_woo_product = wc_get_product( $product_id );
    268 
    269                 $price_div    = '';
    270                 if ( wc_get_price_including_tax( $_woo_product ) ) {
    271                     $price_div .= '× ' . $currency . ' ' . wc_get_price_including_tax( $_woo_product );
    272                 }
    273                 else {
    274                     $price_div .= ' × ' . $currency . ' ' . wc_get_price_excluding_tax( $_woo_product );
    275                 }
    276 
    277                 $wpc_cart_content .= '
    278                         <ul class="woocommerce-mini-cart cart_list product_list_widget ">
    279                             <li class="woocommerce-mini-cart-item mini_cart_item">
    280                                 ' . $wpc_thumbnail . '
    281                                 <a>' . $product_title . '</a>
    282                                 ' .
    283                 sprintf(
    284                     '<a href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-product_sku="%s" data-cart_item_key="%s">&times;</a>',
    285                     esc_url( wc_get_cart_remove_url( $item ) ),
    286                     esc_html__( 'Remove this item', 'woocommerce' ),
    287                     esc_attr( $values['product_id'] ),
    288                     esc_attr( $_woo_product->get_sku() ),
    289                     esc_attr( $item )
    290                 )
    291                     . '
    292                                 <span class="quantity">' . $values['quantity'] . '
    293                                     <span class="woocommerce-Price-amount amount">' . $price_div . '</span>
    294                                 </span>
    295                             </li>
    296                         </ul>';
    297             }
    298 
    299             $wpc_cart_content .= '
    300                     <p class="woocommerce-mini-cart__total total">
    301                         <strong>Subtotal</strong>
    302                         <span class="woocommerce-Price-amount amount">
    303                             ' . WC()->cart->get_cart_total() . '
    304                         </span>
    305                     </p> ';
    306             $cart_url     = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : $woocommerce->cart->get_cart_url();
    307             $checkout_url = function_exists( 'get_checkout_url' ) ? $woocommerce->cart->get_checkout_url() : $woocommerce->cart->wc_get_checkout_url;
    308             $wpc_cart_content .= '
    309                     <p class="woocommerce-mini-cart__buttons buttons">
    310                         <a href="' . $cart_url . '" class="button wc-forward">View Cart</a>
    311                         <a href="' . $checkout_url . '" class="button checkout wc-forward">Checkout</a>
    312                     </p>';
    313242            wp_send_json_success( [
    314                 'wpc_count' => $item_count, 'wpc_cart_content' => $wpc_cart_content] );
     243                'message' => ['success'], 'data' => [] ] );
    315244        }
    316245        die();
  • wp-cafe/trunk/core/base/wpc-settings-field.php

    r2335589 r2358899  
    77
    88class Wpc_Settings_Field {
     9
    910    use Wpc_Singleton;
    1011
    1112    private $key_settings_option;
    12     public $response_message;
    1313
    1414    /**
    … …  
    2929    }
    3030
     31    public function compare_time( $start_arr , $end_arr ){
     32        $time_checking_error = false;
     33        if ( ( is_array( $start_arr ) && count( $start_arr  )>0 && $start_arr [0] !== "" ) && ( is_array($end_arr) && count( $end_arr )>0 && $end_arr[0] !== ""  ) ) {
     34            for ($i=0; $i < count( $start_arr ); $i++) {
     35                if ( $start_arr[$i] >= $end_arr[$i] ) {
     36                    $time_checking_error = true;
     37                }
     38            }
     39        }
     40        return $time_checking_error;
     41    }
     42    public function check_validation( $request ){
     43        // weekly schedule time checking
     44        $weekly_time_error = $this->compare_time( $request['wpc_weekly_schedule_start_time'] ,$request['wpc_weekly_schedule_end_time'] );
     45        // exce schedule time checking
     46        $exception_time_error = $this->compare_time( $request['wpc_exception_start_time'] ,$request['wpc_exception_end_time'] );
     47       
     48        apply_filters("wpcafe/settings/validation",$request);
     49
     50       switch ($request) {
     51           case $request['wpc_min_guest_no'] >= $request['wpc_max_guest_no']:
     52                add_settings_error( "validation_error", 701 , esc_html__( "Minimum guest no. can't be grater than or equal maximum guest no." , "wpcafe"), "error" );
     53                 return false;
     54            break;
     55
     56            case ( ! ( $request['wpc_min_guest_no'] <= $request['wpc_default_gest_no'] ) || ! ( $request['wpc_default_gest_no'] <= $request['wpc_max_guest_no'] ) ) :
     57                add_settings_error( "validation_error", 701 , esc_html__( "Default guest no. must be in between minimum and  maximum guest no." , "wpcafe"), "error" );
     58                 return false;
     59            break;
     60
     61            case  ( ( ( isset($request['wpc_all_day_start_time']) && isset($request['wpc_all_day_end_time']) && $request['wpc_all_day_start_time']!== "" && $request['wpc_all_day_end_time']!== "") && $request['wpc_all_day_start_time'] >= $request['wpc_all_day_end_time'] ) || $exception_time_error == true || $weekly_time_error == true ) :
     62                add_settings_error( "validation_error", 701 , esc_html__( "Schedule start time can't be grater than or equal end time" , "wpcafe"), "error" );
     63                 return false;
     64            break;
     65
     66           default:
     67                return true;
     68            break;
     69       }
     70    }
    3171    public function form_handler() {
    3272
    … …  
    3878            }
    3979
    40             $status = \WpCafe\Core\Action\Wpc_Action::instance()->wpc_store( -1, $request );
    41             return $status;
     80            $data = $this->check_validation( $request );
     81           
     82            if ($data == false) {
     83                return false;
     84            }
     85            return \WpCafe\Core\Action\Wpc_Action::instance()->wpc_store( -1, $request );
    4286        }
    4387    }
  • wp-cafe/trunk/core/enqueue/wpc-enqueue.php

    r2335589 r2358899  
    4343                'deps'    => ['jquery'],
    4444            ],
     45            'wpc-jquery-timepicker' => [
     46                'src'     => WPC_ASSETS . 'js/jquery.timepicker.min.js',
     47                'version' => WPC_VERSION,
     48                'deps'    => ['jquery'],
     49            ],
    4550            'wpc-ui-js'      => [
    4651                'src'     => WPC_ASSETS . 'js/wpc-ui.min.js',
    … …  
    6570            'wpc-flatpicker' => [
    6671                'src'     => WPC_ASSETS . 'css/flatpickr.min.css',
     72                'version' => WPC_VERSION,
     73            ],
     74            'wpc-jquery-timepicker' => [
     75                'src'     => WPC_ASSETS . 'css/jquery.timepicker.min.css',
    6776                'version' => WPC_VERSION,
    6877            ],
    … …  
    111120        // locallize for admin
    112121        $form_data = $this->wpc_settings_obj();
    113         wp_localize_script( 'wpc-admin-js', 'wpc_client_booking_form_data', json_encode( $form_data ) );
     122        wp_localize_script( 'wpc-admin-js', 'wpc_form_data', $form_data );
    114123    }
    115124
    … …  
    183192                'deps'    => ['jquery'],
    184193            ],
     194            'wpc-jquery-timepicker' => [
     195                'src'     => WPC_ASSETS . 'js/jquery.timepicker.min.js',
     196                'version' => WPC_VERSION,
     197                'deps'    => ['jquery'],
     198            ],
    185199            'wpc-public'     => [
    186200                'src'     => WPC_ASSETS . 'js/wpc-public.js',
    … …  
    200214            'wpc-flatpicker' => [
    201215                'src'     => WPC_ASSETS . 'css/flatpickr.min.css',
     216                'version' => WPC_VERSION,
     217            ],
     218            'wpc-jquery-timepicker' => [
     219                'src'     => WPC_ASSETS . 'css/jquery.timepicker.min.css',
    202220                'version' => WPC_VERSION,
    203221            ],
    … …  
    244262        $form_data['wpc_reservation_form_nonce']        = wp_create_nonce( 'wpc_reservation_form_nonce' );
    245263        $form_data['wpc_single_add_to_cart_form_nonce'] = wp_create_nonce( 'wpc_single_add_to_cart_form_nonce' );
    246 
    247         wp_localize_script( 'wpc-public', 'wpc_client_booking_form_data', json_encode( $form_data ) );
     264        wp_localize_script( 'wpc-public', 'wpc_form_client_data', json_encode( $form_data ) );
    248265    }
    249266
  • wp-cafe/trunk/core/report/wpc-reservation-report.php

    r2335589 r2358899  
    1717        add_action( "manage_wpc_reservation_posts_custom_column",
    1818            [$this, 'wpc_reservation_custom_column'], 10, 2 );
     19        // search by invoice
     20        add_filter('pre_get_posts', [$this, 'reservation_filter_request_query']);
     21        add_filter('search-submit', 'reservation_search_form_text');
    1922    }
    2023
    … …  
    4750     * @return void
    4851     */
    49     function wpc_reservation_custom_column( $column, $post_id ) {
     52    public function wpc_reservation_custom_column( $column, $post_id ) {
    5053
    5154        switch ( $column ) {
    … …  
    7780        }
    7881    }
     82
     83    /**
     84     * search button text
     85     */
     86    public function reservation_search_form_text( $text ){
     87        return esc_attr("test");
     88    }
     89
     90    /**
     91     * Search by invoice function
     92     *
     93     */
     94    public function reservation_filter_request_query($query){
     95        if (!(is_admin()) && $query->is_main_query()) {
     96            return $query;
     97        }
     98        $search_value = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
     99        if (!isset($query->query['post_type']) || ('wpc_reservation' !== $query->query['post_type']) || !isset($search_value)) {
     100            return $query;
     101        }
     102        // var_dump(get_query_var( 's' ));die;
     103        // if (!isset($query->query_vars['meta_query'])) {
     104        //     $query->query_vars['meta_query'] = array();
     105        //     $query->set('meta_key', 'wpc_reservation_invoice');
     106        //     $query->set('meta_value', $search_value);
     107        // }
     108        // setup this functions meta values
     109        // $meta = array(
     110        //     'key'       =>   'wpc_reservation_invoice',
     111        //     'value'     =>   $search_value,
     112        //     'compare'   =>  '=',
     113        // );
     114        // append to meta_query array
     115        // $query->query_vars['meta_query'][]= $meta;
     116        // echo "<pre>";
     117        // var_dump($query);die;
     118        if ( get_query_var( 's' ) && $query->is_main_query() ) {
     119            $query->set( 'post_type', 'wpc_reservation' );
     120            $query->set( 'post_status', 'publish' );
     121            $meta_query[] =
     122            //  array(
     123                array(
     124                    'key'       => 'wpc_reservation_invoice',
     125                    'value'     => $search_value,
     126                    'compare'   => 'LIKE'
     127                );
     128            // );
     129   
     130            $query->set( 'meta_query', $meta_query );
     131        }
     132        // echo "<pre>";
     133        // var_dump($query);die;
     134
     135        return $query;
     136    }
    79137}
  • wp-cafe/trunk/core/template/wpc-key-options.php

    r2341364 r2358899  
    9292                            $check_wpc_user_notification_for_cancel_req   =  (isset($settings['wpc_user_notification_for_cancel_req']) ? 'checked' : '');
    9393                           
    94                             $wpc_booking_confirmed =  __('Thank you for  booking. Your booking is confirmed.Please check your email to get invoice no.','wpcafe');
     94                            $wpc_booking_confirmed =  esc_html__('Thank you for  booking. Your booking is confirmed.Please check your email to get invoice no.','wpcafe');
    9595                            $wpc_booking_confirmed_message = $wpc_booking_confirmed;
    96                             $wpc_pending = __('Thank you for  booking. Your booking is pending. Please check your email to get invoice no.','wpcafe');
     96                            $wpc_pending = esc_html__('Thank you for  booking. Your booking is pending. Please check your email to get invoice no.','wpcafe');
    9797                            $wpc_pending_message = $wpc_pending;
    9898
    … …  
    121121                                <div id='<?php echo esc_attr( $item );?>' data-id='tab_<?php echo esc_attr( $item ); ?>' class='tab-pane <?php echo esc_attr( $active_class );?>'>
    122122                                <?php
    123                                     if ( isset( $wpc_doc_link[$item] ) ) {
    124                                         ?>
     123                                    if ( isset( $wpc_doc_link[$item] ) ) { ?>
    125124                                         <!-- documentation link -->
    126                                         <div class="mb-2"><?php echo Wpc_Utilities::wpc_kses( $wpc_doc_link[$item]); ?></div>
     125                                        <div class="mb-2"><?php echo Wpc_Utilities::wpc_kses( $wpc_doc_link[$item] ); ?></div>
    127126                                        <?php
    128127                                    }
    … …  
    162161                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Wed]" class="wed" id="wed<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_wed ); ?> /> <label for="wed<?php echo esc_html($index); ?>"><?php echo esc_html__('Wed', $this->textdomain); ?></label>
    163162                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Thu]" class="thu" id="thu<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_thu ); ?> /> <label for="thu<?php echo esc_html($index); ?>"><?php echo esc_html__('Thu', $this->textdomain); ?></label>
    164                                                                         <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Fri]" class="fri" id="fri<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_fri ); ?> /> <label for="fri<?php  echo esc_html($index); ?>"><?php echo esc_html__('Fri', $this->textdomain); ?></label> 
     163                                                                        <input type="checkbox" name="wpc_weekly_schedule[<?php echo Wpc_Utilities::wpc_numeric($index) ?>][Fri]" class="fri" id="fri<?php echo esc_html($index); ?>" <?php echo Wpc_Utilities::wpc_render( $schedule_fri ); ?> /> <label for="fri<?php  echo esc_html($index); ?>"><?php echo esc_html__('Fri', $this->textdomain); ?></label>
    165164                                                                    </div>
    166165                                                                    <div class="wpc-schedule-field">
    167166                                                                        <input type="text"  name="wpc_weekly_schedule_start_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_schedule['wpc_weekly_schedule_start_time'][ $index ] ); ?>" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_<?php echo Wpc_Utilities::wpc_numeric($index) ?> ml-2 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    168167                                                                        <input type="text"  name="wpc_weekly_schedule_end_time[]"   value="<?php echo Wpc_Utilities::wpc_render( $wpc_schedule['wpc_weekly_schedule_end_time'][ $index ] ); ?>" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_<?php echo Wpc_Utilities::wpc_numeric($index) ?> ml-2 wpc-settings-input attr-form-control" placeholder="End time"/>
    169                                                                         <div class="wpc_weekly_clear wpc_weekly_clear_0" id="<?php echo Wpc_Utilities::wpc_numeric($index) ?>" >clear</div>                                                                     
     168                                                                        <div class="wpc_weekly_clear" id="<?php echo Wpc_Utilities::wpc_numeric($index) ?>" >clear</div>                                                                     
    170169                                                                    </div>
    171170                                                                    <?php if( $index != 0 ) { ?>
    … …  
    192191                                                                    <input type="text" name="wpc_weekly_schedule_start_time[]" class="wpc_weekly_schedule_start_time wpc_weekly_schedule_start_time_0 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    193192                                                                    <input type="text" name="wpc_weekly_schedule_end_time[]" class="wpc_weekly_schedule_end_time wpc_weekly_schedule_end_time_0 wpc-settings-input attr-form-control"  placeholder="End time"/>
    194                                                                     <div class="wpc_weekly_clear" id="0" >clear</div>                                                                     
     193                                                                    <div class="wpc_weekly_clear" id="0" >clear</div> 
    195194                                                                </div>
    196195                                                            </div>
    … …  
    209208                                                            <input type="text" name="wpc_all_day_start_time" value="<?php echo esc_attr( isset($settings['wpc_all_day_start_time'] ) ? $settings['wpc_all_day_start_time'] : ''); ?>"
    210209                                                            class="wpc_all_day_start mb-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    211 
    212210                                                            <input type="text" name="wpc_all_day_end_time" value="<?php echo esc_attr( isset($settings['wpc_all_day_end_time'] ) ? $settings['wpc_all_day_end_time'] : ''); ?>"
    213211                                                            class="wpc_all_day_end wpc-settings-input attr-form-control" placeholder="End time"/>
    214                                                             <div class="wpc_all_day_clear">clear</div>                                                        </div>
     212                                                            <div class="wpc_all_day_clear">clear</div>
     213                                                        </div>
    215214                                                    </div>
    216215                                                </div>
    … …  
    235234                                                                    <input type="text" name="wpc_exception_start_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_exception['wpc_exception_start_time'][ $index ] ); ?>" class="wpc_exception_start_time wpc_exception_start_time_<?php echo Wpc_Utilities::wpc_render( $index )?> mr-1 wpc-settings-input attr-form-control" id="exception_start_time_<?php echo Wpc_Utilities::wpc_render( $index ) ?>"  placeholder="Start time" />
    236235                                                                    <input type="text"  name="wpc_exception_end_time[]" value="<?php echo Wpc_Utilities::wpc_render( $wpc_exception['wpc_exception_end_time'][ $index ] ); ?>" class="wpc_exception_end_time wpc_exception_end_time_<?php echo Wpc_Utilities::wpc_render( $index )?> wpc-settings-input attr-form-control" id="exception_end_time_<?php echo Wpc_Utilities::wpc_render( $index ) ?>"  placeholder="End time"/>
    237                                                                     <div class="exception_time_clear exception_time_clear_0" id="0" >clear</div>
     236                                                                    <div class="exception_time_clear" id="0" >clear</div>
    238237                                                                    <?php if( $index != 0 ) { ?>
    239238                                                                        <span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>
    … …  
    249248                                                                <input type="text" name="wpc_exception_start_time[]" value="" class="wpc_exception_start_time wpc_exception_start_time_0 mr-1 wpc-settings-input attr-form-control" placeholder="Start time" />
    250249                                                                <input type="text" name="wpc_exception_end_time[]" value="" class="wpc_exception_end_time wpc_exception_end_time_0 wpc-settings-input attr-form-control" placeholder="End time"/>
    251                                                                 <div class="exception_time_clear exception_time_clear_0" id="0" >clear</div>
     250                                                                <div class="exception_time_clear" id="0" >clear</div>
    252251                                                            </div>
    253252                                                        <?php
    … …  
    336335                                                <div class="wpc-meta">
    337336                                                    <select id="wpc_default_gest_no" class="wpc-settings-input" name="wpc_default_gest_no">
     337                                                        <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    338338                                                        <?php
    339339                                                        $wpc_no_range = 101;
    … …  
    352352                                                <div class="wpc-meta">
    353353                                                    <select id="wpc_min_guest_no" class="wpc-settings-input" name="wpc_min_guest_no">
     354                                                        <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    354355                                                        <?php
    355356                                                        $wpc_no_range = 101;
    … …  
    368369                                                <div class="wpc-meta">
    369370                                                    <select id="wpc_max_guest_no" class="wpc-settings-input" name="wpc_max_guest_no">
     371                                                    <option value=""><?php echo esc_html__("Select no. of guests",  $this->textdomain )?></option>
    370372                                                        <?php
    371373                                                        for( $i = 1 ; $i <= $wpc_no_range ; $i++ ) { ?>
    … …  
    744746                                            <div class="wpc-label">
    745747                                                <label for="wpcafe_food_location"><?php esc_html_e('Allow location', $this->textdomain ); ?></label>
    746                                                 <div class="wpc-desc"> <?php esc_html_e("Show location dropdown on front-end menu and checkout", 'wpcafe'); ?> </div>
     748                                                <div class="wpc-desc"> <?php esc_html_e("Show location dropdown on front-end menu (only in front page) and checkout", 'wpcafe'); ?> </div>
    747749                                            </div>
    748750                                            <div class="wpc-meta">
  • wp-cafe/trunk/core/widgets/cancellation-form-template.php

    r2335589 r2358899  
    1 <?php
    2  if (!is_admin()) {
    3 ?>
     1<?php if (!is_admin()) { ?>
    42 <div class='wpc-reservation-form '>
    53     <form method='post' class='wpc_reservation_form wpc_reservation_cancel_form' action=''>
    … …  
    2018                </div>
    2119                <div class='wpc-reservation-field phone'>
    22                     <label for='wpc-phone'><?php echo esc_html__('Phone','wpcafe')?><small class='wpc_required'>*</small></label>
    23                     <input type='tel' name='wpc_cancell_phone' class='wpc_cancell_phone wpc-form-control' id='wpc-cancell-phone' value='' required>
     20                    <label for='wpc-phone'><?php echo esc_html__('Phone', 'wpcafe'); ?></label>
     21                    <input type='tel' name='wpc_cancell_phone' class='wpc_cancell_phone wpc-form-control' id='wpc-cancell-phone' value=''>
    2422                </div>
    2523                <div class='wpc-reservation-field area message'>
  • wp-cafe/trunk/core/widgets/hook.php

    r2343218 r2358899  
    3131        add_shortcode('wpc_food_menu_list', [$this, 'wpc_food_menu_list']);
    3232        add_shortcode('wpc_reservation_form', [$this, 'wpc_booking_form_shortcode']);
     33
    3334        // add minicart to header
    3435        add_action('wp_head', [$this, 'wpc_custom_mini_cart']);
    … …  
    4041            add_action('woocommerce_checkout_create_order', [$this, 'wpc_location_update_meta'], 10, 2);
    4142        }
     43
    4244        // menu order action
    4345        add_action('product_cat_add_form_fields', [$this, 'wpc_product_cat_taxonomy_add_new_meta_field'], 10, 1);
    … …  
    4547        add_action('edited_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1);
    4648        add_action('create_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1);
     49       
    4750        //Displaying Additional Columns
    4851        add_filter('manage_edit-product_cat_columns', [$this, 'wpc_custom_fields_list_title']);
    4952        add_action('manage_product_cat_custom_column', [$this, 'wpc_custom_fields_list_diplay'], 10, 3);
     53       
    5054        // update cart counter
    5155        add_filter('woocommerce_add_to_cart_fragments', [$this, 'wpc_add_to_cart_count_fragment_refresh'], 30, 1);
    … …  
    6266        $settings = $this->settings_obj;
    6367        include_once 'reservation-form-template.php';
     68
    6469        if (isset($settings['wpc_allow_cancellation'])) {
    6570            include_once 'cancellation-form-template.php';
    6671        }
     72
    6773        $content = ob_get_clean();
     74
    6875        return $content;
    6976    }
    … …  
    7481     * @param [type] $id
    7582     */
    76     public function wpc_tag($id)
    77     {
    78 ?>
    79         <?php
     83    public function wpc_tag($id , $stock_status ){
    8084        $current_tags = get_the_terms($id, 'product_tag');
    81 
    82         //only start if we have some tags
    83         if ($current_tags && !is_wp_error($current_tags)) {
    8485            //create a list to hold our tags
    85         ?>
     86            ?>
    8687            <ul class="wpc-menu-tag">
    8788                <?php
    88 
    89                 //for each tag we create a list item
    90                 foreach ($current_tags as $tag) {
    91                     $tag_title = $tag->name;
    92                 ?>
    93                     <li><?php echo esc_html($tag_title); ?></li>
    94                 <?php
     89                if ($stock_status == true || ( $current_tags && !is_wp_error($current_tags) ) ) {
     90                    //for each tag we create a list item
     91                    if ( is_array( $current_tags ) && count( $current_tags )>0 ) {
     92                        foreach ($current_tags as $tag) {
     93                            $tag_title = $tag->name;
     94                            ?>
     95                            <li>
     96                                <?php echo esc_html__($tag_title,'wpcafe'); ?>
     97                            </li>
     98                            <?php
     99                        }
     100                    }
     101                }
     102                else{
     103                   ?><li><?php echo esc_html__('Out of stock','wpcafe'); ?></li><?php
    95104                }
    96105                ?>
    97106            </ul>
    98         <?php }
    99     }
    100 
    101     /**
    102      * Location feature function
    103      *
    104      */
    105     public function wpc_location()
    106     {
    107         // show location
    108         $settings = $this->settings_obj;
    109         if (isset($settings['wpcafe_food_location']) && $settings['wpcafe_food_location'] == 'on') {
    110         ?>
    111             <div id="wpc_location_modal" class="wpc_modal">
    112                 <!-- Modal content -->
    113                 <div class="modal-content">
    114                     <select name="wpc-location" class="wpc-location">
    115                         <option value=""><?php echo esc_html('Select a location', 'wpcafe') ?></option>
    116                         <?php
    117                         // get wpcafe locations
    118                         $wpc_loctaion = get_terms('wpcafe_location', ['taxonomy' => 'wpcafe_location', 'hide_empty' => 0, 'orderby' => 'DESC', 'parent' => 0]);
    119                         if (count($wpc_loctaion) > 0) {
    120                             foreach ($wpc_loctaion as $value) {
    121                         ?>
    122                                 <option value="<?php echo esc_html($value->slug); ?>"><?php echo esc_html__($value->name, 'wpcafe') ?></option>
    123                             <?php
    124                             }
    125                         } else {
    126                             ?>
    127                             <option value=""><?php echo esc_html__('No location set', 'wpcafe') ?></option>
    128                         <?php
    129                         }
    130                         ?>
    131                     </select>
    132                     <button class="wpc-select-location wpc-btn wpc-btn-primary">Ok</button>
    133                     <button class="wpc-close wpc-btn"> <i class="dashicons dashicons-no-alt"></i> </button>
    134                 </div>
    135             </div>
    136         <?php
    137         }
     107            <?php
    138108    }
    139109
    … …  
    144114     * @param $content
    145115     */
    146     public function wpc_food_menu_tab($atts, $content)
    147     {
     116    public function wpc_food_menu_tab($atts, $content){
    148117        if (!class_exists('Woocommerce')) {
    149118            return;
    … …  
    152121        // show location
    153122        if (is_front_page()) {
    154             $this->wpc_location();
    155         }
    156         $atts = extract(shortcode_atts(
    157             [
    158                 'wpc_food_catgeries' => '21', 'no_of_product' => 5, 'product_thumnail' => "on", 'wpc_cart_button' => 'on'
     123            Utils::get_location_details();
     124        }
     125        $atts = extract(shortcode_atts([
     126                'wpc_food_catgeries' => '21',
     127                'no_of_product' => 5,
     128                'product_thumbnail' => "on",
     129                'wpc_cart_button' => 'on'
    159130            ],
    160131            $atts
    … …  
    167138        foreach ($wpc_cat_arr as $value) {
    168139            $i++;
    169 
    170140            if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
    171141                $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
    … …  
    187157                        $current      = $wpc_cat->name;
    188158                        $active_class = (($key == array_keys($wpc_cat_sort_arr)[0]) ? 'wpc-active' : ' ');
    189                 ?>
     159                        ?>
    190160                        <li>
    191161                            <a href="#" data-id="tab_<?php echo Utils::wpc_render(Utils::wpc_cat_name_lower($current)); ?>" class="wpc-tab-a <?php echo esc_attr($active_class); ?>" data-toggle="tab" aria-expanded="true">
    … …  
    193163                            </a>
    194164                        </li>
    195                 <?php
     165                        <?php
    196166                    }
    197167                }
    … …  
    210180                    $wpc_cat_id   = Utils::wpc_cat_name_lower($wpc_cat->name);
    211181                    $products = wc_get_products($args);
    212                 ?>
     182                    ?>
    213183                    <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo esc_attr($wpc_cat_id); ?>'>
    214184                        <div class='wpc-row'>
    … …  
    218188                                        <?php
    219189                                        // show tag
    220                                         if ($product_thumnail == "on") {
    221                                         ?>
     190                                        if ( $product_thumbnail == "on" ) {
     191                                            ?>
    222192                                            <div class="wpc-col-md-3">
    223193                                                <div class="wpc-food-menu-thumb">
    224                                                     <a href="<?php echo esc_url(get_permalink($product->get_id())); ?>">
    225                                                         <?php echo Wpc_Utilities::wpc_kses($product->get_image()); ?>
     194                                                    <a href="<?php echo esc_url( get_permalink( $product->get_id() ) ); ?>">
     195                                                        <?php  echo Wpc_Utilities::wpc_kses( $product->get_image() )?>
    226196                                                    </a>
    227197                                                </div>
    228198                                            </div>
    229                                         <?php } ?>
     199                                            <?php
     200                                        }
     201                                        ?>
    230202                                        <div class="wpc-col-md-9">
    231203                                            <div class="wpc-food-inner-content">
    232204                                                <div class="wpc-menu-tag-wrap">
    233205                                                    <?php
    234                                                     $this->wpc_tag($product->get_id());
     206                                                    $this->wpc_tag( $product->get_id() , $product->is_in_stock() );
    235207                                                    $price = '';
    236208                                                    if (wc_get_price_including_tax($product)) {
    … …  
    256228                                                        <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    257229                                                </h3>
    258                                                 <?php echo Wpc_Utilities::wpc_kses(esc_html__(get_the_excerpt($product->get_id(), 'wpcafe')));
     230                                                <?php echo Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) );
    259231                                                // show cart button
    260                                                 if ($wpc_cart_button == 'on') {
    261                                                 ?>
     232                                                if ($wpc_cart_button == 'on' && $product->is_in_stock() == true ) {
     233                                                    ?>
    262234                                                    <div class="wpc-add-to-cart">
    263235                                                        <a href="?add-to-cart<?php echo Wpc_Utilities::wpc_numeric($product->get_id()); ?>" data-product_id="<?php echo Wpc_Utilities::wpc_numeric($product->get_id()); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    … …  
    265237                                                        </a>
    266238                                                    </div>
    267                                                 <?php
     239                                                    <?php
    268240                                                }
    269241                                                ?>
    … …  
    280252            </div>
    281253        </div>
    282     <?php
    283         $contents = ob_get_clean();
    284         return $contents;
     254        <?php
     255        return ob_get_clean();
    285256    }
    286257
    … …  
    290261     * @param Type $var
    291262     */
    292     public function wpc_food_menu_list($atts, $content)
    293     {
     263    public function wpc_food_menu_list($atts, $content){
    294264        if (!class_exists('Woocommerce')) {
    295265            return;
    … …  
    298268        // show location
    299269        if (is_front_page()) {
    300             $this->wpc_location();
     270            Utils::get_location_details();
    301271        }
    302272
    303273        $atts = extract(shortcode_atts(
    304             ['wpc_food_catgeries' => '21', 'no_of_product' => 5, 'wpc_cart_button' => 'on'],
     274            ['wpc_food_catgeries' => '21',
     275            'no_of_product' => 5,
     276            'wpc_cart_button' => 'on'],
    305277            $atts
    306278        ));
    … …  
    330302        };
    331303        $products = wc_get_products($args);
    332     ?>
     304        ?>
    333305        <div class='wpc-food-wrapper'>
    334306            <?php foreach ($products as $product) { ?>
    … …  
    339311                            <div class="wpc-food-menu-thumb">
    340312                                <a href="<?php echo esc_url(get_permalink($product->get_id())); ?>">
    341                                     <?php echo Wpc_Utilities::wpc_kses($product->get_image()); ?>
     313                                    <?php echo Wpc_Utilities::wpc_kses( $product->get_image() ) ?>
    342314                                </a>
    343315                            </div>
    … …  
    349321                            <div class="wpc-menu-tag-wrap">
    350322                                <?php
    351                                 $this->wpc_tag($product->get_id());
     323                                $this->wpc_tag( $product->get_id() , $product->is_in_stock() );
    352324                                $price = '';
    353325                                if (wc_get_price_including_tax($product)) {
    … …  
    373345                            </h3>
    374346                            <?php
    375                             echo esc_html__(get_the_excerpt($product->get_id()), 'wpcafe');
     347                            echo  Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) );
    376348                            // show cart button
    377                             if ($wpc_cart_button == 'on') {
     349                            if ($wpc_cart_button == 'on' && $product->is_in_stock() == true) {
    378350                            ?>
    379351                                <div class="wpc-add-to-cart">
    … …  
    391363        </div>
    392364        <?php
    393 
    394         $contents = ob_get_clean();
    395         return $contents;
     365        return ob_get_clean();
    396366    }
    397367
    … …  
    400370     *
    401371     */
    402     public function wpc_custom_mini_cart()
    403     {
     372    public function wpc_custom_mini_cart(){
    404373        if (!class_exists('WooCommerce')) {
    405374            return;
  • wp-cafe/trunk/core/widgets/reservation-form-template.php

    r2335589 r2358899  
    33$wpc_min_guest_no    = isset($settings['wpc_min_guest_no']) ? $settings['wpc_min_guest_no'] : 1;
    44$wpc_max_guest_no    = isset($settings['wpc_max_guest_no']) ? $settings['wpc_max_guest_no'] : 10;
    5 $wpc_default_gest_no = isset($settings['wpc_default_gest_no']) ? $settings['wpc_default_gest_no'] : 1;
     5$wpc_default_gest_no = isset($settings['wpc_default_gest_no']) ? $settings['wpc_default_gest_no'] : '';
    66$phone_required      = isset($settings['wpc_require_phone']) ? "required" : "";
     7
    78$cancellation_option = '';
    89if (isset($settings['wpc_allow_cancellation']) &&  $settings['wpc_allow_cancellation'] !== '') {
    … …  
    114115                                <div class='wpc-reservation-field phone'>
    115116                                    <label for='wpc-phone'><?php echo esc_html__('Phone', 'wpcafe');
    116                                                             $phone_required === "required" ? "<small class='wpc_required'>*</small>" : ""
    117                                                             ?>
     117                                        echo $phone_required == "required" ? "<small class='wpc_required'>*</small>" : "" ?>
    118118                                    </label>
    119                                     <input type='tel' <?php echo esc_attr($phone_required === "required" ? "required" : ""); ?> name='wpc_phone' class='wpc-form-control' id='wpc-phone' value=''>
     119                                    <input type='tel' <?php echo esc_attr($phone_required == "required" ? "required" : ""); ?> name='wpc_phone' class='wpc-form-control' id='wpc-phone' value=''>
    120120                                </div>
    121121                            </div>
    … …  
    147147                            <label for='wpc-total-guest'><?php echo esc_html__('Total Guest ', 'wpcafe'); ?><small class='wpc_required'>*</small></label>
    148148                            <select name='wpc_guest_count' id='wpc-party' class='wpc-form-control' required aria-required='true'>
     149                                <option value=""><?php echo esc_html__("Select no of geuests","wpcafe")?></option>
    149150                                <?php
    150151                                for ($i = $wpc_min_guest_no; $i <= $wpc_max_guest_no; $i++) {
  • wp-cafe/trunk/plugin.php

    r2343218 r2358899  
    1414final class Plugin{
    1515   
    16     const version = '1.0.5';
     16    const version = '1.0.0';
    1717
    1818    private static $instance;
  • wp-cafe/trunk/readme.txt

    r2343218 r2358899  
    44Requires at least: 5.2
    55Tested up to: 5.4
    6 Stable tag: 1.0.5
     6Stable tag: 1.0.6
    77Requires PHP: 5.6
    88License: GPLv2 or later
    … …  
    3030* Restaurant Menu System
    3131* Restaurant Ordering System for Takeaway / Delivery
     32* Ajax Mini cart
     33* Option to Customize mini-cart icon, color
     34* Food menu based on Location
     35* Customizable e-mail notifications can be sent to customers to provide confirmation, or cancellation
     36* Show reservation list on admin dashboard
     37* Make reservation from front-end
     38* Cancel a reservation from front-end
    3239
    3340####WP Cafe Plugin Integrated with Elementor builder.####
    3441
    35 ####Shortcodes / Elements:####
     42####Shortcodes / Elementor Widgets:####
    3643
    3744* Reservation Form
    … …  
    5057
    5158== Changelog ==
     59
     60= 1.0.6 =
     61
     62Fix    : Food menu stock status checking
     63Fix    : Remove html tag from product description
     64Fix    : Phone required field bug fixed
     65Fix    : Food menu thumbnail enable / disable bug fixed
     66Tweak  : Update reservation booking time validation
     67Tweak  : Update reservation time picker
     68Tweak  : Optimization and performance update for shortcodes and Elementor widgets
     69Tweak  : More validation added in reservation party size settings.
    5270
    5371= 1.0.5 =
  • wp-cafe/trunk/utils/wpc-utilities.php

    r2335589 r2358899  
    142142            'label'                         => [
    143143                'class' => [],
    144             ]
     144            ],
    145145        ];
    146146
    … …  
    216216        $from      = $mail_from;
    217217        $from_name = $mail_from_name;
    218         $headers   = [ 'Content-Type: text/html; charset=UTF-8', 'From: ' . $from_name . ' <' . $from . '>' ];
     218        $headers   = ['Content-Type: text/html; charset=UTF-8', 'From: ' . $from_name . ' <' . $from . '>'];
    219219        wp_mail( $to, $subject, $body, $headers );
    220220    }
    … …  
    251251        }
    252252
    253                 // Is notice dismissible?
     253        // Is notice dismissible?
    254254        if ( true === $notice['dismissible'] ) {
    255255            $classes[] = 'is-dismissible';
    … …  
    281281        }
    282282
    283                 // Notice visible after transient expire.
     283        // Notice visible after transient expire.
    284284        if ( isset( $notice['show_if'] ) ) {
    285285            if ( true === $notice['show_if'] ) {
    286                                 // Is transient expired?
     286
     287                // Is transient expired?
    287288                if ( false === $expired || empty( $expired ) ) {
    288289                    self::markup( $notice );
    289290                }
     291
    290292            }
     293
    291294        } else {
    292295            self::markup( $notice );
    293296        }
     297
    294298    }
    295299
    … …  
    314318                        <?php endif;?>
    315319                </div>
    316       <?php
    317 }
     320        <?php
     321    }
    318322
    319323    public static function wpc_render( $content ) {
    … …  
    321325            return "";
    322326        }
     327
    323328        return $content;
    324329    }
    … …  
    328333            return $content;
    329334        }
     335
    330336        return $content;
    331337    }
    … …  
    389395     * @return void
    390396     */
    391     public static function wpcafe_trim_words( $content, $count = 10, $readmore = null ) {
     397    public static function wpcafe_trim_words( $content, $count = 150, $readmore = null ) {
    392398        return wp_trim_words( $content, $count, $readmore );
    393399    }
     400   
     401        /**
     402         * Post query to get data for widget and shortcode
     403         */
     404    public static function post_data_query( $post_type , $count = null, $order = null ,
     405                                            $term_arr = null, $taxonomy_slug = null, $post__in = null ) {
     406                $data = [];
     407                $args = array(
     408                    'orderby'             => 'post_date',
     409                        'post_type'           => $post_type ,
     410                        'post_status'         => 'publish',
     411                        'suppress_filters'    => false,
     412                );
     413
     414                if( $count != null ){
     415                        $args['posts_per_page']  = $count;
     416                }
     417                if( $order != null ){
     418                        $args['order']                   = $order;
     419                }
     420                if( $post__in != null ){
     421                        $args['post__in']                = $post__in;
     422                }
     423
     424                if ( is_array( $term_arr ) && !empty( $term_arr )) {
     425                        $args['tax_query'] = array(
     426                                array(
     427                                        'taxonomy'      => $taxonomy_slug,
     428                                        'terms'         => $term_arr,
     429                                        'field'         => 'id',
     430                                        'include_children' => true,
     431                                        'operator'      => 'IN'
     432                                ),
     433                        );
     434                };
     435                $data   = get_posts($args);
     436                return $data;
     437    }
     438   
     439   
     440
     441    /**
     442     * Location feature function
     443     *
     444     */
     445    public static function get_location_details(){
     446        $settings =  \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     447        // show location
     448        if (isset($settings['wpcafe_food_location']) && $settings['wpcafe_food_location'] == 'on') {
     449            ?>
     450            <div id="wpc_location_modal" class="wpc_modal">
     451                <!-- Modal content -->
     452                <div class="modal-content">
     453                    <select name="wpc-location" class="wpc-location">
     454                        <option value=""><?php echo esc_html('Select a location', 'wpcafe') ?></option>
     455                        <?php
     456                        // get wpcafe locations
     457                        $wpc_loctaion = get_terms('wpcafe_location', ['taxonomy' => 'wpcafe_location', 'hide_empty' => 0, 'orderby' => 'DESC', 'parent' => 0]);
     458                        if ( !empty($wpc_loctaion) ) {
     459                            foreach ($wpc_loctaion as $value) {
     460                                ?>
     461                                <option value="<?php echo esc_html( $value->slug ); ?>"><?php echo esc_html__($value->name, 'wpcafe') ?></option>
     462                                <?php
     463                            }
     464                        } else {
     465                            ?>
     466                            <option value=""><?php echo esc_html__('No location set', 'wpcafe') ?></option>
     467                        <?php
     468                        }
     469                        ?>
     470                    </select>
     471                    <button class="wpc-select-location wpc-btn wpc-btn-primary">Ok</button>
     472                    <button class="wpc-close wpc-btn"> <i class="dashicons dashicons-no-alt"></i> </button>
     473                </div>
     474            </div>
     475            <?php
     476        }
     477    }
    394478
    395479}
  • wp-cafe/trunk/widgets/wpc-food-menu-tab/style/style-1.php

    r2343218 r2358899  
    11<?php
     2if (!class_exists('Woocommerce')) {
     3    return;
     4}
    25
    3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;
     6use \WpCafe\Utils\Wpc_Utilities as Utilities;
    47
    58$show_thumbnail      = $settings["show_thumbnail"];
    … …  
    811$col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12';
    912
    10 
     13if (is_front_page()) {
     14    Utilities::get_location_details();
     15}
    1116?>
    1217<div class="wpc-food-tab-wrapper">
    1318    <ul class="wpc-nav">
    1419        <?php
    15         foreach ($food_menu_tabs as $tab_key => $value) {
    16             $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
    17         ?>
    18             <li>
    19                 <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
    20                     <span><?php echo esc_html($value['tab_title']); ?></span>
    21                 </a>
    22             </li>
    23 
    24         <?php
     20        if( is_array( $food_menu_tabs ) ){
     21            foreach ($food_menu_tabs as $tab_key => $value) {
     22                $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
     23                ?>
     24                <li>
     25                    <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
     26                        <span><?php echo esc_html($value['tab_title']); ?></span>
     27                    </a>
     28                </li>
     29                <?php
     30            }
    2531        }
    2632        ?>
    … …  
    2834    <div class="wpc-tab-content">
    2935        <?php
    30         foreach ($food_menu_tabs as $content_key => $value) {
    31             $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    32         ?>
    33             <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
    34                 <?php
    35                 $arg = array(
    36                     'post_type'   =>  'product',
    37                     'post_status' => 'publish',
    38                     'posts_per_page' => $wpc_menu_count,
    39                     'order' => $wpc_menu_order,
    40                     'orderby' => 'publish_date',
    41                     'suppress_filters' => false,
    42                 );
    43                 if (is_array($value['post_cats']) && count($value['post_cats'])) {
    44                     $arg['tax_query'] = array(
    45                         array(
    46                             'taxonomy' => 'product_cat',
    47                             'terms'    => $value['post_cats'],
    48                             'field' => 'id',
    49                             'include_children' => true,
    50                             'operator' => 'IN'
    51                         ),
    52                     );
    53                 };
    54                 global  $woocommerce;
    55                 $queryd = new \WP_Query($arg);
     36        if( is_array( $food_menu_tabs ) ){
     37            foreach ($food_menu_tabs as $content_key => $value) {
     38                $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    5639                ?>
    57                 <?php if ($queryd->have_posts()) : ?>
    58                     <div class="wpc-food-block-tab-item">
    59                         <div class="wpc-row">
    60                             <?php while ($queryd->have_posts()) : $queryd->the_post();
    61                                 $product = wc_get_product(get_the_ID());
    62                                 $price = $product->get_price();
    63                                 $current_tags = get_the_terms(get_the_ID(), 'product_tag');
    64                                 $permalink = (($addtocart_link_show == 'yes') ? get_the_permalink() : '');
    65                                 $class = (($addtocart_link_show == 'yes') ? '' : 'wpc-no-link');
    66                             ?>
    67                                 <div class="wpc-col-lg-6">
    68                                     <div class="wpc-food-menu-item wpc-row">
    69                                         <?php if ($show_thumbnail == 'yes') : ?>
    70                                             <div class="wpc-col-md-4">
    71                                                 <!-- thumbnail -->
    72                                                 <?php if (has_post_thumbnail()) { ?>
    73                                                     <div class="wpc-food-menu-thumb">
    74                                                         <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>">
    75                                                             <?php the_post_thumbnail(); ?>
    76                                                         </a>
    77                                                     </div>
    78                                                 <?php } ?>
    79                                             </div>
    80                                         <?php endif; ?>
    81                                         <div class="<?php echo esc_attr($col); ?>">
    82                                             <div class="wpc-food-inner-content">
    83                                                 <!-- product tag and tax -->
    84                                                 <?php if ($current_tags || $product->get_price_suffix()) { ?>
    85                                                     <ul class="wpc-menu-tag">
     40                <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab<?php echo esc_attr($this->get_id()) . "-" . $value['_id']; ?>'>
     41                    <?php
     42                    global  $woocommerce;
     43                    $post_type = "product";
     44                    $data = Utilities::post_data_query( $post_type , $wpc_menu_count, $wpc_menu_order, $value['post_cats'], 'product_cat'  );
     45                    ?>
     46                    <?php
     47                    if ( !empty( $data ) ) {
     48                        ?>
     49                        <div class="wpc-food-block-tab-item">
     50                            <div class="wpc-row">
     51                                <?php
     52                                foreach( $data as $value ) {
     53                                    $product = wc_get_product( $value->ID );
     54                                    $price = $product->get_price();
     55                                    $current_tags = get_the_terms( $value->ID, 'product_tag');
     56                                    $permalink = ( ($addtocart_link_show == 'yes') ? get_the_permalink( $value->ID ) : '');
     57                                    $class = ( ($addtocart_link_show == 'yes') ? '' : 'wpc-no-link' );
     58                                    ?>
     59                                    <div class="wpc-col-lg-6">
     60                                        <div class="wpc-food-menu-item wpc-row">
     61                                            <?php
     62                                            if ($show_thumbnail == 'yes') {
     63                                                ?>
     64                                                <div class="wpc-col-md-4">
     65                                                    <!-- thumbnail -->
     66                                                    <?php
     67                                                    if( get_the_post_thumbnail_url($value->ID) ) {
     68                                                        ?>
     69                                                        <div class="wpc-food-menu-thumb">
     70                                                            <a href="<?php echo esc_url( $permalink ) ; ?>" class="<?php echo esc_attr($class); ?>">
     71                                                                <img src="<?php echo get_the_post_thumbnail_url($value->ID); ?>">
     72                                                            </a>
     73                                                        </div>
     74                                                        <?php
     75                                                    }
     76                                                    ?>
     77                                                </div>
     78                                                <?php
     79                                            }
     80                                            ?>
     81                                            <div class="<?php echo esc_attr($col); ?>">
     82                                                <div class="wpc-food-inner-content">
     83                                                    <!-- product tag and tax -->
     84                                                    <?php
     85                                                    if ($current_tags || $product->get_price_suffix()) {
     86                                                        ?>
     87                                                        <ul class="wpc-menu-tag">
     88                                                            <?php
     89                                                            if ($show_item_status == 'yes' && $current_tags && !is_wp_error($current_tags)) {
     90                                                                //for each tag we create a list item
     91                                                                foreach ($current_tags as $tag) {
     92                                                                    $tag_title = $tag->name;
     93                                                                    ?>
     94                                                                    <li>
     95                                                                        <?php echo esc_html($tag_title); ?>
     96                                                                    </li>
     97                                                                    <?php
     98                                                                }
     99                                                            }
     100                                                            ?>
     101                                                            <!-- product tax -->
     102                                                            <?php if ($product->get_price_suffix() != '') { ?>
     103                                                                <li>
     104                                                                    <?php
     105                                                                    if ( wc_get_price_including_tax( $product ) ) {
     106                                                                        $price      = wc_get_price_including_tax($product);
     107                                                                        // get percentage tax
     108                                                                        echo Utilities::wpc_kses($product->get_price_suffix());
     109                                                                    } else {
     110                                                                        $price = wc_get_price_excluding_tax($product);
     111                                                                    }
     112                                                                    ?>
     113                                                                </li>
     114                                                            <?php } ?>
     115                                                        </ul>
     116                                                        <?php
     117                                                    }
     118                                                    ?>
     119   
     120                                                    <h3 class="wpc-post-title wpc-title-with-border">
     121                                                        <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title( $value->ID ));  ?> </a>
     122                                                        <span class="wpc-title-border"></span>
     123                                                        <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
     124                                                    </h3>
     125                                                    <p>
    86126                                                        <?php
    87                                                         if ($show_item_status == 'yes' && $current_tags && !is_wp_error($current_tags)) {
    88                                                             //for each tag we create a list item
    89                                                             foreach ($current_tags as $tag) {
    90                                                                 $tag_title = $tag->name;
     127                                                        if ($wpc_show_desc == 'yes') {
     128                                                            echo  Utilities::wpcafe_trim_words( get_the_excerpt( $value->ID ) , $wpc_desc_limit);
     129                                                        }
    91130                                                        ?>
    92                                                                 <li><?php echo esc_html($tag_title); ?></li>
    93                                                         <?php }
    94                                                         } ?>
    95                                                         <!-- product tax -->
    96                                                         <?php if ($product->get_price_suffix() != '') { ?>
    97                                                             <li>
    98                                                                 <?php
    99                                                                 if (wc_get_price_including_tax($product)) {
    100                                                                     $price      = wc_get_price_including_tax($product);
    101                                                                     // get percentage tax
    102                                                                     echo Wpc_Utilities::wpc_kses($product->get_price_suffix());
    103                                                                 } else {
    104                                                                     $price = wc_get_price_excluding_tax($product);
    105                                                                 }
    106                                                                 ?>
    107                                                             </li>
    108                                                         <?php } ?>
    109                                                     </ul>
    110                                                 <?php } ?>
    111 
    112                                                 <h3 class="wpc-post-title wpc-title-with-border">
    113                                                     <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title());  ?> </a>
    114                                                     <span class="wpc-title-border"></span>
    115                                                     <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    116 
    117                                                 </h3>
    118                                                 <p>
     131                                                    </p>
    119132                                                    <?php
    120                                                     if ($wpc_show_desc == 'yes') {
    121                                                         echo  WPC_Utilities::wpcafe_trim_words(get_the_excerpt(), $wpc_desc_limit);
     133                                                    // show cart button
     134                                                    if ($wpc_cart_button_show == 'yes' && $product->is_in_stock() == true) {
     135                                                        ?>
     136                                                        <div class="wpc-add-to-cart">
     137                                                            <a href="?add-to-cart<?php echo $value->ID; ?>" data-product_id="<?php echo $value->ID; ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
     138                                                                <i class="wpcafe-cart_icon"></i>
     139                                                            </a>
     140                                                        </div>
     141                                                        <?php
    122142                                                    }
    123143                                                    ?>
    124                                                 </p>
    125                                                 <?php
    126                                                 // show cart button
    127                                                 if ($wpc_cart_button_show == 'yes') {
    128                                                 ?>
    129                                                     <div class="wpc-add-to-cart">
    130                                                         <a href="?add-to-cart<?php echo get_the_id(); ?>" data-product_id="<?php echo get_the_id(); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    131                                                             <i class="wpcafe-cart_icon"></i>
    132                                                         </a>
    133                                                     </div>
    134                                                 <?php
    135                                                 }
    136                                                 ?>
    137 
     144                                                </div>
    138145                                            </div>
    139146                                        </div>
    140147                                    </div>
    141                                 </div>
    142                             <?php
    143                             endwhile; ?>
    144                         </div>
    145                     </div><!-- block-item6 -->
    146                     <?php wp_reset_postdata(); ?>
    147                 <?php endif; ?>
    148             </div><!-- Tab pane 1 end -->
    149         <?php } ?>
     148                                    <?php
     149                                }
     150                                ?>
     151                            </div>
     152                        </div><!-- block-item6 -->
     153                        <?php wp_reset_postdata(); ?>
     154                        <?php
     155                    }
     156                    ?>
     157                </div><!-- Tab pane 1 end -->
     158                <?php
     159            }
     160        }
     161        ?>
    150162    </div><!-- Tab content-->
    151163</div>
  • wp-cafe/trunk/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php

    r2335589 r2358899  
    662662        $wpc_desc_limit = $settings["wpc_desc_limit"];
    663663
    664         ?>
    665         <?php
    666         include WPC_DIR . "/widgets/wpc-food-menu-tab/style/{$style}.php";
     664            include WPC_DIR . "/widgets/wpc-food-menu-tab/style/{$style}.php";
    667665    }
    668666
  • wp-cafe/trunk/widgets/wpc-menus-list/style/style-1.php

    r2343218 r2358899  
    11<?php
    22
    3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;
    4 
     3use \WpCafe\Utils\Wpc_Utilities as Utilities;
     4if (!class_exists('Woocommerce')) {
     5    return;
     6}
    57$wpc_menu_cat      = $settings["wpc_menu_cat"];
    68$wpc_menu_count      = $settings["wpc_menu_count"];
    … …  
    810$show_thumbnail      = $settings["show_thumbnail"];
    911$col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12';
    10 $args = array(
    11     'posts_per_page'   => $wpc_menu_count,
    12     'orderby'          => 'post_date',
    13     'order'            => $wpc_menu_order,
    14     'post_type'        => 'product',
    15     'post_status'      => 'publish',
    16     'suppress_filters' => false,
     12$post_type = 'product';
     13$data = Utilities::post_data_query( $post_type , $wpc_menu_count, $wpc_menu_order, $settings['wpc_menu_cat'], 'product_cat' );                 
    1714
    18 );
    19 
    20 if (is_array($settings['wpc_menu_cat']) && count($settings['wpc_menu_cat'])) {
    21     $args['tax_query'] = array(
    22         array(
    23             'taxonomy' => 'product_cat',
    24             'terms'    => $settings['wpc_menu_cat'],
    25             'field' => 'id',
    26             'include_children' => true,
    27             'operator' => 'IN'
    28         ),
    29     );
    30 };
    31 
    32 $f_query = new \WP_Query($args);
    33 
     15// show location
     16if (is_front_page()) {
     17    Utilities::get_location_details();
     18}
    3419?>
    3520
    … …  
    3722    <?php
    3823    global  $woocommerce;
    39     if ($f_query->have_posts()) {
    40         while ($f_query->have_posts()) {
    41             $f_query->the_post();
    42             $product = wc_get_product(get_the_ID());
     24    if ( !empty( $data ) ) {
     25        foreach( $data as $value ) {
     26            $product = wc_get_product( $value->ID );
    4327            $price = $product->get_price();
    44             $current_tags = get_the_terms(get_the_ID(), 'product_tag');
    45             $permalink = (($addtocart_link_show == 'yes') ? get_the_permalink() : '');
    46             $class = (($addtocart_link_show == 'yes') ? '' : 'wpc-no-link');
    47 
    48     ?>
     28            $current_tags = get_the_terms( $value->ID, 'product_tag');
     29            $permalink = ( ( $addtocart_link_show == 'yes' ) ? get_the_permalink( $value->ID ) : '');
     30            $class = ( ( $addtocart_link_show == 'yes' ) ? '' : 'wpc-no-link');
     31            ?>
    4932            <div class="wpc-food-menu-item wpc-row">
    50                 <?php if ($show_thumbnail == 'yes') : ?>
     33                <?php
     34                if ( $show_thumbnail == 'yes' ) {
     35                ?>
    5136                    <div class="wpc-col-md-4">
    5237                        <!-- thumbnail -->
    53                         <?php if (has_post_thumbnail()) { ?>
     38                        <?php
     39                        if( get_the_post_thumbnail_url( $value->ID ) ) {
     40                            ?>
    5441                            <div class="wpc-food-menu-thumb">
    55                                 <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>">
    56                                     <?php the_post_thumbnail(); ?>
     42                                <a href="<?php echo esc_url( $permalink ); ?>" class="<?php echo esc_attr($class); ?>">
     43                                    <img src="<?php echo get_the_post_thumbnail_url( $value->ID ); ?>">
    5744                                </a>
    5845                            </div>
    59                         <?php } ?>
     46                            <?php
     47                        }
     48                        ?>
    6049                    </div>
    61                 <?php endif; ?>
    62                 <div class="<?php echo esc_attr($col); ?>">
     50                    <?php
     51                }
     52                ?>
     53                <div class="<?php echo esc_attr( $col ); ?>">
    6354                    <div class="wpc-food-inner-content">
    6455                        <!-- product tag and tax -->
    65                         <?php if ($current_tags || $product->get_price_suffix()) { ?>
    66 
     56                        <?php
     57                        if ($current_tags || $product->get_price_suffix()) {
     58                            ?>
    6759                            <ul class="wpc-menu-tag">
    6860                                <?php
    … …  
    7264                                    foreach ($current_tags as $tag) {
    7365                                        $tag_title = $tag->name;
     66                                        ?>
     67                                        <li>
     68                                            <?php echo esc_html( $tag_title ); ?>
     69                                        </li>
     70                                        <?php
     71                                    }
     72                                }
    7473                                ?>
    75                                         <li><?php echo esc_html($tag_title); ?></li>
    76                                 <?php }
    77                                 } ?>
    7874                                <!-- product tax -->
    79                                 <?php if ($product->get_price_suffix() != '') {  ?>
     75                                <?php
     76                                if ( $product->get_price_suffix() != '' ) { 
     77                                    ?>
    8078                                    <li>
    8179                                        <?php
    82                                         if (wc_get_price_including_tax($product)) {
    83                                             $price      = wc_get_price_including_tax($product);
     80                                        if ( wc_get_price_including_tax( $product ) ) {
     81                                            $price      = wc_get_price_including_tax( $product );
    8482                                            // get percentage tax
    85                                             echo Wpc_Utilities::wpc_kses($product->get_price_suffix());
     83                                            echo Utilities::wpc_kses( $product->get_price_suffix() );
    8684                                        } else {
    87                                             $price = wc_get_price_excluding_tax($product);
     85                                            $price = wc_get_price_excluding_tax( $product );
    8886                                        }
    8987                                        ?>
    9088                                    </li>
    91                                 <?php } ?>
     89                                    <?php
     90                                }
     91                                ?>
    9292                            </ul>
    93                         <?php } ?>
    94 
     93                            <?php
     94                        }
     95                        ?>
    9596                        <h3 class="wpc-post-title wpc-title-with-border">
    96                             <a href="<?php echo esc_url($permalink); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html(get_the_title());  ?> </a>
     97                            <a href="<?php echo esc_url( $permalink ); ?>" class="<?php echo esc_attr($class); ?>"><?php echo esc_html( get_the_title( $value->ID ) );  ?> </a>
    9798                            <span class="wpc-title-border"></span>
    98                             <span class="wpc-menu-currency"><?php echo get_woocommerce_currency_symbol(); ?> <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span>
    99 
     99                            <span class="wpc-menu-currency">
     100                                <?php echo get_woocommerce_currency_symbol(); ?>
     101                                <span class="wpc-menu-price"><?php echo esc_html($price); ?>
     102                                </span>
     103                            </span>
    100104                        </h3>
    101105                        <p>
    102106                            <?php
    103                             if ($wpc_show_desc == 'yes') {
    104                                 echo  WPC_Utilities::wpcafe_trim_words(get_the_excerpt(), $wpc_desc_limit);
     107                            if ( $wpc_show_desc == 'yes' ) {
     108                                echo  Utilities::wpcafe_trim_words( get_the_excerpt( $value->ID ), $wpc_desc_limit);
    105109                            }
    106110                            ?>
    … …  
    108112                        <?php
    109113                        // show cart button
    110                         if ($wpc_cart_button == 'yes') {
    111                         ?>
     114                        if ($wpc_cart_button == 'yes' && $product->is_in_stock() == true) {
     115                            ?>
    112116                            <div class="wpc-add-to-cart">
    113                                 <a href="?add-to-cart<?php echo get_the_id(); ?>" data-product_id="<?php echo get_the_id(); ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
     117                                <a href="?add-to-cart<?php echo $value->ID; ?>" data-product_id="<?php echo $value->ID; ?>" rel="nofollow" class="button product_type_simple add_to_cart_button ajax_add_to_cart">
    114118                                    <i class="wpcafe-cart_icon"></i>
    115119                                </a>
    116120                            </div>
    117                         <?php
     121                            <?php
    118122                        }
    119123                        ?>
    … …  
    121125                </div>
    122126            </div>
    123     <?php
     127            <?php
    124128        }
    125129    }
    126     wp_reset_query();
     130    wp_reset_postdata();
    127131    ?>
    128132</div>
  • wp-cafe/trunk/wpcafe.php

    r2343218 r2358899  
    99 * Plugin URI:         https://product.themewinter.com/wpcafe
    1010 * Description:        WordPress Restaurant solution plugin to launch Restaurant Websites.
    11  * Version:            1.0.5
     11 * Version:            1.0.6
    1212 * Author:             Themewinter
    1313 * Author URI:         http://themewinter.com/
Note: See TracChangeset for help on using the changeset viewer.