Use hook woot_profile_extend. Example: add next code to file functions.php of the current wordpress theme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | add_action('woot_profile_extend', function($profile, $action_name) { if ($action_name === 'woot_woocommerce_tables') { $meta_key = 'my_global_column';//important! $meta_data = [ 'title' => WOOT_Vocabulary::get('My meta column'), 'meta_key' => $meta_key, 'meta_type' => 'text', //text, number, calendar ]; $profile[$meta_key] = woot()->columns->meta->assemble_meta_for_system($meta_data); } return $profile; }, 10, 2); |
In code replace your meta key in variable $meta_key and change column title (My meta column). Make your attention on metadata types: text number calendar
No! WOOT just gives another products presentation for the shop site. Google make indexation of the site using sitemap. For SEO use special plugins, for example Yoast SEO.
Example is here: https://demo.products-tables.com/shop Do next: Create new table in WOOT admin page Set its columns, options and assemble filter form if it necessary Open file functions.php of the current wordpress theme and paste there next code:
| add_filter('woocommerce_before_shop_loop', function() { echo do_shortcode('[woot_drop_down id=2]'); echo '<br />'; }); |
Use shortcode [woot_button] and attribute ‘filter_provider’, examples: [woot_button filter_provider=’cross_sells’ product_id=49 mode=”to_json”] [woot_button filter_provider=”woot_upsells” product_id=49 mode=”to_json”] [woot_button filter_provider=”woot_related” product_id=49 mode=”to_json”] [woot_button filter_provider=”woot_grouped” product_id=49 mode=”to_json”] [woot_button filter_provider=”woot_variations” product_id=49 mode=”to_json”]
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | //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’ […]
You can see results on the top menu of the site https://demo.products-tables.com/ -> click on ‘Hottest Products’ Do next: Create on WOOT admin page new shortcode [woot] Open settings of the new shortcode -> tab ‘Predefinition’ -> ‘Products ids’ -> Using comma, set products ids you want to show in the table. Example: 23,99,777. Set […]
Yes! If content of the cell is constant – it is possible use generated CSS class as on the screen: hashXXXXXX Also each cell has CSS class, dependent of the field of the current table cell Also table cell has data-attributes: data-pid, data-key, data-field
| td[data-pid="13287"][data-key="price"]{ background: red; } td[data-pid="14281"][data-key="price"] { background: green; } |
As you can see above using 2 data-attributes allows targeted […]
You can wrap some shortcodes into your custom one. Do next: open file functions.php of the current wordpress theme paste and edit there next code:
| add_shortcode('my_woot_1', function($args) { $user = wp_get_current_user(); if (in_array('administrator', $user->roles)) { return do_shortcode('[woot id=23]'); } elseif (in_array('shop_manager', $user->roles)) { return do_shortcode('[woot id=29]'); } else { return do_shortcode('[woot columns="id,title,price,pa_color,add_to_cart"]'); } }); |
paste shortcode [my_woot_1] to page you want also make your attention to $args – you can make custom shortcode attributes On this way you can create different custom shortcodes […]
If to use sorting by meta keys – will be visible only products which has any value for the selected key. This behavior is peculiarity of WordPress engine. Here is an article about how to resolve it: https://wordpress.stackexchange.com/questions/102447/sort-on-meta-value-but-include-posts-that-dont-have-one
Using FULLTEXT indexing will in increase the speed of products searching by its title. Do next: open your site database using phpmyadmin page enter to your site database find table “wp_posts” click on tab “Structure” find field “post_title” find on the right side and click “More” -> “Fulltext” on the popup click OK and wait […]