fix: Update email body formatting for supplier exports to use HTML and improve readability

This commit is contained in:
2026-01-10 16:17:59 +00:00
parent d5babe6cae
commit b71af26223

View File

@@ -239,25 +239,28 @@ class Siti_Stock_Supplier_Exports {
$config['supplier'] $config['supplier']
); );
$body_lines = array(); $rows_count = count( $data['rows'] );
$body_lines[] = sprintf( $body = '';
$body .= '<p>' . sprintf(
/* translators: %s supplier name */ /* translators: %s supplier name */
__( 'Overzicht voor leverancier %s.', 'siti-stock-plugin' ), esc_html__( 'Overzicht voor leverancier %s.', 'siti-stock-plugin' ),
$config['supplier'] esc_html( $config['supplier'] )
); ) . '</p>';
$body_lines[] = sprintf( $body .= '<p>' . sprintf(
/* translators: %d total items */ /* translators: %d total items */
__( 'Totaal aantal regels: %d.', 'siti-stock-plugin' ), esc_html__( 'Totaal aantal regels: %d.', 'siti-stock-plugin' ),
count( $data['rows'] ) (int) $rows_count
); ) . '</p>';
if ( empty( $data['rows'] ) ) {
$body_lines[] = __( 'Er zijn geen bestellingen gevonden in de afgelopen 24 uur.', 'siti-stock-plugin' );
}
$body_lines[] = '';
$body_lines[] = $csv;
$headers = array( 'Content-Type: text/plain; charset=UTF-8' ); if ( empty( $data['rows'] ) ) {
$sent = wp_mail( $admin_email, $subject, implode( "\r\n", $body_lines ), $headers ); $body .= '<p>' . esc_html__( 'Er zijn geen bestellingen gevonden in de afgelopen 24 uur.', 'siti-stock-plugin' ) . '</p>';
} else {
$body .= '<p>' . esc_html__( 'CSV-overzicht (kopieer onderstaande tabel):', 'siti-stock-plugin' ) . '</p>';
$body .= '<pre style="font-family: monospace; white-space: pre;">' . esc_html( $csv ) . '</pre>';
}
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
$sent = wp_mail( $admin_email, $subject, $body, $headers );
if ( ! $sent ) { if ( ! $sent ) {
return new WP_Error( 'siti_stock_mail_failed', __( 'E-mail verzenden is mislukt.', 'siti-stock-plugin' ) ); return new WP_Error( 'siti_stock_mail_failed', __( 'E-mail verzenden is mislukt.', 'siti-stock-plugin' ) );