我制作了一个wordpress插件 . 它使用信用卡处理新的支付网关 . 在成功完成交易后,我关闭订单但无法发送电子邮件 . 我尝试了一切 . 我试图在init上调用邮件程序,但它在error.log上失败:
PHP致命错误:在布尔中调用成员函数get_order_number()...... / wp-content / plugins / woocommerce / includes / emails / class-wc-email-customer-processing-order.php on line 58
我尝试在init上创建一个 new WC_simplepay();
,但是找不到类失败 .
我尝试使用新功能在类中发送相同的邮件,并使用_2741469从构造函数中调用它 . 它工作,邮件发送,但支付提供商(或我)无法从URL调用此(这就是我检查请求参数的原因) ,因为只有在结帐页面中才会加载类 .
我尝试了全局 $woocommerce
...等解决方案,但也没有在init部分工作,只在类中 .
启动插件代码:
add_action('plugins_loaded', 'woocommerce_simplepay_init', 0);
function woocommerce_simplepay_init(){
if(!class_exists('WC_Payment_Gateway')) return;
if ($_REQUEST['REFNOEXT']!='')
{
/* .... here are some code regarding the gateway provider ,logging, etc... fully working */
$order_id = explode('_',$_REQUEST['REFNOEXT']);
$order = new WC_Order($order_id[0]);
$order->update_status('processing');
WC()->mailer()->emails['WC_Email_Customer_Processing_Order']->trigger($order_id[0]); // this is generating the error
}
class WC_simplepay extends WC_Payment_Gateway{
public function __construct(){
...
那么基本上我如何关闭订单,向客户发送电子邮件并使用远程URL调用处理此类的提供程序?
1 回答
你正在接受错误的操作,我建议你挂钩
init
,因为它已经在所有插件(包括woocommerce)加载后执行 .但是既然你正在使用一个Class,我相信最好将这个函数包含在一个类中 .
Init hook reference