Cart & Checkout Attributes: Technical
Architecture, decision flow, plugin structure, migrations and the CheckoutVisibility enum of the Sylius plugin.
Cart & Checkout Attributes: Technical
Decision flow
graph TD
A["Order item in cart/checkout/summary"] --> B{"Kill switch active?"}
B -->|No| C["Nothing rendered"]
B -->|Yes| D{"Does the order item have a value?"}
D -->|No| C
D -->|Yes| E{"Display config exists?"}
E -->|No| C
E -->|Yes| F{"visibleInCart / checkoutVisibility set?"}
F -->|No| C
F -->|Yes| G["Render via SyliusAttribute partial"]
Plugin structure
src/
Entity/ ProductAttributeDisplayConfig, Settings/CartCheckoutAttributesSettings
Enum/ CheckoutVisibility
Api/ State providers for both API resources
Form/ Type and extension class for the admin form
Command/ SetupCommand
Controller/Admin/ CartCheckoutAttributesSettingsController
Menu/ AdminMenuListener, MenuGroup
Migrations/ 3 Doctrine migrations
Twig/ CartCheckoutAttributeValuesExtension
config/
routes/ admin.yaml (required import), shop.yaml (empty, API comes via API Platform)
twig_hooks/ admin.yaml, shop.yaml
services.php
templates/
admin/product_attribute/form/
shop/cart/, shop/checkout/, shop/shared/order/
Entities & migrations
| Entity | Table | Purpose |
|---|---|---|
ProductAttributeDisplayConfig |
mmd_sylius_cart_checkout_attributes_display_config |
One optional row per product attribute, carries visibleInCart and checkoutVisibility |
CartCheckoutAttributesSettings |
mmd_sylius_cart_checkout_attributes_settings |
Singleton row (id=1) with the kill switch flag active |
| Migration | Purpose | |
| ----------- | --------- | |
Version20260917090000 |
Creates the main table, including the CHECK constraint "mandatory implies visible_in_checkout" | |
Version20260917130000 |
Creates the settings table, seeds the singleton row (active = 1) |
|
Version20260918090000 |
Merges visible_in_checkout and mandatory into the new checkout_visibility field, drops the two old columns and the CHECK constraint |
All three migrations are plain MySQL DDL and skip themselves on any other database.
CheckoutVisibility enum
enum CheckoutVisibility: string
{
case NotVisible = 'not_visible';
case Visible = 'visible';
case Mandatory = 'mandatory';
}
By this construction, Mandatory is always checkout-visible - there is no combination that could mean "mandatory but hidden". visibleInCart is its own, independent boolean field.