<?php
namespace App\EventListener;
use Sylius\Component\Core\Model\Payment;
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
use Symfony\Component\HttpFoundation\RequestStack;
class CheckoutPaymentUpdateListener
{
protected $request;
public function setRequest(RequestStack $request_stack)
{
$this->request = $request_stack->getCurrentRequest();
}
/**
* Avant l'insertion d'un nouveau client :
* - on ajoute la langue si elle est manquante
*/
public function checkoutUpdated(ResourceControllerEvent $event): void
{
// dump($this->request);
$cart = $event->getSubject();
// $ubd
// $giftAmout = (int)($giftCard->getAmount()*100);
// if($cart->getTotal() < $giftAmout) {
// $giftAmout = $cart->getTotal();
// }
// else {
// foreach($cart->getPayments() as $payment) {
// if($payment->getState() == 'cart') {
// $payment->setAmount($payment->getAmount()-$giftAmout);
// break;
// }
// }
// }
// exit();
}
}