Created
October 18, 2016 20:02
-
-
Save juniorthiesen/00d659117af48c0cbd25a3c376059c1c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Add custom column (Custo) to shop_order post type | |
*/ | |
function add_custom_column_to_wc_orders_list($columns){ | |
$new_columns = (is_array($columns)) ? $columns : array(); | |
$new_columns['wc_cog_order_total_cost'] = __('Custo'); | |
return $new_columns; | |
} | |
add_filter('manage_edit-shop_order_columns', 'add_custom_column_to_wc_orders_list'); | |
/** | |
* Add custom value to custom column in shop_order post type | |
* | |
* @return void | |
*/ | |
function add_custom_column_value_to_wc_orders_list($column){ | |
global $post; | |
if($column == 'wc_cog_order_total_cost'){ | |
echo null !== get_post_meta($post->ID, 'wc_cog_order_total_cost', true) ? get_post_meta($post->ID, 'wc_cog_order_total_cost', true) : ''; | |
} | |
} | |
add_action('manage_shop_order_posts_custom_column', 'add_custom_column_value_to_wc_orders_list', 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment