Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author pinal.shah

    (@pinalshah)

    Hi @sinalarteweb,

    Yes, You can use the hook
    do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

    to add any customer details as per your choice. The link you have shared has the correct way to fetch the order note marked as the valid answer.

    Since you already have the order object present in the $order variable, you can fetch the customer order note by using the below line of code.

    $customer_note = $order->get_customer_note();

    The code patch would be something like:

    add_action( 'woocommerce_email_customer_details', 'customer_note_email_after_order_table', 10, 4 );
    function customer_note_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ){
        // Only on some email notifications
        if ( in_array( $email->id, array('qwc_req_new_quote') ) ) :
    
        // Get customer Order note
        $customer_note = $order->get_customer_note();
    
        // Display the Customer order notes section
        echo '<h2>' . __("Order notes", "woocommerce") . '</h2>
        <div style="margin-bottom: 40px;">
        <table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
            <tr><td><p>' . $customer_note . '</p></td></tr>
        </table></div>';
    
        endif;
    }

    The above can be added in the functions.php file of your active theme. The code is untested, so please test on a staging/dev site first before moving it to production.

    I hope this helps.

    Thanks,
    Pinal

    Thread Starter sinalarteweb

    (@sinalarteweb)

    Hi, Pinal Shah

    Thank you for the quick response. The code in functions.php didn’t work. No errors, but didn’t give me nothing, I believe the reason is because i’m using template request-new-quote in child theme.

    Is there a way to insert code between these two lines, at the end of file request-new-quote.php?

    <?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); ?>
    <?php do_action( 'woocommerce_email_footer' ); ?>

    For instance, if I add

    do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );

    it shows me what I want, but also brings up the whole table again, perhaps because of the array.

    Is it possible to work with:

    do_action( 'woocommerce_email_order_meta', <strong>$order->get_customer_note</strong>, $sent_to_admin, $plain_text, $email );

    Plugin Author pinal.shah

    (@pinalshah)

    Hi @sinalarteweb,

    Since you have already customized the request-new-quote.php in your child theme, you can simply add the code to fetch the customer note and display it in the email address.

    Code to add:

    // Get customer Order note
        $customer_note = $order->get_customer_note();
    
        // Display the Customer order notes section
        echo '<h2>' . __("Order notes", "woocommerce") . '</h2>
        <div style="margin-bottom: 40px;">
        <table cellspacing="0" cellpadding="0" style="width: 100%; color: #636363; border: 2px solid #e5e5e5;" border="0">
            <tr><td><p>' . $customer_note . '</p></td></tr>
        </table></div>';
    

    The code can be added between these 2 lines in request-new-quote.php present in the child theme:

    <?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); ?>
    <?php do_action( 'woocommerce_email_footer' ); ?>

    Thanks,
    Pinal

    Thread Starter sinalarteweb

    (@sinalarteweb)

    Hi, Pinal

    Thank you very much, it worked!

    Topic closed.

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display order customer note in request-new-quote’ is closed to new replies.