Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishalck/5c6aa34d7600e3dca221d03bdf588b8e to your computer and use it in GitHub Desktop.
Save vishalck/5c6aa34d7600e3dca221d03bdf588b8e to your computer and use it in GitHub Desktop.
Populate custom order columns with data
<?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