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