0

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?

2
  • Do you want the user to be able to change that value? or is it fixed no matter what? Jul 18, 2021 at 7:18
  • A fixed and constant value no matter what.
    – Erfan
    Jul 18, 2021 at 11:22

1 Answer 1

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;
}
3
  • Hi. Since I already removed email field using checkout fields editor plugin, I only used second filter and it happily solved this issue in my case. Thanks for your help I really appreciate it.
    – Erfan
    Jul 19, 2021 at 7:14
  • @Erfan Glad I could help, please consider upvoting and accepting the answer if it helped you Jul 19, 2021 at 7:43
  • I've newly created my account so still cant upvote an answer but gladly I accepted the answer :)
    – Erfan
    Jul 19, 2021 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.