Skip to content

Hooks & Filters

ProductBay provides an extensive set of WordPress action hooks and filters, enabling developers to extend, customize, and integrate with the plugin without modifying its core source files.

Since v1.0.0

All hooks listed on this page were introduced in ProductBay 1.0.0, unless the hook notes a later version.

Hook Naming Convention

All hooks are prefixed with productbay_ to avoid collisions:

  • Actions — Use do_action( 'productbay_*' )
  • Filters — Use apply_filters( 'productbay_*' )

Core

Hooks fired during the plugin lifecycle.

productbay_loaded

Fires after all free plugin components are initialized. This is the primary hook for add-on plugins to bootstrap themselves.

TypeAction
Parameters$plugin (Plugin) — The main plugin instance
Fileapp/Core/Plugin.php
php
add_action( 'productbay_loaded', function( $plugin ) {
    // Your add-on logic here
} );

productbay_admin_capability

Filters the capability required to reach the ProductBay admin screens and REST routes. Use it to delegate table management to a restricted role instead of full administrators.

TypeFilter
Parameters$capability (string) — defaults to manage_options
Returnsstring — A WordPress capability
Fileapp/Core/Constants.php
Since1.3.1
php
add_filter( 'productbay_admin_capability', function() {
    return 'edit_products';
} );

productbay_admin_init

Fires after the admin component is set up (inside is_admin() context only).

TypeAction
Parameters$admin (Admin) — The admin instance
Fileapp/Core/Plugin.php

Data Layer

Hooks around table CRUD operations in TableRepository.

productbay_before_save_table

Filters table data before it is persisted.

TypeFilter
Parameters$data (array), $id (int)
Returnsarray — Modified table data
Fileapp/Data/TableRepository.php
php
add_filter( 'productbay_before_save_table', function( $data, $id ) {
    // Validate or modify data before save
    return $data;
}, 10, 2 );

productbay_after_save_table

Fires after a table is successfully saved.

TypeAction
Parameters$post_id (int), $data (array)
Fileapp/Data/TableRepository.php

productbay_after_delete_table

Fires after a table is deleted.

TypeAction
Parameters$id (int) — The deleted post ID
Fileapp/Data/TableRepository.php

productbay_table_data

Filters the formatted table data returned by the repository.

TypeFilter
Parameters$table_data (array), $post (WP_Post)
Returnsarray — Modified table data
Fileapp/Data/TableRepository.php
php
add_filter( 'productbay_table_data', function( $data, $post ) {
    $data['my_pro_field'] = get_post_meta( $post->ID, '_my_pro_meta', true );
    return $data;
}, 10, 2 );

API Layer

Hooks for extending the REST API and settings.

productbay_register_routes

Fires after all core REST routes are registered. Use this to register additional endpoints.

TypeAction
Parameters$router (Router) — The router instance
Fileapp/Http/Router.php
php
add_action( 'productbay_register_routes', function( $router ) {
    register_rest_route( 'productbay/v1', '/my-endpoint', [ /* ... */ ] );
} );

productbay_default_settings

Filters the default plugin settings array.

TypeFilter
Parameters$defaults (array)
Returnsarray — Modified defaults
Fileapp/Api/SettingsController.php

productbay_get_settings

Filters settings before they are returned to the frontend.

TypeFilter
Parameters$settings (array)
Returnsarray — Modified settings
Fileapp/Api/SettingsController.php

productbay_settings_updated

Fires after settings are saved.

TypeAction
Parameters$settings (array) — The saved settings
Fileapp/Api/SettingsController.php

productbay_system_status

Filters the system status data (used by the Dashboard).

TypeFilter
Parameters$status (array)
Returnsarray — Modified status data
Fileapp/Api/SystemController.php
php
add_filter( 'productbay_system_status', function( $status ) {
    $status['pro_license'] = 'active';
    return $status;
} );

Frontend Rendering

The most critical layer for extending table output. All hooks are in TableRenderer.php unless noted otherwise.

