PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.69
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.69
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 9 months ago img 9 months ago js 9 months ago partials 9 months ago class-adv-order-filter.php 9 months ago class-analytics.php 9 months ago class-order-tip-promotion.php 9 months ago class-pi-dtt-labels.php 9 months ago class-pi-dtt-order-table.php 9 months ago conflict-fixer.php 9 months ago menu.php 9 months ago options-addons.php 9 months ago options-date.php 9 months ago options-limit.php 9 months ago options-pickup.php 9 months ago options-time-slot.php 9 months ago options-time.php 9 months ago options.php 9 months ago
options-time.php
234 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 $time_type = get_option('pi_use_time_slot','all_slot');
74
75 if($time_type === 'all_slot'){
76 return;
77 }
78
79 $page = sanitize_text_field(filter_input( INPUT_GET, 'page'));
80 $this->tab_name = __('Single time','pisol-dtt');
81 if($time_type === 'all_range'){
82 $this->tab_name = __('Configure timing','pisol-dtt');
83 }
84 ?>
85 <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 ) ); ?>">
86 <span class="dashicons dashicons-dashboard"></span> <?php echo esc_html($this->tab_name); ?>
87 </a>
88 <?php
89 }
90
91 function tab_content(){
92 ?>
93 <form method="post" action="options.php" class="pisol-setting-form">
94 <?php settings_fields( $this->setting_key ); ?>
95 <?php
96 foreach($this->settings as $setting){
97 new pisol_class_form($setting, $this->setting_key);
98 }
99
100 $this->proFeatureRow(__('Monday (Set different time range for Monday)', 'pisol-dtt' ), 'pi_monday_time_slot_delivery', 'pi_monday_time_slot_pickup','monday1');
101 $this->proFeatureRow(__('Tuesday (Set different time range for Tuesday)', 'pisol-dtt' ), 'pi_tuesday_time_slot_delivery', 'pi_tuesday_time_slot_pickup','tuesday1');
102 $this->proFeatureRow(__('Wednesday (Set different time range for Wednesday)', 'pisol-dtt' ), 'pi_wednesday_time_slot_delivery', 'pi_wednesday_time_slot_pickup','wednesday1');
103 $this->proFeatureRow(__('Thursday (Set different time range for Thursday)', 'pisol-dtt' ), 'pi_Thursday_time_slot_delivery', 'pi_Thursday_time_slot_pickup','Thursday1');
104 $this->proFeatureRow(__('Friday (Set different time range for Friday)', 'pisol-dtt' ), 'pi_Friday_time_slot_delivery', 'pi_Friday_time_slot_pickup','Friday1');
105 $this->proFeatureRow(__('Saturday (Set different time range for Saturday)', 'pisol-dtt' ), 'pi_Saturday_time_slot_delivery', 'pi_Saturday_time_slot_pickup','Saturday1');
106 $this->proFeatureRow(__('Sunday (Set different time range for Sunday)', 'pisol-dtt' ), 'pi_Sunday_time_slot_delivery', 'pi_Sunday_time_slot_pickup','Sunday1');
107
108 ?>
109 <input type="submit" name="submit" id="submit" class="btn btn-primary btn-lg my-3" value="<?php echo esc_attr__('Save Changes','pisol-dtt'); ?>">
110 </form>
111
112 <?php
113
114 }
115
116 function validateTime(){
117 $delivery_start = get_option('pi_delivery_start_time', '');
118 $delivery_end = get_option('pi_delivery_end_time', '');
119 $pickup_start = get_option('pi_pickup_start_time', '');
120 $pickup_end = get_option('pi_pickup_end_time', '');
121
122 $time_enabled = get_option('pi_datetime', true);
123
124 if(empty($time_enabled)) return;
125
126 $delivery_types = get_option('pi_type', 'Both');
127
128 $range_slot = get_option('pi_use_time_slot','all_slot');
129
130 $time_range_page = admin_url('admin.php?page=pisol-dtt&tab=time');
131
132 if($range_slot == 'all_range' || $range_slot == 'pickup_slot_delivery_range'){
133 if($delivery_types == 'Both' || $delivery_types == 'Delivery'){
134 if( !empty($delivery_start) && !empty($delivery_end) ){
135 $delivery_start_time = strtotime($delivery_start);
136 $delivery_end_time = strtotime($delivery_end);
137
138 if($delivery_start_time > $delivery_end_time){
139 self::adminError('Delivery start time cant be grater then the end time in Time range', $time_range_page);
140 }
141 }
142
143 if( empty($delivery_start) && empty($delivery_end) ){
144
145 self::adminError('Set Delivery timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
146
147 }
148 }
149 }
150
151 if($range_slot == 'all_range' || $range_slot == 'delivery_slot_pickup_range'){
152 if($delivery_types == 'Both' || $delivery_types == 'Pickup'){
153 if(!empty($pickup_start) && !empty($pickup_end) ){
154 $pickup_start_time = strtotime($pickup_start);
155 $pickup_end_time = strtotime($pickup_end);
156
157 if($pickup_start_time > $pickup_end_time){
158 self::adminError('Pickup start time cant be grater then the end time in Time range', $time_range_page);
159 }
160 }
161
162 if( empty($delivery_start) && empty($delivery_end) ){
163
164 self::adminError('Set Pickup timing range else default timing range will be used 9 AM to 9 PM', $time_range_page);
165
166 }
167 }
168 }
169
170 $delivery_slots = get_option('pi_general_time_slot_delivery',array());
171 $pickup_slots = get_option('pi_general_time_slot_pickup',array());
172
173 $time_slot_page = admin_url('admin.php?page=pisol-dtt&tab=pi_time_slot');
174
175 if(($range_slot == 'all_slot' || $range_slot == 'delivery_slot_pickup_range') && empty($delivery_slots)){
176 self::adminError('Configure Delivery time slots in Time slot tab',$time_slot_page);
177 }
178
179 if(($range_slot == 'all_slot' || $range_slot == 'pickup_slot_delivery_range') && empty($pickup_slots)){
180 self::adminError('Configure Pickup time slots in Time slot tab',$time_slot_page);
181 }
182 }
183
184 static function adminError($msg, $page){
185
186 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));
187 }
188
189 function proFeatureRow($label, $field_delivery, $field_pickup, $overwrite_day = ""){
190 if(empty($overwrite_day)){
191 $bg = 'bg-dark opacity-75';
192 $hide="";
193 }else{
194 $bg = 'bg-dark opacity-75';
195 $overwrite_value = pisol_dtt_get_setting('pi_different_slot_for_'.$overwrite_day, "");
196 $checked = false;
197 $hide =' style="display:none;" ';
198 if(!empty($overwrite_value)){
199 $checked = true;
200 $hide="";
201 }
202 }
203 ?>
204 <div id="row_sunday" class="row py-2 border-bottom align-items-center free-version <?php echo esc_attr( $bg ); ?> text-light">
205 <div class="col-10">
206 <?php if(empty($overwrite_day)){ ?>
207 <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>
208 <?php }else{ ?>
209 <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>
210 <?php } ?>
211 </div>
212 <?php if(!empty($overwrite_day)): ?>
213 <div class="col-2 text-right">
214 <div class="custom-control custom-switch">
215 <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); ?>>
216 <label class="custom-control-label" for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>"></label>
217 </div>
218 </div>
219 <?php endif; ?>
220 </div>
221 <?php
222 }
223
224 }
225
226 add_action('init', function(){
227 /* if we have pro version setting for time tab then we can disable this */
228 new pisol_dtt_option_time();
229 });
230
231
232
233
234