在 hook woocommerce_checkout_order_processed 中获取订单详细信息 [英] Grab order details in hook woocommerce_checkout_order_processed
本文介绍了在 hook woocommerce_checkout_order_processed 中获取订单详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
add_action('woocommerce_checkout_order_processed', 'send_order_fax');
function send_order_fax($order_id) {
print_r($_REQUEST);
die();
}
我想在此钩子触发时获取订单 ID 或订单详细信息,以便我可以生成传真.但它只是发送表单数据.我如何获取订单 ID 以便我可以通过函数获取其他东西.
I want to grab the order id or order details when this hooks fire so that i can generate a fax. But it is only sending the form data. How can i get the order id so that i can fetch other things via functions.
谢谢
推荐答案
您可以使用以下代码获取订单详情:
You can get order details using following code:
add_action('woocommerce_checkout_order_processed', 'send_order_fax');
function send_order_fax($order_id) {
$order = new WC_Order( $order_id );
$items = $order->get_items();
print_r($items);
die();
}
这篇关于在 hook woocommerce_checkout_order_processed 中获取订单详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文