WooCommerce Hooks Reference
Developer documentation for customizing BuddyX Pro’s WooCommerce integration.
Filter Hooks
Section titled “Filter Hooks”buddyx_off_canvas_filter_button_output
Section titled “buddyx_off_canvas_filter_button_output”Customize the off-canvas filter button HTML output.
add_filter( 'buddyx_off_canvas_filter_button_output', 'my_custom_filter_button' );
function my_custom_filter_button( $output ) { return '<button class="my-custom-filter-btn"> <i class="fas fa-filter"></i> Filter Products </button>';}Parameters:
$output(string) - Default button HTML
Return: String - Modified button HTML
woocommerce_add_to_cart_fragments
Section titled “woocommerce_add_to_cart_fragments”BuddyX Pro uses this WooCommerce filter to update cart elements via AJAX.
add_filter( 'woocommerce_add_to_cart_fragments', 'my_custom_fragments' );
function my_custom_fragments( $fragments ) { // Add custom fragment $fragments['.my-custom-cart-element'] = '<div class="my-custom-cart-element">' . WC()->cart->get_cart_contents_count() . ' items</div>';
return $fragments;}Theme-registered fragments:
.menu-icons-wrapper .cart a- Header cart icon with count.buddyx-mini-cart- Mini cart contents.buddyx-cart-count- Cart item count.buddyx-cart-contents- Cart summary text
woocommerce_sale_flash
Section titled “woocommerce_sale_flash”Customize the sale badge output when percentage display is enabled.
add_filter( 'woocommerce_sale_flash', 'my_sale_badge', 10, 3 );
function my_sale_badge( $badge, $post, $product ) { // Custom sale badge with different styling return '<span class="my-sale-badge">SALE!</span>';}Note: Theme only modifies this when buddyx_woo_sale_badge_content is set to ‘percent’.
post_class
Section titled “post_class”BuddyX Pro adds WooCommerce-specific classes to products.
add_filter( 'post_class', 'my_product_classes', 50, 3 );
function my_product_classes( $classes, $class, $post_id ) { if ( ! function_exists( 'wc_get_product' ) ) { return $classes; }
$product = wc_get_product( $post_id ); if ( ! $product ) { return $classes; }
// Add custom class for products on sale if ( $product->is_on_sale() ) { $classes[] = 'my-custom-sale-class'; }
return $classes;}Theme-added classes:
square-sale- When sale badge style is squarecircle-sale- When sale badge style is circleleft-position- When sale badge position is left
loop_shop_per_page
Section titled “loop_shop_per_page”Control products displayed per page.
add_filter( 'loop_shop_per_page', 'my_products_per_page', 30 );
function my_products_per_page( $count ) { // Show 24 products per page return 24;}Note: Theme sets this based on buddyx_woo_product_per_page customizer setting.
Action Hooks
Section titled “Action Hooks”woocommerce_before_shop_loop
Section titled “woocommerce_before_shop_loop”BuddyX Pro adds the filter button here (priority 10).
// Add custom element before shop loopadd_action( 'woocommerce_before_shop_loop', 'my_shop_intro', 5 );
function my_shop_intro() { if ( is_shop() ) { echo '<div class="shop-intro">Welcome to our shop!</div>'; }}woocommerce_after_cart_form
Section titled “woocommerce_after_cart_form”Cross-sell products are moved here from their default location.
// Add custom content after cartadd_action( 'woocommerce_after_cart_form', 'my_cart_message', 5 );
function my_cart_message() { echo '<div class="cart-message">Free shipping on orders over $50!</div>';}wp_footer
Section titled “wp_footer”Theme adds quantity button scripts here.
// Add custom WooCommerce scriptsadd_action( 'wp_footer', 'my_woo_scripts', 20 );
function my_woo_scripts() { if ( ! is_woocommerce() && ! is_cart() ) { return; } ?> <script> // Custom WooCommerce JavaScript jQuery(document).ready(function($) { // Your code here }); </script> <?php}Theme Functions
Section titled “Theme Functions”buddyx_render_cart_icon()
Section titled “buddyx_render_cart_icon()”Renders the shopping cart icon with item count.
// Use in custom templateif ( function_exists( 'buddyx_render_cart_icon' ) ) { buddyx_render_cart_icon();}Output:
<div class="cart cart-widget-opener"> <a href="[cart_url]" title="View Shopping Cart"> <span class="fas fa-shopping-cart"></span> <sup>3</sup> </a></div>buddyx_cart_widget_side()
Section titled “buddyx_cart_widget_side()”Outputs the mini cart sidebar widget.
// Use in custom templateif ( function_exists( 'buddyx_cart_widget_side' ) ) { buddyx_cart_widget_side();}buddyx_filters_widget_side()
Section titled “buddyx_filters_widget_side()”Outputs the off-canvas filter sidebar.
// Use in custom templateif ( function_exists( 'buddyx_filters_widget_side' ) ) { buddyx_filters_widget_side();}buddyx_is_woo_shop()
Section titled “buddyx_is_woo_shop()”Check if current page is the WooCommerce shop page.
if ( buddyx_is_woo_shop() ) { // We're on the shop page}Returns: Boolean
buddyx_is_woo_tax()
Section titled “buddyx_is_woo_tax()”Check if current page is a WooCommerce taxonomy archive.
if ( buddyx_is_woo_tax() ) { // We're on a product category/tag page}Returns: Boolean
Customizer Settings
Section titled “Customizer Settings”Getting Customizer Values
Section titled “Getting Customizer Values”// Sale badge style$sale_style = get_theme_mod( 'buddyx_woo_sale_badge_style', 'default' );
// Sale badge position$sale_position = get_theme_mod( 'buddyx_woo_sale_badge_position', 'right' );
// Sale badge content type$sale_content = get_theme_mod( 'buddyx_woo_sale_badge_content', 'text' );
// Product style$product_style = get_theme_mod( 'woocommerce_product_style', 'default' );
// Show sorting dropdown$show_sort = get_theme_mod( 'buddyx_woo_shop_sort', true );
// Show result count$show_count = get_theme_mod( 'buddyx_woo_shop_result_count', true );
// Products per page$per_page = get_theme_mod( 'buddyx_woo_product_per_page', 16 );
// Off canvas filter enabled$filter_enabled = get_theme_mod( 'buddyx_woo_off_canvas_filter', false );
// Filter button text$filter_text = get_theme_mod( 'buddyx_woo_off_canvas_filter_text', 'Filter' );Removing Theme Modifications
Section titled “Removing Theme Modifications”Restore WooCommerce Breadcrumbs
Section titled “Restore WooCommerce Breadcrumbs”add_action( 'init', function() { add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );}, 15 );Restore Default Sidebar
Section titled “Restore Default Sidebar”add_action( 'init', function() { add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );}, 15 );Restore Cross-Sells Location
Section titled “Restore Cross-Sells Location”add_action( 'init', function() { remove_action( 'woocommerce_after_cart_form', 'woocommerce_cross_sell_display', 10 ); add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );}, 15 );Restore Default Sort/Count
Section titled “Restore Default Sort/Count”add_action( 'init', function() { add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );}, 15 );CSS Classes
Section titled “CSS Classes”Sale Badge Classes
Section titled “Sale Badge Classes”| Class | Applied When |
|---|---|
.onsale |
Default WooCommerce sale badge |
.square-sale |
Sale badge style is “Square” |
.circle-sale |
Sale badge style is “Circle” |
.left-position |
Sale badge position is “Left” |
Cart Classes
Section titled “Cart Classes”| Class | Element |
|---|---|
.cart-widget-opener |
Cart icon container |
.buddyx-cart-widget-side |
Mini cart sidebar |
.buddyx-mini-cart |
Mini cart contents |
.buddyx-cart-count |
Cart count badge |
.buddyx-cart-contents |
Cart summary |
Filter Classes
Section titled “Filter Classes”| Class | Element |
|---|---|
.buddyx-woo-canvas-filter |
Filter button |
.buddyx-filter-widget-side |
Filter sidebar |
.woo-off-canvas-sidebar |
Filter sidebar content |
Shop Classes
Section titled “Shop Classes”| Class | Applied When |
|---|---|
.infinite-loader-active |
Infinite Loader plugin is active |
JavaScript Events
Section titled “JavaScript Events”Mini Cart Open/Close
Section titled “Mini Cart Open/Close”jQuery(document).ready(function($) { // Cart widget opened $(document).on('click', '.cart-widget-opener', function(e) { console.log('Mini cart opened'); });
// Cart widget closed $(document).on('click', '.widget-close', function(e) { console.log('Mini cart closed'); });});Quantity Button Events
Section titled “Quantity Button Events”jQuery(document).ready(function($) { // Quantity changed via +/- buttons $(document.body).on('click', '.plus, .minus', function() { console.log('Quantity changed'); });});Related Documentation
Section titled “Related Documentation”- README - Technical overview
- Customer Guide - Setup instructions
- Developer Hooks - All theme hooks

