Datepicker Filters

The datepicker fields in Conditional Woo Checkout Field Pro by default are set up in English. However, not all users of the plugin are in English speaking areas, with English speaking customers. To support this, we have added filters to the plugin to allow you to modify the English words. Additionally, there are filterst that can modify the behavior of the datepicker fields. For example, the date format, or if you allow the customer to change the months or years.

Here is a complete list of the included filters and their default text. Please note that the datepicker is expecting text to be returned in the same format as what is provided below. So, if the data is in an array, datepicker is expecting that you return an array of the same length (i.e. 7 values for days of the week, or 12 values for months of the year, etc.). True/False values expect to receive one or the other, and no other responses would be valid.

A list of expected responses is provided on the jQuery UI website.

'cwcfp_datepicker_append_text'                Default: ''
'cwcfp_datepicker_auto_size'                  Default: false
'cwcfp_datepicker_button_image'               Default: ''
'cwcfp_datepicker_button_image_only'          Default: false
'cwcfp_datepicker_change_month'               Default: true
'cwcfp_datepicker_change_year'                Default: true
'cwcfp_datepicker_close_text'                 Default: 'Done'
'cwcfp_datepicker_constrain_input'            Default: true
'cwcfp_datepicker_current_text'               Default: 'Today'
'cwcfp_datepicker_date_format'                Default: 'MM d, yy'
'cwcfp_datepicker_day_names'                  Default: array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' )
'cwcfp_datepicker_day_names_min'              Default: array( 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' )
'cwcfp_datepicker_day_names_short'            Default: array( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' )
'cwcfp_datepicker_default_date'               Default: null
'cwcfp_datepicker_duration'                   Default: 'normal'
'cwcfp_datepicker_first_day'                  Default: 0
'cwcfp_datepicker_go_to_current'              Default: false
'cwcfp_datepicker_hide_if_no_prev_next'       Default: false
'cwcfp_datepicker_is_rtl'                     Default: false
'cwcfp_datepicker_max_date'                   Default: null
'cwcfp_datepicker_min_date'                   Default: null
'cwcfp_datepicker_month_names'                Default: array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' )
'cwcfp_datepicker_month_names_short'          Default: array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' )
'cwcfp_datepicker_navigation_as_date_format'  Default: false
'cwcfp_datepicker_next_text'                  Default: 'Next'
'cwcfp_datepicker_number_of_months'           Default: array( 1, 1 )
'cwcfp_datepicker_prevText'                   Default: 'Prev'
'cwcfp_datepicker_select_other_months'        Default: false
'cwcfp_datepicker_short_year_cutoff'          Default: '+10'
'cwcfp_datepicker_show_anim'                  Default: 'show'
'cwcfp_datepicker_show_button_panel'          Default: false
'cwcfp_datepicker_show_current_at_pos'        Default: 0
'cwcfp_datepicker_show_month_after_year'      Default: false
'cwcfp_datepicker_show_on'                    Default: 'focus'
'cwcfp_datepicker_show_other_months'          Default: false
'cwcfp_datepicker_show_week'                  Default: false
'cwcfp_datepicker_step_months'                Default: 1
'cwcfp_datepicker_week_header'                Default: 'Wk'
'cwcfp_datepicker_year_range'                 Default: '1900:2100'
'cwcfp_datepicker_year_suffix'                Default: ''

Here are a few examples of how these filters can be used:

// Copy below into your child theme's functions.php or into a custom plugin.

// Change the days of the week to French
add_filter( 'cwcfp_datepicker_day_names', 'my_custom_day_names' );
function my_custom_day_names( $days ){
  $new_days = array(
    'Dimanche',
    'Lundi',
    'Mardi',
    'Mercredi',
    'Jeudi',
    'Vendredi',
    'Samedi',
  );
  return $new_days;
}

// Change the first day of the week to Monday = 1 (default is Sunday = 0)
add_filter( 'cwcfp_datepicker_first_day', 'my_custom_first_day_of_week' );
function my_custom_first_day_of_week( $day ){
  return 1;
}

// Change the range of years shown (Default is 1900:2100)
add_filter( 'cwcfp_datepicker_year_range', 'my_custom_year_range' );
function my_custom_year_range( $range ){
  return '1950:2050';
}

// Change the default date to be 2 days from today
add_filter( 'cwcfp_datepicker_default_date', 'my_change_default_date' );
function my_change_default_date( $default ){
  return 2;
}

// Change the date format to Year Month Day (i.e. 2018 01 30)
add_filter( 'cwcfp_datepicker_date_format', 'my_custom_date_format' );
function my_custom_date_format( $default ){
  return 'yy mm dd';
}