Search code examples
woocommercehook-woocommerce

How to find a string in Woocommerce hook 'woocommerce_email_order_details'


I'm trying to find (and to modify) a customized string in transactional emails as the one made with /woocommerce/templates/emails/customer-processing-order.php

In that email we have a customized text under the salutation (Hi, surname) and the first row of email text.

We are sure that that customized text is coming from 'woocommerce_email_order_details' hook

How to edit and modify that hook?


Solution

  • If you're sure about it being the right hook, the way you change is by locating the functions.php file in your child theme (are you using a child theme?), and adding the following code to the bottom. You can modify the parameters in the body of the modifyEmailText function.

    add_action( 'woocommerce_email_order_details', 'modifyEmailText', 10, 4 );  
    
    function modifyEmailText($order, $sent_to_admin, $plain_text, $email){
        // modify $plain_text if needed...
    }
    

    There are probably better ways to do this. Here is a guide to customizing WC order emails.

    If you feel that my answer helped you, you could accept my answer.