Advertisement
lorro

WooCommerce - Add column to product list view

Jan 26th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. // add a new menu order column to the product list view
  3. add_filter( 'manage_product_posts_columns', 'custom_product_posts_columns', 99 );
  4. function custom_product_posts_columns( $columns ) {
  5.   $columns['menu_order'] = 'Menu order';
  6.   return $columns;
  7. }
  8. // show the value
  9. add_action( 'manage_product_posts_custom_column' , 'custom_columns', 10, 2 );
  10. function custom_columns( $column_name, $post_id ) {
  11.   switch ( $column_name ) {
  12.     case 'menu_order':
  13.       $product = wc_get_product( $post_id);
  14.       print $product->get_menu_order();      
  15.       break;
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement