Markus Michalski FAQ

Product Custom Inputs: Extending

Extend Product Custom Inputs: Twig function for the inputs of an order item, hooks, repositories with service IDs, translations, menu group and worker mode.

Deutsche Version

Back to overview

Product Custom Inputs: Extending

This documentation always describes the latest published version.

The plugin dispatches no events of its own and ships no service tags to collect. You can extend it through the Twig function, hooks, templates and services.

Twig function

Function Returns Description
mmd_order_item_custom_input_values(item) List of label and value The inputs of an order item, formatted. Empty list for null or on a database error
mmd_product_custom_inputs_plugin_version() String Installed plugin version, shown by the admin in the page header

Use the first function to print the inputs in your own templates, for example an invoice or delivery note.

Hooks

All display spots are Twig Hooks, listed in the table on the Storefront page. You can replace any hook with your own template or attach your own hookables next to it with a different priority.

Repositories

Interface Purpose
ProductCustomInputFieldRepositoryInterface Fields of a product, sorted by position (findByProductOrderedByPosition())
OrderItemCustomInputValueRepositoryInterface Values of an order item (findByOrderItem())

Both can be overridden through their service ID. The field repository has the ID mmd_sylius_product_custom_inputs_plugin.repository.product_custom_input_field, the Sylius resource is called mmd_sylius_product_custom_inputs_plugin.product_custom_input_field.

Translations

All texts of the plugin live under mmd_sylius_product_custom_inputs_plugin.ui.* in the messages domain, with de_DE and en_US included. Add your own translations or adjustments in your application under the same keys. The validation messages (date_invalid, time_invalid, step_invalid, date_disabled) are in the validators domain.

Admin menu

The plugin hangs its entry in the MMKreativ Plugins group (MenuGroup::CODE = 'mmd_plugins'). Other plugins or your application can use the same group so all entries end up under one menu item.

Worker mode

CartItemCustomInputValueCollector only holds data within one request and implements ResetInterface. Under FrankenPHP worker, RoadRunner or Swoole it is reset between requests automatically, with no extra configuration.