custom/plugins/WebkulBookingReservation/src/Subscriber/BookingSubscriber.php line 202

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace WebkulBookingReservation\Subscriber;
  3. use Shopware\Core\Checkout\Order\OrderEvents;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Shopware\Core\Content\Product\ProductEvents;
  7. use Shopware\Core\Framework\Context;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  9. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  10. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  11. use Shopware\Core\System\SystemConfig\SystemConfigService;
  12. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  13. use DateTime;
  14. use DateTimeZone;
  15. use Shopware\Core\Content\Product\Events\ProductListingResultEvent;
  16. use Shopware\Core\Defaults;
  17. use Shopware\Core\Framework\Uuid\Uuid;
  18. use Shopware\Storefront\Page\Account\Order\AccountOrderPageLoadedEvent;
  19. use Shopware\Storefront\Page\Checkout\Cart\CheckoutCartPageLoadedEvent;
  20. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  21. use Shopware\Storefront\Page\Checkout\Finish\CheckoutFinishPageLoadedEvent;
  22. use WebkulBookingReservation\Service\BookingReservationService;
  23. use Shopware\Storefront\Page\Checkout\Offcanvas\OffcanvasCartPageLoadedEvent;
  24. use Symfony\Component\HttpFoundation\Session\Session;
  25. use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
  26. use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent;
  27. class BookingSubscriber  implements EventSubscriberInterface
  28. {   
  29.     /**
  30.      * @var EntityRepositoryInterface
  31.      */
  32.     protected $oneBookingRepository;
  33.     /**
  34.      * @var EntityRepositoryInterface
  35.      */
  36.     protected $manyBookingRepository;
  37.     /**
  38.      * @var EntityRepositoryInterface
  39.      */
  40.     protected $oneBookingSlotRepository;
  41.     /**
  42.      * @var SystemConfigService
  43.      */
  44.     protected $systemConfigService;
  45.     /**
  46.      * @var EntityRepositoryInterface
  47.      */
  48.     protected $orderCustomerRepository;
  49.     /**
  50.      * @var EntityRepositoryInterface
  51.      */
  52.     protected $orderLineItemRepository;
  53.     /**
  54.      * @var BookingReservationService
  55.      */
  56.     protected $bookingReservationService;
  57.     /**
  58.      * @var EntityRepositoryInterface
  59.      */
  60.     protected $bookingOrderProductRepository;
  61.     /**
  62.      * @var EntityRepositoryInterface
  63.      */
  64.     protected $tempCartRepository;
  65.     /**
  66.      * @var EntityRepositoryInterface
  67.      */
  68.     protected $bookingOrderRepository;
  69.     public function __construct(      
  70.         EntityRepositoryInterface $oneBookingRepository,
  71.         EntityRepositoryInterface $manyBookingRepository,
  72.         EntityRepositoryInterface $oneBookingSlotRepository,
  73.         SystemConfigService $systemConfigService,
  74.         EntityRepositoryInterface $orderCustomerRepository,
  75.         EntityRepositoryInterface $orderLineItemRepository,
  76.         BookingReservationService $bookingReservationService,
  77.         EntityRepositoryInterface $bookingOrderProductRepository,
  78.         EntityRepositoryInterface $tempCartRepository,
  79.         EntityRepositoryInterface $bookingOrderRepository
  80.     )
  81.     {
  82.         $this->oneBookingRepository $oneBookingRepository;
  83.         $this->manyBookingRepository $manyBookingRepository;
  84.         $this->oneBookingSlotRepository $oneBookingSlotRepository;
  85.         $this->systemConfigService $systemConfigService;
  86.         $this->orderCustomerRepository $orderCustomerRepository;
  87.         $this->orderLineItemRepository $orderLineItemRepository;
  88.         $this->bookingReservationService $bookingReservationService;
  89.         $this->bookingOrderProductRepository $bookingOrderProductRepository;
  90.         $this->tempCartRepository $tempCartRepository;
  91.         $this->bookingOrderRepository $bookingOrderRepository;
  92.     }
  93.     public static function getSubscribedEvents(): array
  94.     {
  95.         return [
  96.             ProductPageLoadedEvent::class => 'updateProductPage',
  97.             OrderEvents::ORDER_WRITTEN_EVENT => 'orderBooking',
  98.             OffcanvasCartPageLoadedEvent::class => 'updateOffCanvasCart',
  99.             CheckoutCartPageLoadedEvent::class => 'updateCheckoutCart',
  100.             CheckoutConfirmPageLoadedEvent::class => 'updateCheckoutConfrim',
  101.             ProductListingResultEvent::class => 'updateCms',
  102.             CheckoutFinishPageLoadedEvent::class => 'updateCheckoutFinish',
  103.             AccountOrderPageLoadedEvent::class => 'updateAccountOrder',
  104.             ProductSearchResultEvent::class => 'updateSearchResult',
  105.             AccountEditOrderPageLoadedEvent::class => 'updateEditOrder'
  106.             
  107.         ];
  108.     }
  109.     public function updateEditOrder(AccountEditOrderPageLoadedEvent $event) {
  110.         $products $event->getPage()->getOrder()->getLineItems()->getElements();
  111.         $customerId $event->getSalesChannelContext()->getCustomer()->getId();       
  112.       
  113.         foreach($products as $product) {
  114.             $productId $product->getProductId();
  115.             $orderId $product->getOrderId();
  116.             $productId $product->getProductId();
  117.             $orderProducts $this->bookingReservationService->getOrderProductDetail($productId$customerId$orderId);
  118.             if ($orderProducts) {
  119.                 $cartUpdate = [];
  120.                 foreach($orderProducts as $orderProduct) {
  121.                     $cartUpdate [] = [
  122.                         'bookingFrom' => $orderProduct->getStartDay()->format('Y-m-d H:i'),
  123.                         'bookingTill' => $orderProduct->getEndDay()->format('Y-m-d H:i'),
  124.                         'quantity' => $orderProduct->getQuantity(),
  125.                         'id' => $orderProduct->getId(),
  126.                         'edit' => true
  127.                     ];
  128.                 }
  129.                 $product->setExtensions([
  130.                     'booking' => $cartUpdate
  131.                 ]);
  132.             }
  133.         } 
  134.     }
  135.     public function updateSearchResult(ProductSearchResultEvent $event
  136.     {
  137.         $products $event->getResult()->getElements();
  138.         $showPrice 'No';
  139.         foreach($products as $product) {
  140.             $productId $product->getId();
  141.             
  142.             $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  143.             $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  144.             
  145.             if ($oneBooking || $manybooking) {
  146.                 $product->setExtensions([
  147.                     'booking' => "Yes"
  148.                 ]);    
  149.             }
  150.             
  151.         }
  152.     }
  153.     public function updateAccountOrder(AccountOrderPageLoadedEvent $event) {
  154.         
  155.         $orders $event->getPage()->getOrders()->getElements();
  156.         foreach($orders as $order) {
  157.             $customerId $order->getOrderCustomer()->getCustomerId();
  158.             $products $order->getLineItems()->getElements();
  159.             foreach($products as $product) {
  160.                 $orderId $product->getOrderId();
  161.                 $productId $product->getProductId();
  162.                 $orderProducts $this->bookingReservationService->getOrderProductDetail($productId$customerId$orderId);
  163.                 if ($orderProducts) {
  164.                     $cartUpdate = [];
  165.                     foreach($orderProducts as $orderProduct) {
  166.                         $cartUpdate [] = [
  167.                             'bookingFrom' => $orderProduct->getStartDay()->format('Y-m-d H:i'),
  168.                             'bookingTill' => $orderProduct->getEndDay()->format('Y-m-d H:i'),
  169.                             'quantity' => $orderProduct->getQuantity(),
  170.                             'id' => $orderProduct->getId()
  171.                         ];
  172.                     }
  173.                     $product->setExtensions([
  174.                         'booking' => $cartUpdate
  175.                     ]);
  176.                 }
  177.             }
  178.         }
  179.     }
  180.     public function updateCheckoutFinish(CheckoutFinishPageLoadedEvent $event) {
  181.         $products $event->getPage()->getOrder()->getLineItems()->getElements();
  182.         $customerId $event->getPage()->getOrder()->getOrderCustomer()->getCustomerId();
  183.         foreach($products as $product) {
  184.             
  185.             $productId $product->getProductId();
  186.             $orderId $product->getOrderId();
  187.             $orderProducts $this->bookingReservationService->getOrderProductDetail($productId$customerId$orderId);
  188.             if ($orderProducts) {
  189.                 $cartUpdate = [];
  190.                 foreach($orderProducts as $orderProduct) {
  191.                     $cartUpdate [] = [
  192.                         'bookingFrom' => $orderProduct->getStartDay()->format('Y-m-d H:i'),
  193.                         'bookingTill' => $orderProduct->getEndDay()->format('Y-m-d H:i'),
  194.                         'quantity' => $orderProduct->getQuantity(),
  195.                         'id' => $orderProduct->getId()
  196.                     ];
  197.                 }
  198.                 $product->setExtensions([
  199.                     'booking' => $cartUpdate
  200.                 ]);
  201.             }
  202.         }
  203.     }
  204.     public function updateCms(ProductListingResultEvent $event) {
  205.         $products $event->getResult()->getElements();
  206.         $showPrice 'No';
  207.         foreach($products as $product) {
  208.             $productId $product->getId();
  209.             
  210.             $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  211.             $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  212.             
  213.             if ($oneBooking || $manybooking) {
  214.                 $product->setExtensions([
  215.                     'booking' => "Yes"
  216.                 ]);    
  217.             }
  218.             
  219.         }
  220.     }
  221.     public function updateCheckoutConfrim(CheckoutConfirmPageLoadedEvent $event)
  222.     {
  223.         $products $event->getPage()->getCart()->getLineItems()->getElements();
  224.         
  225.         $customerId $event->getSalesChannelContext()->getCustomer()->getId();
  226.         $count 0;
  227.         $item 0;
  228.         foreach($products as $product) {
  229.             $productId $product->getId();
  230.             $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  231.             $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  232.             if ($oneBooking || $manybooking) {
  233.                 $count++;
  234.                 $tempCartDetails $this->bookingReservationService->getTempCart($productId$customerId$event->getSalesChannelContext());
  235.                 $cartUpdate = [];
  236.                 foreach($tempCartDetails as $tempCartDetail) {
  237.                     $cartUpdate [] = [
  238.                         'bookingFrom' => $tempCartDetail->getBookingFrom(),
  239.                         'bookingTill' => $tempCartDetail->getBookingTill(),
  240.                         'quantity' => $tempCartDetail->getQuantity(),
  241.                         'id' => $tempCartDetail->getId(),
  242.                         'edit' => false
  243.                     ];
  244.                 }
  245.                 $product->setExtensions([
  246.                     'booking' => $cartUpdate
  247.                 ]);
  248.                 $item $item count($tempCartDetails);
  249.             }
  250.         } 
  251.        
  252.     }
  253.     public function updateCheckoutCart(CheckoutCartPageLoadedEvent $event) {
  254.         $products $event->getPage()->getCart()->getLineItems()->getElements();
  255.         $cartToken $event->getPage()->getCart()->getToken();
  256.         $customerId $event->getSalesChannelContext()->getCustomer()? $event->getSalesChannelContext()->getCustomer()->getId() : null;
  257.         $count 0;
  258.         $item 0;
  259.         if ($customerId) {
  260.             foreach($products as $product) {
  261.                 $productId $product->getId();
  262.                 $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  263.                 $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  264.                 
  265.                 $cartUpdate = [];
  266.                 if ($oneBooking || $manybooking) {
  267.                     $count++;
  268.                     $tempCartDetails $this->bookingReservationService->getTempCart($productId$customerId$event->getSalesChannelContext());
  269.                     
  270.                     foreach($tempCartDetails as $tempCartDetail) {
  271.                         $cartUpdate [] = [
  272.                             'bookingFrom' => $tempCartDetail->getBookingFrom(),
  273.                             'bookingTill' => $tempCartDetail->getBookingTill(),
  274.                             'quantity' => $tempCartDetail->getQuantity(),
  275.                             'id' => $tempCartDetail->getId()
  276.                         ];
  277.                         
  278.                     }
  279.     
  280.                     $product->setExtensions([
  281.                         'booking' => $cartUpdate
  282.                     ]);
  283.                     $item $item count($tempCartDetails);
  284.                 }
  285.             } 
  286.         }
  287.     }
  288.     public function updateOffCanvasCart(OffcanvasCartPageLoadedEvent $event)
  289.     {   
  290.         $products $event->getPage()->getCart()->getLineItems()->getElements();
  291.         $cartToken $event->getPage()->getCart()->getToken();
  292.         if ($event->getSalesChannelContext()->getCustomer()) {
  293.             $customerId $event->getSalesChannelContext()->getCustomer()->getId();
  294.         }
  295.         $count 0;
  296.         $item 0;
  297.         foreach($products as $product) {
  298.             $productId $product->getId();
  299.             $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  300.             $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  301.             $cartUpdate = [];
  302.             if ($oneBooking || $manybooking) {
  303.                 $count++;
  304.                 $tempCartDetails $this->bookingReservationService->getTempCart($productId$customerId$event->getSalesChannelContext());
  305.                 
  306.                 foreach($tempCartDetails as $tempCartDetail) {
  307.                     $cartUpdate [] = [
  308.                         'bookingFrom' => $tempCartDetail->getBookingFrom(),
  309.                         'bookingTill' => $tempCartDetail->getBookingTill(),
  310.                         'quantity' => $tempCartDetail->getQuantity(),
  311.                         'id' => $tempCartDetail->getId()
  312.                     ];
  313.                     
  314.                 }
  315.                 $product->setExtensions([
  316.                     'booking' => $cartUpdate
  317.                 ]);
  318.                 $item $item count($tempCartDetails);
  319.             }
  320.         } 
  321.         $totalLineItems =  count($products);
  322.         $item $item + ($totalLineItems $count);
  323.         $event->getPage()->setExtensions([
  324.             'item' => $item
  325.         ]);
  326.     }
  327.     public function updateProductPage(ProductPageLoadedEvent $event)
  328.     {   
  329.         $config $this->systemConfigService->get('WebkulBR')['config'];
  330.         
  331.         $productId $event->getPage()->getProduct()->getId();
  332.         // if ($event->getPage()->getProduct()->getParentId()) {
  333.         //     $productId = $event->getPage()->getProduct()->getParentId();
  334.         // } else {
  335.         // }
  336.         if ($productId) {
  337.             $oneBooking $this->oneBookingRepository->search(
  338.                 (new Criteria())
  339.                 ->addFilter(new EqualsFilter('productId'$productId))
  340.                 ->addFilter(new EqualsFilter('status'true))
  341.                 ->addAssociation('slot'),
  342.                 Context::createDefaultContext()
  343.             )->first();
  344.             $manybooking $this->manyBookingRepository->search(
  345.                 (new Criteria())
  346.                 ->addFilter(new EqualsFilter('productId'$productId))
  347.                 ->addFilter(new EqualsFilter('status'true)),
  348.                 Context::createDefaultContext()
  349.             )->first();
  350.             
  351.             if ($oneBooking) {
  352.                 $dateFrom$oneBooking->getDateFrom();
  353.                 $dateFrom =  $dateFrom->format(Defaults::STORAGE_DATE_TIME_FORMAT);
  354.                 $dateFrom = new DateTime($dateFrom, new DateTimeZone('UTC'));
  355.                 $dateFrom->setTimezone(new DateTimeZone($config['timeZone'])); 
  356.                 $dateFrom $dateFrom->format('Y-m-d');
  357.                 $dateTo $oneBooking->getDateTo();
  358.                 $dateTo =  $dateTo->format(Defaults::STORAGE_DATE_TIME_FORMAT);
  359.                 $dateTo = new DateTime($dateTo, new DateTimeZone('UTC'));
  360.                 $dateTo->setTimezone(new DateTimeZone($config['timeZone'])); 
  361.                 $dateTo $dateTo->format('Y-m-d');
  362.                 $sundayStatus false;
  363.                 $mondayStatus false;
  364.                 $tuesdayStatus false;
  365.                 $wednesdayStatus false;
  366.                 $thursdayStatus false;
  367.                 $fridayStatus false;
  368.                 $saturdayStatus false;
  369.                 
  370.                 if ($oneBooking->getSlot()->getElements()) {
  371.                     foreach($oneBooking->getSlot()->getElements() as $slot) {
  372.                         switch ($slot->getStartDay()) {
  373.                             case "Sunday":
  374.                                 $sundayStatus true;
  375.                                 break;
  376.                             case "Monday":
  377.                                 $mondayStatus true;
  378.                                 break;
  379.                             case "Tuesday":
  380.                                 $tuesdayStatus true;
  381.                                 break;
  382.                             case "Wednesday":
  383.                                 $wednesdayStatus true;
  384.                                 break;
  385.                             case "Thursday":
  386.                                 $thursdayStatus true;
  387.                                 break;
  388.                             case "Friday":
  389.                                 $fridayStatus true;
  390.                                 break;
  391.                             case "Saturday":
  392.                                 $saturdayStatus true;
  393.                                 break;
  394.                         }
  395.                     }
  396.                 }
  397.                 $event->getPage()->setExtensions([
  398.                     'booking' => 'oneBooking',
  399.                     'productId' => $oneBooking->getProductId(),
  400.                     'dateFrom' => $dateFrom,
  401.                     'dateTo' => $dateTo,
  402.                     'sundayStatus' => $sundayStatus,
  403.                     'mondayStatus' => $mondayStatus,
  404.                     'tuesdayStatus' => $tuesdayStatus,
  405.                     'wednesdayStatus' => $wednesdayStatus,
  406.                     'thursdayStatus' => $thursdayStatus,
  407.                     'fridayStatus' => $fridayStatus,
  408.                     'saturdayStatus' => $saturdayStatus  
  409.                 ]);
  410.             } else if ($manybooking) {
  411.                 $dateFrom$manybooking->getDateFrom();
  412.                 $dateFrom =  $dateFrom->format(Defaults::STORAGE_DATE_TIME_FORMAT);
  413.                 $dateFrom = new DateTime($dateFrom, new DateTimeZone('UTC'));
  414.                 $dateFrom->setTimezone(new DateTimeZone($config['timeZone'])); 
  415.                 $dateFrom $dateFrom->format('Y-m-d');
  416.                 $dateTo $manybooking->getDateTo();
  417.                 $dateTo =  $dateTo->format(Defaults::STORAGE_DATE_TIME_FORMAT);
  418.                 $dateTo = new DateTime($dateTo, new DateTimeZone('UTC'));
  419.                 $dateTo->setTimezone(new DateTimeZone($config['timeZone'])); 
  420.                 $dateTo $dateTo->format('Y-m-d');
  421.                 $event->getPage()->setExtensions([
  422.                     'booking' => 'manyBooking',
  423.                     'productId' => $manybooking->getProductId(),
  424.                     'dateFrom' => $dateFrom,
  425.                     'dateTo' => $dateTo,
  426.                     'sundayStatus' => $manybooking->getSundayStatus(),
  427.                     'mondayStatus' => $manybooking->getMondayStatus(),
  428.                     'tuesdayStatus' => $manybooking->getTuesdayStatus(),
  429.                     'wednesdayStatus' => $manybooking->getWednesdayStatus(),
  430.                     'thursdayStatus' => $manybooking->getThursdayStatus(),
  431.                     'fridayStatus' => $manybooking->getFridayStatus(),
  432.                     'saturdayStatus' => $manybooking->getSaturdayStatus()   
  433.                 ]);
  434.             }
  435.         }
  436.     }
  437.     public function orderBooking(EntityWrittenEvent $event)
  438.     {   
  439.         $session = new Session();
  440.         $results $event->getWriteResults();
  441.         $manybooking null;
  442.         $oneBooking null;
  443.         foreach($results as $key => $result) {
  444.             if ($result->getOperation() == 'insert') {
  445.                 $orderId $result->getPrimaryKey();
  446.                 $payload $result->getPayload();   
  447.                 if ($payload) {
  448.                     $count 0;
  449.                     $orderCustomer $this->orderCustomerRepository->search(
  450.                         (new Criteria())
  451.                         ->addFilter(new EqualsFilter('orderId'$orderId)),
  452.                         Context::createDefaultContext()
  453.                     )->first(); 
  454.             
  455.                     $customerId $orderCustomer->getCustomerId();
  456.                     
  457.                     if ($session->has($customerId)) {
  458.                         $token $session->get($customerId);
  459.                     }
  460.     
  461.                     $orderLineItems $this->orderLineItemRepository->search(
  462.                         (new Criteria())
  463.                         ->addFilter(new EqualsFilter('orderId'$orderId))
  464.                         ->addAssociation('product'),
  465.                         Context::createDefaultContext()
  466.                     )->getEntities()->getElements();
  467.                    
  468.                     foreach($orderLineItems as $orderLineItem) {
  469.                         $productId $orderLineItem->getIdentifier();
  470.                         $oneBooking $this->bookingReservationService->getOneBookingByProductId($productId);
  471.                         $manybooking $this->bookingReservationService->getManyBookingByProductId($productId);
  472.     
  473.                         if ($oneBooking) {
  474.                             $bookType 2;
  475.                         } else if ($manybooking) {
  476.                             $bookType 1;
  477.                         }
  478.     
  479.                         if ($oneBooking || $manybooking) {
  480.                             $tempCartDetails $this->tempCartRepository->search(
  481.                                 (new Criteria())
  482.                                 ->addFilter(new EqualsFilter('productId'$productId))
  483.                                 ->addFilter(new EqualsFilter('customerId'$customerId))
  484.                                 ->addFilter(new EqualsFilter('cartToken'$token))
  485.                                 ->addAssociation('product')
  486.                                 ->addAssociation('customer'),
  487.                                 Context::createDefaultContext()
  488.                             )->getElements();
  489.     
  490.                             if ($tempCartDetails) {
  491.                                 foreach($tempCartDetails as $key => $tempCartDetail) {
  492.                                     $count++;
  493.                                     $startDay = new DateTime($tempCartDetail->getBookingFrom());
  494.                                     $endDay = new DateTime($tempCartDetail->getBookingTill());
  495.                                     $status false;
  496.                                     
  497.                                     if ($bookType == || $bookType == 1) {
  498.                                         $bookingOrder = [
  499.                                             'id' => Uuid::randomHex(),
  500.                                             'productId' => $productId,  
  501.                                             'orderId' => $orderId,
  502.                                             'customerId' => $customerId,
  503.                                             'quantity' => $tempCartDetail->getQuantity(),
  504.                                             'bookType' => $bookType,    
  505.                                             'startDay' => $startDay,
  506.                                             'endDay' => $endDay
  507.                                             'status' => $status,
  508.                                             'approvedDate' => new DateTime(date('Y-m-d'))
  509.                                         ];
  510.                                        
  511.                                         $this->bookingOrderProductRepository->create(
  512.                                             [$bookingOrder],
  513.                                             Context::createDefaultContext()
  514.                                         );
  515.                                     } 
  516.                                     $this->tempCartRepository->delete([['id' => $tempCartDetail->getId()]], Context::createDefaultContext());
  517.                                 }
  518.     
  519.                             }
  520.                         }
  521.                     }
  522.                     if ($manybooking || $oneBooking) {
  523.                         $order = [
  524.                             'id' => Uuid::randomHex(),
  525.                             'orderId' => $orderId,
  526.                             'customerId' => $customerId,
  527.                             'noOfProduct' => $count
  528.                         ];
  529.                         $this->bookingOrderRepository->create([$order], Context::createDefaultContext());
  530.                         $this->bookingReservationService->bookingMail($orderId);
  531.                         $session->remove($customerId);
  532.                     } 
  533.                 }
  534.             }
  535.         }
  536.     }
  537. }