发送“新订单”-邮件之前的WooCommerce挂钩 [英] WooCommerce Hook before "New Order"-Mail is sent

查看:147
本文介绍了发送“新订单”-邮件之前的WooCommerce挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的WooCommerce订单期间,用户选择要上传到服务器的图像。现在,我需要在发送新订单电子邮件之前编辑此图像(使用ImageMagick调整大小,修剪等),因为我将此图像附加到了这些电子邮件上。

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.

我尝试了payment_complete挂钩,但是这个已经太晚了,邮件已经发送了。我还考虑过在邮件模板中执行此操作,但是它只需要执行一次,因此必须特别在发送邮件之前进行。

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.

当然它应该在谢谢页面之后在服务器上发生,用户不必等待此处理。

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

编辑:挂钩应提供订单ID因为需要访问订单项。

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?

谢谢!

推荐答案

好了,新订单电子邮件被触发运行在 woocommerce_order_status_pending_to_processing_notification woocommerce_order_status_pending_to_on-hold_notification 钩子,具有默认(10)优先级。

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.

因此,您应该能够在优先级较低的同一个钩子上运行代码(例如5)。

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 woocommerce_order_status_pending_to_on-hold

这篇关于发送“新订单”-邮件之前的WooCommerce挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