WooCommerce: Displaying Custom Feild value in “Orders” Admin List
-
Hi everyone, thanks in advance for your help. I’m attempting to add the value of a custom product field that I’ve created to a custom column in the WooCommerce “Orders” admin table. I’ve got the column itself setup, and am able to get the value via the individual product/post ID, but haven’t been able to figure out how to get the product ID from each product dynamically to pass into my “get_post_meta()” function to output each relevant value into the “Orders” table. Here’s my code so far:
//Add 'Course Date' column header to 'Orders' page after 'Total' column. function add_order_coursedates_column_header( $columns ) { $new_columns = array(); foreach ( $columns as $column_name => $column_info ) { $new_columns[ $column_name ] = $column_info; if ( 'order_total' === $column_name ) { $new_columns['order_course_dates'] = __( 'Course Dates', 'my-textdomain' ); } } return $new_columns; } add_filter( 'manage_edit-shop_order_columns', 'add_order_coursedates_column_header', 20 ); // Add Course Dates to new column function add_order_coursedates($column_info) { if($column_info == 'order_course_dates') { $the_product_id = '5316'; $date_field = 'wccaf_gLUNQXKdWIcO'; $course_dates = get_post_meta($the_product_id, $date_field, true); echo $course_dates; } } add_action('manage_shop_order_posts_custom_column', 'add_order_coursedates', 99);
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘WooCommerce: Displaying Custom Feild value in “Orders” Admin List’ is closed to new replies.