Change the subject and header of the email to be sent to the product author
-
My website has a system where users can add their own products and publish them when the admin agrees, so when the product is purchased I want the user/product owner to get an email notification that the product has been checkout. For now I can send email notifications to buyers and product owners. But the email that was sent has the same fields.
So I want to distinguish the contents of the subject and header of the email sent to the product owner so that it is not the same as that sent to the buyer/customer.
Is there any code I can put in function.php or the plugin snippet to build the feature?Thank you, regards.
Here is my code for send product author checkout process email
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'ajout_proprietaire_mail_commande_wc', 10, 2); function ajout_proprietaire_mail_commande_wc ($recipient, $order) { $order = new WC_Order($order->id); $items = $order->get_items(); foreach ( $items as $item ) { $product_id = $item['product_id']; } $product_author_id=get_post_field('post_author', $product_id); $product_author = get_userdata( $product_author_id ); $productAuthorEmail = $product_author->user_email; $recipient = $recipient . ', ' . $productAuthorEmail; return $recipient; }
Here is my try code for send email with different header and send it to product author, but doesnt work
add_filter('woocommerce_email_subject_customer_completed_order', 'change_admin_email_subject', 10, 2); function change_admin_email_subject( $subject,$recipient, $order ) { global $woocommerce; $order = wc_get_order( $order_id ); $order_data = $order->get_data(); foreach ( $order_data as $data_buyer ) { $product_id = $data_buyer['product_id']; $order_billing_email = $data_buyer['billing']['email']; } if ($recipient =! $order_billing_email) { $subject = sprintf( 'ini pelelang'); } else { return $subject; } return $subject; }
Wordpress : V.5.9
Woocommerce : 6.1.1The page I need help with: [log in to see the link]
- The topic ‘Change the subject and header of the email to be sent to the product author’ is closed to new replies.