public function listAction(Request $request, ?string $method): Response
    {
        $calculator = $this->getCalculator($method);

        $params = $request->request->all();

        $pickupTemplate  = $this->getDefaultTemplate();
        $pickupCurrentId = null;
        $pickupList      = [];
        $currentAddress  = null;

        /** @var PickupCalculatorInterface $calculator */
        if ($calculator instanceof PickupCalculatorInterface) {
            if (!empty($calculator->getPickupTemplate())) {
                $pickupTemplate = $calculator->getPickupTemplate();
            }

            $cart = $this->getCurrentCart();
            if (null !== $cart->getId()) {
                $cart    = $this->getOrderRepository()->findCartForSummary($cart->getId());
                $address = $cart->getShippingAddress();

                $shipment = $cart->getShipments()->current();
                $pickupCurrentId = $shipment->getPickupId();

                foreach ($params as $field => $value) {
                    $setter = 'set' . preg_replace('/_/', '', ucwords($field, '_'));
                    if (method_exists($address, $setter)) {
                        $address->$setter($value);
                    }
                }
                $currentAddress = $address;

                $pickupList = $calculator->getPickupList($address, $cart, $this->getMethod($method));
            }
        }

        $pickup = [
            'pickup' => [
                'current_id' => $pickupCurrentId,
                'list'       => $pickupList,
            ],
            'address'   => $currentAddress,
            'countries' => $this->getAvailableCountries(),
            'index'     => $request->get('index', 0),
            'code'      => $method,
        ];

        return $this->render($pickupTemplate, ['method' => $pickup]);
    }
public function listAction(Request $request, ?string $method): Response
    {
        $calculator = $this->getCalculator($method);

        $params = $request->request->all();

        $pickupTemplate  = $this->getDefaultTemplate();
        $pickupCurrentId = null;
        $pickupList      = [];
        $currentAddress  = null;

        /** @var PickupCalculatorInterface $calculator */
        if ($calculator instanceof PickupCalculatorInterface) {
            if (!empty($calculator->getPickupTemplate())) {
                $pickupTemplate = $calculator->getPickupTemplate();
            }

            $cart = $this->getCurrentCart();
            if (null !== $cart->getId()) {
                $cart    = $this->getOrderRepository()->findCartForSummary($cart->getId());
                $address = $cart->getShippingAddress();

                $shipment = $cart->getShipments()->current();
                $pickupCurrentId = $shipment->getPickupId();

                foreach ($params as $field => $value) {
                    $setter = 'set' . preg_replace('/_/', '', ucwords($field, '_'));
                    if (method_exists($address, $setter)) {
                        $address->$setter($value);
                    }
                }
                $currentAddress = $address;

                $pickupList = $calculator->getPickupList($address, $cart, $this->getMethod($method));
            }
        }

        $pickup = [
            'pickup' => [
                'current_id' => $pickupCurrentId,
                'list'       => $pickupList,
            ],
            'address'   => $currentAddress,
            'countries' => $this->getAvailableCountries(),
            'index'     => $request->get('index', 0),
            'code'      => $method,
        ];

        return $this->render($pickupTemplate, ['method' => $pickup]);
    }
public function listAction ( Request $ request , ? string $ method ) : Response { $ calculator = $ this -> getCalculator ( $ method ) ; $ params = $ request -> request -> all ( ) ; $ pickupTemplate = $ this -> getDefaultTemplate ( ) ; $ pickupCurrentId = null ; $ pickupList = [ ] ; $ currentAddress = null ; /** @var PickupCalculatorInterface $calculator */ if ( $ calculator instanceof PickupCalculatorInterface ) { if ( ! empty ( $ calculator -> getPickupTemplate ( ) ) ) { $ pickupTemplate = $ calculator -> getPickupTemplate ( ) ; } $ cart = $ this -> getCurrentCart ( ) ; if ( null !== $ cart -> getId ( ) ) { $ cart = $ this -> getOrderRepository ( ) -> findCartForSummary ( $ cart -> getId ( ) ) ; $ address = $ cart -> getShippingAddress ( ) ; $ shipment = $ cart -> getShipments ( ) -> current ( ) ; $ pickupCurrentId = $ shipment -> getPickupId ( ) ; foreach ( $ params as $ field => $ value ) { $ setter = 'set' . preg_replace ( '/_/' , '' , ucwords ( $ field , '_' ) ) ; if ( method_exists ( $ address , $ setter ) ) { $ address -> $ setter ( $ value ) ; } } $ currentAddress = $ address ; $ pickupList = $ calculator -> getPickupList ( $ address , $ cart , $ this -> getMethod ( $ method ) ) ; } } $ pickup = [ 'pickup' => [ 'current_id' => $ pickupCurrentId , 'list' => $ pickupList , ] , 'address' => $ currentAddress , 'countries' => $ this -> getAvailableCountries ( ) , 'index' => $ request -> get ( 'index' , 0 ) , 'code' => $ method , ] ; return $ this -> render ( $ pickupTemplate , [ 'method' => $ pickup ] ) ; }
Display Pickup List

@param Request $request
@param string $method
@return Response|string
Display Pickup List