This plugin saves order events and allows you to display them in the order history as a timeline. It is based on state machine events.
| Sylius Version | PHP Version |
|---|---|
| 1.12 | 8.1 - 8.2 - 8.3 |
| 1.13 | 8.1 - 8.2 - 8.3 |
| 1.14 | 8.1 - 8.2 - 8.3 |
If you want to use our recipes, you can configure your composer.json by running:
composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'Install the plugin via composer:
composer require monsieurbiz/sylius-order-history-pluginChange your config/bundles.php file to add this line for the plugin declaration:
<?php
return [
//..
MonsieurBiz\SyliusOrderHistoryPlugin\MonsieurBizSyliusOrderHistoryPlugin::class => ['all' => true],
];Copy the plugin configuration files in your config folder:
cp -Rv vendor/monsieurbiz/sylius-order-history-plugin/recipes/1.0/config/ configIn order to create dedicated tables for the plugin, don't forget to execute doctrine migration commands:
bin/console doctrine:migrations:migrateShow any order on the Sylius backend and click on the top right History button.
This plugin is based on the state machine events. It uses both the native Winzou state machine callback system and Symfony Workflow events to save named order events when they are triggered.
Depending on your sylius_state_machine_abstraction.default_adapter configuration:
# src/Resources/config/state_machine/checkout.yaml
winzou_state_machine:
sylius_order_checkout:
callbacks:
after:
monsieur_biz_order_history_notify_address:
on: 'address'
do: [ '@MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\OrderHistoryWithAddressesDataNotifier', 'notifyEvent' ]
args: [ 'object', 'constant("MonsieurBiz\\SyliusOrderHistoryPlugin\\Entity\\OrderHistoryEventInterface::TYPE_CHECKOUT")', '"addressed"' ]or
<?php
declare(strict_types=1);
namespace App\EventListener\Workflow;
use MonsieurBiz\SyliusOrderHistoryPlugin\Entity\OrderHistoryEventInterface;
use MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\OrderHistoryNotifierInterface;
use MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\OrderHistoryWithAddressesDataNotifier;
use Sylius\Component\Core\Model\OrderInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\Workflow\Event\CompletedEvent;
final class CheckoutWorkflowEventListener
{
public function __construct(
#[Autowire(service: OrderHistoryWithAddressesDataNotifier::class)]
private OrderHistoryNotifierInterface $orderHistoryWithAddressesDataNotifier,
) {
}
#[AsEventListener(event: 'workflow.sylius_order_checkout.completed.addressed')]
public function addressed(CompletedEvent $event): void
{
$order = $event->getSubject();
if (!$order instanceof OrderInterface) {
return;
}
$this->orderHistoryWithAddressesDataNotifier->notifyEvent(
$order,
OrderHistoryEventInterface::TYPE_CHECKOUT,
'addressed',
);
}
}Callback dedicated notifier service / actions who add different details following context:
\MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\OrderHistoryNotifieris a basic notifier with no particular details except the given ones as parameters.\MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\OrderHistoryWithAddressesDataNotifieris a notifier dedicated to address events. It adds the billing and shipping address data.\MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\ShipmentOrderHistoryNotifieris a notifier dedicated to shipment events. It adds the shipment method name and the shipment state.\MonsieurBiz\SyliusOrderHistoryPlugin\Notifier\PaymentOrderHistoryNotifieris a notifier dedicated to payment events. It adds the payment method name and the payment state.
- Add more details on existing events
- Add custom event in code
- Add custom event in state machine
- Add custom type and label display in history timeline
You can find a way to run the plugin without effort in the file DEVELOPMENT.md.
Then you can open an issue or a Pull Request if you want! 😘
Thank you!
This plugin is completely free and released under the MIT License.

