fix: Update email body formatting for supplier exports to use HTML and improve readability
This commit is contained in:
@@ -239,25 +239,28 @@ class Siti_Stock_Supplier_Exports {
|
||||
$config['supplier']
|
||||
);
|
||||
|
||||
$body_lines = array();
|
||||
$body_lines[] = sprintf(
|
||||
$rows_count = count( $data['rows'] );
|
||||
$body = '';
|
||||
$body .= '<p>' . sprintf(
|
||||
/* translators: %s supplier name */
|
||||
__( 'Overzicht voor leverancier %s.', 'siti-stock-plugin' ),
|
||||
$config['supplier']
|
||||
);
|
||||
$body_lines[] = sprintf(
|
||||
esc_html__( 'Overzicht voor leverancier %s.', 'siti-stock-plugin' ),
|
||||
esc_html( $config['supplier'] )
|
||||
) . '</p>';
|
||||
$body .= '<p>' . sprintf(
|
||||
/* translators: %d total items */
|
||||
__( 'Totaal aantal regels: %d.', 'siti-stock-plugin' ),
|
||||
count( $data['rows'] )
|
||||
);
|
||||
if ( empty( $data['rows'] ) ) {
|
||||
$body_lines[] = __( 'Er zijn geen bestellingen gevonden in de afgelopen 24 uur.', 'siti-stock-plugin' );
|
||||
}
|
||||
$body_lines[] = '';
|
||||
$body_lines[] = $csv;
|
||||
esc_html__( 'Totaal aantal regels: %d.', 'siti-stock-plugin' ),
|
||||
(int) $rows_count
|
||||
) . '</p>';
|
||||
|
||||
$headers = array( 'Content-Type: text/plain; charset=UTF-8' );
|
||||
$sent = wp_mail( $admin_email, $subject, implode( "\r\n", $body_lines ), $headers );
|
||||
if ( empty( $data['rows'] ) ) {
|
||||
$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 ) {
|
||||
return new WP_Error( 'siti_stock_mail_failed', __( 'E-mail verzenden is mislukt.', 'siti-stock-plugin' ) );
|
||||
|
||||
Reference in New Issue
Block a user