How to change your order details wordpress mail template

To change the order details in the WordPress mail template, you'll need to modify the woocommerce_email_order_details filter. This filter allows you to customize the order details that are sent in the email.

Here's a step-by-step guide to help you achieve this:

Method 1: Using a plugin

  1. Install and activate the WooCommerce Email Customizer plugin.
  2. Go to WooCommerce > Settings > Emails and click on the Customize button next to the email template you want to modify.
  3. In the Order Details section, you can add or remove fields, and reorder them as needed.
  4. Click Save Changes to save your modifications.

Method 2: Using code

  1. Create a new file in your theme's directory (e.g., functions.php) or edit an existing one.

  2. Add the following code to the file:

    function custom_woocommerce_email_order_details($order, $sent_to_admin, $plain_text, $email) {
     // Get the order details
     $order_id = $order->get_id();
     $order_data = wc_get_order_data($order_id);
    
     // Customize the order details
     $order_details = array(
         'Order Number' => $order_data['order_number'],
         'Order Date' => date_i18n(get_option('date_format'), strtotime($order_data['order_date'])),
         'Total' => wc_price($order_data['total']),
         'Status' => $order_data['status'],
         // Add or remove fields as needed
     );
    
     // Return the customized order details
     return $order_details;
    }
    add_filter('woocommerce_email_order_details', 'custom_woocommerce_email_order_details', 10, 4);
  3. Replace the custom_woocommerce_email_order_details function with your own code to customize the order details.

  4. Save the file and refresh your WordPress installation.

Method 3: Using a theme-specific solution

If you're using a theme that provides a way to customize the order details, you can use that theme's built-in functionality. For example, some themes may have a woocommerce_email_order_details filter in their theme functions file.

Remember to test your modifications thoroughly to ensure they work as expected and don't break any functionality.