It seems that Shopware is only really interested in calculating the price of the currently selected shipping method, which leaves the customer unable to know the price of a shipping method when choosing.
Is there a service that would let me calculate the prices of all active shipping methods for a given cart, or similar?
I asked Shopware themselves and they recommended using \Shopware\Core\Checkout\Cart\Delivery\DeliveryCalculator::calculate
which is what calculates the shipping costs on a cart with a given shipping method.
The cart can be cloned and each shipping method applied to the deliveries ($cart->getDeliveries()
) on the clone, to not mess with the actual cart. Once the price has been calculated, the total shipping price can be received using $cart->getDeliveries()->getShippingCosts()->sum()
.