【发布时间】:2019-04-04 09:17:15
【问题描述】:
在 WooCommerce 我的帐户“订单视图”页面中,我应该添加这样的视觉跟踪:
在实际页面上,跟踪每个订单,上面的订单详情:
第一个问题是我不知道如何将 html 和 php 代码添加到视图订单页面我尝试在 functions.php 上添加钩子但它不起作用
第二个问题是我想在查看订单页面中获取每个订单的状态 (例如:处理或交付等)
这是我的functions.php代码来尝试实现它:
// **
// * Add custom tracking code to the view order page
// */
add_action( 'woocommerce_view_order', 'my_custom_tracking' );
function my_custom_tracking(){
$order = wc_get_order( $order_id );
$order_id = $order->get_id(); // Get the order ID
$parent_id = $order->get_parent_id(); // Get the parent order ID (for subscriptions…)
$user_id = $order->get_user_id(); // Get the costumer ID
$user = $order->get_user(); // Get the WP_User object
echo $order_status = $order->get_status(); // Get the order status
}
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce orders