Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php // only copy if needed!
/**
* REQUIRES WC 3.0+
*/
/**
* Adds a new column to the "My Orders" table in the account.
*
* @param string[] $columns the columns in the orders table
* @return string[] updated columns
*/
function sv_wc_add_my_account_orders_column( $columns ) {
$new_columns = array();
foreach ( $columns as $key => $name ) {
$new_columns[ $key ] = $name;
// add ship-to after order status column
if ( 'order-status' === $key ) {
$new_columns['order-ship-to'] = __( 'Ship to', 'textdomain' );
}
}
return $new_columns;
}
add_filter( 'woocommerce_my_account_my_orders_columns', 'sv_wc_add_my_account_orders_column' );
/**
* Adds data to the custom "ship to" column in "My Account > Orders".
*
* @param \WC_Order $order the order object for the row
*/
function sv_wc_my_orders_ship_to_column( $order ) {
$formatted_shipping = $order->get_formatted_shipping_address();
echo ! empty( $formatted_shipping ) ? $formatted_shipping : '&ndash;';
}
add_action( 'woocommerce_my_account_my_orders_column_order-ship-to', 'sv_wc_my_orders_ship_to_column' );
@super4tw

This comment has been minimized.

Copy link

super4tw commented Apr 3, 2019

What to do if you want to display the product name and product quantity ordered by the customer.

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.