WOOT - WooCommerce Active Products Tables

How to add column with custom meta fields in popup

Example of such column you can see on this page: https://demo.products-tables.com/audio-referrals/

Do next:

  • Open file functions.php of the current WordPress theme
  • Add next code:
    add_action('woot_profile_extend', function($profile, $action_name) {
    
        if ($action_name === 'woot_woocommerce_tables') {
         
            //for https://demo.products-tables.com/audio-referrals/
            $profile['sound_options'] = [
                'title' => esc_html('Sound options', 'woocommerce-products-tables'),
                'order' => FALSE,
                'action' => function($post_id) {
                    return do_shortcode("[woot_single_btn id={$post_id} button_text='Options' columns='sound_bitrate,sound_duration,sound_year,sound_artist,sound_info' css_class='woot-btn' help_title='How to add column Options' help_link='https://products-tables.com/how-to-add-column-with-custom-meta-fields-in-popup/']");
                }
            ];
        }
    
        return $profile;
    }, 10, 2);
    
  • Register necessary metafields in WOOT system by code:
    //add custom meta fields not visible on WOOT admin page to select it in sound options
    add_action('woot_profile_extend', function($profile, $action_name) {
    
        $sound_keys = [
            'sound_bitrate' => 'Bitrate (kbps)',
            'sound_duration' => 'Duration',
            'sound_year' => 'Year',
            'sound_artist' => 'Artist',
            'sound_info' => 'Info',
        ];
    
        foreach ($sound_keys as $key => $title) {
            $profile[$key] = [
                'title' => $title,
                'order' => 'asc',
                'display' => false, //do not display in fields list on WOOT backend
                'action' => function($post_id) use($key) {
                    return get_post_meta($post_id, $key, true);
                }
            ];
        }
    
        return $profile;
    }, 10, 2);
    
  • In the table for where you want to display column “Options” create new column, name it and select field ‘Sound options

In such way you can create popups for any kinds of your shop products.