Flexx
Новичок

Нужно,чтобы при изменении статуса приходило письмо пользователю со стандартным набором . Т.е. состав заказа,адрес и тд. Создал хук
в таком варианте все ОК.Но мне в тело письма надо добавть еще это
Подскажите как правильно все это реализовать
PHP:
add_action("woocommerce_order_status_changed", "shipped_notification");
function shipped_notification($order_id, $checkout=null) {
global $woocommerce;
$order = new WC_Order( $order_id );
if($order->status === 'shipped' ) {
$mailer = $woocommerce->mailer();
$message_body = __( 'shipped Hello world2!!!' );
$message = $mailer->wrap_message(
sprintf( __( 'Order %s shipped' ), $order->get_order_number() ), $message_body
);
$mailer->send( $order->billing_email, sprintf( __( 'Order %s shipped' ), $order->get_order_number() ), $message );
}
}
PHP:
<?php $message_body = '<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">';
$message_body .= '<thead>';
$message_body .= '<tr>';
$message_body .= '<th scope="col" style="text-align:left; border: 1px solid #eee;">';
__( 'Product', 'woocommerce' );
$message_body .= '</th>';
$message_body .= '<th scope="col" style="text-align:left; border: 1px solid #eee;">';
__( 'Quantity', 'woocommerce' );
$message_body .= '</th>';
$message_body .= '<th scope="col" style="text-align:left; border: 1px solid #eee;">';
__( 'Price', 'woocommerce' );
$message_body .= '</th>';
$message_body .= '</tr>';
$message_body .= '</thead>';
$message_body .= '<tbody>';
sprintf("123");
//echo $order->email_order_items_table( true, false, true );
$message_body .= '</tbody>';
$message_body .= '<tfoot>';
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<?php $total['value'] = preg_replace('/[\(].*[\)]/U','(Includes all applicable taxes)',$total['value']); ?>
<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
$message_body .= '</tfoot></table>';