Created
May 25, 2021 14:47
-
-
Save CapWebSolutions/77e3dbbdff9b9001369b4a698a8edc77 to your computer and use it in GitHub Desktop.
Display Tax Status column in WooCommerce Admin
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
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()]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.