首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WooCommerce订阅2.0 - wcs_renewal_order_created操作/筛选抛出错误

WooCommerce订阅2.0 - wcs_renewal_order_created操作/筛选抛出错误
EN

Stack Overflow用户
提问于 2017-12-13 20:34:47
回答 1查看 1.4K关注 0票数 0

当WooCommerce订阅创建新的订阅更新顺序时,我试图执行一个函数。

原因是我希望捕捉这个事件,并将详细信息传递到一个不同的数据库,这样我们就可以在后端系统中用我们的支付网关触发业务工作流。

我尝试过使用add_action和add_filter使用wcs_renewal_order_created,然后通过从父订阅订单手动创建更新付款来测试这一点。

钩子调用函数,执行代码,将一些数据放入一些测试表中,然后Wordpress显示一个错误,如下所示。

在创建更新订阅订单时,是否有一种更简单的触发函数的方法?如果没有,是否有人能帮助了解为什么它似乎无法调用一个似乎设置了支付方法的类。

代码语言:javascript
复制
function log_renewal_order_interface($order, $subscription) {
write_log('woocommerce_subscriptions_renewal_order_created function called');

global $conn;
global $wpdb, $table_prefix;

write_log('woocommerce_subscriptions_renewal_order_created setting up test variables');

write_log($order);


$test1 = 'logged renewal order';
$test2 = 'order_id'.$order_id;
$test3 = 'not set';
$test4 = 'not set';
$test5 = 'not set';

// test table entry
$conn->insert('test_tabel', 
    array('test1' => $test1, 'test2' => $test2, 'test3' => $test3, 'test4' => $test4, 'test5' => $test5),
    array('%s', '%s', '%s', '%s', '%s'));

 }

add_filter ('wcs_renewal_order_created', 'log_renewal_order_interface', 10,2);

然后,我得到以下错误:

致命错误:未捕获错误:调用/home/ourislan/lifestyle5d.ourislandsvoice.com/wp-content/plugins/woocommerce-subscriptions/includes/admin/class-wcs-admin-meta-boxes.php:176堆栈跟踪中null上的成员函数set_payment_method():#0 /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-includes/class-wp-hook.php(286):WCS_Admin_Meta_Boxes::create_pending_renewal_action_request(Object(WC_Subscription) #1 /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-includes/class-wp-hook.php(310):WP_Hook->应用_过滤器(‘’,数组) #2 /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-includes/plugin.php(453):WP_Hook->do_action(Array) #3 /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php(131):do_action(‘woocommerce_ord.’,对象( /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-includes/class-wp-hook.php(286):(WC_Subscription)) #4 /home/ourislan/lifestyle5d.ourislandsvoice.com/wp-content/plugins/woocommerce-subscriptions/includes/admin/class-wcs-admin-meta-boxes.php WC_Meta_Box_Order_Actions::save(812,Object(WP_Post)) #5

EN

回答 1

Stack Overflow用户

发布于 2017-12-14 07:08:12

弄明白了。我需要在函数的末尾显式返回$object。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47801689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档