Show shipping price in checkout for not selected methods

I’ve solved the issue. You need to also set the delivery shipping price to zero, otherwise, it doesn’t calculate it

public function load(Request $request, SalesChannelContext $context, Criteria $criteria): ShippingMethodRouteResponse {

      $criteria->addAssociation('prices');
      $result = $this->shippingMethodRoute->load($request, $context, $criteria);
      $originalResult = clone $result;
      $cart = $this->cartService->getCart($context->getToken(), $context);
      $shippingMethods = $result->getShippingMethods()->filterByActiveRules($context);
      /** @var ShippingMethodEntity $shippingMethod */
      try {
          foreach ($shippingMethods as $shippingMethod) {
              $cartClone = clone $cart;
              $cartData =  $cartClone->getData();
              $deliveries = $cartClone->getDeliveries();
              /** @var Delivery $delivery */
              foreach ($deliveries as $delivery) {
                  $delivery->setShippingCosts(new CalculatedPrice(0, 0, new CalculatedTaxCollection(), new TaxRuleCollection()));
                  $delivery->setShippingMethod($shippingMethod);
              }
              $cartData->set(DeliveryProcessor::buildKey($shippingMethod->getId()), $shippingMethod);
              $this->deliveryCalculator->calculate($cartData, $cartClone, $deliveries, $context);
              $shippingCost = $cartClone->getDeliveries()->getShippingCosts()->sum()->getTotalPrice();
              $shippingMethod->shippingPrice = $shippingCost;
          }
      } catch (\Error $exception) {
          return $originalResult;
      }


      return $result;
  }
1 „Gefällt mir“