custom/static-plugins/AcidSplitCartCheckout/src/Subscriber/CheckoutFinishPageSubscriber.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace AcidSplitCartCheckout\Subscriber;
  3. use AcidSplitCartCheckout\Service\SplitCartService;
  4. use Shopware\Storefront\Page\Checkout\Finish\CheckoutFinishPageLoadedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class CheckoutFinishPageSubscriber implements EventSubscriberInterface
  7. {
  8.     protected SplitCartService $splitCartService;
  9.     public function __construct(SplitCartService $splitCartService)
  10.     {
  11.         $this->splitCartService $splitCartService;
  12.     }
  13.     public static function getSubscribedEvents()
  14.     {
  15.         return [
  16.             CheckoutFinishPageLoadedEvent::class => 'onCheckoutFinishPageLoaded'
  17.         ];
  18.     }
  19.     public function onCheckoutFinishPageLoaded(CheckoutFinishPageLoadedEvent $event)
  20.     {
  21.         $order $event->getPage()->getOrder();
  22.         $order->addExtension(
  23.             "acid_split_summary",
  24.             $this->splitCartService->calculateOrderSummary(
  25.                 $event->getPage()->getOrder()->getLineItems(),
  26.                 $event->getPage()->getOrder()->getDeliveries(),
  27.                 $event->getSalesChannelContext()
  28.             )
  29.         );
  30.         $order->addExtension(
  31.             "acid_split_items",
  32.             $this->splitCartService->collectSplitItems(
  33.                 $event->getPage()->getOrder()->getLineItems(),
  34.                 $event->getSalesChannelContext()
  35.             )
  36.         );
  37.         if($splittedOrder $this->splitCartService->getSplittedStoreOrder($order->getId())) {
  38.             $order->addExtension(
  39.                 "acid_splitted_store_order",
  40.                 $splittedOrder
  41.             );
  42.         }
  43.     }
  44. }