Domenikus Gruber
Domenikus Gruber

Reputation: 49

Custom email notification

I have integrated this code for the custom email. It works, but I would like to send all the order details. Is that possible?

add_action("woocommerce_order_status_changed", "my_awesome_publication_notification");

function my_awesome_publication_notification($order_id, $checkout=null) {
   global $woocommerce;
   $order = new WC_Order( $order_id );
   $first_name = $order->billing_first_name;

   if($order->status === 'processing' ) {
      // Create a mailer
      $mailer = $woocommerce->mailer();
      $message_body = "<p>$first_name</p>";
      $message_body .= '<p>hat sich angemeldet für:</p>';



      $message_body .= '<p>Elisabeth Zangerle<br/>Koordinatorin FoBU</p>';

      $message = $mailer->wrap_message(
        // Message head and message body.
        sprintf( __( 'Fortbildung im Bezirk' ), $order->get_order_number() ),
                                                $message_body );


      // Cliente email, email subject and message.
     $mailer->send( $order->billing_company, sprintf( __( 'Fortbildung im Bezirk' ),
                    $order->get_order_number() ), $message );
     }
   }

Upvotes: 0

Views: 339

Answers (1)

Serg Chernata
Serg Chernata

Reputation: 12400

Sure is possible, just add whatever you want, one by one:

$items = $order->get_items();

foreach($items as $item){
    print "Product Name: ".$item['name']."<br/>";
}

Upvotes: 1

Related Questions