Fix the rental dates to be in the formate of tags to veiw it better and user friendly //…
- User
Fix the rental dates to be in the formate of tags to veiw it better and user friendly
// Disable Rent Dates - Multiselect Datepicker (multiple dates) woocommerce_wp_text_input([ 'id' => '_woorent_disable_dates', 'label' => __('Disable Rent Dates', 'woorent'), 'placeholder' => 'default: none', 'description' => __('Select multiple dates to disable for rent.', 'woorent'), 'desc_tip' => true, 'type' => 'text', ]);
code// JQ Datepicker Script for Multiple Dates echo '<script type="text/javascript">'; echo 'jQuery(document).ready(function($) {'; echo ' var disableDates = $("#_woorent_disable_dates").val() ? $("#_woorent_disable_dates").val().split(",") : [];'; echo ' $("#_woorent_disable_dates").datepicker({'; echo ' dateFormat: "yy-mm-dd",'; echo ' beforeShowDay: function(date) {'; echo ' var string = $.datepicker.formatDate("yy-mm-dd", date);'; echo ' return [disableDates.indexOf(string) == -1];'; echo ' },'; echo ' onSelect: function(dateText) {'; echo ' if (disableDates.indexOf(dateText) === -1) {'; echo ' disableDates.push(dateText);'; echo ' } else {'; echo ' disableDates = disableDates.filter(function(date) { return date !== dateText; });'; echo ' }'; echo ' $("#_woorent_disable_dates").val(disableDates.join(","));'; echo ' }'; echo ' });'; // On change of the input field value (dates), update the datepicker echo ' $("#_woorent_disable_dates").change(function() {'; echo ' disableDates = $(this).val().split(",");'; echo ' $("#_woorent_disable_dates").datepicker("refresh");'; echo ' });'; echo '});'; echo '</script>'; // Disable Rent Days - Multiselect woocommerce_wp_select([ 'id' => '_woorent_disable_days', 'name' => '_woorent_disable_days[]', 'label' => __('Disable Rent Days', 'woorent'), 'description' => __('Select multiple days to disable for rent.', 'woorent'), 'desc_tip' => true, 'options' => [ 'monday' => __('Monday', 'woorent'), 'tuesday' => __('Tuesday', 'woorent'), 'wednesday' => __('Wednesday', 'woorent'), 'thursday' => __('Thursday', 'woorent'), 'friday' => __('Friday', 'woorent'), 'saturday' => __('Saturday', 'woorent'), 'sunday' => __('Sunday', 'woorent'), ], 'custom_attributes' => [ 'multiple' => 'multiple', ], ]); // Add Select2 for better UX echo '<script type="text/javascript">'; echo 'jQuery(document).ready(function($) {'; echo ' $("#_woorent_disable_days").select2({'; echo ' placeholder: "Select days to disable",'; echo ' allowClear: true,'; echo ' });'; echo '});'; echo '</script>'; - Assistant