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 / public / class-js.php
pi-woocommerce-order-date-time-and-type / public Last commit date
css 10 months ago js 10 months ago class-css.php 10 months ago class-date.php 10 months ago class-delivery-type.php 10 months ago class-display-field.php 10 months ago class-js.php 10 months ago class-main.php 10 months ago class-myaccount.php 10 months ago class-order.php 10 months ago class-pickup-location.php 10 months ago class-shipping-method.php 10 months ago class-time-range.php 10 months ago class-time-slot.php 10 months ago class-time.php 10 months ago class-validate.php 10 months ago class-woo-app.php 10 months ago
class-js.php
174 lines
1 <?php
2 if ( ! defined( 'WPINC' ) ) {
3 die;
4 }
5 class pi_dtt_js{
6
7 public $plugin_name;
8
9 function __construct(){
10 $this->plugin_name = 'pi-woocommerce-order-date-time-and-type-pro';
11 add_action( 'wp_enqueue_scripts', array($this,'addJs'),990 );
12 }
13
14 function addJs(){
15 if( is_checkout() ){
16 $this->addJsFile();
17 $this->addLocalizedJs();
18 }
19 }
20
21 function addJsFile(){
22
23 wp_enqueue_script( 'jquery-ui-datepicker' );
24 wp_enqueue_script( 'jquery-blockui' );
25 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/pi-woocommerce-order-date-time-and-type-pro-public.js', array( 'jquery','jquery-ui-datepicker', 'jquery-blockui', 'selectWoo' ),'3.3.2.6');
26
27 if(defined( 'ET_CORE_VERSION' ) && apply_filters('pi_dtt_enable_divi_compatibility_js', true)){
28 wp_enqueue_script( $this->plugin_name.'-divi-compatible', plugin_dir_url( __FILE__ ) . 'js/pi-divi-page-builder.js', array( 'jquery'),'3.3.9.3');
29 }
30
31 wp_enqueue_script( $this->plugin_name.'-save-checkout', plugin_dir_url( __FILE__ ) . 'js/save-checkout-data.js', array( 'jquery'),'3.3.2.6');
32 wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full.min.js', array( 'jquery' ) );
33 wp_enqueue_script( 'selectWoo' );
34 wp_enqueue_style( 'select2', WC()->plugin_url() . '/assets/css/select2.css');
35
36 }
37
38 function addLocalizedJs(){
39
40 $localize_values = self::dateOptions();
41 wp_localize_script( 'pi-woocommerce-order-date-time-and-type-pro', 'pi_date_options', $localize_values);
42
43 }
44
45 static function dateOptions(){
46 $minDate = (int)pisol_dtt_get_setting('pi_order_preparation_days',0);
47 $pre_order_days = empty(pisol_dtt_get_setting('pi_preorder_days', 10)) ? 0 : abs(pisol_dtt_get_setting('pi_preorder_days', 10));
48 $allowed_dates = self::allowedDates();
49
50 $maxDateBasedOnDates = self::longestDateAwayFromToday($allowed_dates);
51 if($maxDateBasedOnDates <= ($pre_order_days+$minDate)){
52 $maxDate = apply_filters('pisol_calendar_max_date',$pre_order_days+$minDate);
53 }elseif($maxDateBasedOnDates > ($pre_order_days+$minDate)){
54 $maxDate = apply_filters('pisol_calendar_max_date',$maxDateBasedOnDates);
55 }
56
57 $minDate = self::minDateBasedOnAvailableDates($minDate, $maxDate, $allowed_dates);
58
59 $disable_ajax_loading_location = pi_dtt_pickup_location::isLocationPresentInSystem() ? false : true;
60
61 $return = array(
62 'ajaxUrl'=>admin_url('admin-ajax.php'),
63 'minDate' => $minDate,
64 'maxDate' => $maxDate,
65 'allowedDates' => $allowed_dates,
66 'allSlotsBooked'=>__('All time slots booked for this date','pisol-dtt'),
67 'selectTimeSlot' => __('Time', 'pisol-dtt'),
68 'todaysDate'=>current_time('Y/m/d'),
69 'datePlaceholder' => __('Date','pisol-dtt'),
70 'autoSelectDate'=>apply_filters('pisol_auto_select_date', '0'), // false, first, last
71 'autoSelectTime'=>apply_filters('pisol_auto_select_time', '0'),
72 'allDatesBooked'=>__('All dates are booked', 'pisol-dtt'),
73 'disableAjaxLocationReload'=>apply_filters('pisol_disable_ajax_location',true),
74 'typeSupportingPickupLocation'=> apply_filters('pisol_dtt_type_supporting_pickup_location',''),
75 'delivery_type_label' => self::get_type_label(),
76 'date_label' => __('Date','pisol-dtt'),
77 'time_label' => __('Time','pisol-dtt'),
78 'dateFormat' => self::date_format_for_jquery(),
79 );
80 return apply_filters('pisol_dtt_settings_filter',$return);
81 }
82
83 static function date_format_for_jquery(){
84 $datepicker_date_format = str_replace(
85 array(
86 'd',
87 'j',
88 'l',
89 'z', // Day.
90 'F',
91 'M',
92 'n',
93 'm', // Month.
94 'Y',
95 'y', // Year.
96 ),
97 array(
98 'dd',
99 'd',
100 'DD',
101 'o',
102 'MM',
103 'M',
104 'm',
105 'mm',
106 'yy',
107 'y',
108 ),
109 get_option( 'date_format','F j, Y' )
110 );
111 return $datepicker_date_format;
112 }
113
114 static function get_type_label(){
115 $show_delivery_type_label = get_option('pi_show_delivery_type_label', 1);
116 $delivery_type_label = !empty($show_delivery_type_label) ? __('Delivery Type','pisol-dtt') : '';
117 return $delivery_type_label;
118 }
119
120 static function allowedDates(){
121 $obj = new pi_dtt_date();
122 $dates = $obj->getValidDates();
123 return !empty($dates) ? array_values($dates) : array();
124 }
125
126 static function minDateBasedOnAvailableDates($minDate, $maxDate, $allowed_dates){
127
128 if(empty($allowed_dates) || !is_array($allowed_dates)) return $minDate;
129 $today = current_time('Y/m/d');
130 $today_timestamp = strtotime($today);
131 $shortest_date = "";
132 foreach($allowed_dates as $date){
133 if(empty($shortest_date)){
134 $shortest_date = $date;
135 }
136
137 $date_timestamp = strtotime($date);
138 $shortest_date_timestamp = strtotime($shortest_date);
139 if($date_timestamp < $shortest_date_timestamp){
140 $shortest_date = $date;
141 }
142
143 }
144
145 $date1 = date_create($today);
146 $date2 = date_create($shortest_date);
147 $diff = date_diff($date1,$date2);
148 $minDate = $diff->format('%a');
149 if($minDate < 0 || $minDate > $maxDate) return 0;
150 return $minDate;
151 }
152
153 static function longestDateAwayFromToday($dates){
154 if(!is_array($dates)) array();
155 $today = current_time('Y/m/d');
156 $today_timestamp = strtotime($today);
157 $longest_date = $today;
158 foreach($dates as $date){
159
160 $date_timestamp = strtotime($date);
161 $longest_date_timestamp = strtotime($longest_date);
162 if($date_timestamp > $longest_date_timestamp){
163 $longest_date = $date;
164 }
165
166 }
167 $date1=date_create($today);
168 $date2=date_create($longest_date);
169 $diff = date_diff($date1,$date2);
170 return $diff->format('%a');
171 }
172 }
173
174 new pi_dtt_js();