• Hi,

    I created a new order action, in order to send to the admin an email with the exact same content as the customer-invoice.php (usualy sent to the customer)

    Problem is I can’t get all the content from this email into a new function, here is my code so far :

    /* Creating the new order action */

    function send_email_to_admin( $actions ) {
    global $theorder;

    $actions[‘wc_custom_order_action’] = ‘Envoyer facture à tagua’;
    return $actions;
    }
    add_action( ‘woocommerce_order_actions’, ‘send_email_to_admin’ );

    /* Sending the content into a new email */

    function process_sending_email_to_admin( $order_id ) {

    $order = new WC_Order( $order_id );

    $ordernumber = $order->get_order_number();
    $ordertotal = $order->get_total();

    $to = “olivier*********”;
    $subject = “Invoice n°”. $ordernumber .” / “. $ordertotal ;
    $content = “?”;
    $headers = array(‘Content-Type: text/html; charset=UTF-8’);
    $status = wp_mail($to, $subject, $content, $headers);
    }
    add_action( ‘woocommerce_order_action_wc_custom_order_action’, ‘process_sending_email_to_admin’ );

    Can anyone help me to get the $content set as in the customer invoice please ?
    I still have issues with the hooks and get lost with this …

    Thanks in advance,

    Olivier

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Why create the whole order email from scratch and not just use the woocommerce_email_headers to add an email address? Have a look at the following example: https://wordpress.stackexchange.com/questions/92020/adding-a-second-email-address-to-a-completed-order-in-woocommerce

    Thread Starter alguna

    (@alguna)

    Hi Riann,

    Thanks a lot for your answer, the problem with that is that the consumer is going to receive the email too. I only want to be able to resend to the admin the emails from orders with this function, but without sending it again to the consumer, this is why I’m trying to re-create it from scratch with adding another action button …

    Any idea how I could get the content from customer-invoice within the $content of the message ? Or would you suggest another trick ?

    Thank you,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘order action : send invoice to admin’ is closed to new replies.