custom.js
10 months ago
jquery.timepicker.min.js
10 months ago
pi-order-page.js
10 months ago
pi-woocommerce-order-date-time-and-type-pro-admin.js
10 months ago
pisol-quick-save.js
10 months ago
custom.js
140 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-remove-date").on("click", function () { |
| 40 | $(this).closest('.pisol_grid').find('.pisol-date-picker').val(''); |
| 41 | }); |
| 42 | |
| 43 | $("#pi_order_preparation_days").on("change", function () { |
| 44 | var value = parseInt($(this).val()); |
| 45 | if (value > 0) { |
| 46 | preparationHours(false); |
| 47 | } else { |
| 48 | preparationHours(true); |
| 49 | } |
| 50 | |
| 51 | if (value >= 2) { |
| 52 | nextDayCutOffTime(false); |
| 53 | } else { |
| 54 | nextDayCutOffTime(true); |
| 55 | } |
| 56 | |
| 57 | if (value == 0) { |
| 58 | sameDayCutOffTime(true); |
| 59 | } else { |
| 60 | sameDayCutOffTime(false); |
| 61 | } |
| 62 | |
| 63 | }); |
| 64 | |
| 65 | function nextDayCutOffTime(show) { |
| 66 | if (show) { |
| 67 | jQuery("#row_pi_next_day_delivery_cutoff_time-pro").fadeIn(); |
| 68 | jQuery("#row_pi_next_day_pickup_cutoff_time-pro").fadeIn(); |
| 69 | } else { |
| 70 | jQuery("#row_pi_next_day_delivery_cutoff_time-pro").fadeOut(); |
| 71 | jQuery("#row_pi_next_day_pickup_cutoff_time-pro").fadeOut(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | function sameDayCutOffTime(show) { |
| 76 | if (show) { |
| 77 | jQuery("#row_pi_same_day_delivery_cutoff_time-pro").fadeIn(); |
| 78 | jQuery("#row_pi_same_day_pickup_cutoff_time-pro").fadeIn(); |
| 79 | } else { |
| 80 | jQuery("#row_pi_same_day_delivery_cutoff_time-pro").fadeOut(); |
| 81 | jQuery("#row_pi_same_day_pickup_cutoff_time-pro").fadeOut(); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | $("#pi_order_preparation_days").trigger("change"); |
| 86 | |
| 87 | function preparationHours(state) { |
| 88 | if (state) { |
| 89 | $("#row_pi_order_preparation_hours").fadeIn(); |
| 90 | } else { |
| 91 | $("#row_pi_order_preparation_hours").fadeOut(); |
| 92 | } |
| 93 | } |
| 94 | 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"]; |
| 95 | $.each(ids, function (index, value) { |
| 96 | $("#" + value).css("text-align", "left"); |
| 97 | clearValue(value); |
| 98 | }); |
| 99 | |
| 100 | function clearValue(id) { |
| 101 | $("<a class='pi-clear-value btn btn-primary text-light'>Clear Value</a>").insertAfter("#" + id); |
| 102 | } |
| 103 | $(".pi-clear-value").on("click", function () { |
| 104 | $("input", $(this).parent()).val(""); |
| 105 | }); |
| 106 | |
| 107 | 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"]; |
| 108 | |
| 109 | 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"]; |
| 110 | |
| 111 | hide_time_based_on_delivery_type(pickup_time_ids, delivery_time_ids); |
| 112 | |
| 113 | function hide_time_based_on_delivery_type(pickup_time_ids, delivery_time_ids) { |
| 114 | var type = pi_dtt_settings.delivery_type; |
| 115 | if (type == 'Both') return; |
| 116 | |
| 117 | if (type == 'Delivery') { |
| 118 | pi_hide_rows(pickup_time_ids); |
| 119 | } |
| 120 | |
| 121 | if (type == 'Pickup') { |
| 122 | pi_hide_rows(delivery_time_ids); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | function pi_hide_rows($ids) { |
| 127 | var $ = jQuery; |
| 128 | $.each($ids, function (index, value) { |
| 129 | $(value).fadeOut(); |
| 130 | }); |
| 131 | } |
| 132 | |
| 133 | |
| 134 | /** |
| 135 | * selectwo0 |
| 136 | */ |
| 137 | jQuery("#pi_delivery_days, #pi_pickup_days, #pi_dtt_remove_billing_when_pickup-pro, #pi_dtt_remove_billing_when_delivery-pro").selectWoo(); |
| 138 | |
| 139 | }); |
| 140 |