PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.61
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.61
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 10 months ago img 10 months ago js 10 months ago partials 10 months ago class-adv-order-filter.php 10 months ago class-analytics.php 10 months ago class-order-tip-promotion.php 10 months ago class-pi-dtt-labels.php 10 months ago class-pi-dtt-order-table.php 10 months ago conflict-fixer.php 10 months ago menu.php 10 months ago options-addons.php 10 months ago options-date.php 10 months ago options-limit.php 10 months ago options-pickup.php 10 months ago options-time-slot.php 10 months ago options-time.php 10 months ago options.php 10 months ago
options-time.php
225 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-dark opacity-75 text-light', 'class_title'=>'text-light font-weight-light h4', 'label'=>__('Set default time range for all days','pisol-dtt'), 'type'=>'setting_category', 'links' => [
26 [
27 "name" => "Read more about this",
28 "url" => "https://www.piwebsolution.com/user-documentation/#Single_Time_Setting"
29 ]
30 ]),
31
32 array('field'=>'pi_delivery_start_time', 'label'=>__('Delivery start time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly'),
33
34 array('field'=>'pi_delivery_end_time', 'label'=>__('Delivery end time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly') ,
35
36 array('field'=>'pi_pickup_start_time', 'label'=>__('Pickup start time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly'),
37
38 array('field'=>'pi_pickup_end_time', 'label'=>__('Pickup end time','pisol-dtt'), 'type'=>'text', 'required'=>'required', 'readonly'=>'readonly')
39 );
40
41
42 if($this->this_tab == $this->active_tab){
43 add_action('pisol_dtt_tab_content', array($this,'tab_content'));
44 }
45
46 add_action('pisol_dtt_tab', array($this,'tab'),2);
47
48 add_action('admin_notices',array($this,'validateTime'));
49
50 $this->register_settings();
51
52 if(PISOL_DTT_FREE_RESET_SETTING){
53 $this->delete_settings();
54 }
55
56 }
57
58 function delete_settings(){
59 foreach($this->settings as $setting){
60 delete_option( $setting['field'] );
61 }
62 }
63
64 function register_settings(){
65
66 foreach($this->settings as $setting){
67 pisol_class_form::register_setting( $this->setting_key, $setting);
68 }
69
70 }
71
72 function tab(){
73 $page = sanitize_text_field(filter_input( INPUT_GET, 'page'));
74 $this->tab_name = __('Single time','pisol-dtt');
75 ?>
76 <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 ) ); ?>">
77 <span class="dashicons dashicons-dashboard"></span> <?php echo esc_html($this->tab_name); ?>
78 </a>
79 <?php
80 }
81
82 function tab_content(){
83 ?>
84 <form method="post" action="options.php" class="pisol-setting-form">
85 <?php settings_fields( $this->setting_key ); ?>
86 <?php
87 foreach($this->settings as $setting){
88 new pisol_class_form($setting, $this->setting_key);
89 }
90
91 $this->proFeatureRow(__('Monday (Set different time range for Monday)', 'pisol-dtt' ), 'pi_monday_time_slot_delivery', 'pi_monday_time_slot_pickup','monday1');
92 $this->proFeatureRow(__('Tuesday (Set different time range for Tuesday)', 'pisol-dtt' ), 'pi_tuesday_time_slot_delivery', 'pi_tuesday_time_slot_pickup','tuesday1');
93 $this->proFeatureRow(__('Wednesday (Set different time range for Wednesday)', 'pisol-dtt' ), 'pi_wednesday_time_slot_delivery', 'pi_wednesday_time_slot_pickup','wednesday1');
94 $this->proFeatureRow(__('Thursday (Set different time range for Thursday)', 'pisol-dtt' ), 'pi_Thursday_time_slot_delivery', 'pi_Thursday_time_slot_pickup','Thursday1');
95 $this->proFeatureRow(__('Friday (Set different time range for Friday)', 'pisol-dtt' ), 'pi_Friday_time_slot_delivery', 'pi_Friday_time_slot_pickup','Friday1');
96 $this->proFeatureRow(__('Saturday (Set different time range for Saturday)', 'pisol-dtt' ), 'pi_Saturday_time_slot_delivery', 'pi_Saturday_time_slot_pickup','Saturday1');
97 $this->proFeatureRow(__('Sunday (Set different time range for Sunday)', 'pisol-dtt' ), 'pi_Sunday_time_slot_delivery', 'pi_Sunday_time_slot_pickup','Sunday1');
98
99 ?>
100 <input type="submit" name="submit" id="submit" class="btn btn-primary btn-lg my-3" value="<?php echo esc_attr__('Save Changes','pisol-dtt'); ?>">
101 </form>
102
103 <?php
104
105 }
106
107 function validateTime(){
108 $delivery_start = get_option('pi_delivery_start_time', '');
109 $delivery_end = get_option('pi_delivery_end_time', '');
110 $pickup_start = get_option('pi_pickup_start_time', '');
111 $pickup_end = get_option('pi_pickup_end_time', '');
112
113 $time_enabled = get_option('pi_datetime', true);
114
115 if(empty($time_enabled)) return;
116
117 $delivery_types = get_option('pi_type', 'Both');
118
119 $range_slot = get_option('pi_use_time_slot','all_slot');
120
121 $time_range_page = admin_url('admin.php?page=pisol-dtt&tab=time');
122
123 if($range_slot == 'all_range' || $range_slot == 'pickup_slot_delivery_range'){
124 if($delivery_types == 'Both' || $delivery_types == 'Delivery'){
125 if( !empty($delivery_start) && !empty($delivery_end) ){
126 $delivery_start_time = strtotime($delivery_start);
127 $delivery_end_time = strtotime($delivery_end);
128
129 if($delivery_start_time > $delivery_end_time){
130 self::adminError('Delivery start time cant be grater then the end time in Time range', $time_range_page);
131 }
132 }
133
134 if( empty($delivery_start) && empty($delivery_end) ){
135
136 self::adminError('Set Delivery timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
137
138 }
139 }
140 }
141
142 if($range_slot == 'all_range' || $range_slot == 'delivery_slot_pickup_range'){
143 if($delivery_types == 'Both' || $delivery_types == 'Pickup'){
144 if(!empty($pickup_start) && !empty($pickup_end) ){
145 $pickup_start_time = strtotime($pickup_start);
146 $pickup_end_time = strtotime($pickup_end);
147
148 if($pickup_start_time > $pickup_end_time){
149 self::adminError('Pickup start time cant be grater then the end time in Time range', $time_range_page);
150 }
151 }
152
153 if( empty($delivery_start) && empty($delivery_end) ){
154
155 self::adminError('Set Pickup timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
156
157 }
158 }
159 }
160
161 $delivery_slots = get_option('pi_general_time_slot_delivery',array());
162 $pickup_slots = get_option('pi_general_time_slot_pickup',array());
163
164 $time_slot_page = admin_url('admin.php?page=pisol-dtt&tab=pi_time_slot');
165
166 if(($range_slot == 'all_slot' || $range_slot == 'delivery_slot_pickup_range') && empty($delivery_slots)){
167 self::adminError('Configure Delivery time slots in Time slot tab',$time_slot_page);
168 }
169
170 if(($range_slot == 'all_slot' || $range_slot == 'pickup_slot_delivery_range') && empty($pickup_slots)){
171 self::adminError('Configure Pickup time slots in Time slot tab',$time_slot_page);
172 }
173 }
174
175 static function adminError($msg, $page){
176
177 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));
178 }
179
180 function proFeatureRow($label, $field_delivery, $field_pickup, $overwrite_day = ""){
181 if(empty($overwrite_day)){
182 $bg = 'bg-dark opacity-75';
183 $hide="";
184 }else{
185 $bg = 'bg-dark opacity-75';
186 $overwrite_value = pisol_dtt_get_setting('pi_different_slot_for_'.$overwrite_day, "");
187 $checked = false;
188 $hide =' style="display:none;" ';
189 if(!empty($overwrite_value)){
190 $checked = true;
191 $hide="";
192 }
193 }
194 ?>
195 <div id="row_sunday" class="row py-2 border-bottom align-items-center free-version <?php echo esc_attr( $bg ); ?> text-light">
196 <div class="col-10">
197 <?php if(empty($overwrite_day)){ ?>
198 <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 ); ?>" class="mb-0"><?php echo esc_html( $label ); ?></label></h5>
199 <?php }else{ ?>
200 <h5 class="mt-0 mb-0 text-light font-weight-light h5"><label for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>" class="mb-0"><?php echo esc_html( $label ); ?></label></h5>
201 <?php } ?>
202 </div>
203 <?php if(!empty($overwrite_day)): ?>
204 <div class="col-2 text-right">
205 <div class="custom-control custom-switch">
206 <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); ?>>
207 <label class="custom-control-label" for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>"></label>
208 </div>
209 </div>
210 <?php endif; ?>
211 </div>
212 <?php
213 }
214
215 }
216
217 add_action('init', function(){
218 /* if we have pro version setting for time tab then we can disable this */
219 new pisol_dtt_option_time();
220 });
221
222
223
224
225