WooCommerce order email and mandrill

15 thoughts on “WooCommerce order email and mandrill”

    1. Out-of-the-box, it won’t. But it’ll mess up the standard WordPress mails, cause they will be sent as HTML emails. So the line breaks won’t be there for standard mails. This trick is to both work the standard emails and also the HTML mails for WooCommerce order.

  1. Okay thanks. Does mandrill allow you to edit the woocommerce templates using mandrill’s system, or does it only act as a mail server / analytics?

    1. Actually, maybe I spoke too soon… Although unchecking that setting makes WooCommerce emails look much better, I don’t think the snippet worked quite right because now regular plain text emails don’t have line breaks anymore…

  2. Tareq – thanks for sharing, this was really useful.

    To clarify, the code needs to go in your themes functions.php file, and you will also need to uncheck the “Replace all line feeds (“\n”) by in the message body?” option within wpMandrill config settings (Settings -> Mandrill).

    If you’re still not seeing the changes, make sure you’ve cleared your cache (and WP’s object cache and anything else, e.g. Cloudflare cache).

    Best wishes,

    Tim Durden
    Twitter: @tjdurden

    1. Mandrill changed their plan from last month and merged with Mailchimp as a paid add-on. Yes, it was free before that and was an excellent service.

  3. Hello, if, like me, you’re using the mandrill templates and are confused about how to let some plugins like woocommerce use their template system, you can use this. Update it to add the right tags. Pay attention some plugins don’t add them well.

    // Hook into the mandrill_payload filter.
    add_filter(‘mandrill_payload’, ‘kainjoo_force_native_mail_for_woocommerce’);

    /**
    * Forces WooCommerce emails to use the native wp_mail() function.
    *
    * @param array $message The Mandrill payload.
    * @return array Modified Mandrill payload.
    */
    function kainjoo_force_native_mail_for_woocommerce($message) {
    // Check if the email is from WooCommerce.
    if (isset($message[‘tags’]) && is_array($message[‘tags’]) && in_array(‘woocommerce’, $message[‘tags’])) {
    $message[‘force_native’] = true;
    }
    return $message;
    }
    ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.