如何在WooCommerce中选择第一个选项选择“无法选择”字段?
我在WordPress中使用PHP功能将自定义Selectfield添加到我的WooCommerce结帐时。 我想使第一个选项(命名为空白)无法选择。我该如何实现?
woocommerce_form_field( 'cstm_leeftijd'.$i, array(
'type' => 'select',
'class' => array('my-field-class form-row-first'),
'label' => __('Leeftijd bij start Summer Camp'),
'required' => true,
'options' => array(
'blank' => __( 'Selecteer', 'njengah' ),
'4' => __( '4', 'njengah' ),
'5' => __( '5', 'njengah' ),
'6' => __( '6', 'njengah' ),
'7' => __( '7', 'njengah' ),
'8' => __( '8', 'njengah' ),
'9' => __( '9', 'njengah' ),
'10' => __( '10', 'njengah' ),
'11' => __( '11', 'njengah' )
)), $checkout->get_value( 'cstm_leeftijd'.$i ));
I use a php function in wordpress to add a custom selectfield to my woocommerce checkout.
I want to make the first option (named blank) unselectable. How can i achieve this?
woocommerce_form_field( 'cstm_leeftijd'.$i, array(
'type' => 'select',
'class' => array('my-field-class form-row-first'),
'label' => __('Leeftijd bij start Summer Camp'),
'required' => true,
'options' => array(
'blank' => __( 'Selecteer', 'njengah' ),
'4' => __( '4', 'njengah' ),
'5' => __( '5', 'njengah' ),
'6' => __( '6', 'njengah' ),
'7' => __( '7', 'njengah' ),
'8' => __( '8', 'njengah' ),
'9' => __( '9', 'njengah' ),
'10' => __( '10', 'njengah' ),
'11' => __( '11', 'njengah' )
)), $checkout->get_value( 'cstm_leeftijd'.$i ));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过禁用将第一个选项归因于第一个选项。
您可以检查Woocommerce_form_field()函数机制,以检查其支持通过禁用属性的方式。
您甚至可以通过jQuery做到这一点。通过您的自定义课程我的班级
Passing disabled attribute to the first option would do the trick.
You can check the woocommerce_form_field() function mechanism to check in which way it supports passing the disabled attribute.
You can even do this by jquery. Through your custom class my-field-class
您可以使用类似的放置变量:
you can use a placholder variable like this: