PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.27
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.27
3.0.63 3.0.62 3.0.61 3.0.60 3.0.49.49 3.0.49.6 3.0.49.60 3.0.49.61 3.0.49.62 3.0.49.63 3.0.49.64 3.0.49.66 3.0.49.67 3.0.49.69 3.0.49.7 3.0.49.70 3.0.49.72 3.0.49.73 3.0.49.74 3.0.49.76 3.0.49.77 3.0.49.79 3.0.49.9 3.0.49.90 3.0.49.91 3.0.49.92 3.0.49.93 3.0.49.94 3.0.49.96 3.0.49.97 3.0.49.99 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 2.9.17 3.0.47 3.0.49 3.0.49.1 3.0.49.10 3.0.49.11 3.0.49.12 3.0.49.13 3.0.49.16 3.0.49.17 3.0.49.19 3.0.49.2 3.0.49.20 3.0.49.21 3.0.49.22 3.0.49.23 3.0.49.24 3.0.49.26 3.0.49.27 3.0.49.29 3.0.49.3 3.0.49.30 3.0.49.31 3.0.49.32 3.0.49.33 3.0.49.34 3.0.49.36 3.0.49.37 3.0.49.39 3.0.49.4 3.0.49.40 3.0.49.41 3.0.49.42 3.0.49.43 3.0.49.44 3.0.49.46 3.0.49.47
pi-woocommerce-order-date-time-and-type / admin / options-time.php
pi-woocommerce-order-date-time-and-type / admin Last commit date
css 1 year ago img 1 year ago js 1 year ago class-adv-order-filter.php 1 year ago class-pi-dtt-labels.php 1 year ago class-pi-dtt-order-table.php 1 year ago conflict-fixer.php 1 year ago menu.php 1 year ago options-addons.php 1 year ago options-date.php 1 year ago options-limit.php 1 year ago options-pickup.php 1 year ago options-time-slot.php 1 year ago options-time.php 1 year ago options.php 1 year ago
options-time.php
216 lines
1 <?php
2
3 class pisol_dtt_option_time{
4
5 private $settings = array();
6
7 private $active_tab;
8
9 private $this_tab = 'time';
10
11 private $tab_name = "Time Range";
12
13 private $setting_key = 'pisol_dtt_time';
14
15 public $tab;
16
17 function __construct(){
18
19 $this->tab = sanitize_text_field(filter_input( INPUT_GET, 'tab'));
20 $this->active_tab = $this->tab != "" ? $this->tab : 'default';
21
22
23
24 $this->settings = array(
25 array('field'=>'sunday', 'class'=> 'bg-secondary text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Set general time range, that will be applied for all days of the week','pisol-dtt'), 'type'=>'setting_category'),
26
27 array('field'=>'pi_delivery_start_time', 'label'=>__('Delivery start time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly'),
28
29 array('field'=>'pi_delivery_end_time', 'label'=>__('Delivery end time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly') ,
30
31 array('field'=>'pi_pickup_start_time', 'label'=>__('Pickup start time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly'),
32
33 array('field'=>'pi_pickup_end_time', 'label'=>__('Pickup end time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly')
34 );
35
36
37 if($this->this_tab == $this->active_tab){
38 add_action('pisol_dtt_tab_content', array($this,'tab_content'));
39 }
40
41 add_action('pisol_dtt_tab', array($this,'tab'),2);
42
43 add_action('admin_notices',array($this,'validateTime'));
44
45 $this->register_settings();
46
47 if(PISOL_DTT_FREE_RESET_SETTING){
48 $this->delete_settings();
49 }
50
51 }
52
53 function delete_settings(){
54 foreach($this->settings as $setting){
55 delete_option( $setting['field'] );
56 }
57 }
58
59 function register_settings(){
60
61 foreach($this->settings as $setting){
62 pisol_class_form::register_setting( $this->setting_key, $setting);
63 }
64
65 }
66
67 function tab(){
68 $page = sanitize_text_field(filter_input( INPUT_GET, 'page'));
69 $this->tab_name = __('Time Range','pisol-dtt');
70 ?>
71 <a class=" pi-side-menu <?php echo ($this->active_tab == $this->this_tab ? 'bg-primary' : 'bg-secondary'); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page='.$page.'&tab='.$this->this_tab ) ); ?>">
72 <span class="dashicons dashicons-dashboard"></span> <?php echo esc_html($this->tab_name); ?>
73 </a>
74 <?php
75 }
76
77 function tab_content(){
78 ?>
79 <form method="post" action="options.php" class="pisol-setting-form">
80 <?php settings_fields( $this->setting_key ); ?>
81 <?php
82 foreach($this->settings as $setting){
83 new pisol_class_form($setting, $this->setting_key);
84 }
85
86 $this->proFeatureRow(__('Monday (Set different time range for Monday)', 'pisol-dtt' ), 'pi_monday_time_slot_delivery', 'pi_monday_time_slot_pickup','monday1');
87 $this->proFeatureRow(__('Tuesday (Set different time range for Tuesday)', 'pisol-dtt' ), 'pi_tuesday_time_slot_delivery', 'pi_tuesday_time_slot_pickup','tuesday1');
88 $this->proFeatureRow(__('Wednesday (Set different time range for Wednesday)', 'pisol-dtt' ), 'pi_wednesday_time_slot_delivery', 'pi_wednesday_time_slot_pickup','wednesday1');
89 $this->proFeatureRow(__('Thursday (Set different time range for Thursday)', 'pisol-dtt' ), 'pi_Thursday_time_slot_delivery', 'pi_Thursday_time_slot_pickup','Thursday1');
90 $this->proFeatureRow(__('Friday (Set different time range for Friday)', 'pisol-dtt' ), 'pi_Friday_time_slot_delivery', 'pi_Friday_time_slot_pickup','Friday1');
91 $this->proFeatureRow(__('Saturday (Set different time range for Saturday)', 'pisol-dtt' ), 'pi_Saturday_time_slot_delivery', 'pi_Saturday_time_slot_pickup','Saturday1');
92 $this->proFeatureRow(__('Sunday (Set different time range for Sunday)', 'pisol-dtt' ), 'pi_Sunday_time_slot_delivery', 'pi_Sunday_time_slot_pickup','Sunday1');
93
94 ?>
95 <input type="submit" name="submit" id="submit" class="btn btn-primary btn-lg my-3" value="<?php echo esc_attr__('Save Changes','pisol-dtt'); ?>">
96 </form>
97
98 <?php
99
100 }
101
102 function validateTime(){
103 $delivery_start = get_option('pi_delivery_start_time', '');
104 $delivery_end = get_option('pi_delivery_end_time', '');
105 $pickup_start = get_option('pi_pickup_start_time', '');
106 $pickup_end = get_option('pi_pickup_end_time', '');
107
108 $time_enabled = get_option('pi_datetime', true);
109
110 if(empty($time_enabled)) return;
111
112 $delivery_types = get_option('pi_type', 'Both');
113
114 $range_slot = get_option('pi_use_time_slot','all_range');
115
116 $time_range_page = admin_url('admin.php?page=pisol-dtt&tab=time');
117
118 if($range_slot == 'all_range' || $range_slot == 'pickup_slot_delivery_range'){
119 if($delivery_types == 'Both' || $delivery_types == 'Delivery'){
120 if( !empty($delivery_start) && !empty($delivery_end) ){
121 $delivery_start_time = strtotime($delivery_start);
122 $delivery_end_time = strtotime($delivery_end);
123
124 if($delivery_start_time > $delivery_end_time){
125 self::adminError('Delivery start time cant be grater then the end time in Time range', $time_range_page);
126 }
127 }
128
129 if( empty($delivery_start) && empty($delivery_end) ){
130
131 self::adminError('Set Delivery timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
132
133 }
134 }
135 }
136
137 if($range_slot == 'all_range' || $range_slot == 'delivery_slot_pickup_range'){
138 if($delivery_types == 'Both' || $delivery_types == 'Pickup'){
139 if(!empty($pickup_start) && !empty($pickup_end) ){
140 $pickup_start_time = strtotime($pickup_start);
141 $pickup_end_time = strtotime($pickup_end);
142
143 if($pickup_start_time > $pickup_end_time){
144 self::adminError('Pickup start time cant be grater then the end time in Time range', $time_range_page);
145 }
146 }
147
148 if( empty($delivery_start) && empty($delivery_end) ){
149
150 self::adminError('Set Pickup timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
151
152 }
153 }
154 }
155
156 $delivery_slots = get_option('pi_general_time_slot_delivery',array());
157 $pickup_slots = get_option('pi_general_time_slot_pickup',array());
158
159 $time_slot_page = admin_url('admin.php?page=pisol-dtt&tab=pi_time_slot');
160
161 if(($range_slot == 'all_slot' || $range_slot == 'delivery_slot_pickup_range') && empty($delivery_slots)){
162 self::adminError('Configure Delivery time slots in Time slot tab',$time_slot_page);
163 }
164
165 if(($range_slot == 'all_slot' || $range_slot == 'pickup_slot_delivery_range') && empty($pickup_slots)){
166 self::adminError('Configure Pickup time slots in Time slot tab',$time_slot_page);
167 }
168 }
169
170 static function adminError($msg, $page){
171
172 echo sprintf('<div class="notice notice-error is-dismissible"><p><strong><span style="color:#f00;">ERROR: </span> %s</strong> <a href="%s">Click here to correct this issue</a></p></div>', esc_html($msg), esc_attr($page));
173 }
174
175 function proFeatureRow($label, $field_delivery, $field_pickup, $overwrite_day = ""){
176 if(empty($overwrite_day)){
177 $bg = 'bg-primary';
178 $hide="";
179 }else{
180 $bg = 'bg-dark';
181 $overwrite_value = pisol_dtt_get_setting('pi_different_slot_for_'.$overwrite_day, "");
182 $checked = false;
183 $hide =' style="display:none;" ';
184 if(!empty($overwrite_value)){
185 $checked = true;
186 $hide="";
187 }
188 }
189 ?>
190 <div id="row_sunday" class="row py-2 border-bottom align-items-center free-version <?php echo esc_attr( $bg ); ?> text-light">
191 <div class="col-10">
192 <?php if(empty($overwrite_day)){ ?>
193 <h5 class="mt-0 mb-0 py-2 text-light font-weight-light h4"><label for="pi_different_slot_for_<?php echo esc_attr($overwrite_day ); ?>"><?php echo esc_html( $label ); ?></label></h5>
194 <?php }else{ ?>
195 <h5 class="mt-0 mb-0 text-light font-weight-light h5"><label for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>"><?php echo esc_html( $label ); ?></label></h5>
196 <?php } ?>
197 </div>
198 <?php if(!empty($overwrite_day)): ?>
199 <div class="col-2 text-right">
200 <div class="custom-control custom-switch">
201 <input type="checkbox" class="custom-control-input" name="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>" id="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>" <?php checked(true, $checked); ?>>
202 <label class="custom-control-label" for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>"></label>
203 </div>
204 </div>
205 <?php endif; ?>
206 </div>
207 <?php
208 }
209
210 }
211
212 /* if we have pro version setting for time tab then we can disable this */
213 new pisol_dtt_option_time();
214
215
216