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