Files
kupshop/bundles/KupShop/OrderDiscountBundle/Triggers/IsicTrigger.php
2025-08-02 16:30:27 +02:00

44 lines
1.2 KiB
PHP

<?php
namespace KupShop\OrderDiscountBundle\Triggers;
use KupShop\KupShopBundle\Config;
use KupShop\OrderDiscountBundle\Entity\OrderDiscount;
use KupShop\OrderDiscountBundle\Triggers\Frontend\IsicHandler;
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
class IsicTrigger extends AbstractTrigger
{
protected static $type = 'isic';
protected static $position = 81;
protected $adminTemplate = 'triggers/isic.tpl';
private IsicHandler $isicHandler;
public function __construct(IsicHandler $isicHandler)
{
if (empty(Config::get()['Modules']['isic']['priceLevel'])) {
$this->isicHandler = $isicHandler;
}
}
public function isApplicable(PurchaseState $purchaseState, OrderDiscount $orderDiscount, array $data, ?array $persistentData = null): bool
{
return $persistentData['success'] ?? false;
}
public function getErrorMessage(PurchaseState $purchaseState, array $data): string
{
return translate('isic_not_valid', 'or der');
}
public function getFrontendHandler(): ?IsicHandler
{
if (!empty(Config::get()['Modules']['isic']['priceLevel'])) {
return null;
}
return $this->isicHandler ?: null;
}
}