FlowInterface is the contract every UTB flow must satisfy. It lives in UTB\ProductBuilder\Flows and is implemented by AbstractFlow and any custom flow class you create.
Identity methods
get_id(): string
Returns the unique machine identifier for this flow. Used as the _utb_flow_id cart and order item meta key, and as the key in FlowRegistry.
get_name(): string
Returns a human-readable display name shown in the WordPress admin flow selector.
get_description(): string
Returns a short description shown in the admin panel next to the flow name.
get_icon(): string
Returns a Dashicons class name (including the dashicons- prefix) used to represent the flow in the admin UI.
Lifecycle methods
init(): void
Registers all WordPress and WooCommerce hooks needed by this flow. Called once during plugin initialization. AbstractFlow provides a complete implementation; override only when you need to register additional hooks beyond what the base class provides.
applies_to_product(int $product_id): bool
Returns true if this flow is assigned to the given WooCommerce product ID. The base implementation in AbstractFlow delegates to FlowRegistry::get_flow_for_product().
The WooCommerce product ID to check.
Registration methods
get_shortcodes(): array
Returns an associative array mapping shortcode tag names to method names on the flow class. AbstractFlow::init() iterates this array and calls add_shortcode() for each entry.
| Return value | Description |
|---|---|
array<string, string> | Keys are shortcode tags; values are method names on $this. |
get_ajax_endpoints(): array
Returns an associative array mapping WordPress AJAX action names to method names on the flow class. AbstractFlow::init() registers each entry for both wp_ajax_{action} and wp_ajax_nopriv_{action}, making all endpoints available to authenticated and unauthenticated users.
| Return value | Description |
|---|---|
array<string, string> | Keys are AJAX action names; values are method names on $this. |
Cart integration methods
validate_cart_data(array $post_data)
Validates the form submission before the product is added to the cart. Called by AbstractFlow::validate_add_to_cart() which is hooked to woocommerce_add_to_cart_validation.
The raw
$_POST data submitted with the add-to-cart request.true if validation passes; a string containing an error message if validation fails. The error string is passed to wc_add_notice() and displayed to the user.
prepare_cart_metadata(array $post_data): array
Builds the metadata array that will be merged into the cart item data and eventually saved as WooCommerce order item meta. Called by AbstractFlow::add_cart_item_data_filter() which is hooked to woocommerce_add_cart_item_data.
The base class automatically appends _utb_unique_key (to prevent cart item merging) and _utb_flow_id.
The raw
$_POST data from the add-to-cart request._utb_ are automatically persisted to order item meta by AbstractFlow::save_order_item_meta().
calculate_dynamic_price(array $cart_item_data): ?float
Returns a dynamic price for a cart item. Called by AbstractFlow::apply_dynamic_pricing() which is hooked to woocommerce_before_calculate_totals. Return null to leave the product’s configured price unchanged.
The full WooCommerce cart item array, including all metadata keys set by
prepare_cart_metadata().float price in the store’s base currency, or null to skip dynamic pricing for this item.