src/EventListener/CheckoutPaymentUpdateListener.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Sylius\Component\Core\Model\Payment;
  4. use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. class CheckoutPaymentUpdateListener
  7. {
  8.     protected $request;
  9.     public function setRequest(RequestStack $request_stack)
  10.     {
  11.         $this->request $request_stack->getCurrentRequest();
  12.     }
  13.     /**
  14.      * Avant l'insertion d'un nouveau client :
  15.      * - on ajoute la langue si elle est manquante
  16.      */
  17.     public function checkoutUpdated(ResourceControllerEvent $event): void
  18.     {
  19.     //    dump($this->request);
  20.        $cart $event->getSubject();
  21.     //    $ubd
  22.     //    $giftAmout = (int)($giftCard->getAmount()*100);
  23.     //             if($cart->getTotal() < $giftAmout) {
  24.     //                 $giftAmout = $cart->getTotal();
  25.     //             }
  26.     //             else {
  27.     //                 foreach($cart->getPayments() as $payment) {
  28.     //                     if($payment->getState() == 'cart') {
  29.     //                         $payment->setAmount($payment->getAmount()-$giftAmout);
  30.     //                         break;
  31.     //                     }
  32.     //                 }
  33.     //             }
  34.     //    exit();
  35.     }
  36. }