What Are Avada WooCommerce Hooks?Avada uses different hooks (actions and filters) that WooCommerce offers to change styling and to extend the functionality of certain components. Any of Avada』s WooCommerce hooks can be replaced with your own, which allows you to override both, WooCommerce and Avada native behaviour.
For more information about the general concept of action and filters in WordPress, please see the links below:
WordPress Plugin API: Actions & FiltersWordPress Plugin Handbook: Hooks,Changing Avada WooCommerce HooksIn general, the WooCommerce hook overrides used by Avada are stored in class-avada-woocommerce.php in the Avada/includes folder. To make the class object available, we have created a global variable for it called $avada_woocommerce. This variable has to be used in order to remvoe any of the hooks that are defined in that class. It is defined in Avada』s functions.php, so will be available once the theme is fully loaded. Thus you have to make sure you use the after_setup_theme WP hook when referencing $avada_woocommerce. The next section will illustrate the correct setup.
Removing Avada WooCommerce HooksThe following example function removes the add_product_border WooCommerce action from Avada. (This would remove the border from the product summary section on a single product page.) Notice, that we create a new function, remove_woocommerce_hooks, so we are able to hook it to WP』s after_setup_theme action. This ensures that we can access the needed $avada_woocommerce variable, which we load using the PHP keyword global. Now we can use that variable in the following removal function.
If you want to remove several hooks, you can add all the removal functions inside the wrapping remove_woocommerce_hooks function.
A list of all available hooks, functions that use them and their corresponding priorities can be found in the list below.
Copy to Clipboardfunction remove_woo_commerce_hooks() {
global $avada_woocommerce;
remove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'add_product_border' ), 19 );
}
add_action( 'after_setup_theme', 'remove_woo_commerce_hooks' ); 1function remove_woo_commerce_hooks() {2 global $avada_woocommerce;3 remove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'add_product_border' ), 19 );4}5add_action( 'after_setup_theme', 'remove_woo_commerce_hooks' );Replacing Avada WooCommerce HooksThe following example function replaces the add_product_border WooCommerce action with add_my_product_border function. Since we consider the case of replacement here, we assume that you have already removed the hooks in question, in the way that was described in the last section. Now, to add your own replacements, you don』t have to use a wrapping function or the global avada_woocommerce variable. You can directly hook your own function to the desired action or filter.
Copy to Clipboardfunction add_my_product_border() {
// your code here
}
add_action( 'woocommerce_single_product_summary', 'add_my_product_border', 19 );xxxxxxxxxx4 1function add_my_product_border() {2 // your code here3}4add_action( 'woocommerce_single_product_summary', 'add_my_product_border', 19 );767,641 Businesses Trust Avada
Get Avada767,641 Businesses Trust Avada
Get Avada767,641 Businesses Trust Avada
Get Avada,Avada WooCommerce HooksAvada WooCommerce ActionsBelow is a list of Avada WooCommerce actions that can be removed or replaced with your own action.
Summary border on a single product page.
Copy to Clipboardremove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'add_product_border' ), 19 );xxxxxxxxxx1 1remove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'add_product_border' ), 19 );Product title on a single product page.
Copy to Clipboardremove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'template_single_title' ), 5 );xxxxxxxxxx1 1remove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'template_single_title' ), 5 );Show details button on a single product page.
Copy to Clipboardremove_action( 'woocommerce_after_shop_loop_item', array( $avada_woocommerce, 'show_details_button' ), 15 );xxxxxxxxxx1 1remove_action( 'woocommerce_after_shop_loop_item', array( $avada_woocommerce, 'show_details_button' ), 15 );Product stock HTML on a single product page.
Copy to Clipboardremove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'stock_html' ), 10 );xxxxxxxxxx1 1remove_action( 'woocommerce_single_product_summary', array( $avada_woocommerce, 'stock_html' ), 10 );Social icons below product description on a single product page.
Copy to Clipboardremove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'after_single_product_summary' ), 15 );xxxxxxxxxx1 1remove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'after_single_product_summary' ), 15 );Related products on a single product page.
Copy to Clipboardremove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'output_related_products' ), 15 );xxxxxxxxxx1 1remove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'output_related_products' ), 15 );Upsell products on a single product page.
Copy to Clipboardremove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'upsell_display' ), 10 );xxxxxxxxxx1 1remove_action( 'woocommerce_after_single_product_summary', array( $avada_woocommerce, 'upsell_display' ), 10 );Sidebar on WooCommerce page.
Copy to Clipboardremove_action( 'woocommerce_sidebar', array( $avada_woocommerce, 'add_sidebar' ), 10 );xxxxxxxxxx1 1remove_action( 'woocommerce_sidebar', array( $avada_woocommerce, 'add_sidebar' ), 10 );Welcome bar to checkout page.
Copy to Clipboardremove_action( 'woocommerce_before_checkout_form', array( $avada_woocommerce, 'avada_top_user_container' ), 1 );xxxxxxxxxx1 1remove_action( 'woocommerce_before_checkout_form', array( $avada_woocommerce, 'avada_top_user_container' ), 1 );Proceed to checkout button.
Copy to Clipboardremove_action( 'woocommerce_proceed_to_checkout', array( $avada_woocommerce, 'proceed_to_checkout' ), 10 );xxxxxxxxxx1 1remove_action( 'woocommerce_proceed_to_checkout', array( $avada_woocommerce, 'proceed_to_checkout' ), 10 );View order form on my account page.
Copy to Clipboardremove_action( 'woocommerce_view_order', array( $avada_woocommerce, 'view_order' ), 10 );xxxxxxxxxx1 1remove_action( 'woocommerce_view_order', array( $avada_woocommerce, 'view_order' ), 10 );Thank you message on my account page.
Copy to Clipboardremove_action( 'woocommerce_thankyou', array( $avada_woocommerce, 'view_order' ) );xxxxxxxxxx1 1remove_action( 'woocommerce_thankyou', array( $avada_woocommerce, 'view_order' ) );
Override Avada WooCommerce Hooks
Override Avada WooCommerce Hooks