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-slot.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-slot.php
271 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 class pisol_dtt_option_time_slot{
5
6 private $settings = array();
7
8 private $active_tab;
9
10 private $this_tab = 'pi_time_slot';
11
12 private $tab_name = "Time Slot";
13
14 private $setting_key = 'pisol_time_slot';
15
16 private $pro_version = false;
17
18 public $tab;
19
20
21 function __construct(){
22
23 $this->pro_version = pi_dtt_pro_check();
24
25 $this->tab = sanitize_text_field(filter_input( INPUT_GET, 'tab'));
26 $this->active_tab = $this->tab != "" ? $this->tab : 'default';
27
28 $this->settings = array(
29
30 array('field'=>'pi_general_time_slot_delivery', 'sanitize_callback'=> [__CLASS__,'sanitize_time_slot']),
31 array('field'=>'pi_general_time_slot_pickup', 'sanitize_callback'=> [__CLASS__,'sanitize_time_slot'])
32
33 );
34
35
36 if($this->this_tab == $this->active_tab){
37 add_action('pisol_dtt_tab_content', array($this,'tab_content'));
38 }
39
40 add_action('pisol_dtt_tab', array($this,'tab'),3);
41
42 $this->register_settings();
43
44
45 }
46
47 function register_settings(){
48
49 foreach($this->settings as $setting){
50 pisol_class_form::register_setting( $this->setting_key, $setting);
51 }
52
53 }
54
55 function tab(){
56 $time_type = get_option('pi_use_time_slot','all_slot');
57
58 if($time_type === 'all_range'){
59 return;
60 }
61
62 $page = sanitize_text_field(filter_input( INPUT_GET, 'page'));
63 $this->tab_name = __('Time Slot','pisol-dtt');
64 if($time_type === 'all_slot'){
65 $this->tab_name = __('Configure timing','pisol-dtt');
66 }
67 ?>
68 <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 ) ); ?>">
69 <span class="dashicons dashicons-dashboard"></span> <?php echo esc_html($this->tab_name); ?>
70 </a>
71 <?php
72 }
73
74 function tab_content(){
75 ?>
76 <form method="post" action="options.php" class="pisol-setting-form">
77 <?php settings_fields( $this->setting_key ); ?>
78 <?php
79 echo '<script>';
80 foreach($this->settings as $setting){
81 $val = pisol_dtt_get_setting($setting['field'], array());
82 if(!is_array($val) || count($val) < 1){
83 $val = array();
84 }
85 ?>
86 var <?php echo esc_js( $setting['field'] ); ?> = <?php echo json_encode(array_values($val)); ?>;
87 <?php
88 }
89 echo '</script>';
90 ?>
91 <?php
92 foreach($this->settings as $setting){
93 new pisol_class_form($setting, $this->setting_key);
94 }
95
96 $this->timesForm(__('General Time Slot (this will be applied for all days of the week)', 'pisol-dtt' ), 'pi_general_time_slot_delivery', 'pi_general_time_slot_pickup');
97
98 $this->proFeatureRow(__('Monday (Set different time slot for Monday)', 'pisol-dtt' ), 'pi_monday_time_slot_delivery', 'pi_monday_time_slot_pickup','monday1');
99 $this->proFeatureRow(__('Tuesday (Set different time slot for Tuesday)', 'pisol-dtt' ), 'pi_tuesday_time_slot_delivery', 'pi_tuesday_time_slot_pickup','tuesday1');
100 $this->proFeatureRow(__('Wednesday (Set different time slot for Wednesday)', 'pisol-dtt' ), 'pi_wednesday_time_slot_delivery', 'pi_wednesday_time_slot_pickup','wednesday1');
101 $this->proFeatureRow(__('Thursday (Set different time slot for Thursday)', 'pisol-dtt' ), 'pi_Thursday_time_slot_delivery', 'pi_Thursday_time_slot_pickup','Thursday1');
102 $this->proFeatureRow(__('Friday (Set different time slot for Friday)', 'pisol-dtt' ), 'pi_Friday_time_slot_delivery', 'pi_Friday_time_slot_pickup','Friday1');
103 $this->proFeatureRow(__('Saturday (Set different time slot for Saturday)', 'pisol-dtt' ), 'pi_Saturday_time_slot_delivery', 'pi_Saturday_time_slot_pickup','Saturday1');
104 $this->proFeatureRow(__('Sunday (Set different time slot for Sunday)', 'pisol-dtt' ), 'pi_Sunday_time_slot_delivery', 'pi_Sunday_time_slot_pickup','Sunday1');
105
106
107 ?>
108 <input type="submit" name="submit" id="submit" class="btn btn-primary btn-md my-3" value="<?php echo esc_attr__('Save Changes','pisol-dtt'); ?>">
109 </form>
110 <?php
111 }
112
113 function timesForm($label, $field_delivery, $field_pickup, $overwrite_day = ""){
114 if(empty($overwrite_day)){
115 $bg = 'bg-dark opacity-75';
116 $hide="";
117 }else{
118 $bg = 'bg-dark opacity-75';
119 $overwrite_value = pisol_dtt_get_setting('pi_different_slot_for_'.$overwrite_day, "");
120 $checked = false;
121 $hide ='display:none;';
122 if(!empty($overwrite_value)){
123 $checked = true;
124 $hide="";
125 }
126 }
127 ?>
128 <div id="row_sunday" class="row py-2 border-bottom align-items-center <?php echo esc_attr( $bg ); ?> text-light">
129 <div class="col-9">
130 <?php if(empty($overwrite_day)){ ?>
131 <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>
132 <a class="pi-info-links my-0 text-light" href="https://www.piwebsolution.com/user-documentation/#Time_Slot_Settings" target="_blank">Know more about this?</a>
133 <?php }else{ ?>
134 <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>
135 <?php } ?>
136 </div>
137 <?php if(!empty($overwrite_day)): ?>
138 <div class="col-3 text-right">
139 <div class="custom-control custom-switch">
140 <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); ?>>
141 <label class="custom-control-label" for="pi_different_slot_for_<?php echo esc_attr( $overwrite_day ); ?>"></label>
142 </div>
143 </div>
144 <?php endif; ?>
145 </div>
146
147 <div class="row mb-2 pt-2" id="pi_slots_for_<?php echo esc_attr( $overwrite_day ); ?>" style="<?php echo esc_attr($hide); ?>">
148 <div class="col-12 col-md-6">
149 <div class="row align-items-center">
150 <div class="col-7 mt-2">
151 <strong><?php esc_html_e('Delivery Time slots', 'pisol-dtt' ); ?></strong>
152 </div>
153 <div class="col text-right">
154 <a class="btn btn-primary btn-sm pi_add_time_slot text-light" data-slot="<?php echo esc_attr( $field_delivery ); ?>" ><?php esc_html_e('Add Time Slot', 'pisol-dtt' ); ?></a>
155 </div>
156 </div>
157 <div class="row align-items-center">
158 <div class="col-12 mt-2">
159 <div id="<?php echo esc_attr( $field_delivery ); ?>_container"></div>
160 </div>
161 </div>
162 </div>
163
164
165 <div class="col-12 col-md-6 border-left">
166 <div class="row align-items-center">
167 <div class="col-7 mt-2">
168 <strong><?php esc_html_e('Pickup Time slots', 'pisol-dtt' ); ?></strong>
169 </div>
170 <div class="col text-right">
171 <a class="btn btn-primary btn-sm pi_add_time_slot text-light" data-slot="<?php echo esc_attr( $field_pickup ); ?>" ><?php esc_html_e('Add Time Slot', 'pisol-dtt' ); ?></a>
172 </div>
173 </div>
174 <div class="row align-items-center">
175 <div class="col-12 mt-2">
176 <div id="<?php echo esc_attr( $field_pickup ); ?>_container"></div>
177 </div>
178 </div>
179 </div>
180 </div>
181 <?php
182 }
183
184 function proFeatureRow($label, $field_delivery, $field_pickup, $overwrite_day = ""){
185 if(empty($overwrite_day)){
186 $bg = 'bg-dark opacity-75';
187 $hide="";
188 }else{
189 $bg = 'bg-dark opacity-75';
190 $overwrite_value = pisol_dtt_get_setting('pi_different_slot_for_'.$overwrite_day, "");
191 $checked = false;
192 $hide =' style="display:none;" ';
193 if(!empty($overwrite_value)){
194 $checked = true;
195 $hide="";
196 }
197 }
198 ?>
199 <div id="row_sunday" class="row py-2 border-bottom align-items-center free-version <?php echo esc_attr($bg); ?> text-light">
200 <div class="col-9">
201 <?php if(empty($overwrite_day)){ ?>
202 <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>
203 <?php }else{ ?>
204 <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>
205 <?php } ?>
206 </div>
207 <?php if(!empty($overwrite_day)): ?>
208 <div class="col-3 text-right">
209 <div class="custom-control custom-switch">
210 <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); ?>>
211 <label class="custom-control-label" for="pi_different_slot_for_<?php echo esc_attr($overwrite_day); ?>"></label>
212 </div>
213 </div>
214 <?php endif; ?>
215 </div>
216 <?php
217 }
218
219 static function sanitize_time_slot($inputs){
220 if(!is_array($inputs) || empty($inputs)){
221 return array();
222 }
223
224 foreach($inputs as $key => $values){
225 $inputs[$key]['from'] = isset($values['from']) ? sanitize_text_field($values['from']) : "";
226 $inputs[$key]['to'] = isset($values['to']) ? sanitize_text_field($values['to']) : "";
227 $inputs[$key]['order_limit'] = !empty($values['order_limit']) ? abs(intval($values['order_limit'])) : "";
228
229 if(empty($values['from']) && empty($values['to'])){
230 unset($inputs[$key]);
231 }
232
233 }
234
235 return array_values($inputs);
236 }
237
238 static function createDefaultTimeSlot(){
239 $auto_slot_created = get_option('pi_dtt_auto_slot_created', false);
240 if($auto_slot_created){
241 return;
242 }
243 update_option('pi_dtt_auto_slot_created', true);
244
245 $default_time_slot = [
246 ['from' => '09:00 AM', 'to' => '10:00 AM', 'order_limit' => '', 'quantity_limit' => ''],
247 ['from' => '10:00 AM', 'to' => '11:00 AM', 'order_limit' => '', 'quantity_limit' => ''],
248 ['from' => '11:00 AM', 'to' => '12:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
249 ['from' => '12:00 PM', 'to' => '01:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
250 ['from' => '01:00 PM', 'to' => '02:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
251 ['from' => '02:00 PM', 'to' => '03:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
252 ['from' => '03:00 PM', 'to' => '04:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
253 ['from' => '04:00 PM', 'to' => '05:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
254 ['from' => '05:00 PM', 'to' => '06:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
255 ['from' => '06:00 PM', 'to' => '07:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
256 ['from' => '07:00 PM', 'to' => '08:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
257 ['from' => '08:00 PM', 'to' => '09:00 PM', 'order_limit' => '', 'quantity_limit' => ''],
258 ];
259
260 $present_delivery = get_option('pi_general_time_slot_delivery', array());
261 $present_pickup = get_option('pi_general_time_slot_pickup', array());
262 if(empty($present_delivery) && empty($present_pickup)){
263 update_option('pi_general_time_slot_delivery', $default_time_slot);
264 update_option('pi_general_time_slot_pickup', $default_time_slot);
265 }
266
267 }
268 }
269
270 new pisol_dtt_option_time_slot();
271