Auto print on receipt of a new order with Woocommerce

Hello, on more than one occasion I have come across this question from many customers or users who have an online shop with Woocommerce and for some reason at some point they have seen the need to respond to the client from the email they receive from Woocommerce when a new order has been created.

By default when Woocommerce sends the email to the store administrator when a new order has been placed, the response email if we use the reply function of our email client, is usually the same as the administrator Woocommerce (in this case the same address as the administrator or [email protected]).

This makes it impossible to respond to the client from the email itself, and it is necessary to access our intranet. Woocommerce, access the order and respond from the notifications section or from the customer's email address that appears in the order.

If you have not yet thought about what this function can be used for, I give you several examples:

  1. You are a company that manages emails from a CRM and you want to respond to the client from your own CRM (you can't do it, because you don't have the client's email in the same email, you have to access Woocommerce or to the order panel of the CRM to access your email).
  2. You have a type of business that, out of habit, usually responds to emails from your mobile phone, and since you usually use the reply button on your email client, in this case you cannot do so either because once again you do not have the customer's email since Woocommerce does not provide it to you in this email.
  3. Do you have a type of business, for example a fast food o restaurant and you want to configure an auto-reply system in your email client to be able to automatically reply to the customer when you have received a new order, with a e-mail for example: your order has been sent to the kitchen.

In none of the previous options you can use the answer option, since Woocommerce By default, it does not send you the customer email as a response option in the new order email.

That's why I have created a small plugin that works just by having it installed and activated, this plugin allows you without having to configure anything that Woocommerce, send you the customer's email as a response option in the new order email, this way you can respond from your CRM, email client or create auto-responder functions with filters when you receive emails about new orders Woocommerce.

An example of real use:

In a client's cafeterias, a Woocommerce as an online store so that its customers can place orders for their pizzas, hamburgers, sandwiches, etc. and be able to send them to your home or for customers to pick them up at the store like Tele Pizza or any other store of this type.

As there are several cafeterias from which orders are received but Woocommerce It does not allow you to create substores or filters for which cafeteria to send the email to depending on the options chosen by the client, it was decided to use the email client as an alternative thanks to many useful functions that were needed in the POS of the cafeterias.

What exactly did the client need?

  1. Being able to receive the new order email in the corresponding email account that you used in all the POS and your own cell phone to be able to monitor orders at all times.
  2. That orders could be printed when received through the printer TICKET from the coffee shop.
  3. That when the TICKET was printed, an automatic email could be sent to the customer indicating that their order was being prepared (don't forget that the orders were to prepare orders for food at home or for local pickup)

What was done to solve the problems?

  1. I chose to install the email client Mozilla Thunderbird, since the use of email was a priority and Thunderbird allows us to use extra functions to use in the cafeteria equipment (since Woocommerce It is on an Online server and does not have access to the computer, so it cannot interact with operating system functions).
  2. The complete one was installed Filtaquilla for Thunderbird, this plugin allows us to use special filtering functions such as sending an email to print automatically, running a computer program, even playing an alert sound when an email is received.
  3. The plugin is installed PrintingTools of Thunderbird to be able to make settings in the way you print Thunderbird, such as the list of printers not appearing, this way we can print directly without dialogue or human interaction (remember that this entire process has to be carried out automatically).
  4. The filter configuration was made that allows Thunderbird to select emails with the subject “new order“, and that the content of the emails had texts related to the methods of sending Woocommerce, in this case the shipping methods were: Pick up at XXX cafeteria, Pick up at OOO cafeteria, Home Service.
  5. Configurations and previews of the emails were also carried out before being printed to make test prints and see that everything worked well.
  6. The new order email was set to Text Only in the email settings. Woocommerce, since printers TICKET They usually have problems printing colors, images or even tables, it is best to print texts.
  7. An email template was configured to be able to respond to the client automatically once the email was sent. TICKET to the printer, this is configured in the same filter options, looking like this:
    => The subject contains “new order” => The body of the message contains “coffee shop”, “pick up”, “coffee shop name” => print email => reply to the customer using the template we had previously created with the message “ Your order is being prepared right now, in 40 minutes we will be at your house.”
  8. He created the plugin for Woocommerce that allows you to send the customer's email as a reply option in the email to be able to use the automatic reply option in the filters Thunderbird.

Things to keep in mind

The printers TICKET On many computers they are usually configured with the drivers generic Windows, as Generic / Text Only, but for what Thunderbird can print without problems, it is necessary to install the printers TICKET with his drivers original so you can create the correct print formats for the correct paper size, as well as enable all printer options.

Final conclusion

The choice to use Thunderbird as an email client was due to its additional plugins, since they allow you to use special functions within the computer, including running other programs or script that can be created (imagination is power).

Surely the system can be created or carried out in another way, but since it was required to use email as the main part of usability and control, other systems, perhaps more complex such as a plugins of websocket to communicate with cafeteria teams or similar things.

Facebook
Twitter
Email
Print

5 responses

  1. Thank you very much for this article, it really enlightened me, I had been searching and searching for 3 weeks, I only found paid tools, this is great.
    Again thank you very much.

    Note: For printing, install the “PrintingTools NG” plugin for many options for printing.

  2. What a pity, can you tell me how I can configure the email so that it responds to the client? Just as you did it, I remain attentive.
    Thank you

    1. Here is a code snippet that you can add to your active theme's functions.php file or to a custom plugin:

      add_filter( 'woocommerce_email_headers', 'add_reply_to_customer_email', 10, 3 );

      function add_reply_to_customer_email( $headers, $email_id, $order ) {
      // Comprueba si el email es de un nuevo pedido
      if ( $email_id == 'new_order' ) {
      // Obtén el email del cliente
      $customer_email = $order->get_billing_email();

      // Añade el encabezado "Reply-To"
      $headers .= 'Reply-To: ' . $customer_email . "\r\n";
      }

      return $headers;
      }

      Here I explain the code:

      Hook woocommerce_email_headers: We use this hook to modify the email headers.
      add_reply_to_customer_email function: This function is executed every time a WooCommerce email is sent.
      $headers: The email headers.
      $email_id: The ID of the email being sent (for example, new_order for a new order).
      $order: The WooCommerce order object.
      Condition if ($email_id == 'new_order'): Check if the email is from a new order.
      Get the client's email: Use $order->get_billing_email() to get the customer's billing email.
      Add the “Reply-To” header: Add the customer's email to the email headers.

      Considerations to take into account:
      This code adds the “Reply-To” header only for new order emails. You can adapt the condition for other types of emails if necessary.
      Be sure to test this code in a development environment before deploying it to production to ensure it works correctly and doesn't cause issues with other WooCommerce emails.

  3. Hello… thank you very much for your contribution… because I find it super useful, I don’t fully understand some things… but from what I did manage to understand, I find it super interesting.

    I have a situation, please if you can give me some of your valuable time and knowledge, I would appreciate it.

    I have created a site for a friend (it is a Mexican food restaurant) everything works without problems (JetPack + WooCommerce configuration triggers the “Order Received” “Order Ready for In-Store Pickup” emails without problems) Also the WooCommerce App makes the new order notification sound without problems.

    What I'm stuck on is that my friend wants the "order" (with all its details of "Without Onion" "With Sauce" etc. etc.) to be automatically printed on a thermal printer BUT from a tablet.

    Will this be possible or does it necessarily have to be from a desktop computer?

    1. Every time I've done something like this, it's been with a computer or mini PC with a printer connected via USB. I've never had this happen with any other type of device. But I imagine you'll need an APP on the device that will automatically start printing.

Leave a Reply

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

en_GBEnglish