public function add_holiday_fields() { $field = ''; $existing_data = eddwc_option('holiday'); $field .= '<table data-total-count="0" style="width:80%;margin-top:5px" class="eddwc-holidays widefat" cellspacing="0">'; $field .= '<thead>'; $field .= '<tr>'; //$field .= '<th class="checkbox" ></th>'; $field .= '<th class="title">' . __("Holiday Name", EDDWC_TXT) . '</th>'; $field .= '<th class="date">' . __("Holiday Date", EDDWC_TXT) . '</th>'; $field .= '<th class="actions">' . __("Actions", EDDWC_TXT) . '</th>'; $field .= '</tr>'; $field .= '</thead>'; $field .= '<tbody>'; if (!empty($existing_data)) { foreach ($existing_data as $dataK => $dataV) { $field .= '<tr>'; //$field .= '<td><input type="checkbox" /></td> '; $field .= '<td><input value="' . $dataV['name'] . '" class="holiday_name_input" name="eddwc_holidays[' . $dataK . '][name]" type="text" /></td> '; $field .= '<td><input class="holiday_date_input" data-type="datepicker" name="eddwc_holidays[' . $dataK . '][date]" type="text" value="' . $dataV['date'] . '" /></td> '; $field .= '<td> <button type="button" class="add eddwc_btn button button-primary" id="add"><span class="dashicons dashicons-plus-alt"></span></button> <button type="button" class="edit eddwc_btn button button-edit" id="edit"><span class="dashicons dashicons-edit"></span></button> <button type="button" class="save eddwc_btn button button-save" id="save"><span class="dashicons dashicons-yes"></span></button> <button type="button" class="delete eddwc_btn button button-delete" id="delete"><span class="dashicons dashicons-trash"></span></button> </td> '; $field .= '</tr>'; } } $field .= '<tr>'; //$field .= '<td><input type="checkbox" /></td> '; $field .= '<td><input class="holiday_name_input" name="eddwc_holidays[][name]" type="text" /></td> '; $field .= '<td><input class="holiday_date_input" data-type="datepicker" name="eddwc_holidays[][date]" type="text" /></td> '; $field .= '<td> <button type="button" class="add eddwc_btn button button-primary" id="add"><span class="dashicons dashicons-plus-alt"></span></button> <button type="button" class="edit eddwc_btn button button-edit" id="edit"><span class="dashicons dashicons-edit"></span></button> <button type="button" class="save eddwc_btn button button-save" id="save"><span class="dashicons dashicons-yes"></span></button> <button type="button" class="delete eddwc_btn button button-delete" id="delete"><span class="dashicons dashicons-trash"></span></button> </td> '; $field .= '</tr>'; $field .= '<tr class="hidden" id="template_settings">'; //$field .= '<td><input type="checkbox" /></td> '; $field .= '<td><input class="holiday_name_input" type="text" /></td> '; $field .= '<td><input class="holiday_date_input" data-type="datepicker" type="text" /></td> '; $field .= '<td> <button type="button" class="add eddwc_btn button button-primary" id="add"><span class="dashicons dashicons-plus-alt"></span></button> <button type="button" class="edit eddwc_btn button button-edit" id="edit"><span class="dashicons dashicons-edit"></span></button> <button type="button" class="save eddwc_btn button button-save" id="save"><span class="dashicons dashicons-yes"></span></button> <button type="button" class="delete eddwc_btn button button-delete" id="delete"><span class="dashicons dashicons-trash"></span></button> </td> '; $field .= '</tr>'; $field .= '</tbody>'; $field .= '</table>'; echo $field; }
public function eddwc_add_order_meta($order_id) { $general_options = eddwc_option('product_general_date_settings'); if (isset($general_options['actual_date'])) { update_post_meta($order_id, '_eddwc_order_range', $this->eddwc_cart_max_range()); } update_post_meta($order_id, '_eddwc_order_date', $this->eddwc_get_dispatch_date($this->eddwc_cart_max_date())); update_post_meta($order_id, '_eddwc_order_format', eddwc_option('date_display_format')); }
function eddwc_get_dispatch_date($date) { $eddwc_holiday = eddwc_option('holiday'); $eddwc_holidays = array(); foreach ($eddwc_holiday as $eddwc_hday) { $eddwc_holidays[] = $eddwc_hday['date']; } $eddwc_workdays = eddwc_option('operation_days'); $cutOff = eddwc_option('day_cutoftime'); list($cut_hrs, $cut_min) = explode(':', $cutOff); $cut_hrs = intval($cut_hrs); $cut_min = intval($cut_min); $wp_timezone_string = get_option('timezone_string'); $wp_timezone_offset = get_option('gmt_offset'); if ($wp_timezone_string) { $eddwc_timezone = $wp_timezone_string; } else { $eddwc_timezone = ini_get('date.timezone'); } date_default_timezone_set($eddwc_timezone); $eddwc_date = new DateTime(); $eddwc_cut_off = $cutOff; $eddwc_time = clone $eddwc_date; $eddwc_time->setTime($cut_hrs, $cut_min); $eddwc_next_date = clone $eddwc_date; if ($eddwc_date >= $eddwc_time) { $eddwc_next_date->modify('+1 day'); } $i = 0; while ($i < $date) { $eddwc_next_date->modify('+1 day'); $ndate = strtolower($eddwc_next_date->format('D')); if (in_array($ndate, $eddwc_workdays)) { //$i++; if (in_array($eddwc_next_date->format('d-m-Y'), $eddwc_holidays) == false) { $i++; } } } return $eddwc_next_date->format(eddwc_option('date_display_format')); }