Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • None
  • Order-Delivery-Date-Pro-for-WooCommerce
    • Admin
      • Edit-Order
      • Non-Sensitive-Data-Capture
      • Settings
        • Custom-Delivery
        • General
        • Google-Calendar-Sync
    • Class-ORDDD-Email-Manager
    • Common-Functions
    • Delivery-Calendar
    • Emails
      • Class-ORDDD-Email-Update-Date
    • Filter
    • Frontend
      • Checkout-Page-Processes
      • ICS-Files-Data
    • Google-Calendar
    • Integration
    • Lang
    • License
    • Plugin-Updates
      • EDD-SL-Plugin-Updater

Classes

  • EDD_SL_Plugin_Updater
  • orddd_additional_settings
  • orddd_admin_delivery_class
  • orddd_appearance_settings
  • orddd_calendar_sync
  • orddd_calendar_sync_settings
  • orddd_class_view_deliveries
  • orddd_common
  • orddd_date_settings
  • orddd_delivery_days_settings
  • ORDDD_Email_Manager
  • ORDDD_Email_Update_Date
  • orddd_filter
  • orddd_holidays_settings
  • orddd_integration
  • orddd_license
  • orddd_process
  • orddd_settings
  • orddd_shipping_based_settings
  • orddd_shipping_days_settings
  • orddd_shipping_multiple_address
  • orddd_time_settings
  • orddd_time_slot_settings
  • ORDDD_View_Delivery_Dates_Table
  • ORDDD_View_Disable_Time_Slots_Table
  • ORDDD_View_Holidays_Table
  • ORDDD_View_Shipping_Settings_Table
  • ORDDD_View_Time_Slots_Table
  • OrdddGcal
  • order_delivery_date
  • TS_Tracker
  • TS_tracking

Functions

  • orddd_get_dateToCal
  • orddd_get_escapeString
  • orddd_t
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 
<?php

/**
 * Specific Delivery Dates Settings for Order Delivery Date
 *
 * @author Tyche Softwares
 * @package Order-Delivery-Date-Pro-for-WooCommerce/Admin/Settings/General
 * @since 2.8.3
 * @category Classes
 */

class orddd_delivery_days_settings {
    
    /**
     * Callback for adding Delivery Dates tab settings
     */
    public static function orddd_delivery_days_admin_setting_callback() { }
    
    /**
     * Callback for adding Enable Specific date setting
     *
     * @param array $args Extra arguments for outputting the field
     * @since 2.8.3
     */
    
