Unfortunately, this uCommerce method only returns the first price from the shipping method’s Pricing tab that matches the given currency:

It does not account for the calculations in your IShippingMethodService.

#Correctly get the cost for each shipping method

The correct way to do it is to manually call the IShippingMethodService, passing your current shipment.

At run-time we do not know which implementation of IShippingMethodService is set against a shipping method in uCommerce. Helpfully, uCommerce exposes this for us through the method GetShippingMethodService().

Using this, we can simply get the relevant IShippingMethodService for
a given shipping method, construct a fake Shipment object (using our real basket of course) and pass it to the service to find out how much it
would cost to ship our basket with that shipping method.

varpurchaseOrder=TransactionLibrary.GetBasket().PurchaseOrder;varallShippingMethods=TransactionLibrary.GetShippingMethods(country);foreach(varshippingMethodinallShippingMethods){// Get the IShippingMethodService for this ShippingMethodvarshippingService=shippingMethod.GetShippingMethodService();// Construct a fake shipping method to call the service withvarshipment=newShipment{ShippingMethod=shippingMethod,PurchaseOrder=purchaseOrder,ShipmentAddress=purchaseOrder.BillingAddress};varshippingMethodPrice=shippingService.CalculateShippingPrice(shipment);}

Of course, you might want some null checks and you will need to actually do something with the resulting price to display it, but you get the idea.

The default implementation of IShippingMethodService requires that you populate the Country in the ShipmentAddress, and the PurchaseOrder (as above), so make sure you
set those in addition to whatever your custom service needs, just in case a given shipping method is using the default service.

And that’s it! Once you know how, it’s fairly simple to display the costs of custom IShippingMethodServices to the user.