Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Woocommerce 如何删除帐户详细信息中的姓氏字段?(非签出字段)_Woocommerce - Fatal编程技术网

Woocommerce 如何删除帐户详细信息中的姓氏字段?(非签出字段)

Woocommerce 如何删除帐户详细信息中的姓氏字段?(非签出字段),woocommerce,Woocommerce,我想删除帐户详细信息页面中的姓氏字段。我尝试编辑form-edit-account.php文件并删除姓氏字段。该字段已删除,但无法保存。有一条消息“姓氏是必填字段”。如何删除它? 我试过钩子,但没用 add_filter( 'woocommerce_billing_fields' , 'remove_billing_fields' ); function remove_billing_fields( $fields ) { unset($fields['billing_last

我想删除帐户详细信息页面中的姓氏字段。我尝试编辑form-edit-account.php文件并删除姓氏字段。该字段已删除,但无法保存。有一条消息“姓氏是必填字段”。如何删除它? 我试过钩子,但没用

add_filter( 'woocommerce_billing_fields' , 'remove_billing_fields' );
function remove_billing_fields( $fields ) {
         unset($fields['billing_last_name']);
         return $fields;
}

以下是相关信息和说明:

你可以试试这个,它对我有用

在子主题的functions.php中添加以下内容,以删除account_first_name和account_last_name输入的required属性

/*WOOCOMMERCE UNSET REQUIRED FIELD IN EDIT ACCOUNT*/
add_filter( 'woocommerce_save_account_details_required_fields' , 
'smtl_edit_account_remove_required_names' );
  function smtl_edit_account_remove_required_names( $fields ) {
   unset($fields['account_first_name']);
   unset($fields['account_last_name']);
   return $fields;
}
然后,您可以简单地使用一些css隐藏字段

.woocommerce-EditAccountForm .woocommerce-form-row--last,
.woocommerce-EditAccountForm .woocommerce-form-row--first {
  display: none;
}

谢谢,我试过这个指令,但它不是我想要的。我是指账户详情页面中的姓氏。