    public static function orddd_delivery_days_enable_callback( $args ) {
        $enable_delivery_dates = "";
        if ( get_option( 'orddd_enable_specific_delivery_dates' ) == 'on' ) {
            $enable_delivery_dates = "checked";
        }
        
        echo '<input type="checkbox" name="orddd_enable_specific_delivery_dates" id="orddd_enable_specific_delivery_dates" class="day-checkbox" ' . $enable_delivery_dates . '/>';
        
        $html = '<label for="orddd_enable_specific_delivery_dates"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback to add first Specific date field
     *
     * @param array $args Extra arguments for outputting the field
     * @since 2.8.3
     * 
     */
    
    public static function orddd_delivery_days_datepicker_1_callback( $args ) {
        $currency_symbol = get_woocommerce_currency_symbol();
        print( '<script type="text/javascript">
           jQuery( document ).ready( function() {
              jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
              jQuery( "#orddd_delivery_date_1" ).width( "100px" );
              var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
              jQuery( "#orddd_delivery_date_1" ).val("").datepicker( {constrainInput: true, dateFormat: formats[0], minDate: new Date() } );
          } );
          </script>' );
                
        echo '<input type="text" name="orddd_delivery_date_1" id="orddd_delivery_date_1" class="day-checkbox" placeholder="Select Date"/>' . $currency_symbol . '<input class="orddd_specific_charges" type="text" name="additional_charges_1" id="additional_charges_1" placeholder="Charges" disabled/>';
        echo '<input class="orddd_specific_charges_label" type="text" name="specific_charges_label_1" id="specific_charges_label_1" placeholder="Delivery Charges Label" disabled />';
                                
        $html = '<label for="orddd_delivery_date_1"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback to add second Specific date field
     *
     * @param array $args Extra arguments for outputting the field
     * @since 2.8.3
     */
    
    public static function orddd_delivery_days_datepicker_2_callback( $args ) {
        $currency_symbol = get_woocommerce_currency_symbol();
        print( '<script type="text/javascript">
           jQuery( document ).ready( function() {
              jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
              jQuery( "#orddd_delivery_date_2" ).width( "100px" );
              var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
              jQuery( "#orddd_delivery_date_2" ).val("").datepicker( {constrainInput: true, dateFormat: formats[0], minDate: new Date() } )
          } );
          </script>' );
    
        echo '<input type="text" name="orddd_delivery_date_2" id="orddd_delivery_date_2" class="day-checkbox" placeholder="Select Date"/>' . $currency_symbol . '<input class="orddd_specific_charges" type="text" name="additional_charges_2" id="additional_charges_2" placeholder="Charges" disabled />';
        echo '<input class="orddd_specific_charges_label" type="text" name="specific_charges_label_2" id="specific_charges_label_2" placeholder="Delivery Charges Label" disabled />';
    
        $html = '<label for="orddd_delivery_date_2"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback to add third Specific date field
     *
     * @param array $args Extra arguments for outputting the field
     * @since 2.8.3
     */
    
    public static function orddd_delivery_days_datepicker_3_callback( $args ) {
        $currency_symbol = get_woocommerce_currency_symbol();
        print( '<script type="text/javascript">
           jQuery( document ).ready( function() {
              jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
              jQuery( "#orddd_delivery_date_3" ).width( "100px" );
              var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
              jQuery( "#orddd_delivery_date_3" ).val("").datepicker( {constrainInput: true, dateFormat: formats[0], minDate: new Date() })
          } );
          </script>' );
    
        echo '<input type="text" name="orddd_delivery_date_3" id="orddd_delivery_date_3" class="day-checkbox" placeholder="Select Date"/>' . $currency_symbol . '<input class="orddd_specific_charges" type="text" name="additional_charges_3" id="additional_charges_3" placeholder="Charges" disabled />';
        echo '<input class="orddd_specific_charges_label" type="text" name="specific_charges_label_3" id="specific_charges_label_3" placeholder="Delivery Charges Label" disabled />';
    
        $html = '<label for="orddd_delivery_date_3"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Save the specific delivery dates
     * 
     * @param array $input 
     * @return string $delivery_dates_str JSON Encoded value for specific delivery dates
     * @since 2.8.3
     */
    
    public static function orddd_delivery_dates_callback( $input ){
        $holidays = get_option( 'orddd_delivery_dates' );
        if ( $holidays == '' || $holidays == '{}' || $holidays == '[]' || $holidays == 'null' ){
            $holidays_arr = array();
        } else {
            $holidays_arr = json_decode( $holidays );
        }
        $holidays_new_arr = $dates_temp = array();
        foreach ( $holidays_arr as $key => $value ) {
            foreach ( $value as $k => $v ) {
                $temp_arr[ $k ] = $v;
                if( $k == 'date' ) {
                    $dates_temp[] = $v;
                }
            }
            $holidays_new_arr[] = $temp_arr;
        }
        $delivery_dates_arr = array();
        if ( !isset( $holidays_new_arr ) ) {
            $holidays_new_arr = array();
        }
        if ( isset( $_POST[ 'orddd_delivery_date_1' ] ) && $_POST[ 'orddd_delivery_date_1' ] != "" ) {
            $date_1_arr = explode( "-", $_POST[ 'orddd_delivery_date_1' ] ); 
            $tstmp1 = gmmktime( 0, 0, 0, $date_1_arr[ 0 ], $date_1_arr[ 1 ], $date_1_arr[ 2 ] );
            $holiday_date_1 = date( ORDDD_HOLIDAY_DATE_FORMAT, $tstmp1 );
            if( !in_array( $holiday_date_1, $dates_temp ) ) {
                $delivery_dates_arr[ 'date' ] = $holiday_date_1;
                if ( isset( $_POST[ 'additional_charges_1' ] ) ) {
                    $delivery_dates_arr[ 'fees' ] = $_POST[ 'additional_charges_1' ];
                } else {
                    $delivery_dates_arr[ 'fees' ] = '0';
                }
                if ( isset( $_POST[ 'specific_charges_label_1' ] ) ) {
                    $delivery_dates_arr[ 'label' ] = $_POST[ 'specific_charges_label_1' ];
                } else {
                    $delivery_dates_arr[ 'label' ] = 'Delivery Charges';
                }
                array_push( $holidays_new_arr, $delivery_dates_arr );
            }
        }
        if ( isset( $_POST[ 'orddd_delivery_date_2' ] ) && $_POST[ 'orddd_delivery_date_2' ] != "" ) {
            $date_2_arr = explode( "-", $_POST[ 'orddd_delivery_date_2' ] );
            $tstmp2 = gmmktime( 0, 0, 0, $date_2_arr[ 0 ], $date_2_arr[ 1 ], $date_2_arr[ 2 ] );
            $holiday_date_2 = date( ORDDD_HOLIDAY_DATE_FORMAT, $tstmp2 );
            if ( !in_array( $holiday_date_2, $dates_temp ) ) {
                $delivery_dates_arr[ 'date' ] = $holiday_date_2;
                if ( isset( $_POST[ 'additional_charges_2' ] ) ) {
                    $delivery_dates_arr[ 'fees' ] = $_POST[ 'additional_charges_2' ];
                } else {
                    $delivery_dates_arr[ 'fees' ] = '0';
                }
                if ( isset( $_POST[ 'specific_charges_label_2' ] ) ) {
                    $delivery_dates_arr[ 'label' ] = $_POST[ 'specific_charges_label_2' ];
                } else {
                    $delivery_dates_arr[ 'label' ] = 'Delivery Charges';
                }
                array_push( $holidays_new_arr, $delivery_dates_arr );
            }
        }
        if ( isset( $_POST[ 'orddd_delivery_date_3' ] ) && $_POST[ 'orddd_delivery_date_3' ] != "" ) {
            $date_3_arr = explode( "-", $_POST[ 'orddd_delivery_date_3' ] );
            $tstmp3 = gmmktime( 0, 0, 0, $date_3_arr[ 0 ], $date_3_arr[ 1 ], $date_3_arr[ 2 ] );
            $holiday_date_3 = date( ORDDD_HOLIDAY_DATE_FORMAT, $tstmp3 );
            if ( !in_array( $holiday_date_3, $dates_temp ) ) {
                $delivery_dates_arr[ 'date' ] = $holiday_date_3;
                if ( isset( $_POST[ 'additional_charges_3' ] ) ) {
                    $delivery_dates_arr[ 'fees' ] = $_POST[ 'additional_charges_3' ];
                } else {
                    $delivery_dates_arr[ 'fees' ] = '0';
                }
                if ( isset( $_POST[ 'specific_charges_label_3' ] ) ) {
                    $delivery_dates_arr[ 'label' ] = $_POST[ 'specific_charges_label_3' ];
                } else {
                    $delivery_dates_arr[ 'label' ] = 'Delivery Charges';
                }
                array_push( $holidays_new_arr, $delivery_dates_arr );
            }
        }
        $delivery_dates_str = json_encode( $holidays_new_arr );
        return $delivery_dates_str;
    }
}
API documentation generated by ApiGen