Add product min, max and step quantity columns to admin products list in WooCommerce

add_filter( 'manage_edit-product_columns', 'wpcb_add_product_qty_columns' );
if ( ! function_exists( 'wpcb_add_product_qty_columns' ) ) {
    /**
     * Add qty columns to products list.
     */
    function wpcb_add_product_qty_columns( $columns ) {
        $columns['wpcb_min_qty']  = 'Min Qty';
        $columns['wpcb_max_qty']  = 'Max Qty';
        $columns['wpcb_qty_step'] = 'Qty Step';
        return $columns;
    }
}

add_action( 'manage_product_posts_custom_column', 'wpcb_render_product_qty_columns' );
if ( ! function_exists( 'wpcb_render_product_qty_columns' ) ) {
    /**
     * Output qty columns.
     */
    function wpcb_render_product_qty_columns( $column ) {
        switch ( $column ) {
            case 'wpcb_min_qty':
                echo apply_filters( 'woocommerce_quantity_input_min',  1, wc_get_product() );
                break;
            case 'wpcb_max_qty':
                echo apply_filters( 'woocommerce_quantity_input_max',  1, wc_get_product() );
                break;
            case 'wpcb_qty_step':
                echo apply_filters( 'woocommerce_quantity_input_step', 1, wc_get_product() );
                break;
        }
    }
}

No comments yet.

Leave a Reply