Last active
June 12, 2017 12:58
-
-
Save vishalck/5c6aa34d7600e3dca221d03bdf588b8e to your computer and use it in GitHub Desktop.
Populate custom order columns with data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'manage_shop_order_posts_custom_column', 'MY_COLUMNS_VALUES_FUNCTION', 2 ); | |
function MY_COLUMNS_VALUES_FUNCTION( $column ) { | |
global $post; | |
$data = get_post_meta( $post->ID ); | |
//start editing, I was saving my fields for the orders as custom post meta | |
//if you did the same, follow this code | |
if ( $column == 'MY_COLUMN_ID_1' ) { | |
echo ( isset( $data[ 'MY_COLUMN_1_POST_META_ID' ] ) ? $data[ 'MY_COLUMN_1_POST_META_ID' ] : '' ); | |
} | |
if ( $column == 'MY_COLUMN_ID_2' ) { | |
echo ( isset( $data[ 'MY_COLUMN_2_POST_META_ID' ] ) ? $data[ 'MY_COLUMN_2_POST_META_ID' ] : '' ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment