-1

How to Display additional custom column in woocommerce products listing page:

saif
  • 1
  • 2
  • 1
    Welcome to Stack Overflow _ I just Googled **custom column in woocommerce** & got back 2mill+ search results, including many as Stack Overflow answers. This is just one example but even if it doesn't work for your specific case I still think it would be a good idea if you took a minute to carry out a similar search >>> https://stackoverflow.com/questions/52684073/add-custom-column-product-visibility-to-admin-product-list-in-woocommerce-3 – inputforcolor Nov 17 '19 at 10:55
  • Does this answer your question? [Get custom product attributes in Woocommerce](https://stackoverflow.com/questions/13374883/get-custom-product-attributes-in-woocommerce) – Demi-Lune Nov 17 '19 at 12:16

1 Answers1

0

Here is the solution:

// ADDING A CUSTOM COLUMN TITLE TO ADMIN PRODUCTS LIST

add_filter( 'manage_edit-product_columns', 'custom_product_column',11);

function custom_product_column($columns)

{

//add columns

$columns['cost'] = __( 'cost','woocommerce'); // title

return $columns;

}

// ADDING THE DATA FOR EACH PRODUCTS BY COLUMN (EXAMPLE)

add_action( 'manage_product_posts_custom_column' , 'custom_product_list_column_content', 10, 2 );

function custom_product_list_column_content( $column, $product_id )

{

global $post;

// HERE get the data from your custom field (set the correct meta key below)

$cost_price = get_post_meta( $product_id, '_cost_price', true );

switch ( $column )

{

case 'cost' :

echo $cost_price; // display the data

break;

}

}

Use the above code and change the name of the column with your column name and paste it in function.php file

screenshot

saif
  • 1
  • 2