## plugin contact form 7 – CF7 make selection unavailable after a number of bookings

Question

I recognise that this question was asked and answered 2-3 years ago but after trying to apply the solution to my own cf7 booking form I have been unable to make Smart Grid Layout Extension with dynamic dropdown work for me. My knowledge in this area is very limited. Essentially I have a set number of dates that will each have an allocation capacity for booking. When that limit is reached I want the individual date selection to become greyed out and unavailable.

This was the solution given:

function filter_options($options,$field_name, $form_key){ if($form_key != ‘my-form’) return $options; //check this is the correct form. if($field_name != ‘bookings’) return $options; //check this is the correct field.$options = array();
foreach($bookings as$booking){
//verify if the booking limit is crossed.
if($booking->count <$limit){
$options[$booking->id] = $booking->title; //$options are $value=>$name pairs.
}
}
return \$options;
}

Is this still the correct structure? If so I recognise what I need to add to the ‘my-form’ and ‘bookings’ fields at the beginning but cannot fathom how i add a list of 3 dates and for example a limit of 20 booking quantities to the modify this resolution.

Any help would be much appreciated.

0
4 weeks 2022-06-07T17:04:55-05:00 0 Answers 0 views 0