in woocommerce, is there a shortcode/page to view all orders?

前端 未结 2 1264
予麋鹿
予麋鹿 2020-12-17 00:57

I\'m using the plugin woocommerce for my wordpress site, and need a section where member can see their order history. Are there any shortcodes or page in woocommerce that s

2条回答
  •  悲哀的现实
    2020-12-17 01:22

    I was reading about extract and apparently its not recommended by Wordpress anymore. I found this soloution, hope this helps:

    function shortcode_my_orders( $atts ) {
    $args= shortcode_atts( 
    array(
        'order_count' => -1
        ), 
    $atts
    );
    $order_count = esc_attr( $args['order_count'] );
    
    
    ob_start();
    wc_get_template( 'myaccount/my-orders.php', array(
        'current_user'  => get_user_by( 'id', get_current_user_id() ),
        'order_count'   => $order_count
    ) );
    return ob_get_clean();
    

    }

提交回复
热议问题