WooCommerce Hook before “New Order”-Mail is sent

During my WooCommerce order, the user selects an image that gets uploaded to the server. Now I need to edit this image (resize, trim etc. with ImageMagick) BEFORE the “new Order” emails are sent, because I attach this image to these emails.

I tried the payment_complete hook, but this one is too late, the mails are already sent. I also thought about doing it in the mail templates, but it only needs to be done once, so it has to especially be before the mails are sent out.

Read More

Of course it should happen on the server after the “thank you” page, the user shouldn’t have to wait for this processing.

Edit: The hook should deliver the order id because I need to access the order items.

Where can I insert/hook my code to achieve this?

Thank you!

Related posts

1 comment

  1. Well the new order emails are triggered to run on the woocommerce_order_status_pending_to_processing_notification and woocommerce_order_status_pending_to_on-hold_notification hooks, with default (10) priority.

    Therefore, you should be able to run your code on the same hooks with a lower priority (say, 5).

    Failing that, you could skip the notification and just focus on the order status change, so the following hooks:

    woocommerce_order_status_pending_to_processing and woocommerce_order_status_pending_to_on-hold

Comments are closed.