Changeset 2358899
- Timestamp:
- 08/12/2020 01:13:19 PM (6 years ago)
- Location:
- wp-cafe
- Files:
-
- 3 deleted
- 22 edited
- 45 copied
-
tags/1.0.6 (copied) (copied from wp-cafe/trunk )
-
tags/1.0.6/assets/css/wpc-admin.css (copied) (copied from wp-cafe/trunk/assets/css/wpc-admin.css )
-
tags/1.0.6/assets/css/wpc-icon.css (copied) (copied from wp-cafe/trunk/assets/css/wpc-icon.css )
-
tags/1.0.6/assets/css/wpc-public.css (copied) (copied from wp-cafe/trunk/assets/css/wpc-public.css ) (2 diffs)
-
tags/1.0.6/assets/fonts/wpcafe.eot (copied) (copied from wp-cafe/trunk/assets/fonts/wpcafe.eot )
-
tags/1.0.6/assets/fonts/wpcafe.svg (copied) (copied from wp-cafe/trunk/assets/fonts/wpcafe.svg )
-
tags/1.0.6/assets/fonts/wpcafe.ttf (copied) (copied from wp-cafe/trunk/assets/fonts/wpcafe.ttf )
-
tags/1.0.6/assets/fonts/wpcafe.woff (copied) (copied from wp-cafe/trunk/assets/fonts/wpcafe.woff )
-
tags/1.0.6/assets/js/elementor.js (copied) (copied from wp-cafe/trunk/assets/js/elementor.js )
-
tags/1.0.6/assets/js/wpc-admin-menu.js (copied) (copied from wp-cafe/trunk/assets/js/wpc-admin-menu.js ) (1 diff)
-
tags/1.0.6/assets/js/wpc-admin.js (copied) (copied from wp-cafe/trunk/assets/js/wpc-admin.js ) (12 diffs)
-
tags/1.0.6/assets/js/wpc-public.js (copied) (copied from wp-cafe/trunk/assets/js/wpc-public.js ) (12 diffs)
-
tags/1.0.6/assets/scss/wpc-admin.scss (copied) (copied from wp-cafe/trunk/assets/scss/wpc-admin.scss ) (1 diff)
-
tags/1.0.6/assets/scss/wpc-public.scss (copied) (copied from wp-cafe/trunk/assets/scss/wpc-public.scss )
-
tags/1.0.6/autoloader.php (copied) (copied from wp-cafe/trunk/autoloader.php )
-
tags/1.0.6/core.php (copied) (copied from wp-cafe/trunk/core.php )
-
tags/1.0.6/core/Template (deleted)
-
tags/1.0.6/core/action/wpc-action.php (copied) (copied from wp-cafe/trunk/core/action/wpc-action.php ) (1 diff)
-
tags/1.0.6/core/action/wpc-ajax-action.php (copied) (copied from wp-cafe/trunk/core/action/wpc-ajax-action.php ) (3 diffs)
-
tags/1.0.6/core/action/wpc-reservation.php (deleted)
-
tags/1.0.6/core/base/wpc-custom-post.php (copied) (copied from wp-cafe/trunk/core/base/wpc-custom-post.php )
-
tags/1.0.6/core/base/wpc-menu-build.php (copied) (copied from wp-cafe/trunk/core/base/wpc-menu-build.php )
-
tags/1.0.6/core/base/wpc-metabox.php (copied) (copied from wp-cafe/trunk/core/base/wpc-metabox.php )
-
tags/1.0.6/core/base/wpc-settings-field.php (copied) (copied from wp-cafe/trunk/core/base/wpc-settings-field.php ) (3 diffs)
-
tags/1.0.6/core/enqueue (copied) (copied from wp-cafe/trunk/core/enqueue )
-
tags/1.0.6/core/enqueue/wpc-enqueue.php (modified) (6 diffs)
-
tags/1.0.6/core/menu/wpc-menus.php (copied) (copied from wp-cafe/trunk/core/menu/wpc-menus.php )
-
tags/1.0.6/core/metaboxes/wpc-reservation-meta.php (copied) (copied from wp-cafe/trunk/core/metaboxes/wpc-reservation-meta.php )
-
tags/1.0.6/core/post-type/cpt.php (copied) (copied from wp-cafe/trunk/core/post-type/cpt.php )
-
tags/1.0.6/core/report/wpc-menu-report.php (copied) (copied from wp-cafe/trunk/core/report/wpc-menu-report.php )
-
tags/1.0.6/core/report/wpc-reservation-report.php (copied) (copied from wp-cafe/trunk/core/report/wpc-reservation-report.php ) (3 diffs)
-
tags/1.0.6/core/template (copied) (copied from wp-cafe/trunk/core/template )
-
tags/1.0.6/core/template/wpc-key-options.php (copied) (copied from wp-cafe/trunk/core/template/wpc-key-options.php ) (11 diffs)
-
tags/1.0.6/core/widgets/cancellation-form-template.php (copied) (copied from wp-cafe/trunk/core/widgets/cancellation-form-template.php ) (2 diffs)
-
tags/1.0.6/core/widgets/hook.php (copied) (copied from wp-cafe/trunk/core/widgets/hook.php ) (23 diffs)
-
tags/1.0.6/core/widgets/reservation-form-template.php (copied) (copied from wp-cafe/trunk/core/widgets/reservation-form-template.php ) (3 diffs)
-
tags/1.0.6/languages (copied) (copied from wp-cafe/trunk/languages )
-
tags/1.0.6/plugin.php (copied) (copied from wp-cafe/trunk/plugin.php ) (1 diff)
-
tags/1.0.6/readme.txt (copied) (copied from wp-cafe/trunk/readme.txt ) (3 diffs)
-
tags/1.0.6/traits/wpc-singleton.php (copied) (copied from wp-cafe/trunk/traits/wpc-singleton.php )
-
tags/1.0.6/uninstall.php (deleted)
-
tags/1.0.6/utils/wpc-utilities.php (copied) (copied from wp-cafe/trunk/utils/wpc-utilities.php ) (8 diffs)
-
tags/1.0.6/widgets/manifest.php (copied) (copied from wp-cafe/trunk/widgets/manifest.php )
-
tags/1.0.6/widgets/wpc-food-menu-tab/style/style-1.php (copied) (copied from wp-cafe/trunk/widgets/wpc-food-menu-tab/style/style-1.php ) (3 diffs)
-
tags/1.0.6/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php (copied) (copied from wp-cafe/trunk/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php ) (1 diff)
-
tags/1.0.6/widgets/wpc-menus-list/style/style-1.php (copied) (copied from wp-cafe/trunk/widgets/wpc-menus-list/style/style-1.php ) (6 diffs)
-
tags/1.0.6/widgets/wpc-menus-list/wpc-menus-list.php (copied) (copied from wp-cafe/trunk/widgets/wpc-menus-list/wpc-menus-list.php )
-
tags/1.0.6/widgets/wpc-resevation-form/wpc-resevation-form.php (copied) (copied from wp-cafe/trunk/widgets/wpc-resevation-form/wpc-resevation-form.php )
-
tags/1.0.6/wpcafe.php (copied) (copied from wp-cafe/trunk/wpcafe.php ) (1 diff)
-
trunk/assets/css/wpc-public.css (modified) (2 diffs)
-
trunk/assets/js/wpc-admin-menu.js (modified) (1 diff)
-
trunk/assets/js/wpc-admin.js (modified) (12 diffs)
-
trunk/assets/js/wpc-public.js (modified) (12 diffs)
-
trunk/assets/scss/wpc-admin.scss (modified) (1 diff)
-
trunk/core/action/wpc-action.php (modified) (1 diff)
-
trunk/core/action/wpc-ajax-action.php (modified) (3 diffs)
-
trunk/core/base/wpc-settings-field.php (modified) (3 diffs)
-
trunk/core/enqueue/wpc-enqueue.php (modified) (6 diffs)
-
trunk/core/report/wpc-reservation-report.php (modified) (3 diffs)
-
trunk/core/template/wpc-key-options.php (modified) (11 diffs)
-
trunk/core/widgets/cancellation-form-template.php (modified) (2 diffs)
-
trunk/core/widgets/hook.php (modified) (23 diffs)
-
trunk/core/widgets/reservation-form-template.php (modified) (3 diffs)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/utils/wpc-utilities.php (modified) (8 diffs)
-
trunk/widgets/wpc-food-menu-tab/style/style-1.php (modified) (3 diffs)
-
trunk/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php (modified) (1 diff)
-
trunk/widgets/wpc-menus-list/style/style-1.php (modified) (6 diffs)
-
trunk/wpcafe.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-cafe/tags/1.0.6/assets/css/wpc-public.css
r2343218 r2358899 341 341 margin-left: auto; 342 342 } 343 343 .ui-timepicker-standard a{ 344 padding: 0 !important; 345 } 344 346 @media (min-width: 576px) { 345 347 .wpc-container { … … 5114 5116 background: #5D78FF; 5115 5117 padding: 8px 10px; 5116 margin-right: 5px;5118 margin-right: 2px; 5117 5119 color: #fff; 5118 5120 } -
wp-cafe/tags/1.0.6/assets/js/wpc-admin-menu.js
r2335589 r2358899 1 1 (function ($) { 2 "use strict"; 2 3 $(document).ready(function () { 3 4 $('.toplevel_page_cafe_menu') -
wp-cafe/tags/1.0.6/assets/js/wpc-admin.js
r2335589 r2358899 1 1 (function($) { 2 "use strict"; 2 3 $(document).ready(function() { 3 4 4 // load color picker 5 5 $("#wpc_primary_color").wpColorPicker(); … … 12 12 }); 13 13 }); 14 15 // Shcedule dynamically increase decrease 14 // Exceptional Shcedule dynamically increase decrease 16 15 var countExceptionBlock = $('.exception_block').length; 17 16 var increase=countExceptionBlock; … … 23 22 '<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" />'+ 24 23 '<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>'+26 24 '<span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>'+ 27 25 '</div>'); 28 26 $('.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 }) 35 34 }); 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 44 37 var countScheduleBox = $('.schedule_block').length; 45 38 var i = countScheduleBox; 46 39 var createField = 7 - i ; 40 // add shcedule block 47 41 $(document).on( 'click' , '.add_schedule_block' , function() { 48 42 if( i <= createField ){ … … 61 55 '<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" />'+ 62 56 '<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>'+64 57 '</div>'+ 65 58 '<span class="dashicons dashicons-no-alt remove_schedule_block wpc-btn"></span>'+ … … 69 62 } 70 63 }); 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', 72 78 '.wpc_exception_end_time']; 73 // date flatpicker79 // date timepicker 74 80 $.map(time_class,function(value,index){ 75 81 $(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 81 88 }); 82 89 }); 83 90 }); 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 }) 104 109 105 110 // weekly schedule select … … 141 146 }); 142 147 // 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(){ 144 149 if( selected_values.length == 0 ){ 145 150 $('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 151 157 }); 152 158 }else{ … … 163 169 (function($){ 164 170 $(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 } 167 176 // set location in local storage 168 177 $(document).on( 'click' , '.wpc-select-location' ,function(){ … … 229 238 } 230 239 // 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'; 244 244 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 } 245 258 } 246 259 // check weekly and all day schedule … … 312 325 } 313 326 } 314 // change date format to expected format in flas327 // change date format to expected format 315 328 const wpc_flatpicker_date_change =(selectedDates,format)=>{ 316 329 const wpc_date_ar = selectedDates.map(date => flatpickr.formatDate(date, format)); … … 319 332 } 320 333 // 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 } 339 371 } 340 372 } 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 }353 373 } 354 374 }); 355 375 356 376 // 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, 362 380 }); 363 381 … … 365 383 $(document).on('focus','#wpc_booking_date', function( e ){ 366 384 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 } 414 439 else 415 440 { … … 418 443 } 419 444 } 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 } 425 466 } 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 } 448 471 }); 449 472 -
wp-cafe/tags/1.0.6/assets/js/wpc-public.js
r2343218 r2358899 1 "use strict"; 1 2 // get object key name 2 3 const objectKeyName = (obj) => { … … 40 41 } 41 42 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{ 117 125 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'; 120 127 } else { 121 wpc_time_format = 'h:i K'; 122 wpc_flat_time_format = false; 128 wpc_time_format = 'h:mm p'; 123 129 } 124 130 // date format 125 if ( wpc_booking_form_data.wpc_date_format != "") {131 if ( wpc_booking_form_data.wpc_date_format != "") { 126 132 wpc_date_format = wpc_booking_form_data.wpc_date_format; 127 133 } else { 128 134 wpc_date_format = 'yyyy-mm-dd' 129 135 } 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); 137 162 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); 140 165 } 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; 143 168 } 144 169 $('#wpc-booking-date').removeClass("wpc_booking_error"); 145 170 button_disable(); 146 171 } 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 } 157 237 } 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{ 223 243 $('#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) { 237 255 $('#wpc-to-time').removeClass("wpc_booking_error"); 238 256 button_disable(); 239 257 } 240 258 } 241 }); 259 } 260 }); 261 if ( typeof wpc_booking_form_data !== "undefined") { 242 262 var wpc_early_bookings = wpc_booking_form_data.wpc_early_bookings; 243 263 var wpc_one_day = wpc_booking_form_data.wpc_one_day; … … 257 277 wpc_max_day = false; 258 278 } 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") { 273 295 var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "Y-m-d"); 296 274 297 var exception_date = wpc_booking_form_data.wpc_exception_date; 275 276 298 if (typeof exception_date === "undefined") { 277 299 var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "D"); … … 302 324 $("#wpc-from-time").prop('disabled', false); 303 325 $("#wpc-to-time").prop('disabled', false); 304 if (wpc_flat_time_format === false) { 326 327 if (wpc_time_format == "h:mm p") { 305 328 wpc_start_time = convertTime12to24(wpc_start_time); 306 wpc_end_time = convertTime12to24(wpc_end_time);329 wpc_end_time = convertTime12to24(wpc_end_time); 307 330 } 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 } 371 420 button_disable(); 372 421 }); 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 { 412 447 $('.cancell_form_submit').prop('disabled', true); 413 448 $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled'); 414 449 415 450 } 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 } 418 467 cancell_button_disable(); 419 468 }); 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 tab430 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) { 436 485 $(".wpc_modal").fadeOut(); 437 486 $('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') { 481 523 // reservation form submit 482 524 var wpc_ajax_url = wpc_form_data.wpc_ajax_url; 483 525 var wpc_reservation_form_nonce = wpc_form_data.wpc_reservation_form_nonce; 484 526 $(".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(); 487 529 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(); 496 538 497 539 if (wpc_booking_form_data.wpc_time_format == '12') { … … 507 549 $('.wpc_log_message').html(''); 508 550 $('.wpc_error_message').fadeIn('slow'); 509 $('.wpc_error_message').html(" End time must be afterstart time.");551 $('.wpc_error_message').html("Booking end time must be before start time."); 510 552 } else { 511 553 $('.wpc_error_message').html(''); … … 527 569 $(".cancell_form_submit,.confirm_booking_btn").on('click', function (e) { 528 570 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(); 534 578 var data = { 535 579 action: 'wpc_check_for_submission', … … 541 585 wpc_action: 'wpc_cancellation', 542 586 } 543 } else { 544 reservation_form_second_step = $(this).data('id'); 587 } 588 else { 589 var reservation_form_second_step = $(this).data('id'); 545 590 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(); 554 599 var data = { 555 600 action: 'wpc_check_for_submission', … … 597 642 else if (response.data.data.form_type == 'wpc_reservation_cancell' && 598 643 ($.isArray(response.data.message) && response.data.message.length>0) ) { 644 // console.log(response.data); 599 645 $('.wpc_error_message').css('display', 'none'); 600 646 $('.wpc_error_message').html(''); … … 605 651 $(".wpc_cancell_message").val(""); 606 652 $(".wpc-invoice").val(""); 607 $(".cancell_form_submit").fadeOut('slow'); 653 if (response.data.status_code === 200) { 654 $(".cancell_form_submit").fadeOut('slow'); 655 } 656 608 657 } 609 658 else if (response.data.data.form_type == 'wpc_reservation_cancell_field_missing' && 610 659 ($.isArray(response.data.message) && response.data.message.length>0) ) { 660 console.log("else"); 611 661 $('.wpc_error_message').css('display', 'block'); 612 662 $('.wpc_cancell_log_message').css('display', 'none'); … … 620 670 $('.single_add_to_cart_button').click(function (e) { 621 671 e.preventDefault(); 622 $thisbutton = $(this)672 var $thisbutton = $(this) 623 673 var product_id = $(this).val(); 624 674 var quantity = $('input[name="quantity"]').val(); 625 675 var variation_id = $('input[name="variation_id"]').val(); 626 676 var id_arr = []; 627 quantity_arr = [];677 var quantity_arr = []; 628 678 if (typeof quantity === 'undefined') { 629 679 $('input[name^="quantity"]').each(function () { … … 679 729 success: function (results) { 680 730 $( 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');686 731 } 687 732 }); 688 733 }); 689 }); 734 } 735 // back to edit form 690 736 $(".edit_booking_btn").on('click', function (e) { 691 737 e.preventDefault(); … … 694 740 $(".wpc_reservation_form_one").fadeIn('slow'); 695 741 }); 696 697 })(jQuery);742 }); 743 })(jQuery); -
wp-cafe/tags/1.0.6/assets/scss/wpc-admin.scss
r2335589 r2358899 109 109 } 110 110 } 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 123 111 // checkbox style 124 112 .wpc-weekly-schedule-list { -
wp-cafe/tags/1.0.6/core/action/wpc-action.php
r2335589 r2358899 32 32 */ 33 33 public function wpc_store( $form_id, $form_setting ) { 34 35 34 if ( !current_user_can( 'manage_options' ) ) { 36 35 return; -
wp-cafe/tags/1.0.6/core/action/wpc-ajax-action.php
r2343218 r2358899 176 176 //check if all required fields are given 177 177 //else show a message 178 if ( $invoice_no && $wpc_ phone && $wpc_email ) {178 if ( $invoice_no && $wpc_email ) { 179 179 $args = [ 180 180 'post_type' => 'wpc_reservation', … … 188 188 'key' => 'wpc_email', 189 189 'value' => $wpc_email, 190 ], 191 [ 192 'key' => 'wpc_phone', 193 'value' => $wpc_phone, 194 ], 190 ] 195 191 ], 196 192 ]; … … 244 240 245 241 } 246 247 // mini cart content248 $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">×</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>';313 242 wp_send_json_success( [ 314 ' wpc_count' => $item_count, 'wpc_cart_content' => $wpc_cart_content] );243 'message' => ['success'], 'data' => [] ] ); 315 244 } 316 245 die(); -
wp-cafe/tags/1.0.6/core/base/wpc-settings-field.php
r2335589 r2358899 7 7 8 8 class Wpc_Settings_Field { 9 9 10 use Wpc_Singleton; 10 11 11 12 private $key_settings_option; 12 public $response_message;13 13 14 14 /** … … 29 29 } 30 30 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 } 31 71 public function form_handler() { 32 72 … … 38 78 } 39 79 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 ); 42 86 } 43 87 } -
wp-cafe/tags/1.0.6/core/enqueue/wpc-enqueue.php
r2335589 r2358899 43 43 'deps' => ['jquery'], 44 44 ], 45 'wpc-jquery-timepicker' => [ 46 'src' => WPC_ASSETS . 'js/jquery.timepicker.min.js', 47 'version' => WPC_VERSION, 48 'deps' => ['jquery'], 49 ], 45 50 'wpc-ui-js' => [ 46 51 'src' => WPC_ASSETS . 'js/wpc-ui.min.js', … … 65 70 'wpc-flatpicker' => [ 66 71 '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', 67 76 'version' => WPC_VERSION, 68 77 ], … … 111 120 // locallize for admin 112 121 $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 ); 114 123 } 115 124 … … 183 192 'deps' => ['jquery'], 184 193 ], 194 'wpc-jquery-timepicker' => [ 195 'src' => WPC_ASSETS . 'js/jquery.timepicker.min.js', 196 'version' => WPC_VERSION, 197 'deps' => ['jquery'], 198 ], 185 199 'wpc-public' => [ 186 200 'src' => WPC_ASSETS . 'js/wpc-public.js', … … 200 214 'wpc-flatpicker' => [ 201 215 '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', 202 220 'version' => WPC_VERSION, 203 221 ], … … 244 262 $form_data['wpc_reservation_form_nonce'] = wp_create_nonce( 'wpc_reservation_form_nonce' ); 245 263 $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 ) ); 248 265 } 249 266 -
wp-cafe/tags/1.0.6/core/report/wpc-reservation-report.php
r2335589 r2358899 17 17 add_action( "manage_wpc_reservation_posts_custom_column", 18 18 [$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'); 19 22 } 20 23 … … 47 50 * @return void 48 51 */ 49 function wpc_reservation_custom_column( $column, $post_id ) {52 public function wpc_reservation_custom_column( $column, $post_id ) { 50 53 51 54 switch ( $column ) { … … 77 80 } 78 81 } 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 } 79 137 } -
wp-cafe/tags/1.0.6/core/template/wpc-key-options.php
r2341364 r2358899 92 92 $check_wpc_user_notification_for_cancel_req = (isset($settings['wpc_user_notification_for_cancel_req']) ? 'checked' : ''); 93 93 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'); 95 95 $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'); 97 97 $wpc_pending_message = $wpc_pending; 98 98 … … 121 121 <div id='<?php echo esc_attr( $item );?>' data-id='tab_<?php echo esc_attr( $item ); ?>' class='tab-pane <?php echo esc_attr( $active_class );?>'> 122 122 <?php 123 if ( isset( $wpc_doc_link[$item] ) ) { 124 ?> 123 if ( isset( $wpc_doc_link[$item] ) ) { ?> 125 124 <!-- 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> 127 126 <?php 128 127 } … … 162 161 <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> 163 162 <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> 165 164 </div> 166 165 <div class="wpc-schedule-field"> 167 166 <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" /> 168 167 <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> 170 169 </div> 171 170 <?php if( $index != 0 ) { ?> … … 192 191 <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" /> 193 192 <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> 195 194 </div> 196 195 </div> … … 209 208 <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'] : ''); ?>" 210 209 class="wpc_all_day_start mb-1 wpc-settings-input attr-form-control" placeholder="Start time" /> 211 212 210 <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'] : ''); ?>" 213 211 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> 215 214 </div> 216 215 </div> … … 235 234 <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" /> 236 235 <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> 238 237 <?php if( $index != 0 ) { ?> 239 238 <span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span> … … 249 248 <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" /> 250 249 <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> 252 251 </div> 253 252 <?php … … 336 335 <div class="wpc-meta"> 337 336 <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> 338 338 <?php 339 339 $wpc_no_range = 101; … … 352 352 <div class="wpc-meta"> 353 353 <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> 354 355 <?php 355 356 $wpc_no_range = 101; … … 368 369 <div class="wpc-meta"> 369 370 <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> 370 372 <?php 371 373 for( $i = 1 ; $i <= $wpc_no_range ; $i++ ) { ?> … … 744 746 <div class="wpc-label"> 745 747 <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> 747 749 </div> 748 750 <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()) { ?> 4 2 <div class='wpc-reservation-form '> 5 3 <form method='post' class='wpc_reservation_form wpc_reservation_cancel_form' action=''> … … 20 18 </div> 21 19 <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=''> 24 22 </div> 25 23 <div class='wpc-reservation-field area message'> -
wp-cafe/tags/1.0.6/core/widgets/hook.php
r2343218 r2358899 31 31 add_shortcode('wpc_food_menu_list', [$this, 'wpc_food_menu_list']); 32 32 add_shortcode('wpc_reservation_form', [$this, 'wpc_booking_form_shortcode']); 33 33 34 // add minicart to header 34 35 add_action('wp_head', [$this, 'wpc_custom_mini_cart']); … … 40 41 add_action('woocommerce_checkout_create_order', [$this, 'wpc_location_update_meta'], 10, 2); 41 42 } 43 42 44 // menu order action 43 45 add_action('product_cat_add_form_fields', [$this, 'wpc_product_cat_taxonomy_add_new_meta_field'], 10, 1); … … 45 47 add_action('edited_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1); 46 48 add_action('create_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1); 49 47 50 //Displaying Additional Columns 48 51 add_filter('manage_edit-product_cat_columns', [$this, 'wpc_custom_fields_list_title']); 49 52 add_action('manage_product_cat_custom_column', [$this, 'wpc_custom_fields_list_diplay'], 10, 3); 53 50 54 // update cart counter 51 55 add_filter('woocommerce_add_to_cart_fragments', [$this, 'wpc_add_to_cart_count_fragment_refresh'], 30, 1); … … 62 66 $settings = $this->settings_obj; 63 67 include_once 'reservation-form-template.php'; 68 64 69 if (isset($settings['wpc_allow_cancellation'])) { 65 70 include_once 'cancellation-form-template.php'; 66 71 } 72 67 73 $content = ob_get_clean(); 74 68 75 return $content; 69 76 } … … 74 81 * @param [type] $id 75 82 */ 76 public function wpc_tag($id) 77 { 78 ?> 79 <?php 83 public function wpc_tag($id , $stock_status ){ 80 84 $current_tags = get_the_terms($id, 'product_tag'); 81 82 //only start if we have some tags83 if ($current_tags && !is_wp_error($current_tags)) {84 85 //create a list to hold our tags 85 ?>86 ?> 86 87 <ul class="wpc-menu-tag"> 87 88 <?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 95 104 } 96 105 ?> 97 106 </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 138 108 } 139 109 … … 144 114 * @param $content 145 115 */ 146 public function wpc_food_menu_tab($atts, $content) 147 { 116 public function wpc_food_menu_tab($atts, $content){ 148 117 if (!class_exists('Woocommerce')) { 149 118 return; … … 152 121 // show location 153 122 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' 159 130 ], 160 131 $atts … … 167 138 foreach ($wpc_cat_arr as $value) { 168 139 $i++; 169 170 140 if ($wpc_cat = get_term_by('id', $value, 'product_cat')) { 171 141 $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true); … … 187 157 $current = $wpc_cat->name; 188 158 $active_class = (($key == array_keys($wpc_cat_sort_arr)[0]) ? 'wpc-active' : ' '); 189 ?>159 ?> 190 160 <li> 191 161 <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"> … … 193 163 </a> 194 164 </li> 195 <?php165 <?php 196 166 } 197 167 } … … 210 180 $wpc_cat_id = Utils::wpc_cat_name_lower($wpc_cat->name); 211 181 $products = wc_get_products($args); 212 ?>182 ?> 213 183 <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo esc_attr($wpc_cat_id); ?>'> 214 184 <div class='wpc-row'> … … 218 188 <?php 219 189 // show tag 220 if ( $product_thumnail == "on") {221 ?>190 if ( $product_thumbnail == "on" ) { 191 ?> 222 192 <div class="wpc-col-md-3"> 223 193 <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() )?> 226 196 </a> 227 197 </div> 228 198 </div> 229 <?php } ?> 199 <?php 200 } 201 ?> 230 202 <div class="wpc-col-md-9"> 231 203 <div class="wpc-food-inner-content"> 232 204 <div class="wpc-menu-tag-wrap"> 233 205 <?php 234 $this->wpc_tag( $product->get_id());206 $this->wpc_tag( $product->get_id() , $product->is_in_stock() ); 235 207 $price = ''; 236 208 if (wc_get_price_including_tax($product)) { … … 256 228 <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span> 257 229 </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() ) ); 259 231 // show cart button 260 if ($wpc_cart_button == 'on' ) {261 ?>232 if ($wpc_cart_button == 'on' && $product->is_in_stock() == true ) { 233 ?> 262 234 <div class="wpc-add-to-cart"> 263 235 <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"> … … 265 237 </a> 266 238 </div> 267 <?php239 <?php 268 240 } 269 241 ?> … … 280 252 </div> 281 253 </div> 282 <?php 283 $contents = ob_get_clean(); 284 return $contents; 254 <?php 255 return ob_get_clean(); 285 256 } 286 257 … … 290 261 * @param Type $var 291 262 */ 292 public function wpc_food_menu_list($atts, $content) 293 { 263 public function wpc_food_menu_list($atts, $content){ 294 264 if (!class_exists('Woocommerce')) { 295 265 return; … … 298 268 // show location 299 269 if (is_front_page()) { 300 $this->wpc_location();270 Utils::get_location_details(); 301 271 } 302 272 303 273 $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'], 305 277 $atts 306 278 )); … … 330 302 }; 331 303 $products = wc_get_products($args); 332 ?>304 ?> 333 305 <div class='wpc-food-wrapper'> 334 306 <?php foreach ($products as $product) { ?> … … 339 311 <div class="wpc-food-menu-thumb"> 340 312 <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() ) ?> 342 314 </a> 343 315 </div> … … 349 321 <div class="wpc-menu-tag-wrap"> 350 322 <?php 351 $this->wpc_tag( $product->get_id());323 $this->wpc_tag( $product->get_id() , $product->is_in_stock() ); 352 324 $price = ''; 353 325 if (wc_get_price_including_tax($product)) { … … 373 345 </h3> 374 346 <?php 375 echo esc_html__(get_the_excerpt($product->get_id()), 'wpcafe');347 echo Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) ); 376 348 // show cart button 377 if ($wpc_cart_button == 'on' ) {349 if ($wpc_cart_button == 'on' && $product->is_in_stock() == true) { 378 350 ?> 379 351 <div class="wpc-add-to-cart"> … … 391 363 </div> 392 364 <?php 393 394 $contents = ob_get_clean(); 395 return $contents; 365 return ob_get_clean(); 396 366 } 397 367 … … 400 370 * 401 371 */ 402 public function wpc_custom_mini_cart() 403 { 372 public function wpc_custom_mini_cart(){ 404 373 if (!class_exists('WooCommerce')) { 405 374 return; -
wp-cafe/tags/1.0.6/core/widgets/reservation-form-template.php
r2335589 r2358899 3 3 $wpc_min_guest_no = isset($settings['wpc_min_guest_no']) ? $settings['wpc_min_guest_no'] : 1; 4 4 $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'] : ''; 6 6 $phone_required = isset($settings['wpc_require_phone']) ? "required" : ""; 7 7 8 $cancellation_option = ''; 8 9 if (isset($settings['wpc_allow_cancellation']) && $settings['wpc_allow_cancellation'] !== '') { … … 114 115 <div class='wpc-reservation-field phone'> 115 116 <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>" : "" ?> 118 118 </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=''> 120 120 </div> 121 121 </div> … … 147 147 <label for='wpc-total-guest'><?php echo esc_html__('Total Guest ', 'wpcafe'); ?><small class='wpc_required'>*</small></label> 148 148 <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> 149 150 <?php 150 151 for ($i = $wpc_min_guest_no; $i <= $wpc_max_guest_no; $i++) { -
wp-cafe/tags/1.0.6/plugin.php
r2343218 r2358899 14 14 final class Plugin{ 15 15 16 const version = '1.0. 5';16 const version = '1.0.0'; 17 17 18 18 private static $instance; -
wp-cafe/tags/1.0.6/readme.txt
r2343218 r2358899 4 4 Requires at least: 5.2 5 5 Tested up to: 5.4 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 Requires PHP: 5.6 8 8 License: GPLv2 or later … … 30 30 * Restaurant Menu System 31 31 * 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 32 39 33 40 ####WP Cafe Plugin Integrated with Elementor builder.#### 34 41 35 ####Shortcodes / Element s:####42 ####Shortcodes / Elementor Widgets:#### 36 43 37 44 * Reservation Form … … 50 57 51 58 == Changelog == 59 60 = 1.0.6 = 61 62 Fix : Food menu stock status checking 63 Fix : Remove html tag from product description 64 Fix : Phone required field bug fixed 65 Fix : Food menu thumbnail enable / disable bug fixed 66 Tweak : Update reservation booking time validation 67 Tweak : Update reservation time picker 68 Tweak : Optimization and performance update for shortcodes and Elementor widgets 69 Tweak : More validation added in reservation party size settings. 52 70 53 71 = 1.0.5 = -
wp-cafe/tags/1.0.6/utils/wpc-utilities.php
r2335589 r2358899 142 142 'label' => [ 143 143 'class' => [], 144 ] 144 ], 145 145 ]; 146 146 … … 216 216 $from = $mail_from; 217 217 $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 . '>']; 219 219 wp_mail( $to, $subject, $body, $headers ); 220 220 } … … 251 251 } 252 252 253 // Is notice dismissible?253 // Is notice dismissible? 254 254 if ( true === $notice['dismissible'] ) { 255 255 $classes[] = 'is-dismissible'; … … 281 281 } 282 282 283 // Notice visible after transient expire.283 // Notice visible after transient expire. 284 284 if ( isset( $notice['show_if'] ) ) { 285 285 if ( true === $notice['show_if'] ) { 286 // Is transient expired? 286 287 // Is transient expired? 287 288 if ( false === $expired || empty( $expired ) ) { 288 289 self::markup( $notice ); 289 290 } 291 290 292 } 293 291 294 } else { 292 295 self::markup( $notice ); 293 296 } 297 294 298 } 295 299 … … 314 318 <?php endif;?> 315 319 </div> 316 <?php317 }320 <?php 321 } 318 322 319 323 public static function wpc_render( $content ) { … … 321 325 return ""; 322 326 } 327 323 328 return $content; 324 329 } … … 328 333 return $content; 329 334 } 335 330 336 return $content; 331 337 } … … 389 395 * @return void 390 396 */ 391 public static function wpcafe_trim_words( $content, $count = 1 0, $readmore = null ) {397 public static function wpcafe_trim_words( $content, $count = 150, $readmore = null ) { 392 398 return wp_trim_words( $content, $count, $readmore ); 393 399 } 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 } 394 478 395 479 } -
wp-cafe/tags/1.0.6/widgets/wpc-food-menu-tab/style/style-1.php
r2343218 r2358899 1 1 <?php 2 if (!class_exists('Woocommerce')) { 3 return; 4 } 2 5 3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;6 use \WpCafe\Utils\Wpc_Utilities as Utilities; 4 7 5 8 $show_thumbnail = $settings["show_thumbnail"]; … … 8 11 $col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12'; 9 12 10 13 if (is_front_page()) { 14 Utilities::get_location_details(); 15 } 11 16 ?> 12 17 <div class="wpc-food-tab-wrapper"> 13 18 <ul class="wpc-nav"> 14 19 <?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 } 25 31 } 26 32 ?> … … 28 34 <div class="wpc-tab-content"> 29 35 <?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' : ' '); 56 39 ?> 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> 86 126 <?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 } 91 130 ?> 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> 119 132 <?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 122 142 } 123 143 ?> 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> 138 145 </div> 139 146 </div> 140 147 </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 ?> 150 162 </div><!-- Tab content--> 151 163 </div> -
wp-cafe/tags/1.0.6/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php
r2335589 r2358899 662 662 $wpc_desc_limit = $settings["wpc_desc_limit"]; 663 663 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"; 667 665 } 668 666 -
wp-cafe/tags/1.0.6/widgets/wpc-menus-list/style/style-1.php
r2343218 r2358899 1 1 <?php 2 2 3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities; 4 3 use \WpCafe\Utils\Wpc_Utilities as Utilities; 4 if (!class_exists('Woocommerce')) { 5 return; 6 } 5 7 $wpc_menu_cat = $settings["wpc_menu_cat"]; 6 8 $wpc_menu_count = $settings["wpc_menu_count"]; … … 8 10 $show_thumbnail = $settings["show_thumbnail"]; 9 11 $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' ); 17 14 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 16 if (is_front_page()) { 17 Utilities::get_location_details(); 18 } 34 19 ?> 35 20 … … 37 22 <?php 38 23 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 ); 43 27 $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 ?> 49 32 <div class="wpc-food-menu-item wpc-row"> 50 <?php if ($show_thumbnail == 'yes') : ?> 33 <?php 34 if ( $show_thumbnail == 'yes' ) { 35 ?> 51 36 <div class="wpc-col-md-4"> 52 37 <!-- thumbnail --> 53 <?php if (has_post_thumbnail()) { ?> 38 <?php 39 if( get_the_post_thumbnail_url( $value->ID ) ) { 40 ?> 54 41 <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 ); ?>"> 57 44 </a> 58 45 </div> 59 <?php } ?> 46 <?php 47 } 48 ?> 60 49 </div> 61 <?php endif; ?> 62 <div class="<?php echo esc_attr($col); ?>"> 50 <?php 51 } 52 ?> 53 <div class="<?php echo esc_attr( $col ); ?>"> 63 54 <div class="wpc-food-inner-content"> 64 55 <!-- 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 ?> 67 59 <ul class="wpc-menu-tag"> 68 60 <?php … … 72 64 foreach ($current_tags as $tag) { 73 65 $tag_title = $tag->name; 66 ?> 67 <li> 68 <?php echo esc_html( $tag_title ); ?> 69 </li> 70 <?php 71 } 72 } 74 73 ?> 75 <li><?php echo esc_html($tag_title); ?></li>76 <?php }77 } ?>78 74 <!-- product tax --> 79 <?php if ($product->get_price_suffix() != '') { ?> 75 <?php 76 if ( $product->get_price_suffix() != '' ) { 77 ?> 80 78 <li> 81 79 <?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 ); 84 82 // get percentage tax 85 echo Wpc_Utilities::wpc_kses($product->get_price_suffix());83 echo Utilities::wpc_kses( $product->get_price_suffix() ); 86 84 } else { 87 $price = wc_get_price_excluding_tax( $product);85 $price = wc_get_price_excluding_tax( $product ); 88 86 } 89 87 ?> 90 88 </li> 91 <?php } ?> 89 <?php 90 } 91 ?> 92 92 </ul> 93 <?php } ?> 94 93 <?php 94 } 95 ?> 95 96 <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> 97 98 <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> 100 104 </h3> 101 105 <p> 102 106 <?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); 105 109 } 106 110 ?> … … 108 112 <?php 109 113 // show cart button 110 if ($wpc_cart_button == 'yes' ) {111 ?>114 if ($wpc_cart_button == 'yes' && $product->is_in_stock() == true) { 115 ?> 112 116 <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"> 114 118 <i class="wpcafe-cart_icon"></i> 115 119 </a> 116 120 </div> 117 <?php121 <?php 118 122 } 119 123 ?> … … 121 125 </div> 122 126 </div> 123 <?php127 <?php 124 128 } 125 129 } 126 wp_reset_ query();130 wp_reset_postdata(); 127 131 ?> 128 132 </div> -
wp-cafe/tags/1.0.6/wpcafe.php
r2343218 r2358899 9 9 * Plugin URI: https://product.themewinter.com/wpcafe 10 10 * Description: WordPress Restaurant solution plugin to launch Restaurant Websites. 11 * Version: 1.0. 511 * Version: 1.0.6 12 12 * Author: Themewinter 13 13 * Author URI: http://themewinter.com/ -
wp-cafe/trunk/assets/css/wpc-public.css
r2343218 r2358899 341 341 margin-left: auto; 342 342 } 343 343 .ui-timepicker-standard a{ 344 padding: 0 !important; 345 } 344 346 @media (min-width: 576px) { 345 347 .wpc-container { … … 5114 5116 background: #5D78FF; 5115 5117 padding: 8px 10px; 5116 margin-right: 5px;5118 margin-right: 2px; 5117 5119 color: #fff; 5118 5120 } -
wp-cafe/trunk/assets/js/wpc-admin-menu.js
r2335589 r2358899 1 1 (function ($) { 2 "use strict"; 2 3 $(document).ready(function () { 3 4 $('.toplevel_page_cafe_menu') -
wp-cafe/trunk/assets/js/wpc-admin.js
r2335589 r2358899 1 1 (function($) { 2 "use strict"; 2 3 $(document).ready(function() { 3 4 4 // load color picker 5 5 $("#wpc_primary_color").wpColorPicker(); … … 12 12 }); 13 13 }); 14 15 // Shcedule dynamically increase decrease 14 // Exceptional Shcedule dynamically increase decrease 16 15 var countExceptionBlock = $('.exception_block').length; 17 16 var increase=countExceptionBlock; … … 23 22 '<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" />'+ 24 23 '<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>'+26 24 '<span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span>'+ 27 25 '</div>'); 28 26 $('.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 }) 35 34 }); 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 44 37 var countScheduleBox = $('.schedule_block').length; 45 38 var i = countScheduleBox; 46 39 var createField = 7 - i ; 40 // add shcedule block 47 41 $(document).on( 'click' , '.add_schedule_block' , function() { 48 42 if( i <= createField ){ … … 61 55 '<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" />'+ 62 56 '<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>'+64 57 '</div>'+ 65 58 '<span class="dashicons dashicons-no-alt remove_schedule_block wpc-btn"></span>'+ … … 69 62 } 70 63 }); 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', 72 78 '.wpc_exception_end_time']; 73 // date flatpicker79 // date timepicker 74 80 $.map(time_class,function(value,index){ 75 81 $(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 81 88 }); 82 89 }); 83 90 }); 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 }) 104 109 105 110 // weekly schedule select … … 141 146 }); 142 147 // 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(){ 144 149 if( selected_values.length == 0 ){ 145 150 $('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 151 157 }); 152 158 }else{ … … 163 169 (function($){ 164 170 $(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 } 167 176 // set location in local storage 168 177 $(document).on( 'click' , '.wpc-select-location' ,function(){ … … 229 238 } 230 239 // 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'; 244 244 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 } 245 258 } 246 259 // check weekly and all day schedule … … 312 325 } 313 326 } 314 // change date format to expected format in flas327 // change date format to expected format 315 328 const wpc_flatpicker_date_change =(selectedDates,format)=>{ 316 329 const wpc_date_ar = selectedDates.map(date => flatpickr.formatDate(date, format)); … … 319 332 } 320 333 // 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 } 339 371 } 340 372 } 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 }353 373 } 354 374 }); 355 375 356 376 // 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, 362 380 }); 363 381 … … 365 383 $(document).on('focus','#wpc_booking_date', function( e ){ 366 384 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 } 414 439 else 415 440 { … … 418 443 } 419 444 } 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 } 425 466 } 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 } 448 471 }); 449 472 -
wp-cafe/trunk/assets/js/wpc-public.js
r2343218 r2358899 1 "use strict"; 1 2 // get object key name 2 3 const objectKeyName = (obj) => { … … 40 41 } 41 42 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{ 117 125 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'; 120 127 } else { 121 wpc_time_format = 'h:i K'; 122 wpc_flat_time_format = false; 128 wpc_time_format = 'h:mm p'; 123 129 } 124 130 // date format 125 if ( wpc_booking_form_data.wpc_date_format != "") {131 if ( wpc_booking_form_data.wpc_date_format != "") { 126 132 wpc_date_format = wpc_booking_form_data.wpc_date_format; 127 133 } else { 128 134 wpc_date_format = 'yyyy-mm-dd' 129 135 } 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); 137 162 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); 140 165 } 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; 143 168 } 144 169 $('#wpc-booking-date').removeClass("wpc_booking_error"); 145 170 button_disable(); 146 171 } 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 } 157 237 } 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{ 223 243 $('#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) { 237 255 $('#wpc-to-time').removeClass("wpc_booking_error"); 238 256 button_disable(); 239 257 } 240 258 } 241 }); 259 } 260 }); 261 if ( typeof wpc_booking_form_data !== "undefined") { 242 262 var wpc_early_bookings = wpc_booking_form_data.wpc_early_bookings; 243 263 var wpc_one_day = wpc_booking_form_data.wpc_one_day; … … 257 277 wpc_max_day = false; 258 278 } 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") { 273 295 var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "Y-m-d"); 296 274 297 var exception_date = wpc_booking_form_data.wpc_exception_date; 275 276 298 if (typeof exception_date === "undefined") { 277 299 var wpc_new_selected_date = wpc_flatpicker_date_change(selectedDates, "D"); … … 302 324 $("#wpc-from-time").prop('disabled', false); 303 325 $("#wpc-to-time").prop('disabled', false); 304 if (wpc_flat_time_format === false) { 326 327 if (wpc_time_format == "h:mm p") { 305 328 wpc_start_time = convertTime12to24(wpc_start_time); 306 wpc_end_time = convertTime12to24(wpc_end_time);329 wpc_end_time = convertTime12to24(wpc_end_time); 307 330 } 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 } 371 420 button_disable(); 372 421 }); 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 { 412 447 $('.cancell_form_submit').prop('disabled', true); 413 448 $('.cancell_form_submit').addClass('wpc_cancell_form_submit_disabled'); 414 449 415 450 } 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 } 418 467 cancell_button_disable(); 419 468 }); 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 tab430 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) { 436 485 $(".wpc_modal").fadeOut(); 437 486 $('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') { 481 523 // reservation form submit 482 524 var wpc_ajax_url = wpc_form_data.wpc_ajax_url; 483 525 var wpc_reservation_form_nonce = wpc_form_data.wpc_reservation_form_nonce; 484 526 $(".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(); 487 529 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(); 496 538 497 539 if (wpc_booking_form_data.wpc_time_format == '12') { … … 507 549 $('.wpc_log_message').html(''); 508 550 $('.wpc_error_message').fadeIn('slow'); 509 $('.wpc_error_message').html(" End time must be afterstart time.");551 $('.wpc_error_message').html("Booking end time must be before start time."); 510 552 } else { 511 553 $('.wpc_error_message').html(''); … … 527 569 $(".cancell_form_submit,.confirm_booking_btn").on('click', function (e) { 528 570 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(); 534 578 var data = { 535 579 action: 'wpc_check_for_submission', … … 541 585 wpc_action: 'wpc_cancellation', 542 586 } 543 } else { 544 reservation_form_second_step = $(this).data('id'); 587 } 588 else { 589 var reservation_form_second_step = $(this).data('id'); 545 590 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(); 554 599 var data = { 555 600 action: 'wpc_check_for_submission', … … 597 642 else if (response.data.data.form_type == 'wpc_reservation_cancell' && 598 643 ($.isArray(response.data.message) && response.data.message.length>0) ) { 644 // console.log(response.data); 599 645 $('.wpc_error_message').css('display', 'none'); 600 646 $('.wpc_error_message').html(''); … … 605 651 $(".wpc_cancell_message").val(""); 606 652 $(".wpc-invoice").val(""); 607 $(".cancell_form_submit").fadeOut('slow'); 653 if (response.data.status_code === 200) { 654 $(".cancell_form_submit").fadeOut('slow'); 655 } 656 608 657 } 609 658 else if (response.data.data.form_type == 'wpc_reservation_cancell_field_missing' && 610 659 ($.isArray(response.data.message) && response.data.message.length>0) ) { 660 console.log("else"); 611 661 $('.wpc_error_message').css('display', 'block'); 612 662 $('.wpc_cancell_log_message').css('display', 'none'); … … 620 670 $('.single_add_to_cart_button').click(function (e) { 621 671 e.preventDefault(); 622 $thisbutton = $(this)672 var $thisbutton = $(this) 623 673 var product_id = $(this).val(); 624 674 var quantity = $('input[name="quantity"]').val(); 625 675 var variation_id = $('input[name="variation_id"]').val(); 626 676 var id_arr = []; 627 quantity_arr = [];677 var quantity_arr = []; 628 678 if (typeof quantity === 'undefined') { 629 679 $('input[name^="quantity"]').each(function () { … … 679 729 success: function (results) { 680 730 $( 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');686 731 } 687 732 }); 688 733 }); 689 }); 734 } 735 // back to edit form 690 736 $(".edit_booking_btn").on('click', function (e) { 691 737 e.preventDefault(); … … 694 740 $(".wpc_reservation_form_one").fadeIn('slow'); 695 741 }); 696 697 })(jQuery);742 }); 743 })(jQuery); -
wp-cafe/trunk/assets/scss/wpc-admin.scss
r2335589 r2358899 109 109 } 110 110 } 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 123 111 // checkbox style 124 112 .wpc-weekly-schedule-list { -
wp-cafe/trunk/core/action/wpc-action.php
r2335589 r2358899 32 32 */ 33 33 public function wpc_store( $form_id, $form_setting ) { 34 35 34 if ( !current_user_can( 'manage_options' ) ) { 36 35 return; -
wp-cafe/trunk/core/action/wpc-ajax-action.php
r2343218 r2358899 176 176 //check if all required fields are given 177 177 //else show a message 178 if ( $invoice_no && $wpc_ phone && $wpc_email ) {178 if ( $invoice_no && $wpc_email ) { 179 179 $args = [ 180 180 'post_type' => 'wpc_reservation', … … 188 188 'key' => 'wpc_email', 189 189 'value' => $wpc_email, 190 ], 191 [ 192 'key' => 'wpc_phone', 193 'value' => $wpc_phone, 194 ], 190 ] 195 191 ], 196 192 ]; … … 244 240 245 241 } 246 247 // mini cart content248 $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">×</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>';313 242 wp_send_json_success( [ 314 ' wpc_count' => $item_count, 'wpc_cart_content' => $wpc_cart_content] );243 'message' => ['success'], 'data' => [] ] ); 315 244 } 316 245 die(); -
wp-cafe/trunk/core/base/wpc-settings-field.php
r2335589 r2358899 7 7 8 8 class Wpc_Settings_Field { 9 9 10 use Wpc_Singleton; 10 11 11 12 private $key_settings_option; 12 public $response_message;13 13 14 14 /** … … 29 29 } 30 30 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 } 31 71 public function form_handler() { 32 72 … … 38 78 } 39 79 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 ); 42 86 } 43 87 } -
wp-cafe/trunk/core/enqueue/wpc-enqueue.php
r2335589 r2358899 43 43 'deps' => ['jquery'], 44 44 ], 45 'wpc-jquery-timepicker' => [ 46 'src' => WPC_ASSETS . 'js/jquery.timepicker.min.js', 47 'version' => WPC_VERSION, 48 'deps' => ['jquery'], 49 ], 45 50 'wpc-ui-js' => [ 46 51 'src' => WPC_ASSETS . 'js/wpc-ui.min.js', … … 65 70 'wpc-flatpicker' => [ 66 71 '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', 67 76 'version' => WPC_VERSION, 68 77 ], … … 111 120 // locallize for admin 112 121 $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 ); 114 123 } 115 124 … … 183 192 'deps' => ['jquery'], 184 193 ], 194 'wpc-jquery-timepicker' => [ 195 'src' => WPC_ASSETS . 'js/jquery.timepicker.min.js', 196 'version' => WPC_VERSION, 197 'deps' => ['jquery'], 198 ], 185 199 'wpc-public' => [ 186 200 'src' => WPC_ASSETS . 'js/wpc-public.js', … … 200 214 'wpc-flatpicker' => [ 201 215 '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', 202 220 'version' => WPC_VERSION, 203 221 ], … … 244 262 $form_data['wpc_reservation_form_nonce'] = wp_create_nonce( 'wpc_reservation_form_nonce' ); 245 263 $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 ) ); 248 265 } 249 266 -
wp-cafe/trunk/core/report/wpc-reservation-report.php
r2335589 r2358899 17 17 add_action( "manage_wpc_reservation_posts_custom_column", 18 18 [$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'); 19 22 } 20 23 … … 47 50 * @return void 48 51 */ 49 function wpc_reservation_custom_column( $column, $post_id ) {52 public function wpc_reservation_custom_column( $column, $post_id ) { 50 53 51 54 switch ( $column ) { … … 77 80 } 78 81 } 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 } 79 137 } -
wp-cafe/trunk/core/template/wpc-key-options.php
r2341364 r2358899 92 92 $check_wpc_user_notification_for_cancel_req = (isset($settings['wpc_user_notification_for_cancel_req']) ? 'checked' : ''); 93 93 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'); 95 95 $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'); 97 97 $wpc_pending_message = $wpc_pending; 98 98 … … 121 121 <div id='<?php echo esc_attr( $item );?>' data-id='tab_<?php echo esc_attr( $item ); ?>' class='tab-pane <?php echo esc_attr( $active_class );?>'> 122 122 <?php 123 if ( isset( $wpc_doc_link[$item] ) ) { 124 ?> 123 if ( isset( $wpc_doc_link[$item] ) ) { ?> 125 124 <!-- 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> 127 126 <?php 128 127 } … … 162 161 <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> 163 162 <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> 165 164 </div> 166 165 <div class="wpc-schedule-field"> 167 166 <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" /> 168 167 <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> 170 169 </div> 171 170 <?php if( $index != 0 ) { ?> … … 192 191 <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" /> 193 192 <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> 195 194 </div> 196 195 </div> … … 209 208 <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'] : ''); ?>" 210 209 class="wpc_all_day_start mb-1 wpc-settings-input attr-form-control" placeholder="Start time" /> 211 212 210 <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'] : ''); ?>" 213 211 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> 215 214 </div> 216 215 </div> … … 235 234 <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" /> 236 235 <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> 238 237 <?php if( $index != 0 ) { ?> 239 238 <span class="wpc-btn dashicons dashicons-no-alt remove_exception_block wpc_icon_middle_position"></span> … … 249 248 <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" /> 250 249 <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> 252 251 </div> 253 252 <?php … … 336 335 <div class="wpc-meta"> 337 336 <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> 338 338 <?php 339 339 $wpc_no_range = 101; … … 352 352 <div class="wpc-meta"> 353 353 <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> 354 355 <?php 355 356 $wpc_no_range = 101; … … 368 369 <div class="wpc-meta"> 369 370 <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> 370 372 <?php 371 373 for( $i = 1 ; $i <= $wpc_no_range ; $i++ ) { ?> … … 744 746 <div class="wpc-label"> 745 747 <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> 747 749 </div> 748 750 <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()) { ?> 4 2 <div class='wpc-reservation-form '> 5 3 <form method='post' class='wpc_reservation_form wpc_reservation_cancel_form' action=''> … … 20 18 </div> 21 19 <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=''> 24 22 </div> 25 23 <div class='wpc-reservation-field area message'> -
wp-cafe/trunk/core/widgets/hook.php
r2343218 r2358899 31 31 add_shortcode('wpc_food_menu_list', [$this, 'wpc_food_menu_list']); 32 32 add_shortcode('wpc_reservation_form', [$this, 'wpc_booking_form_shortcode']); 33 33 34 // add minicart to header 34 35 add_action('wp_head', [$this, 'wpc_custom_mini_cart']); … … 40 41 add_action('woocommerce_checkout_create_order', [$this, 'wpc_location_update_meta'], 10, 2); 41 42 } 43 42 44 // menu order action 43 45 add_action('product_cat_add_form_fields', [$this, 'wpc_product_cat_taxonomy_add_new_meta_field'], 10, 1); … … 45 47 add_action('edited_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1); 46 48 add_action('create_product_cat', [$this, 'wpc_product_cat_taxonomy_save_meta_field'], 10, 1); 49 47 50 //Displaying Additional Columns 48 51 add_filter('manage_edit-product_cat_columns', [$this, 'wpc_custom_fields_list_title']); 49 52 add_action('manage_product_cat_custom_column', [$this, 'wpc_custom_fields_list_diplay'], 10, 3); 53 50 54 // update cart counter 51 55 add_filter('woocommerce_add_to_cart_fragments', [$this, 'wpc_add_to_cart_count_fragment_refresh'], 30, 1); … … 62 66 $settings = $this->settings_obj; 63 67 include_once 'reservation-form-template.php'; 68 64 69 if (isset($settings['wpc_allow_cancellation'])) { 65 70 include_once 'cancellation-form-template.php'; 66 71 } 72 67 73 $content = ob_get_clean(); 74 68 75 return $content; 69 76 } … … 74 81 * @param [type] $id 75 82 */ 76 public function wpc_tag($id) 77 { 78 ?> 79 <?php 83 public function wpc_tag($id , $stock_status ){ 80 84 $current_tags = get_the_terms($id, 'product_tag'); 81 82 //only start if we have some tags83 if ($current_tags && !is_wp_error($current_tags)) {84 85 //create a list to hold our tags 85 ?>86 ?> 86 87 <ul class="wpc-menu-tag"> 87 88 <?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 95 104 } 96 105 ?> 97 106 </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 138 108 } 139 109 … … 144 114 * @param $content 145 115 */ 146 public function wpc_food_menu_tab($atts, $content) 147 { 116 public function wpc_food_menu_tab($atts, $content){ 148 117 if (!class_exists('Woocommerce')) { 149 118 return; … … 152 121 // show location 153 122 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' 159 130 ], 160 131 $atts … … 167 138 foreach ($wpc_cat_arr as $value) { 168 139 $i++; 169 170 140 if ($wpc_cat = get_term_by('id', $value, 'product_cat')) { 171 141 $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true); … … 187 157 $current = $wpc_cat->name; 188 158 $active_class = (($key == array_keys($wpc_cat_sort_arr)[0]) ? 'wpc-active' : ' '); 189 ?>159 ?> 190 160 <li> 191 161 <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"> … … 193 163 </a> 194 164 </li> 195 <?php165 <?php 196 166 } 197 167 } … … 210 180 $wpc_cat_id = Utils::wpc_cat_name_lower($wpc_cat->name); 211 181 $products = wc_get_products($args); 212 ?>182 ?> 213 183 <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo esc_attr($wpc_cat_id); ?>'> 214 184 <div class='wpc-row'> … … 218 188 <?php 219 189 // show tag 220 if ( $product_thumnail == "on") {221 ?>190 if ( $product_thumbnail == "on" ) { 191 ?> 222 192 <div class="wpc-col-md-3"> 223 193 <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() )?> 226 196 </a> 227 197 </div> 228 198 </div> 229 <?php } ?> 199 <?php 200 } 201 ?> 230 202 <div class="wpc-col-md-9"> 231 203 <div class="wpc-food-inner-content"> 232 204 <div class="wpc-menu-tag-wrap"> 233 205 <?php 234 $this->wpc_tag( $product->get_id());206 $this->wpc_tag( $product->get_id() , $product->is_in_stock() ); 235 207 $price = ''; 236 208 if (wc_get_price_including_tax($product)) { … … 256 228 <span class="wpc-menu-price"><?php echo esc_html($price); ?></span></span> 257 229 </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() ) ); 259 231 // show cart button 260 if ($wpc_cart_button == 'on' ) {261 ?>232 if ($wpc_cart_button == 'on' && $product->is_in_stock() == true ) { 233 ?> 262 234 <div class="wpc-add-to-cart"> 263 235 <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"> … … 265 237 </a> 266 238 </div> 267 <?php239 <?php 268 240 } 269 241 ?> … … 280 252 </div> 281 253 </div> 282 <?php 283 $contents = ob_get_clean(); 284 return $contents; 254 <?php 255 return ob_get_clean(); 285 256 } 286 257 … … 290 261 * @param Type $var 291 262 */ 292 public function wpc_food_menu_list($atts, $content) 293 { 263 public function wpc_food_menu_list($atts, $content){ 294 264 if (!class_exists('Woocommerce')) { 295 265 return; … … 298 268 // show location 299 269 if (is_front_page()) { 300 $this->wpc_location();270 Utils::get_location_details(); 301 271 } 302 272 303 273 $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'], 305 277 $atts 306 278 )); … … 330 302 }; 331 303 $products = wc_get_products($args); 332 ?>304 ?> 333 305 <div class='wpc-food-wrapper'> 334 306 <?php foreach ($products as $product) { ?> … … 339 311 <div class="wpc-food-menu-thumb"> 340 312 <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() ) ?> 342 314 </a> 343 315 </div> … … 349 321 <div class="wpc-menu-tag-wrap"> 350 322 <?php 351 $this->wpc_tag( $product->get_id());323 $this->wpc_tag( $product->get_id() , $product->is_in_stock() ); 352 324 $price = ''; 353 325 if (wc_get_price_including_tax($product)) { … … 373 345 </h3> 374 346 <?php 375 echo esc_html__(get_the_excerpt($product->get_id()), 'wpcafe');347 echo Wpc_Utilities::wpc_kses( get_the_excerpt($product->get_id() ) ); 376 348 // show cart button 377 if ($wpc_cart_button == 'on' ) {349 if ($wpc_cart_button == 'on' && $product->is_in_stock() == true) { 378 350 ?> 379 351 <div class="wpc-add-to-cart"> … … 391 363 </div> 392 364 <?php 393 394 $contents = ob_get_clean(); 395 return $contents; 365 return ob_get_clean(); 396 366 } 397 367 … … 400 370 * 401 371 */ 402 public function wpc_custom_mini_cart() 403 { 372 public function wpc_custom_mini_cart(){ 404 373 if (!class_exists('WooCommerce')) { 405 374 return; -
wp-cafe/trunk/core/widgets/reservation-form-template.php
r2335589 r2358899 3 3 $wpc_min_guest_no = isset($settings['wpc_min_guest_no']) ? $settings['wpc_min_guest_no'] : 1; 4 4 $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'] : ''; 6 6 $phone_required = isset($settings['wpc_require_phone']) ? "required" : ""; 7 7 8 $cancellation_option = ''; 8 9 if (isset($settings['wpc_allow_cancellation']) && $settings['wpc_allow_cancellation'] !== '') { … … 114 115 <div class='wpc-reservation-field phone'> 115 116 <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>" : "" ?> 118 118 </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=''> 120 120 </div> 121 121 </div> … … 147 147 <label for='wpc-total-guest'><?php echo esc_html__('Total Guest ', 'wpcafe'); ?><small class='wpc_required'>*</small></label> 148 148 <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> 149 150 <?php 150 151 for ($i = $wpc_min_guest_no; $i <= $wpc_max_guest_no; $i++) { -
wp-cafe/trunk/plugin.php
r2343218 r2358899 14 14 final class Plugin{ 15 15 16 const version = '1.0. 5';16 const version = '1.0.0'; 17 17 18 18 private static $instance; -
wp-cafe/trunk/readme.txt
r2343218 r2358899 4 4 Requires at least: 5.2 5 5 Tested up to: 5.4 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 Requires PHP: 5.6 8 8 License: GPLv2 or later … … 30 30 * Restaurant Menu System 31 31 * 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 32 39 33 40 ####WP Cafe Plugin Integrated with Elementor builder.#### 34 41 35 ####Shortcodes / Element s:####42 ####Shortcodes / Elementor Widgets:#### 36 43 37 44 * Reservation Form … … 50 57 51 58 == Changelog == 59 60 = 1.0.6 = 61 62 Fix : Food menu stock status checking 63 Fix : Remove html tag from product description 64 Fix : Phone required field bug fixed 65 Fix : Food menu thumbnail enable / disable bug fixed 66 Tweak : Update reservation booking time validation 67 Tweak : Update reservation time picker 68 Tweak : Optimization and performance update for shortcodes and Elementor widgets 69 Tweak : More validation added in reservation party size settings. 52 70 53 71 = 1.0.5 = -
wp-cafe/trunk/utils/wpc-utilities.php
r2335589 r2358899 142 142 'label' => [ 143 143 'class' => [], 144 ] 144 ], 145 145 ]; 146 146 … … 216 216 $from = $mail_from; 217 217 $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 . '>']; 219 219 wp_mail( $to, $subject, $body, $headers ); 220 220 } … … 251 251 } 252 252 253 // Is notice dismissible?253 // Is notice dismissible? 254 254 if ( true === $notice['dismissible'] ) { 255 255 $classes[] = 'is-dismissible'; … … 281 281 } 282 282 283 // Notice visible after transient expire.283 // Notice visible after transient expire. 284 284 if ( isset( $notice['show_if'] ) ) { 285 285 if ( true === $notice['show_if'] ) { 286 // Is transient expired? 286 287 // Is transient expired? 287 288 if ( false === $expired || empty( $expired ) ) { 288 289 self::markup( $notice ); 289 290 } 291 290 292 } 293 291 294 } else { 292 295 self::markup( $notice ); 293 296 } 297 294 298 } 295 299 … … 314 318 <?php endif;?> 315 319 </div> 316 <?php317 }320 <?php 321 } 318 322 319 323 public static function wpc_render( $content ) { … … 321 325 return ""; 322 326 } 327 323 328 return $content; 324 329 } … … 328 333 return $content; 329 334 } 335 330 336 return $content; 331 337 } … … 389 395 * @return void 390 396 */ 391 public static function wpcafe_trim_words( $content, $count = 1 0, $readmore = null ) {397 public static function wpcafe_trim_words( $content, $count = 150, $readmore = null ) { 392 398 return wp_trim_words( $content, $count, $readmore ); 393 399 } 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 } 394 478 395 479 } -
wp-cafe/trunk/widgets/wpc-food-menu-tab/style/style-1.php
r2343218 r2358899 1 1 <?php 2 if (!class_exists('Woocommerce')) { 3 return; 4 } 2 5 3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities;6 use \WpCafe\Utils\Wpc_Utilities as Utilities; 4 7 5 8 $show_thumbnail = $settings["show_thumbnail"]; … … 8 11 $col = ($show_thumbnail == 'yes') ? 'wpc-col-md-8' : 'wpc-col-md-12'; 9 12 10 13 if (is_front_page()) { 14 Utilities::get_location_details(); 15 } 11 16 ?> 12 17 <div class="wpc-food-tab-wrapper"> 13 18 <ul class="wpc-nav"> 14 19 <?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 } 25 31 } 26 32 ?> … … 28 34 <div class="wpc-tab-content"> 29 35 <?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' : ' '); 56 39 ?> 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> 86 126 <?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 } 91 130 ?> 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> 119 132 <?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 122 142 } 123 143 ?> 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> 138 145 </div> 139 146 </div> 140 147 </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 ?> 150 162 </div><!-- Tab content--> 151 163 </div> -
wp-cafe/trunk/widgets/wpc-food-menu-tab/wpc-food-menu-tab.php
r2335589 r2358899 662 662 $wpc_desc_limit = $settings["wpc_desc_limit"]; 663 663 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"; 667 665 } 668 666 -
wp-cafe/trunk/widgets/wpc-menus-list/style/style-1.php
r2343218 r2358899 1 1 <?php 2 2 3 use \WpCafe\Utils\Wpc_Utilities as Wpc_Utilities; 4 3 use \WpCafe\Utils\Wpc_Utilities as Utilities; 4 if (!class_exists('Woocommerce')) { 5 return; 6 } 5 7 $wpc_menu_cat = $settings["wpc_menu_cat"]; 6 8 $wpc_menu_count = $settings["wpc_menu_count"]; … … 8 10 $show_thumbnail = $settings["show_thumbnail"]; 9 11 $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' ); 17 14 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 16 if (is_front_page()) { 17 Utilities::get_location_details(); 18 } 34 19 ?> 35 20 … … 37 22 <?php 38 23 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 ); 43 27 $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 ?> 49 32 <div class="wpc-food-menu-item wpc-row"> 50 <?php if ($show_thumbnail == 'yes') : ?> 33 <?php 34 if ( $show_thumbnail == 'yes' ) { 35 ?> 51 36 <div class="wpc-col-md-4"> 52 37 <!-- thumbnail --> 53 <?php if (has_post_thumbnail()) { ?> 38 <?php 39 if( get_the_post_thumbnail_url( $value->ID ) ) { 40 ?> 54 41 <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 ); ?>"> 57 44 </a> 58 45 </div> 59 <?php } ?> 46 <?php 47 } 48 ?> 60 49 </div> 61 <?php endif; ?> 62 <div class="<?php echo esc_attr($col); ?>"> 50 <?php 51 } 52 ?> 53 <div class="<?php echo esc_attr( $col ); ?>"> 63 54 <div class="wpc-food-inner-content"> 64 55 <!-- 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 ?> 67 59 <ul class="wpc-menu-tag"> 68 60 <?php … … 72 64 foreach ($current_tags as $tag) { 73 65 $tag_title = $tag->name; 66 ?> 67 <li> 68 <?php echo esc_html( $tag_title ); ?> 69 </li> 70 <?php 71 } 72 } 74 73 ?> 75 <li><?php echo esc_html($tag_title); ?></li>76 <?php }77 } ?>78 74 <!-- product tax --> 79 <?php if ($product->get_price_suffix() != '') { ?> 75 <?php 76 if ( $product->get_price_suffix() != '' ) { 77 ?> 80 78 <li> 81 79 <?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 ); 84 82 // get percentage tax 85 echo Wpc_Utilities::wpc_kses($product->get_price_suffix());83 echo Utilities::wpc_kses( $product->get_price_suffix() ); 86 84 } else { 87 $price = wc_get_price_excluding_tax( $product);85 $price = wc_get_price_excluding_tax( $product ); 88 86 } 89 87 ?> 90 88 </li> 91 <?php } ?> 89 <?php 90 } 91 ?> 92 92 </ul> 93 <?php } ?> 94 93 <?php 94 } 95 ?> 95 96 <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> 97 98 <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> 100 104 </h3> 101 105 <p> 102 106 <?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); 105 109 } 106 110 ?> … … 108 112 <?php 109 113 // show cart button 110 if ($wpc_cart_button == 'yes' ) {111 ?>114 if ($wpc_cart_button == 'yes' && $product->is_in_stock() == true) { 115 ?> 112 116 <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"> 114 118 <i class="wpcafe-cart_icon"></i> 115 119 </a> 116 120 </div> 117 <?php121 <?php 118 122 } 119 123 ?> … … 121 125 </div> 122 126 </div> 123 <?php127 <?php 124 128 } 125 129 } 126 wp_reset_ query();130 wp_reset_postdata(); 127 131 ?> 128 132 </div> -
wp-cafe/trunk/wpcafe.php
r2343218 r2358899 9 9 * Plugin URI: https://product.themewinter.com/wpcafe 10 10 * Description: WordPress Restaurant solution plugin to launch Restaurant Websites. 11 * Version: 1.0. 511 * Version: 1.0.6 12 12 * Author: Themewinter 13 13 * Author URI: http://themewinter.com/
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)