admin管理员组文章数量:1122832
I have the admin or store owner emails disabled but would like to programmatically fire the action so that once a function runs using AJAX to finalize an order I can send the email as intended, but only after an AJAX function that is fired on the return of the reciept page after payment.
The flow is as follows currently:
Add to Cart -> Cart -> Checkout -> Reciept Page (disabled new order email here) -> Redirect to Payment -> Payment -> Redirect to final Reciept Page (send the disabled new order notification here).
I'm trying to use the following to send the disabled new order email:
// Get the WC_Email_New_Order object
$email_new_order = WC()->mailer()->get_emails()['WC_Email_New_Order'];
// Sending the new Order email notification for an $order_id (order ID)
$email_new_order->trigger( $order->get_id() );
but the email is never sent, I assume because its disabled under WC > Settings > Email > New Order - but is there a way around this?
I have the admin or store owner emails disabled but would like to programmatically fire the action so that once a function runs using AJAX to finalize an order I can send the email as intended, but only after an AJAX function that is fired on the return of the reciept page after payment.
The flow is as follows currently:
Add to Cart -> Cart -> Checkout -> Reciept Page (disabled new order email here) -> Redirect to Payment -> Payment -> Redirect to final Reciept Page (send the disabled new order notification here).
I'm trying to use the following to send the disabled new order email:
// Get the WC_Email_New_Order object
$email_new_order = WC()->mailer()->get_emails()['WC_Email_New_Order'];
// Sending the new Order email notification for an $order_id (order ID)
$email_new_order->trigger( $order->get_id() );
but the email is never sent, I assume because its disabled under WC > Settings > Email > New Order - but is there a way around this?
Share Improve this question edited Aug 4, 2019 at 20:56 CJ Ratliff asked Aug 4, 2019 at 20:47 CJ RatliffCJ Ratliff 1015 bronze badges1 Answer
Reset to default 0I ended up answering my own question, using the woocommerce_email_enabled_new_order filter and setting it to true prior to triggering the email, example:
add_filter( 'woocommerce_email_enabled_new_order', function($enabled, $order) {
return true;
}, 10, 2 );
本文标签: How to fire a disabled WooCommerce New Order notification
版权声明:本文标题:How to fire a disabled WooCommerce New Order notification? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293102a1929074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论