Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WooCommerce] 顯示訂單資訊的短碼(Shortcode)
function woocommerce_orders() {
$user_id = get_current_user_id();
if ($user_id == 0) {
return do_shortcode('[woocommerce_my_account]');
} else {
//登入的用戶就撈 orders 的樣板來顯示訂單資料
wc_get_template('myaccount/my-orders.php', array(
'current_user' => get_user_by('id', $user_id),
'order_count' => $order_count,
return ob_get_clean();
add_shortcode('woocommerce_orders', 'woocommerce_orders');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.