productbay_query_args

Filters WP_Query arguments before the product query executes.

TypeFilter
Parameters$args (array), $source (array), $settings (array)
Returnsarray — Modified query args
Fileapp/Frontend/TableRenderer.php
php
add_filter( 'productbay_query_args', function( $args, $source, $settings ) {
    // Example: only show featured products
    $args['tax_query'][] = [
        'taxonomy' => 'product_visibility',
        'field'    => 'name',
        'terms'    => 'featured',
    ];
    return $args;
}, 10, 3 );

productbay_table_columns

Filters the columns array before rendering.

TypeFilter
Parameters$columns (array), $table_id (int)
Returnsarray — Modified columns

productbay_cell_output

Filters a single cell's HTML output.

TypeFilter
Parameters$cell_html (string), $col (array), $product (WC_Product)
Returnsstring — Modified HTML
php
add_filter( 'productbay_cell_output', function( $html, $col, $product ) {
    if ( $col['type'] === 'my_custom_type' ) {
        return '<span>' . esc_html( $product->get_attribute('brand') ) . '</span>';
    }
    return $html;
}, 10, 3 );

productbay_table_output

Filters the complete table HTML before it is returned.

TypeFilter
Parameters$html (string), $table (array)
Returnsstring — Modified HTML

productbay_table_styles

Filters the generated scoped CSS for a table.

TypeFilter
Parameters$css (string), $table (array)
Returnsstring — Modified CSS

Button & toggle text filters

Four filters override the customer-facing labels on a table's action controls. Each receives an empty string plus the table's resolved cart settings, so returning a non-empty string wins. Returning '' falls through to the global Cart Customization setting, and then to the built-in translatable default.

These are the seam ProductBay Pro uses to implement per-table custom text; a filter added at the default priority will run alongside it, so use a later priority if you need to override Pro.

FilterDefault labelSince
productbay_add_to_cart_textWooCommerce's add-to-cart text1.3.2
productbay_select_options_text"Select Options" / "View Products"1.3.2
productbay_bulk_list_text"Add to bulk list"1.3.4
productbay_bulk_list_added_text"Added"1.3.4
TypeFilter
Parameters$text (string) — empty by default, $cart_settings (array) — the table's resolved cart settings
Returnsstring — The label to render, or '' to fall back
php
// Call the bulk list an "order sheet" on every table.
add_filter( 'productbay_bulk_list_text', function( $text, $cart_settings ) {
    return __( 'Add to order sheet', 'my-textdomain' );
}, 10, 2 );

add_filter( 'productbay_bulk_list_added_text', function( $text, $cart_settings ) {
    return __( 'On sheet', 'my-textdomain' );
}, 10, 2 );

TIP

The bulk-list labels are always rendered — they give the select checkbox its accessible name on desktop, and become the visible toggle button on stacked mobile cards.

productbay_filter_options

Filters the choices offered by the category and product type dropdowns above a table.

Options are resolved from the table's own base product set — the source scope, ignoring the visitor's current selection — so the dropdowns never offer a value that would render an empty table. Use this filter to add a choice back (for example a category the table does not contain yet but soon will) or to drop one.

TypeFilter
Parameters$options (array), $source (array), $settings (array), $table_id (int)
Returnsarrayproduct_cat as a list of ['slug' => …, 'name' => …], product_type as a map of slug => label
php
add_filter( 'productbay_filter_options', function( $options, $source, $settings, $table_id ) {
    // Always offer the Clearance category, even while it is empty.
    $options['product_cat'][] = array( 'slug' => 'clearance', 'name' => __( 'Clearance', 'my-textdomain' ) );
    return $options;
}, 10, 4 );

productbay_filter_options_cache_ttl

Filters how long resolved filter choices stay cached, in seconds. Resolving them costs one ID-only product query plus two term queries, so the result is cached per table; the cache key carries a hash of the resolved query args, so editing a table's source takes effect immediately, while catalog changes are picked up when the transient expires.

