Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

My-account order shortcode not displaying new columns

Home / Forums / Virtue Theme / My-account order shortcode not displaying new columns

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
November 12, 2019 at 3:43 am

Hi Guys

I’ve added a new sub-total column to my-account/order table using the following snippet(which is working and displays the new column on the my-account/order tab) (with the help of Ben in a previous support question) the snippet :
//show sub total in order page

add_filter( 'woocommerce_account_orders_columns', 'add_account_orders_column', 10, 1 );

function add_account_orders_column( $columns ){

$columns['item_subtotal_tax_excl'] = __( 'Sub-total', 'woocommerce' );

return $columns;

}

add_action( 'woocommerce_my_account_my_orders_column_item_subtotal_tax_excl',
'add_account_orders_column_rows' );

function add_account_orders_column_rows( $order ) {

// Example with a custom field

if ( $value = $order->get_subtotal() ) {{

echo esc_html( $value );

}

}
}

Then I used a function to display my-account order tab on any page with a short code . The function I used to be able to display order tab on another page which is:
function woocommerce_orders() {
$user_id = get_current_user_id();
if ($user_id == 0) {
return do_shortcode('[woocommerce_my_account]');
}else{
ob_start();
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');

Now when I display the my-account order tab using the added short code [woocommerce_orders] it displays the default order columns but it does not display my newly added “sub-total” column on the page with the short code [woocommerce_orders]

Any ideas how I can display my newly added “sub-total” column along with all the other my-account order columns when I use the shortcode [woocommerce_orders] ?

  • This topic was modified 6 years, 5 months ago by walter.
  • The forum ‘Virtue Theme’ is closed to new topics and replies.