Double email invoice
-
Hello,
I want to ensure that the personal user field of the second user’s email automatically sends every email made by the client. (Exactly like this post)
https://wordpress.org/support/topic/send-the-pdf-invoice-to-another-email/
The page I need help with: [log in to see the link]
-
Hello @abitp,
What’s the issue you’re encountering that’s different from anything outlined in that thread?I successfully copied and pasted the code into my function.php file, and I changed the code from:
$extra_email_address = $order->get_meta( ‘extra_email_address’ )
to :
$extra_email_address = $order->get_meta( ‘b2bking_custom_field_171853’ )
However, when I create an invoice, it is not being sent to the address I entered in the custom field.my new code doesn’t works
add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3);
function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) {
// Si la notification par e-mail est "Completed order" ou "Processing order"
if ( in_array( $email_id, array('customer_completed_order', 'customer_processing_order') ) ) {
// Remplacez 'b2bking_custom_field_171853' par la clé de métadonnées réelle de votre champ personnalisé
if ( $extra_email_address = get_user_meta( $order->get_user_id(), 'b2bking_custom_field_171853', true ) ) {
$billing_full_name = $order->get_formatted_billing_full_name();
$headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '>' . "\r\n";
}
}
return $headers;
}-
This reply was modified 2 years, 9 months ago by
ITP TECHNOLOGIE.
@abitp can you confirm that ‘b2bking_custom_field_171853‘ is the name of the meta field saved to the order? You can use this guide to check.
Yes is a good name ! ( i use B2Bking for create this field )
Give this one a try:
add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3); function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) { // Si la notification par e-mail est "Completed order" ou "Processing order" if ( in_array( $email_id, array('customer_completed_order', 'customer_processing_order') ) ) { // Remplacez 'b2bking_custom_field_171853' par la clé de métadonnées réelle de votre champ personnalisé if ( $extra_email_address = $order->get_meta( 'b2bking_custom_field_171853' ) ) { $billing_full_name = $order->get_formatted_billing_full_name(); $headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '>' . "\r\n"; } } return $headers; }doesn’t works 🙁
up
Could you share a screenshot of the order meta data showing how the b2b meta key is saved, please?
Okay, I managed to get it working with the developers of the B2BKING plugin. Now, I have a problem because no emails are being sent or received when an order is in the status ‘In preparation’…
function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) { if ( in_array( $email_id, array('customer_refunded_order', 'customer_completed_order') ) ) { if ( $extra_email_address = $order->get_meta( 'b2bking_custom_field_171853' ) ) { $billing_full_name = $order->get_formatted_billing_full_name(); $headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '> ' . "\r\n"; } } return $headers; } add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3);-
This reply was modified 2 years, 9 months ago by
ITP TECHNOLOGIE.
-
This reply was modified 2 years, 9 months ago by
ITP TECHNOLOGIE.
You can add a check for the status. I have added it
function woocommerce_emails_bcc_copy( $headers, $email_id, $order, $email = null ) { if ( in_array( $email_id, array('customer_refunded_order', 'customer_completed_order') ) ) { if ( $extra_email_address = $order->get_meta( 'b2bking_custom_field_171853' ) && $order->get_status() != 'preparation' ) { $billing_full_name = $order->get_formatted_billing_full_name(); $headers .= 'BCC: ' . $billing_full_name . ' <' . $extra_email_address . '> ' . "\r\n"; } } return $headers; } add_filter( 'woocommerce_email_headers', 'woocommerce_emails_bcc_copy', 10, 3);I used the status name ‘preparation’. this will likely need to be changed to the actual name of the status.
-
This reply was modified 2 years, 9 months ago by
The topic ‘Double email invoice’ is closed to new replies.