Hello,
I've been searching on this forum (and the WordPress forum) for a solution to my problem and haven't found anything that's helped yet.
My client would like to add a new field to the purchase orders to store some text (a note) we've been able to add this field to the purchase order easily by creating a new piece of metadata for that post type. It shows up and allows us to save the custom note on the post edit page of any Purchase Order in ATUM.
The client would also like this new metadata to show up in the PO table of ATUM, and this is what we're having issues doing. I've read in other threads that the tables in ATUM are generated using the WP core WP_List_Table() class, so we expected this to be an easy fix with a wp filter, but haven't had any success.
I'll share what code we're using in our functions.php to attempt this.
add_action("admin_init", "admin_init");
// Add the new metadata
function admin_init()
{
add_meta_box("tcs-note", "TCS Note", "tcs_note_render_html", "atum_purchase_order", "side", "low");
}
// Display it on the post edit page
function tcs_note_render_html()
{
global $post;
$custom = get_post_custom($post->ID);
$tcs_note = $custom["tcs_note"][0];
?>
<label>TCS Note:</label><input name="tcs_note" value="<?php echo $tcs_note; ?>" />
<?php
}
add_action('save_post', 'save_tcs_note');
// Allow the data to be saved when the post is saved.
function save_tcs_note()
{
global $post;
update_post_meta($post->ID, "tcs_note", $_POST["tcs_note"]);
}
add_filter( 'manage_atum_purchase_order_posts_columns', 'pn_atum_filter_posts_columns' );
// Create the new column.
function pn_atum_filter_posts_columns( $columns )
{
$columns['tcs_note'] = __( 'TCS Note' );
return $columns;
}
add_filter( 'manage_atum_purchase_order_posts_columns', 'pn_atum_purchase_order_columns' );
// Add the new column to the ATUM Table.
function pn_atum_purchase_order_columns( $columns )
{
$columns = array(
'cb' => $columns['cb'],
'atum_order_title' => __( 'PO', ATUM_TEXT_DOMAIN ),
'date_created' => __( 'Created', ATUM_TEXT_DOMAIN ),
'last_modified' => __( 'Last Modified', ATUM_TEXT_DOMAIN ),
'status' => __( 'Status', ATUM_TEXT_DOMAIN ),
'supplier' => __( 'Supplier', ATUM_TEXT_DOMAIN ),
'tcs_note' => 'TCS Note',
'date_expected' => __( 'Date Expected', ATUM_TEXT_DOMAIN ),
'total' => __( 'Total', ATUM_TEXT_DOMAIN ),
'actions' => __( 'Actions', ATUM_TEXT_DOMAIN ),
);
return $columns;
}
We've used similar code elsewhere to achieve the desired result and it's worked, but in this example it isn't, am I missing something? I'm unsure if we're targeting the right filter for adding the column but can't find anything online to point us in the right direction.
Any help with this matter would be greatly appreciated,
Thanking you in advance,
Scottish Dev