WOOT - WooCommerce Active Products Tables

woot_profile_extend

This hook allows to extend tables columns or change already existed ones.

Examples:

//lets add button to the table with contact form in iframe. Contact form provided by another pl.
add_action('woot_profile_extend', function($profile, $action_name) {

    if ($action_name === 'woot_woocommerce_tables') {
        $profile['ask_me'] = [
            'title' => esc_html('Ask Me', 'woocommerce-products-tables'),
            'order' => FALSE,
            'action' => function($post_id) {
                return WOOT_HELPER::draw_html_item('a', [
                            'href' => 'javascript: new Popup23({iframe:"https://dev.products-tables.com/contact/", allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"});void(0);',
                            'class' => 'woot-btn'
                                ], esc_html('Ask Me', 'woocommerce-products-tables'));
            }
        ];
    }

    return $profile;
}, 10, 2);

 

//answer to: - how to [woot_upsells] add meta value?? [woot_upsells id=49 columns='id,title,price,hmeta_1,cart']
add_action('woot_profile_extend', function($profile, $action_name) {

    $profile['hmeta_1'] = [
        'title' => esc_html('Meta 1 by hands', 'woocommerce-products-tables'),
        'order' => 'asc',
        'display' => false, //display in fields list in the settings
        'action' => function($post_id) {
            return get_post_meta($post_id, 'meta_1', true);
        }
    ];

    return $profile;
}, 10, 2);

 

//changing already existed column on_sale
add_action('woot_profile_extend', function($profile, $action_name) {

    if ($action_name === 'woot_woocommerce_tables') {
        $profile['on_sale']['action'] = function($post_id) {
            $product = WOOT_WooCommerce::get_product($post_id);
            if (is_object($product)) {
                return $product->is_on_sale() ? "<span class=''>Yes</span>" : "<span class='woot-html-cross2'>No</span>";
            }
        };
    }

    return $profile;
}, 10, 2);

 

//lets add refferal button to the table
add_action('woot_profile_extend', function($profile, $action_name) {

    if ($action_name === 'woot_woocommerce_tables') {
        $profile['refferals'] = [
            'title' => 'Refferal btn',
            'order' => FALSE,
            'action' => function($post_id) {
                $refferal = 'demo';
                $link_data = WOOT_HELPER::get_link_data();

                if (isset($link_data['woot_refferal'])) {
                    $refferal = $link_data['woot_refferal'];
                }

                return WOOT_HELPER::draw_html_item('a', [
                            'href' => "https://demo.products-tables.com?ref={$refferal}&product_id={$post_id}",
                            'class' => 'woot-btn',
                            'target' => '_blank'
                                ], 'Get it for free');
            }
        ];
    }

    return $profile;
}, 10, 2);

Make your attention to link param ‘woot_refferal‘, using prefix ‘woot_‘ it is possible to transmit different data, for example ‘woot_id=77&woot_any_param=asdfgh