Return 0 to disable caching — useful on a store whose product categories change constantly.

TypeFilter
Parameters$ttl (int) — default 12 * HOUR_IN_SECONDS, $table_id (int)
Returnsint — Lifetime in seconds, or 0 to skip caching

productbay_render_filters

Action fired inside the filter bar, after the built-in category and product type dropdowns and before the Clear button. This is where add-ons inject their own filter controls — Pro's price range filter uses it.

TypeAction
Parameters$settings (array), $source (array)
Fileapp/Frontend/TableRenderer.php

productbay_before_table / productbay_after_table

Actions fired before and after the table wrapper <div>.

TypeAction
Parameters$table (array)

productbay_before_row / productbay_after_row

Actions fired before and after each product row <tr>.

TypeAction
Parameters$product (WC_Product), $table (array)

productbay_toolbar_start / productbay_toolbar_end

Actions to inject content at the start or end of the toolbar area (above the table, where search and bulk actions live).

TypeAction
Parameters$table (array)

Frontend AJAX

Hooks for AJAX operations in AjaxRenderer.php.

productbay_ajax_filter_response

Filters the AJAX response for table filtering/search/pagination.

TypeFilter
Parameters$response (array), $table (array)
Returnsarray — Modified response

productbay_after_bulk_add_to_cart

Fires after a bulk add-to-cart operation completes.

TypeAction
Parameters$added_count (int), $errors (array)

Shortcode

Hooks in Shortcode.php.

productbay_shortcode_atts

Filters the parsed shortcode attributes.

TypeFilter
Parameters$atts (array)
Returnsarray — Modified attributes

productbay_enqueue_frontend_assets

Action to enqueue additional frontend assets when a ProductBay shortcode is rendered.

TypeAction
Parameters(none)

Blocks & Preview

productbay_block_editor_css_paths

Filters the CSS files injected into the block editor's iframe, so a table rendered inside the editor looks like it does on the storefront. Return absolute filesystem paths, not URLs.

TypeFilter
Parameters$paths (string[]) — absolute paths, defaults to the plugin's frontend.css and block-tabs.css
Returnsstring[]
Fileapp/Blocks/BlockManager.php
Since1.1.0
php
add_filter( 'productbay_block_editor_css_paths', function( $paths ) {
    $paths[] = MY_ADDON_PATH . 'assets/css/my-addon-frontend.css';
    return $paths;
} );

productbay_preview_css_urls

Filters the stylesheet URLs loaded inside the admin live-preview iframe. The block editor equivalent above takes paths; this one takes URLs.

TypeFilter
Parameters$css_urls (array) — defaults to the plugin's frontend.css
Returnsarray
Fileapp/Api/PreviewController.php

Activity Log

productbay_log_created

Fires after an entry has been appended to the activity log. Useful for mirroring ProductBay events into an external audit trail.

TypeAction
Parameters$entry (array) — the log entry that was written
Fileapp/Data/ActivityLog.php
Since1.2.0

productbay_log_retention_days

Filters how many days of log files are kept before the daily prune deletes them. The unfiltered value comes from the log_retention plugin setting.

TypeFilter
Parameters$retention_days (int)
Returnsint — Number of days to keep
Fileapp/Data/ActivityLog.php
Since1.2.0

Admin

Hooks in Admin.php.

productbay_after_register_menu

Fires after all admin menu items are registered.

TypeAction
Parameters(none)

productbay_admin_script_data

Filters the data passed to the React admin app via wp_localize_script.

TypeFilter
Parameters$data (array)
Returnsarray — Modified script data
php
add_filter( 'productbay_admin_script_data', function( $data ) {
    $data['proActive'] = true;
    $data['license']   = 'valid';
    return $data;
} );

productbay_enqueue_admin_assets

Action to enqueue additional admin assets on ProductBay pages.

TypeAction
Parameters(none)

Released under the GPL-2.0+ License.