admin管理员组文章数量:1335832
All payment methods are sending email to admin and customer after completed order. I have custom payment method via plugin with a bank, that is on success returning empty cart, new order in list and everything else works fine, but it doesn't send emails. Because mail function doesn't exist inside plugin. On successful payment I need to send exactly the same email from processing order template as with other payment methods. I know when to trigger function, but do not know what function to call.
<?php
class My_Class extends WC_Payment_Gateway {
...
function __construct() {
...
if ( is_admin() ) {
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
}
if( isset($_POST['oid']) && isset($_POST['Response']) )
$this->process_respond($_POST['oid'], $_POST['Response']);
}
public function process_respond($response_order_id, $result){
global $woocommerce;
$customer_order = new WC_Order( $response_order_id );
$error_msg = "Error in transaction";
if ( $result == "Approved" ) {
My_Class::extend($customer_order);
...
// I need to trigger function here
wp_mail(...)
die();
} else {
...
}
}
}
All payment methods are sending email to admin and customer after completed order. I have custom payment method via plugin with a bank, that is on success returning empty cart, new order in list and everything else works fine, but it doesn't send emails. Because mail function doesn't exist inside plugin. On successful payment I need to send exactly the same email from processing order template as with other payment methods. I know when to trigger function, but do not know what function to call.
<?php
class My_Class extends WC_Payment_Gateway {
...
function __construct() {
...
if ( is_admin() ) {
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
}
if( isset($_POST['oid']) && isset($_POST['Response']) )
$this->process_respond($_POST['oid'], $_POST['Response']);
}
public function process_respond($response_order_id, $result){
global $woocommerce;
$customer_order = new WC_Order( $response_order_id );
$error_msg = "Error in transaction";
if ( $result == "Approved" ) {
My_Class::extend($customer_order);
...
// I need to trigger function here
wp_mail(...)
die();
} else {
...
}
}
}
Share
Improve this question
asked Jul 19, 2017 at 14:27
Nemanja ĐatkovNemanja Đatkov
11 silver badge4 bronze badges
1 Answer
Reset to default 0You can do it very easily by using his mail class. you can extend that class as well. Here is the code which should work with your class code. if it did not work than you need to extend the woocommerce email class same like you did for your custom payment gateway.
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) {
if ( $mail->id == 'new_order' || $mail->id == 'customer_processing_order' ){
$mail->trigger( $order->id );
}
}
}
本文标签: woocommerce offtopicSend Processing Order Email from custom payment plugin
版权声明:本文标题:woocommerce offtopic - Send Processing Order Email from custom payment plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742384982a2464850.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论