Last active
April 21, 2025 16:57
-
-
Save corsonr/5947181 to your computer and use it in GitHub Desktop.
Show WooCommerce product ID in a custom column on products list page
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
<?php | |
/** | |
* Plugin Name: WooCommerce - Show products IDs | |
* Plugin URI: http://www.remicorson.com/easily-find-woocommerce-products-id/ | |
* Description: Adds a new columns to products list page to display product IDs | |
* Version: 1.0 | |
* Author: Remi Corson | |
* Author URI: http://remicorson.com | |
* Requires at least: 3.5 | |
* Tested up to: 3.5 | |
* | |
* Text Domain: - | |
* Domain Path: - | |
* | |
*/ | |
/* | |
|-------------------------------------------------------------------------- | |
| WooCommerce Product Extra Columns | |
|-------------------------------------------------------------------------- | |
*/ | |
/** | |
* Load Custom Product Columns | |
* | |
* @access public | |
* @since 1.0 | |
* @return | |
*/ | |
function woo_product_extra_columns($columns) | |
{ | |
$newcolumns = array( | |
"cb" => "<input type = \"checkbox\" />", | |
"product_ID" => esc_html__('ID', 'woocommerce'), | |
); | |
$columns = array_merge($newcolumns, $columns); | |
return $columns; | |
} | |
add_filter("manage_edit-product_columns", "woo_product_extra_columns"); | |
/** | |
* Charge Product Columns Content | |
* | |
* @access public | |
* @since 1.0 | |
* @return | |
*/ | |
function woo_product_extra_columns_content($column) | |
{ | |
global $post; | |
$product_id = $post->ID; | |
switch ($column) | |
{ | |
case "product_ID": | |
echo $product_id; | |
break; | |
} | |
} | |
add_action("manage_posts_custom_column", "woo_product_extra_columns_content"); |
I am trying to access the product id from the extension but I am still not able to figure it out. Could you please help me out?
How can I get an downloadable file of this plugin?
Thanks: René.
Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i created few functions to display ID columns for almost all Wordpress tables, and Woocommerce, can i share the code? Maybe there is better/shorter way to make this work?