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

FilterPurpose
veyo_admin_menusAdd or modify entries in the Product Personalizer admin menu.
veyo_product_settingsModify 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_cssAppend or modify custom CSS injected into the designer.
veyo_inline_stylesModify inline style output for the designer shell.
veyo_calculate_custom_priceAdjust the computed personalization price for a design.
veyo_cart_item_dataAdd or modify custom data attached to a cart item.
veyo_order_item_metaAdd or modify order line-item meta saved with a design.
veyop_pricing_componentsReturn 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_fileControl whether a specific addon asset file should load for the current request.
veyop_addon_designer_assetsModify the list of designer JS/CSS assets enqueued for enabled addons.
veyop_export_item_svgModify the SVG fragment generated for a single design item during export.
veyop_export_composed_svgModify the fully composed SVG for a view before rasterization.
veyop_export_format_handlersRegister a custom export format handler (e.g. an embroidery .dst writer).
veyop_design_record_resolveModify how a saved design record is resolved/loaded.
veyop_design_save_dataModify the data payload written when a design is saved.
veyop_designer_calculate_priceLower-level hook into the designer's price calculation, upstream of veyop_pricing_components.
veyop_themes_discoveredModify the list of discovered designer UI themes.
veyop_active_theme_slug / veyop_active_themeOverride which designer theme is active.
veyop_theme_should_load_fileControl whether a specific theme asset file loads.
veyop_theme_designer_assetsModify assets enqueued for the active theme.
veyop_designer_theme_configModify the theme configuration payload sent to the designer.
veyop_addon_trusted_signing_keysAdd public keys that addon package signatures can verify against.
veyop_addon_post_install_errorsLet a security scanner report problems with a newly installed package. Any error restores the previous version.
veyop_api_public_requestMake a portable api/v1 request public. It cannot open the license or addons resources.
veyop_api_read_actionsList the portable api/v1 actions that may answer GET.

Actions

ActionFires
veyo_before_customer_design_viewBefore the customer's design library page renders.
veyo_after_customer_design_viewAfter the customer's design library page renders.
veyo_product_personalizer_menuWhile the admin menu is being built — a lower-level companion to the veyo_admin_menus filter.
veyop_addons_discoveredAfter core finishes scanning plugins/ for addon packages.
veyop_addon_before_include / veyop_addon_after_includeImmediately before/after an enabled addon's server entrypoint is loaded.
veyop_order_item_design_savedAfter a design is attached to an order line item.
veyop_design_savedWhenever a customer design is saved (draft or final).
veyop_theme_before_include / veyop_theme_after_includeImmediately 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.

HookTypeFires
veyop_host_readyActionThe host is fully initialised. $addon->ready($callback) is the short form.
veyop_product_editor_registerFilter or action, by hostThe admin product editor is being built.
veyop_product_config_loadFilterProduct personalization config is loaded.
veyop_product_config_saveActionProduct personalization config is saved.
veyop_storefront_mountActionThe designer is mounting on a storefront product page.
veyop_cart_validateFilterA personalized product is being added to the cart. Return false to refuse it.
veyop_cart_item_enrichFilterA cart line is being built.
veyop_order_createdActionAn order is placed.
veyop_order_status_changedActionAn order's status changes ($orderId, $from, $to).
veyop_order_lines_changedActionLines of a placed order were refunded, returned, or cancelled.
veyop_scheduled_jobActionA 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.