daily pastebin goal
92%
SHARE
TWEET

WooCommerce - Add column to product list view

lorro Jan 26th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top