最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Contact Form 7 - Make a selection unavailable after a number of bookings

programmeradmin2浏览0评论

Is it possible that a selection from a drop-down menu becomes unavailable after a certain number of bookings?

I am taking ticket bookings and they are in batches and I would like to have certain batches become unavailable after a certain amount of bookings.

Thanks for your help

Is it possible that a selection from a drop-down menu becomes unavailable after a certain number of bookings?

I am taking ticket bookings and they are in batches and I would like to have certain batches become unavailable after a certain amount of bookings.

Thanks for your help

Share Improve this question asked Nov 10, 2019 at 10:48 Gabriel CamilleriGabriel Camilleri 1 1
  • how do you fill the drop-down menu ? edit your question to show the form code. – Kaperto Commented Nov 10, 2019 at 11:15
Add a comment  | 

1 Answer 1

Reset to default 0

It is possible with the Smart Grid-layout Extension for CF7C plugin. The smart grid plugin has a [dynamic_dropdown] tag which allows you to filter the options.

Replace your dropdown menu with a dynamic dropdown and in the tag Custom Source select the Custom tab, you can then populate the dropdown dynamically using,

add_filter('cf7sg_dynamic_dropdown_custom_options', 'filter_options',10,3);
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();
  //load all your booking options.
  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;
}

发布评论

评论列表(0)

  1. 暂无评论