PHP hooks reference
Server-side extension points for addon bootstrap.php files. Register through VeyopHooks so the same addon code runs on WordPress, OpenCart, PrestaShop, and Shopware.
Registering a hook
<?php
// plugins/my-addon/bootstrap.php
VeyopHooks::addFilter('veyop_pricing_components', function ($components, $context, $lines) {
$components[] = [
'key' => 'my_addon_fee', // required, stable identifier
'label' => 'My Addon Fee', // required
'unit' => 1.50, // required, must be above 0
'qty' => 1, // optional, defaults to 1
'per' => 'unit', // 'unit' (default) or 'line' for a one-off fee
];
return $components;
}, 10, 3);
VeyopHooks::addAction('veyop_design_saved', function ($design, $context) {
// e.g. write an audit log entry
});
Use VeyopHooks in any addon code that should run on every platform. On WordPress these hooks are also bridged to add_filter / add_action, so a theme or site plugin can use them, but those functions do not exist on OpenCart, PrestaShop, or Shopware.
A few older names are kept as aliases of their current hook: veyo_cart_item_data for veyop_cart_item_data, veyo_calculate_custom_price for veyop_calculate_custom_price, and veyo_product_personalizer_product_set_attribute for veyop_product_set_attribute. Register your own with VeyopHooks::registerAlias($canonical, $alias).
Filters
| Filter | Purpose |
|---|---|
veyo_admin_menus | Add or modify entries in the Product Personalizer admin menu. |
veyo_product_settings | Modify the designer config payload sent to the front-end Vue app for a product. veyop_designer_config is a separate filter on the same payload and runs after this one. |
veyo_custom_css | Append or modify custom CSS injected into the designer. |
veyo_inline_styles | Modify inline style output for the designer shell. |
veyo_calculate_custom_price | Adjust the computed personalization price for a design. |
veyo_cart_item_data | Add or modify custom data attached to a cart item. |
veyo_order_item_meta | Add or modify order line-item meta saved with a design. |
veyop_pricing_components | Return additional validated pricing line items for a quote. Core owns the final arithmetic — addons only contribute components. A component without a key, a label, and a positive amount is dropped. |
veyop_addon_should_load_file | Control whether a specific addon asset file should load for the current request. |
veyop_addon_designer_assets | Modify the list of designer JS/CSS assets enqueued for enabled addons. |
veyop_export_item_svg | Modify the SVG fragment generated for a single design item during export. |
veyop_export_composed_svg | Modify the fully composed SVG for a view before rasterization. |
veyop_export_format_handlers | Register a custom export format handler (e.g. an embroidery .dst writer). |
veyop_design_record_resolve | Modify how a saved design record is resolved/loaded. |
veyop_design_save_data | Modify the data payload written when a design is saved. |
veyop_designer_calculate_price | Lower-level hook into the designer's price calculation, upstream of veyop_pricing_components. |
veyop_themes_discovered | Modify the list of discovered designer UI themes. |
veyop_active_theme_slug / veyop_active_theme | Override which designer theme is active. |
veyop_theme_should_load_file | Control whether a specific theme asset file loads. |
veyop_theme_designer_assets | Modify assets enqueued for the active theme. |
veyop_designer_theme_config | Modify the theme configuration payload sent to the designer. |
veyop_addon_trusted_signing_keys | Add public keys that addon package signatures can verify against. |
veyop_addon_post_install_errors | Let a security scanner report problems with a newly installed package. Any error restores the previous version. |
veyop_api_public_request | Make a portable api/v1 request public. It cannot open the license or addons resources. |
veyop_api_read_actions | List the portable api/v1 actions that may answer GET. |
Actions
| Action | Fires |
|---|---|
veyo_before_customer_design_view | Before the customer's design library page renders. |
veyo_after_customer_design_view | After the customer's design library page renders. |
veyo_product_personalizer_menu | While the admin menu is being built — a lower-level companion to the veyo_admin_menus filter. |
veyop_addons_discovered | After core finishes scanning plugins/ for addon packages. |
veyop_addon_before_include / veyop_addon_after_include | Immediately before/after an enabled addon's server entrypoint is loaded. |
veyop_order_item_design_saved | After a design is attached to an order line item. |
veyop_design_saved | Whenever a customer design is saved (draft or final). |
veyop_theme_before_include / veyop_theme_after_include | Immediately before/after a designer theme's files load. |
Platform lifecycle
These hooks fire on every platform, so prefer them over a host's own cart or order hooks. Constants are on VeyopLifecycle, for example VeyopLifecycle::ORDER_CREATED.
| Hook | Type | Fires |
|---|---|---|
veyop_host_ready | Action | The host is fully initialised. $addon->ready($callback) is the short form. |
veyop_product_editor_register | Filter or action, by host | The admin product editor is being built. |
veyop_product_config_load | Filter | Product personalization config is loaded. |
veyop_product_config_save | Action | Product personalization config is saved. |
veyop_storefront_mount | Action | The designer is mounting on a storefront product page. |
veyop_cart_validate | Filter | A personalized product is being added to the cart. Return false to refuse it. |
veyop_cart_item_enrich | Filter | A cart line is being built. |
veyop_order_created | Action | An order is placed. |
veyop_order_status_changed | Action | An order's status changes ($orderId, $from, $to). |
veyop_order_lines_changed | Action | Lines of a placed order were refunded, returned, or cancelled. |
veyop_scheduled_job | Action | A scheduled job runs ($hook, $args). |
Addon lifecycle
Core fires veyop_addon_activate, veyop_addon_deactivate, veyop_addon_upgrade, and veyop_addon_uninstall after it loads the addon's server entrypoint. Each receives the addon's $plugin record. Only uninstall runs the code of an addon that is not currently loaded, so it can clean up its data.
REST route registration
Register portable routes with $addon->route(), which works on every platform. WordPress-specific routes can use rest_api_init and register_rest_route(), which do not run anywhere else. See REST API reference.