Php 将“订单注释”更改为定义了maxlength的文本输入字段
我想将Woocommerce中的订单注释字段从文本框更改为最多18个字符的输入框。另外,将名称更改为订单说明 我找到了使用以下代码编辑functions.php中字段的方法:Php 将“订单注释”更改为定义了maxlength的文本输入字段,php,wordpress,woocommerce,field,checkout,Php,Wordpress,Woocommerce,Field,Checkout,我想将Woocommerce中的订单注释字段从文本框更改为最多18个字符的输入框。另外,将名称更改为订单说明 我找到了使用以下代码编辑functions.php中字段的方法: // remove Order Notes from checkout field in Woocommerce add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' ); function alter_woocomm
// remove Order Notes from checkout field in Woocommerce
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
这可以通过functions.php中的过滤器完成吗?更新:您可以使用以下for Order Comments签出字段: 将字段类型更改为输入文本 设置最大长度 将标签更改为订购说明 这是密码
// Change Order Notes type to 'text' on Woocommerce checkout
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
// Change field type
$fields['order']['order_comments']['type'] = 'text';
// Limit to a max length
$fields['order']['order_comments']['custom_attributes'] = array('maxlength' => 18);
// Change the label name
$fields['order']['order_comments']['label'] = __('Order Instructions', "woocommerce");
return $fields;
}
代码进入活动子主题或活动主题的function.php文件。测试和工作
Post locked可停止在此问题上发生的错误。我不知道那里发生了什么。看起来mujuonly正在进行一次建设性的编辑,以修复专有名称的大写。