Reputation: 81
I changed checkout page for simpler process - I removed all billing fields and using shipping fields instead. So instead of billing_email I have shipping_email.
When customer makes order he didn't receive email notification because billing_email is not set.
Can you advice how to change customers notifications to be sent to shipping_email instead.
Upvotes: 2
Views: 1062
Reputation: 253968
You can try to use the following custom hooked function, where I set the billing email from your custom shipping email. This way the notifications are sent to the correct email.
You should need to check that
'_shipping_email'
is the correct metakey for the Shipping email custom checkout field… If not replace it by the right one.
The code:
add_action('woocommerce_checkout_update_order_meta', 'set_billing_email_from_shipping_email', 50, 2 );
function set_billing_email_from_shipping_email( $order_id, $data ) {
// Get customer shipping email
$email = get_post_meta( $order_id, '_shipping_email', true );
// Set billing email from shipping email
update_post_meta( $order_id, '_billing_email', $email );
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works.
Upvotes: 0