【发布时间】:2019-03-12 06:07:07
【问题描述】:
我有一个带有标签的自定义我的帐户页面,我想在订单标签上显示订单详细信息。我尝试添加短代码 [my_orders]。
function shortcode_my_orders( $atts ) {
extract( shortcode_atts( array(
'order_count' => -1
), $atts ) );
ob_start();
$customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array(
'customer' => get_current_user_id(),
'page' => $current_page,
'paginate' => true,
) ) );
wc_get_template(
'myaccount/orders.php',
array(
'current_page' => absint( $current_page ),
'customer_orders' => $customer_orders,
'has_orders' => 0 < $customer_orders->total,
)
);
return ob_get_clean();
}
add_shortcode('my_orders', 'shortcode_my_orders');
这会在前端显示订单,但是当我单击查看订单按钮时,它会将我重定向到仪表板页面。如何使查看订单按钮像在默认的我的帐户页面上正常工作一样工作。
【问题讨论】:
-
我的查看订单页面的 URL 为 localhost/my_site/my-account/#view-orders。默认视图按钮具有指向 URL localhost/my_site/my-account/view-order/order-number 的链接。我认为这是一个问题。我不想更改 WordPress 核心文件。
-
@LoicTheAztec 有没有办法可以显示默认我的帐户的订单选项卡的内容,并且仍然可以使用查看按钮。
标签: php wordpress woocommerce shortcode