Skip to content

Instantly share code, notes, and snippets.

@CapWebSolutions
Created May 25, 2021 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CapWebSolutions/77e3dbbdff9b9001369b4a698a8edc77 to your computer and use it in GitHub Desktop.
Save CapWebSolutions/77e3dbbdff9b9001369b4a698a8edc77 to your computer and use it in GitHub Desktop.
Display Tax Status column in WooCommerce Admin
add_filter( 'manage_edit-product_columns', 'tax_status_product_column');
function tax_status_product_column($columns){
$new_columns = [];
foreach( $columns as $key => $column ){
$new_columns[$key] = $columns[$key];
if( $key == 'is_in_stock' ) {
$new_columns['tax_status'] = __( 'Tax status','woocommerce');
}
}
return $new_columns;
}
add_action( 'manage_product_posts_custom_column', 'tax_status_product_column_content', 10, 2 );
function tax_status_product_column_content( $column, $post_id ){
if( $column == 'tax_status' ){
global $post, $product;
// Excluding variable and grouped products
if( is_a( $product, 'WC_Product' ) ) {
$args = array(
'taxable' => __( 'Taxable', 'woocommerce' ),
'shipping' => __( 'Shipping only', 'woocommerce' ),
'none' => _x( 'None', 'Tax status', 'woocommerce' ),
);
echo $args[$product->get_tax_status()];
}
}
}
@CapWebSolutions
Copy link
Author

CapWebSolutions commented May 25, 2021

Ref: https://stackoverflow.com/questions/63133918/display-tax-status-on-woocommerce-admin-product-list
Last tested / works on WooCommerce v5.3.0 on WordPress 5.7.2
Add code to Woo customization area of your core functionality plugin, or in your functions.php file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment