2015-05-01 38 views

回答

12

我的帳戶簡碼:

[woocommerce_my_account order_count="-1"] 

Shows the ‘my account’ section where the customer can view past orders and update their information. You can specify the number or order to show, it’s set by default to 15 (use -1 to display all orders.)

參考:Woocommerce Shortcodes


更新

如果您只需要在命令我不知道是否有做alread Ÿ一個短代碼,但我做了一個了結woocommerce_my_account爲例:

function shortcode_my_orders($atts) { 
    extract(shortcode_atts(array(
     'order_count' => -1 
    ), $atts)); 

    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(); 
} 
add_shortcode('my_orders', 'shortcode_my_orders'); 

添加到您的的functions.php文件,然後使用它像[my_orders order_counts=10]order_counts是可選的,如果缺少它會列出所有的訂單)。

+0

實際上它只是把我送到我的賬戶頁面,用戶可以看到他們的送貨地址,並在我的帳戶頁面時的歡迎信息。 – dave

+0

非常感謝的人。我會盡快嘗試。 – dave

+0

好吧我試圖把上面的代碼放在ROOT/wp-includes/functions.php中,但它給了我「致命錯誤:調用未定義的函數add_shortcode()在C:\ xampp \ htdocs \ localpressjuic \ wp-includes \ functions中。 php「 – dave

0

我正在閱讀有關提取物,顯然它不再由Wordpress推薦。 我發現這個soloution,希望這有助於:

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(); 

}

+0

你好,我怎麼能包括這個名字? – winresh24

相關問題