Wordpress wc_get_order()返回false
我使用下面的链接到管理订单退款挂钩中,以获取订单数据并将其发送到另一个数据库。但是,wc_get_order始终返回false 当你从管理员那里退款时,它会通过ajax重新加载页面,所以我想知道我是否遗漏了什么 注意:我把我的插件文件和类称为“plugins\u-loaded”。我也尝试过加载init和woo,但没有成功Wordpress wc_get_order()返回false,wordpress,woocommerce,Wordpress,Woocommerce,我使用下面的链接到管理订单退款挂钩中,以获取订单数据并将其发送到另一个数据库。但是,wc_get_order始终返回false 当你从管理员那里退款时,它会通过ajax重新加载页面,所以我想知道我是否遗漏了什么 注意:我把我的插件文件和类称为“plugins\u-loaded”。我也尝试过加载init和woo,但没有成功 //Add the full order refund action add_action( 'woocommerce_order_fully_refunded', [$thi
//Add the full order refund action
add_action( 'woocommerce_order_fully_refunded', [$this, 'refund_items_mysql_insert'], 20, 2);
add_action( 'woocommerce_order_partially_refunded', [$this, 'refund_items_mysql_insert'], 20, 2);
public function refund_items_mysql_insert($order_id, $refund_id){
// Get the WC_Order Object instance (from the order ID)
$order = wc_get_order( $order_id );
echo json_encode($order);
wp_die();
}
这里的错误是对象受到保护,因此它不会将数据作为json发送回
// Get the WC_Order Object instance (from the order ID)
$order = wc_get_order( $order_id );
echo <pre>;
print_r($order);
echo </pre>
wp_die();
//获取WC\u Order对象实例(从订单ID)
$order=wc\u get\u order($order\u id);
回声;
打印(订单);
回音
wp_die();