admin管理员组

文章数量:1289423

I use wordpress and woocommerce to sell online courses. also I use "digits" plugin to make users able to order and create accounts using only their mobile phone numbers and therefore, email is not needed and I have removed email field from checkout using "checkout filed editor" plugin.

But woocommerce creates download links based on user emails, therefore download links are invalid for users after they buy something and want to download it. because of that, I have to manually add an email like "[email protected]" to every order and revoke download links of that order to make download links work.


the question is : how to automatically add "[email protected]" to email field of every order when users order something?

I use wordpress and woocommerce to sell online courses. also I use "digits" plugin to make users able to order and create accounts using only their mobile phone numbers and therefore, email is not needed and I have removed email field from checkout using "checkout filed editor" plugin.

But woocommerce creates download links based on user emails, therefore download links are invalid for users after they buy something and want to download it. because of that, I have to manually add an email like "[email protected]" to every order and revoke download links of that order to make download links work.


the question is : how to automatically add "[email protected]" to email field of every order when users order something?

Share Improve this question asked Jul 17, 2021 at 15:04 ErfanErfan 35 bronze badges 2
  • Do you want the user to be able to change that value? or is it fixed no matter what? – Buttered_Toast Commented Jul 18, 2021 at 7:18
  • A fixed and constant value no matter what. – Erfan Commented Jul 18, 2021 at 11:22
Add a comment  | 

1 Answer 1

Reset to default 0

In order to achive that you only need two woocommerce filters.

First we remove the email post field from the checkout form.

Second we set the the submited form data, email, to some fixed value.

This is the whole code, paste it into functions.php and you are good to go. Don't forget to change the email to what ever you need.

add_filter('woocommerce_checkout_fields', 'bt_manipulate_checkout_fields');
function bt_manipulate_checkout_fields ($fields) {
    unset($fields['billing']['billing_email']);

    return $fields;
}

add_filter('woocommerce_checkout_posted_data', 'bt_manipulate_checkout_posted_data');
function bt_manipulate_checkout_posted_data ($data) {
    $data['billing_email'] = '[email protected]';

    return $data;
}

本文标签: WoocommerceHow to automatically input the same email for every order