My intention is to display the coupons used in an order, in a custom column in the order table of WooCommerce "My Account".
Image of table on site:
My code attempt:
add_filter( 'woocommerce_account_orders_columns',
'add_coupon_codes_column');
function add_coupon_codes_column( $columns ){
$new_columns = [
"order-number" => $columns["order-number"],
// ...
"coupon-codes" => __( 'Code', '' ),
// ...
"order-actions" => $columns["order-actions"]
];
return $new_columns;
}
add_action( 'woocommerce_my_account_my_orders_column_coupon_codes',
'add_coupon_codes_content' );
function add_coupon_codes_content($order) {
echo esc_html($order->get_coupon_codes());
}
Which is based on Add a custom column with meta data to My Account Orders table in Woocommerce 3+ answer code.
I can create the column just fine, but unfortunately the desired data does not appear. Someone who can assist me with this?