Add minutes as an option for Lead time

Issue #672 resolved
Valentina R created an issue

Requested here.

Comments (1)

  1. Željan Topić

    Won't be added to core, but can be added through code snippet. Here's an example for 15 minutes Lead time:

    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