Date in WooCommerce checkout page

This plugin allows the customer to select a date on the WooCommerce checkout page. This date is associated with the order and can also be displayed in the order list and/or in the order parameters.

Main functions

  • Parameterize optional dates
    There are several parameters in the plugin settings to help you set the duration you can choose from.
  • Disabled days
    You can specify days that cannot be selected in any way. (e.g. holidays)
  • Optional display location
    You can choose where the date field appears within the WooCommerce checkout page
  • Shipping Mode Assignment
    You can specify for which delivery methods the date selection is displayed.
    (If you create a new shipping method in WooCommerce, it will not appear by default.)
  • Custom appearance option
    The plugin offers several options to customize the look. (You need a little more WordPress to use these.)
You can find the settings of the plugin on the „Integration” tab of the WooCommerce / Settings page, on the „Request date at checkout” page!

Filters and hooks

You can find the program codes in the /libs/hooks.php file.

  • Display the days in the header of the date picker
    add_filter( 'request_a_date_render_days_in_week', 'request_a_date_403_render_days_in_week', 10, 1 );
  • Show empty day in calendar (placeholder)
    add_filter( 'request_a_date_render_empty_day', 'request_a_date_403_render_empty_day', 10, 1);
  • Show a day on the calendar
    add_filter( 'request_a_date_render_day', 'request_a_date_403_render_day', 10, 3);
  • Display a button next to the date selection field
    add_filter( 'request_a_date_render_button', 'request_a_date_403_render_button', 10, 1);
  • Displays the date picker for tabular display
    add_filter('request_a_date_render_in_table', 'request_a_date_403_render_in_table', 10, 3);
  • Show date picker not for spreadsheets
    add_filter('request_a_date_render_in_div', 'request_a_date_403_render_in_div', 10, 3);
  • Display the selected date on the „thakyou” page
    add_filter('request_a_date_render_in_thankyou', 'request_a_date_403_render_in_thankyou', 10, 2);
  • Display date in email
    add_filter('request_a_date_render_in_email', 'request_a_date_403_render_in_email', 10, 2);
  • Change the first possible day
    (This filter is not declared, but if you define it, it will be used.)

    function request_a_date_my_modify_first($date) {
        $date = date_i18n('Y-m-d', strtotime('+1 day', strtotime($date)));
       	return $date;
    } 
    add_filter('request_a_date_modify_first', 'request_a_date_my_modify_first', 10, 1);
  • Change last possible day
    (This filter is not declared, but if you define it, it will be used.)

    function request_a_date_my_modify_last($date) {
        $date = date_i18n('Y-m-d', strtotime('+1 day', strtotime($date)));
        return $date;
    } 
    add_filter('request_a_date_modify_last', 'request_a_date_my_modify_last', 10, 1);
  • Increase earliest day
    (This filter is not declared, but if you define it, it will be used.)

    function my_add_custom_days($days_count) {
        // In the $days_count variable, you get the number of days 
        // that the earliest selectable date must be due to the reorder.
    	return $days_count;
    }
    add_filter('request_a_date_add_custom_days', 'my_add_custom_days', 10, 1);

Customize button

Experience has shown that, due to the variety of topics, it is usually necessary to change the appearance of the button. By default, this is given the class="button" class, which is appropriate in most cases, but in many cases something else is needed.

In the example below, we modify this according to Bootstrap and add the class="btn btn-secondary" class to the button.

// Delete original filter
remove_filter( 'request_a_date_render_button', 'request_a_date_403_render_button');
function request_a_date_my_render_button($script) {
	// Here we use our own class:
	$html = '<button type="button" '.$script.' class="btn btn-secondary">'.
            '<span class="dashicons dashicons-calendar-alt"></span>'.
            '</button>';
    return $html;
}
// Use new filter
add_filter( 'request_a_date_render_button', 'request_a_date_my_render_button', 20, 1);

Frequently asked Questions

  • I would like the earliest date to be later for some product categories. Is it possible?

    Yes, it is possible. To do this, you need to edit functions.php in your (child) theme and place the following code in it:

    function my_add_custom_days($days_count) {
        // In the $days_count variable, you get the number of days 
        // that the earliest selectable date must be due to the reorder.
        
        // These products are in the cart
        $items = WC()->cart->get_cart();
        $add = 0;
        
        foreach ($items as $item) {
            $terms = get_the_terms( $item['product_id'], 'product_cat' );
            foreach ($terms as $term) {
                // Check the category slug
                switch ($term->slug){ 
                    // Here you can examine all categories of slugs
                	case 'other':
                        // You set it if not bigger. This is how you will get the highest value.
                        if ($add < 4) {
                            // You claim as much as you want.
                            $add = 4;
                        }
                        break;
                	default :
                }            
            }
        }
        if ($add != 0) {
            // If you want to increase it anyway
            // return $days_count + $add;
            
            // OR
            // If you want the later of the two dates
            if ($add > $days_count) {
                return $add;
            } else {
                return $days_count;
            }
                    
        } else {
            return $days_count;
        }     
    }
    add_filter('request_a_date_add_custom_days', 'my_add_custom_days', 10, 1);