diff --git a/includes/Core/Notifications/EmailRenderer.php b/includes/Core/Notifications/EmailRenderer.php index 0e69fa0..1f31707 100644 --- a/includes/Core/Notifications/EmailRenderer.php +++ b/includes/Core/Notifications/EmailRenderer.php @@ -152,6 +152,20 @@ class EmailRenderer { // Calculate estimated delivery (3-5 business days from now) $estimated_delivery = date('F j', strtotime('+3 days')) . '-' . date('j', strtotime('+5 days')); + // Completion date (for completed orders) + $completion_date = ''; + if ($data->get_date_completed()) { + $completion_date = $data->get_date_completed()->date('F j, Y'); + } else { + $completion_date = date('F j, Y'); // Fallback to today + } + + // Payment date + $payment_date = ''; + if ($data->get_date_paid()) { + $payment_date = $data->get_date_paid()->date('F j, Y'); + } + $variables = array_merge($variables, [ 'order_number' => $data->get_order_number(), 'order_id' => $data->get_id(), @@ -164,8 +178,12 @@ class EmailRenderer { 'order_status' => wc_get_order_status_name($data->get_status()), 'order_url' => $data->get_view_order_url(), 'payment_method' => $data->get_payment_method_title(), + 'payment_status' => $data->get_status(), + 'payment_date' => $payment_date, + 'transaction_id' => $data->get_transaction_id() ?: 'N/A', 'shipping_method' => $data->get_shipping_method(), 'estimated_delivery' => $estimated_delivery, + 'completion_date' => $completion_date, 'customer_name' => $data->get_formatted_billing_full_name(), 'customer_first_name' => $data->get_billing_first_name(), 'customer_last_name' => $data->get_billing_last_name(), @@ -173,20 +191,48 @@ class EmailRenderer { 'customer_phone' => $data->get_billing_phone(), 'billing_address' => $data->get_formatted_billing_address(), 'shipping_address' => $data->get_formatted_shipping_address(), + // URLs + 'review_url' => $data->get_view_order_url(), // Can be customized later + 'shop_url' => get_permalink(wc_get_page_id('shop')), + 'my_account_url' => get_permalink(wc_get_page_id('myaccount')), + 'payment_retry_url' => $data->get_checkout_payment_url(), + // Tracking (if available from meta) + 'tracking_number' => $data->get_meta('_tracking_number') ?: 'N/A', + 'tracking_url' => $data->get_meta('_tracking_url') ?: '#', + 'shipping_carrier' => $data->get_meta('_shipping_carrier') ?: 'Standard Shipping', ]); - // Order items - $items_html = ''; + // Order items table + $items_html = '
| Product | '; + $items_html .= 'Qty | '; + $items_html .= 'Price | '; + $items_html .= '
|---|---|---|
| %s × %d | %s | %s | ', + $item->get_name() + ); + $items_html .= sprintf( + '%d | ', + $item->get_quantity() + ); + $items_html .= sprintf( + '%s | ', wc_price($item->get_total()) ); + $items_html .= ''; } + + $items_html .= '