• 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 2 replies - 1 through 2 (of 2 total)
  • laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @winock

    Thanks for reaching out.

    As this requires more development-oriented knowledge, I’ll go ahead and leave this thread open for a while in case anyone else wants to chime in. However, in the meantime, I can also recommend the following resources for more development-oriented questions:

    – WooCommerce Slack Community: https://woocommerce.com/community-slack/
    – Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Cheers.

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Howdy,

    This thread has been inactive for a bit, so I’m going to mark it as Resolved now for the overall health of the forums. Please feel free check out the resources listed above for further help!

    Also, if you’re interested in hiring someone to review your code, I can also recommend the following experts: https://woocommerce.com/customizations/

    Hope this helps! Cheers 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘custom column admin before price’ is closed to new replies.