Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

custom column admin before price

$
0
0

Replies: 0

Hi, i have a code underneath and try to get this as a column between stock and price but it stil placed after the column price, how get it before price? any help appriciated.

// Add a new column to Admin products list with a custom order
add_filter( 'manage_edit-product_columns', 'visibility_product_column', 10);
function visibility_product_column($columns){
    $new_columns = [];
    foreach( $columns as $key => $column ){
        $new_columns[$key] = $columns[$key];
        if( $key == 'price' ) { // Or use: if( $key == 'featured' ) {
             $new_columns['visibility'] = __( 'Visibility','woocommerce');
        }
    }
    return $new_columns;
}

// Add content to new column raows in Admin products list
add_action( 'manage_product_posts_custom_column', 'visibility_product_column_content', 10, 2 );
function visibility_product_column_content( $column, $product_id ){
    global $post;

    if( $column =='visibility' ){
        if( has_term( 'exclude-from-catalog', 'product_visibility', $product_id ) )
            echo '<em style="color:red;">' . __("No") . '</em>';
        else
            echo '<span style="color:green;">' . __("Yes") . '</span>';
    }
}

Viewing all articles
Browse latest Browse all 59525

Trending Articles