admin管理员组文章数量:1334421
Is there a possibility to disable the email field on WooCommerce customer account details? Or Is there a hook or action available to do such thing? I'm just using a pre-made themes and not that much into PHP. Have tried this plugin called "Prevent Email Change" by Happy Plugins, but it didn't worked.
Would really appreciate any help from this.
Thanks,
Is there a possibility to disable the email field on WooCommerce customer account details? Or Is there a hook or action available to do such thing? I'm just using a pre-made themes and not that much into PHP. Have tried this plugin called "Prevent Email Change" by Happy Plugins, but it didn't worked.
Would really appreciate any help from this.
Thanks,
Share Improve this question asked Mar 31, 2017 at 5:13 Bry LedesmaBry Ledesma 251 gold badge1 silver badge4 bronze badges3 Answers
Reset to default 4You can do it by adding this code to functions.php
:
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_email']);
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 1000, 1 );
But it is wrong approach, since WooCommerce uses email to notify user about status of the order.
This is what I use. I was also troubleshooting with wrong emails on registered accounts. So I simply disabled the field and set it to 'required' => false
if the user is logged in.
if ( is_user_logged_in() ) {
$fields['billing']['billing_email'] = [
'label' => 'E-Mail-Adresse',
'required' => false,
'custom_attributes' => [
'disabled' => 'disabled',
]
];
} else {
$fields['billing']['billing_email'] = [
'label' => 'E-Mail-Adresse',
'required' => true,
];
}
Hope this helps someone out there!
I found in this file: wp-content\plugins\woocommerce\includes\class-wc-countries.php:
public function get_address_fields( $country = '', $type = 'billing_' )
Set required to false and the email would be optional.
本文标签: customizationDisable email field on WooCommerce customer account details
版权声明:本文标题:customization - Disable email field on WooCommerce customer account details 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742268335a2443828.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论