Bright WooCommerce Integrations Actions And Filters
Bright WooCommerce Integrations — Actions and Filters
This page documents WordPress hooks provided by the Bright WooCommerce integration. Add your custom code in a small custom plugin or your theme’s functions.php.
Requirements: Enable Bright WooCommerce integration under Bright settings. License-related hooks apply when the site creates license keys (single-license or multi-license orders).
Filters
bright_license_key_name
Override the license key name sent to Bright when an order creates license key(s).
When it runs: During license order processing (manageLicenseOrder), for both:
- Single-license orders — one key per order (
createInvitation) - Multi-license orders — one key per seat (
createMultiLicenseInvitations; requires Enforce Multilicense Orders)
Callback signature:
add_filter( 'bright_license_key_name', 'my_bright_license_key_name', 10, 2 );
function my_bright_license_key_name( $override, $context ) {
// $override — value from a previous filter, or null
// $context — array with:
// 'order_id' => (int) WooCommerce order ID
// 'multilicense' => (bool) true for multi-license orders
}
Return a non-empty string to set the name parameter on the Bright API request. Return null or an empty string to use Bright’s default (random word-based names).
Single-license orders
Your callback should return the complete license key string. Bright uses it as-is for the one invitation.
Example — numeric groups (no order prefix):
function my_bright_license_key_name( $override, $context ) {
$digits = 5;
$part = function() use ( $digits ) {
return (string) random_int( pow( 10, $digits - 1 ), pow( 10, $digits ) - 1 );
};
return $part() . '-' . $part() . '-' . $part() . '-' . $part();
// Example: 21051-64391-74916-16898
}
add_filter( 'bright_license_key_name', 'my_bright_license_key_name', 10, 2 );
Example — order number prefix plus numeric suffix (single-license only):
function my_bright_license_key_name( $override, $context ) {
if ( ! empty( $override ) || ! empty( $context['multilicense'] ) ) {
return $override;
}
$order_id = (int) $context['order_id'];
$prefix = str_pad( (string) $order_id, 10, '0', STR_PAD_LEFT );
$suffix = (string) random_int( 1000000000, 9999999999 );
return $prefix . $suffix;
}
add_filter( 'bright_license_key_name', 'my_bright_license_key_name', 10, 2 );
Multi-license orders
Your callback should return a prefix only, not the full key for every seat.
Bright’s server appends a unique suffix to each key so they do not collide:
{your-prefix}-{8 hex chars}-{8 hex chars}
Example with zero-padded order ID 684:
0000000684-a1b2c3d4-e5f67890
Example — shared order prefix for all keys on a multi-license order:
function my_bright_license_key_name( $override, $context ) {
if ( ! empty( $override ) ) {
return $override;
}
$order_id = isset( $context['order_id'] ) ? (int) $context['order_id'] : 0;
if ( $order_id <= 0 ) {
return null;
}
$prefix = str_pad( (string) $order_id, 10, '0', STR_PAD_LEFT );
if ( ! empty( $context['multilicense'] ) ) {
return $prefix; // Bright appends -xxxxxxxx-xxxxxxxx per seat
}
// Single-license: full key (numeric example)
$suffix = (string) random_int( 1000000000, 9999999999 );
return $prefix . $suffix;
}
add_filter( 'bright_license_key_name', 'my_bright_license_key_name', 10, 2 );
Note: With multi-license, you cannot make the entire key numeric-only through this filter alone; the suffix is hexadecimal. Fully numeric multi-license keys would require a Bright server change.
bright_woocommerce_determine_quantity
By default, seats available per course on a license key match the purchased quantity for that course in the order.
Use this filter to replace that logic. The filter may run multiple times while seat counts are accumulated.
Callback signature:
add_filter( 'bright_woocommerce_determine_quantity', 'my_determine_quantity', 10, 2 );
function my_determine_quantity( $quantity, $data ) {
// $quantity — current seat count for the course being updated
// $data — array with 'items' => WooCommerce order line items
return $quantity;
}
Example — use the sum of all line-item quantities in the order for every course:
add_filter( 'bright_woocommerce_determine_quantity', function ( $quantity, $data ) {
$items = \Bright\extractFromArray( $data, 'items', array() );
$total_quantity = 0;
foreach ( $items as $item ) {
$total_quantity += $item->get_quantity();
}
return $total_quantity;
}, 10, 2 );
bright_woocommerce_add_simple_order_details
Override the HTML/text block shown on the customer View order page for completed Bright orders that are not license orders (standard course purchases).
Callback signature:
add_filter( 'bright_woocommerce_add_simple_order_details', 'my_simple_order_details', 10, 1 );
function my_simple_order_details( $text ) {
return $text; // or your custom HTML
}
Configure the default text in Bright → WooCommerce settings → Order details (bright_woocommerce_simple_order_details_text).
bright_woocommerce_license_order_completed_email_text
Override the introductory text row shown above license key details on the order details page and in related license order displays (single- and multi-license).
Callback signature:
add_filter( 'bright_woocommerce_license_order_completed_email_text', 'my_license_intro_text', 10, 1 );
function my_license_intro_text( $text ) {
return $text;
}
Default text comes from Bright → WooCommerce settings (bright_woocommerce_license_order_details_text).
bright_woocommerce_license_key_url
Rewrite the redeem license key URL shown on order details (and used when building redemption links).
Callback signature:
add_filter( 'bright_woocommerce_license_key_url', 'my_license_key_url', 10, 2 );
function my_license_key_url( $url, $license ) {
// $license — license key string
return $url; // or your custom URL
}
bright_woocommerce_license_key_report_url
Rewrite the learners report URL for a license key on order details.
Callback signature:
add_filter( 'bright_woocommerce_license_key_report_url', 'my_license_report_url', 10, 2 );
function my_license_report_url( $url, $license ) {
return $url;
}
Requires a License Key Report page configured in Bright WooCommerce settings.
bright_set_license_field_on_checkout
Replace the function that decides whether checkout creates a single-license or multi-license order (sets order metadata).
Callback signature:
The filter receives the callable name (string) of the default function. Return a different callable to replace it entirely.
add_filter( 'bright_set_license_field_on_checkout', function ( $function_name ) {
return '\MyNamespace\my_set_license_field_on_checkout';
}, 10, 1 );
Default behavior:
- If Enforce Multilicense Orders is on and the cart includes Bright courses → multi-license order.
- Else if Always use license keys is on → single-license order.
- Else if the customer checked the license option on checkout → single-license order.
Your replacement function receives $order_id (integer) and should update order meta accordingly (see bright_set_license_field_on_checkout in the plugin).
bright_wc_license_key_page
Replace the callback that renders the My License Keys WooCommerce account endpoint.
add_filter( 'bright_wc_license_key_page', function ( $function_name ) {
return '\MyNamespace\my_license_key_page';
}, 10, 1 );
The plugin also supports switching to the v2 license key page via the Use v2 license key page setting, which uses this filter internally.
bright_woocommerce_integration_autocomplete_order_default
Control the site default for whether Bright products should move orders to completed automatically when registrations are created.
Callback signature:
add_filter( 'bright_woocommerce_integration_autocomplete_order_default', function ( $default ) {
return true; // or false
}, 10, 1 );
Per-product behavior can still be set with the Bright product meta autocomplete order.
Page content filters (integration page setup)
When Bright creates default WooCommerce pages, page body content can be filtered:
bright_woocommerce_{page_key}_page_content
Examples:
bright_woocommerce_license_key_report_page_contentbright_woocommerce_bright_registration_page_contentbright_woocommerce_certificate_page_content
add_filter( 'bright_woocommerce_bright_registration_page_content', function ( $content ) {
return $content;
}, 10, 1 );
Actions
bright_woocommerce_added_license_key
Fires after Bright successfully creates or reuses license data for an order.
Callback signature:
add_action( 'bright_woocommerce_added_license_key', 'my_after_license_key', 10, 2 );
function my_after_license_key( $wc_order, $license_data ) {
// $wc_order — WC_Order object
// $license_data — single-license: license key string (invitation name)
// multi-license: array/structure stored in order meta
}
Use for notifications, CRM sync, or custom logging. This also runs when an existing license is reused (order note is added; no new API call).
bright_before_purchased_products_shortcode / bright_after_purchased_products_shortcode
Wrap output of the [bright_woocommerce_purchased_products] shortcode (My Courses / purchased products list).
add_action( 'bright_before_purchased_products_shortcode', function () {
// before shortcode output
} );
add_action( 'bright_after_purchased_products_shortcode', function () {
// after shortcode output
} );
Related settings (not hooks)
These options affect license behavior but are configured in Bright → WooCommerce settings, not via filters:
| Setting | Option name |
|---|---|
| Enforce Multilicense Orders | bright_woocommerce_multilicense_enabled |
| Always use license keys | bright_woocommerce_always_use_license_keys |
| Offer license keys at checkout | bright_woocommerce_offer_license_key_at_checkout |
For multi-license administration, see the plugin guide md/multi-license-user-guide.md.
Quick reference
| Hook | Type | Arguments |
|---|---|---|
bright_license_key_name |
filter | $override, $context (order_id, multilicense) |
bright_woocommerce_determine_quantity |
filter | $quantity, $data (items) |
bright_woocommerce_add_simple_order_details |
filter | $text |
bright_woocommerce_license_order_completed_email_text |
filter | $text |
bright_woocommerce_license_key_url |
filter | $url, $license |
bright_woocommerce_license_key_report_url |
filter | $url, $license |
bright_set_license_field_on_checkout |
filter | $callable_name |
bright_wc_license_key_page |
filter | $callable_name |
bright_woocommerce_integration_autocomplete_order_default |
filter | $default (bool) |
bright_woocommerce_{page}_page_content |
filter | $content |
bright_woocommerce_added_license_key |
action | $wc_order, $license_data |
bright_before_purchased_products_shortcode |
action | none |
bright_after_purchased_products_shortcode |
action | none |

