A list of some WooCoommerce filter hooks I have found useful while working on a couple of WooCommerce projects. The list is a work in progress.
woocommerce_add_to_cart_fragments
- Use to ajaxify cart counts.
- Location: includes/class-wc-ajax.php
- Example: WooCommerce Docs - Show cart contents / total
- Note: Since WooCommerce 7.8 wc-cart-fragments is only enqueued if you use the Mini Cart widget. If you don’t use the widget, enqueue wc-cart-fragments manually.
woocommerce_breadcrumb_defaults
- Use to modify the breadcrumbs generated for WooCommerce pages
- Examples for breadcrumb filters: WooCommerce Docs - Customize the WooCommerce breadcrumb
woocommerce_breadcrumb_home_url
woocommerce_breadcrumb_main_term
woocommerce_checkout_get_value
- Use to set values for checkout fields.
- Location: includes/class-wc-checkout.php
woocommerce_checkout_fields
woocommerce_enable_order_notes_field
- Return false to remove order notes from checkout page.
woocommerce_endpoint_order-received_title
- Use to modify the title of the order-received page. This filter is one of several instances of the woocommerce_endpoint_$ENDPOINT_title filter.
woocommerce_enqueue_styles
- Return empty array to disable all 3 default WooCommerce styles.
- Location: includes/class-wc-frontend-scripts.php
- Example: WooCommerce Docs - Disable the default stylesheet
woocommerce_post_class
- Use to modify CSS classes returned by
wc_get_product_class()
. Especially useful when combined with the$woocommerce_loop
global. - Location: includes/wc-template-functions.php
- Use to modify CSS classes returned by
woocommerce_price_trim_zeros
- Return true to trim zeros in price decimals.
- Locaton: includes/wc-formatting-fuctions.php
- Example: WooCommerce Docs - Hide trailing zeros on prices
woocommerce_product_add_to_cart_text
- Use to change ADD TO CART text in product archives.
- Example: WooCommerce Docs - Change ADD TO CART button text
woocommerce_product_loop_start
- Use to modify the opening markup (UL) of product loops.
Additionally useful when combined with the
$woocommerce_loop
global. - Location: includes/wc-template-functions.php
- Use to modify the opening markup (UL) of product loops.
Additionally useful when combined with the
woocommerce_product_single_add_to_cart_text
- Use to change ADD TO CART text in single product pages.
- Example: WooCommerce Docs - Change ADD TO CART button text
woocommerce_product_tabs
- Use to add/remove/modify product tabs in product pages.
- Location: templates/single-product/tabs/tabs.php
- Examples: WooCommerce Docs - Editing product data tabs
woocommerce_set_cookie_enabled
- Use to disable specific cookies.
- Location: includes/wc-core-functions.php
woocommerce_short_description
- Use to modify the short description (excerpt) of WooCommerce products.
woocommerce_thankyou_order_received_text
- Use to modify the thank-you text in the order-received page.
Changelog
-
2024-05-22
- Added woocommerce_set_cookie_enabled
-
2024-05-15
- Added four filters: woocommerce_breadcrumb_defaults, woocommerce_breadcrumb_home_url, woocommerce_breadcrumb_main_term, woocommerce_product_loop_start
-
2023-11-30
- Added note to woocommerce_add_to_cart_fragments
- Added two filters: woocommerce_endpoint_order-received_title and woocommerce_thankyou_order_received_text