woocommerce视图命令短代码,查看订单按钮不工作

问题描述 投票:1回答:1

我有一个带标签的自定义帐户页面,我想在订单标签上显示订单详情。我尝试添加短代码[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');

这会在前端显示订单,但是当我点击查看订单按钮时​​,它会将我重定向到仪表板页面。如何使视图顺序按钮正常工作,因为它通常在默认的我的帐户页面上工作。

php wordpress woocommerce shortcode
1个回答
0
投票

经过大量的搜索,我发现它是可能的,但我将不得不重写所有没有意义的woocommerce默认代码,另一种选择是使用重写规则但是再次出现错误,因为订单部分有一个许多功能,如再次订购,支付挂单等,所以这将是一个坏主意。因此,任何查看此问题的人都会建议您使用默认仪表板,然后对其进行任何前端更改。

© www.soinside.com 2019 - 2024. All rights reserved.