简体   繁体   English

发送“新订单”-邮件之前的WooCommerce挂钩

[英]WooCommerce Hook before “New Order”-Mail is sent

During my WooCommerce order, the user selects an image that gets uploaded to the server. 在我的WooCommerce订单期间,用户选择要上传到服务器的图像。 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. 现在,我需要在发送“新订单”电子邮件之前编辑此图像(使用ImageMagick调整大小,修剪等),因为我将此图像附加到了这些电子邮件中。

I tried the payment_complete hook, but this one is too late, the mails are already sent. 我尝试了payment_complete挂钩,但是这已经太晚了,邮件已经发送了。 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. 当然,它应该在“谢谢”页面之后在服务器上发生,用户不必等待此处理。

Edit: The hook should deliver the order id because I need to access the order items. 编辑:挂钩应该提供订单ID,因为我需要访问订单商品。

Where can I insert/hook my code to achieve this? 我在哪里可以插入/挂钩我的代码来实现这一目标?

Thank you! 谢谢!

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. 好吧,新订单电子邮件被触发以默认(10)优先级在woocommerce_order_status_pending_to_processing_notificationwoocommerce_order_status_pending_to_on-hold_notification挂钩上运行。

Therefore, you should be able to run your code on the same hooks with a lower priority (say, 5). 因此,您应该能够以较低的优先级(例如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 woocommerce_order_status_pending_to_processingwoocommerce_order_status_pending_to_on-hold

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM