-
Notifications
You must be signed in to change notification settings - Fork 18
Woo Product Table Hooks: Actions and filters
Hooks in WordPress essentially allow you to change or add code without editing core files. They are used extensively throughout WordPress and WooCommerce and are very useful for developers.
There are two types of hook: actions and filters.
- Action Hooks allow you to insert custom code at various points (wherever the hook is run).
- Filter Hooks allow you to manipulate and return a variable which it passes (for instance a product price).
There are variety of ways to add your custom code to manipulate code by hooks:
- To a custom child theme’s
functions.php
file. - Using a plugin such as Code Snippets.
To execute your own code, you hook in by using the action hook do_action('action_name');
. Here is where to place your code:
add_action( 'action_name', 'your_function_name' );
function your_function_name() {
// Your code
}
Filter hooks are called throughout are code using apply_filter( 'filter_name', $variable );
.To manipulate the passed variable, you can do something like the following:
add_filter( 'filter_name', 'your_function_name' );
function your_function_name( $variable ) {
// Your code
return $variable;
}
With filters, you must return a value.
To learn more about options for using hooks and filters see Snippet doc section.
In the example below, both action hooks and filter hooks are used. This tutorial teaches you how to change and add fields to the checkout.
- Actions are used to:
- Add a new field to the checkout
- Add that new field to the order
- Filters are used to:
- Override the labels and placeholders of existing fields
- Make an existing field optional while it used to be required
- Remove existing fields
For details on what the action hooks and filters do, reference the Woo Product Table Hooks Reference.
Still Need Help? Contact over Support
- wpto_admin_tab_array
- wpto_save_tab_array
- wpto_form_tab_validation_[tab_name]
- wpt_table_show_top
- wpto_column_arr
- wpto_column_settings
- wpto_enabled_column_array
- wpto_thumbs_size
- wpto_table_show
- woocommerce_add_to_cart_validation
- woocommerce_attribute
- woocommerce_loop_add_to_cart_link
- woocommerce_quantity_input_max
- woocommerce_quantity_input_min
- wpo_row_manager_loc
- wpt_action_variation
- wpt_admin_form_top_links
- wpt_menu_capability
- wpt_supported_terms
- wpto_action_start_table
- wpto_action_table_wrapper_top
- wpto_add_to_cart_text
- wpto_add_to_cart_url
- wpto_additional_variable
- wpto_addnew_col_arr
- wpto_admin_tab_file_loc
- wpto_admin_tab_file_loc_{$tab}
- wpto_admin_tab_folder_dir
- wpto_ajax_form_submit
- wpto_before_row
- wpto_blank_centent
- wpto_blank_type_column
- wpto_blank_type_column_{$keyword}
- wpto_checkbox_validation
- wpto_column_bottom
- wpto_column_top
- wpto_column_type
- wpto_configuration_settings
- wpto_curent_deteted_device
- wpto_default_column_arr
- wpto_default_configure
- wpto_default_enable_column_arr
- wpto_default_width_freeze_col
- wpto_defult_file_loc
- wpto_element_bottom
- wpto_element_top
- wpto_extra_items_arr
- wpto_form_tab_validation_{$tab}
- wpto_get_config_value
- wpto_inside_checked_item_arr
- wpto_inside_item_arr
- wpto_inside_item_arr_{$keyword}
- updating__
- updating__
- updating__
- updating__
- updating__