Skip to content

Instantly share code, notes, and snippets.

@lchrusciel
Created May 15, 2024 19:16
Show Gist options
  • Save lchrusciel/29c498b2b590536a3422471e9f95f951 to your computer and use it in GitHub Desktop.
Save lchrusciel/29c498b2b590536a3422471e9f95f951 to your computer and use it in GitHub Desktop.
Sample configuration of new promotion action
<?php
// src/Promotion/Action/FreeItemPromotionActionCommand.php
declare(strict_types=1);
namespace App\Promotion\Action;
use Sylius\Component\Promotion\Action\PromotionActionCommandInterface;
use Sylius\Component\Promotion\Model\PromotionInterface;
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
final class FreeItemPromotionActionCommand implements PromotionActionCommandInterface
{
public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion): bool
{
// Promotion logic
}
public function revert(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion): void
{
// Promotion reverting logic
}
}
services:
# other definitions
App\Promotion\Action\FreeItemPromotionActionCommand:
tags:
- {
name: sylius.promotion_action,
type: free_item,
label: 'app.form.promotion_action.free_item',
form_type: App\Form\Type\Promotion\Action\FreeItemConfigurationType
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment