custom.js
1 year ago
jquery.timepicker.min.js
1 year ago
pi-order-page.js
1 year ago
pi-woocommerce-order-date-time-and-type-pro-admin.js
1 year ago
pisol-quick-save.js
1 year ago
custom.js
160 lines
| 1 | jQuery(function ($) { |
| 2 | $( |
| 3 | "#pi_delivery_start_time, #pi_pickup_start_time, #pi_pickup_end_time, #pi_delivery_end_time" |
| 4 | ).timepicker({ scrollbar: true, dynamic: false }); |
| 5 | |
| 6 | $("#pi_delivery_end_time").timepicker({ |
| 7 | minTime: $("#pi_delivery_start_time").val() |
| 8 | }); |
| 9 | |
| 10 | $("#pi_pickup_end_time").timepicker({ |
| 11 | minTime: $("#pi_pickup_start_time").val() |
| 12 | }); |
| 13 | |
| 14 | $("#pi_delivery_start_time").timepicker("option", "change", function () { |
| 15 | $("#pi_delivery_end_time").val(""); |
| 16 | $("#pi_delivery_end_time").timepicker( |
| 17 | "option", |
| 18 | "minTime", |
| 19 | $("#pi_delivery_start_time").val() |
| 20 | ); |
| 21 | }); |
| 22 | |
| 23 | $("#pi_pickup_start_time").timepicker("option", "change", function () { |
| 24 | $("#pi_pickup_end_time").val(""); |
| 25 | $("#pi_pickup_end_time").timepicker( |
| 26 | "option", |
| 27 | "minTime", |
| 28 | $("#pi_pickup_start_time").val() |
| 29 | ); |
| 30 | }); |
| 31 | |
| 32 | $("body").on("focus", ".pisol-date-picker", function () { |
| 33 | $.datepicker.setDefaults($.datepicker.regional["en"]); |
| 34 | $(this).datepicker({ |
| 35 | dateFormat: "yy/mm/dd" |
| 36 | }); |
| 37 | }); |
| 38 | |
| 39 | $("#pi_order_preparation_days").on("change", function () { |
| 40 | var value = parseInt($(this).val()); |
| 41 | if (value > 0) { |
| 42 | preparationHours(false); |
| 43 | } else { |
| 44 | preparationHours(true); |
| 45 | } |
| 46 | |
| 47 | if (value >= 2) { |
| 48 | nextDayCutOffTime(false); |
| 49 | } else { |
| 50 | nextDayCutOffTime(true); |
| 51 | } |
| 52 | |
| 53 | if (value == 0) { |
| 54 | sameDayCutOffTime(true); |
| 55 | } else { |
| 56 | sameDayCutOffTime(false); |
| 57 | } |
| 58 | |
| 59 | }); |
| 60 | |
| 61 | function nextDayCutOffTime(show) { |
| 62 | if (show) { |
| 63 | jQuery("#row_pi_next_day_delivery_cutoff_time-pro").fadeIn(); |
| 64 | jQuery("#row_pi_next_day_pickup_cutoff_time-pro").fadeIn(); |
| 65 | } else { |
| 66 | jQuery("#row_pi_next_day_delivery_cutoff_time-pro").fadeOut(); |
| 67 | jQuery("#row_pi_next_day_pickup_cutoff_time-pro").fadeOut(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | function sameDayCutOffTime(show) { |
| 72 | if (show) { |
| 73 | jQuery("#row_pi_same_day_delivery_cutoff_time-pro").fadeIn(); |
| 74 | jQuery("#row_pi_same_day_pickup_cutoff_time-pro").fadeIn(); |
| 75 | } else { |
| 76 | jQuery("#row_pi_same_day_delivery_cutoff_time-pro").fadeOut(); |
| 77 | jQuery("#row_pi_same_day_pickup_cutoff_time-pro").fadeOut(); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | $("#pi_order_preparation_days").trigger("change"); |
| 82 | |
| 83 | function preparationHours(state) { |
| 84 | if (state) { |
| 85 | $("#row_pi_order_preparation_hours").fadeIn(); |
| 86 | } else { |
| 87 | $("#row_pi_order_preparation_hours").fadeOut(); |
| 88 | } |
| 89 | } |
| 90 | var ids = ["pi_delivery_start_time", "pi_delivery_end_time", "pi_pickup_start_time", "pi_pickup_end_time", "pi_delivery_sunday_start_time", "pi_delivery_sunday_end_time", "pi_pickup_sunday_start_time", "pi_pickup_sunday_end_time", "pi_delivery_monday_start_time", "pi_delivery_monday_end_time", "pi_pickup_monday_start_time", "pi_pickup_monday_end_time", "pi_delivery_tuesday_start_time", "pi_delivery_tuesday_end_time", "pi_pickup_tuesday_start_time", "pi_pickup_tuesday_end_time", "pi_delivery_wednesday_start_time", "pi_delivery_wednesday_end_time", "pi_pickup_wednesday_start_time", "pi_pickup_wednesday_end_time", "pi_delivery_thursday_start_time", "pi_delivery_thursday_end_time", "pi_pickup_thursday_start_time", "pi_pickup_thursday_end_time", "pi_delivery_friday_start_time", "pi_delivery_friday_end_time", "pi_pickup_friday_start_time", "pi_pickup_friday_end_time", "pi_delivery_saturday_start_time", "pi_delivery_saturday_end_time", "pi_pickup_saturday_start_time", "pi_pickup_saturday_end_time"]; |
| 91 | $.each(ids, function (index, value) { |
| 92 | $("#" + value).css("text-align", "left"); |
| 93 | clearValue(value); |
| 94 | }); |
| 95 | |
| 96 | function clearValue(id) { |
| 97 | $("<a class='pi-clear-value btn btn-danger text-light'>Clear Value</a>").insertAfter("#" + id); |
| 98 | } |
| 99 | $(".pi-clear-value").on("click", function () { |
| 100 | $("input", $(this).parent()).val(""); |
| 101 | }); |
| 102 | |
| 103 | var pickup_time_ids = ["#row_pi_pickup_start_time", "#row_pi_pickup_end_time", "#row_pi_pickup_sunday_start_time", "#row_pi_pickup_sunday_end_time", "#row_pi_pickup_monday_start_time", "#row_pi_pickup_monday_end_time", "#row_pi_pickup_tuesday_start_time", "#row_pi_pickup_tuesday_end_time", "#row_pi_pickup_wednesday_start_time", "#row_pi_pickup_wednesday_end_time", "#row_pi_pickup_thursday_start_time", "#row_pi_pickup_thursday_end_time", "#row_pi_pickup_friday_start_time", "#row_pi_pickup_friday_end_time", "#row_pi_pickup_saturday_start_time", "#row_pi_pickup_saturday_end_time"]; |
| 104 | |
| 105 | var delivery_time_ids = ["#row_pi_delivery_start_time", "#row_pi_delivery_end_time", "#row_pi_delivery_sunday_start_time", "#row_pi_delivery_sunday_end_time", "#row_pi_delivery_monday_start_time", "#row_pi_delivery_monday_end_time", "#row_pi_delivery_tuesday_start_time", "#row_pi_delivery_tuesday_end_time", "#row_pi_delivery_wednesday_start_time", "#row_pi_delivery_wednesday_end_time", "#row_pi_delivery_thursday_start_time", "#row_pi_delivery_thursday_end_time", "#row_pi_delivery_friday_start_time", "#row_pi_delivery_friday_end_time", "#row_pi_delivery_saturday_start_time", "#row_pi_delivery_saturday_end_time"]; |
| 106 | |
| 107 | hide_time_based_on_delivery_type(pickup_time_ids, delivery_time_ids); |
| 108 | |
| 109 | function hide_time_based_on_delivery_type(pickup_time_ids, delivery_time_ids) { |
| 110 | var type = pi_dtt_settings.delivery_type; |
| 111 | if (type == 'Both') return; |
| 112 | |
| 113 | if (type == 'Delivery') { |
| 114 | pi_hide_rows(pickup_time_ids); |
| 115 | } |
| 116 | |
| 117 | if (type == 'Pickup') { |
| 118 | pi_hide_rows(delivery_time_ids); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | function pi_hide_rows($ids) { |
| 123 | var $ = jQuery; |
| 124 | $.each($ids, function (index, value) { |
| 125 | $(value).fadeOut(); |
| 126 | }); |
| 127 | } |
| 128 | |
| 129 | function hideProFeature() { |
| 130 | var load_status = localStorage.getItem('pisol-dtt-pro-feature-state'); |
| 131 | if (load_status == '' || load_status == undefined || load_status == 'show') { |
| 132 | jQuery("#hid-pro-feature").html('Hide Pro feature'); |
| 133 | jQuery(".free-version, #promotion-sidebar, .hide-pro").fadeIn(); |
| 134 | } else { |
| 135 | jQuery("#hid-pro-feature").html('Show Pro feature'); |
| 136 | jQuery(".free-version, #promotion-sidebar, .hide-pro").fadeOut(); |
| 137 | } |
| 138 | |
| 139 | jQuery("#hid-pro-feature").on("click", function () { |
| 140 | var state = localStorage.getItem('pisol-dtt-pro-feature-state'); |
| 141 | if (state == '' || state == undefined || state == 'show') { |
| 142 | localStorage.setItem('pisol-dtt-pro-feature-state', 'hidden'); |
| 143 | jQuery("#hid-pro-feature").html('Show Pro feature'); |
| 144 | jQuery(".free-version, #promotion-sidebar, .hide-pro").fadeOut(); |
| 145 | } else { |
| 146 | localStorage.setItem('pisol-dtt-pro-feature-state', 'show'); |
| 147 | jQuery("#hid-pro-feature").html('Hide Pro feature'); |
| 148 | jQuery(".free-version, #promotion-sidebar, .hide-pro").fadeIn(); |
| 149 | } |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | hideProFeature(); |
| 154 | /** |
| 155 | * selectwo0 |
| 156 | */ |
| 157 | jQuery("#pi_delivery_days, #pi_pickup_days, #pi_dtt_remove_billing_when_pickup-pro, #pi_dtt_remove_billing_when_delivery-pro").selectWoo(); |
| 158 | |
| 159 | }); |
| 160 |