Option to have 'minutes' in Lead time

Issue #605 resolved
Valentina R created an issue

There is no option in the dropdown for minutes. I tried setting it to ‘minute’ with this filter ‘woocommerce_appointments_min_date_unit’ but it is understood by the system as ‘year’.

I tried setting the value in ‘woocommerce_appointments_min_date’ to 0.25 but it acts as 25.

Requested here.

Comments (1)

  1. Željan Topić

    This is due to an issue with strtotime PHP function that does not interpret minutes correctly. Customers can use the following code snippet to use minutes instead (example set to 15 minutes and for specific product IDs):

    add_filter( 'woocommerce_appointments_min_date', 'custom_lead_time_value', 10, 2 );
    function custom_lead_time_value( $value, $product_id ) {
        // Return time in seconds for products with IDs of #123 or #456.
        if ( in_array( $product_id, array( 5900, 123, 456 ) ) ) {
            return 15*60; #must be seconds
        }
        return $value;
    }
    
    add_filter( 'woocommerce_appointments_min_date_unit', 'custom_lead_time_unit', 10, 2 );
    function custom_lead_time_unit( $unit, $product_id ) {
        // Return 15 for products with IDs of #123 or #456.
        if ( in_array( $product_id, array( 5900, 123, 456 ) ) ) {
            return 'seconds';
        }
        return $unit;
    }
    
  2. Log in to comment