Previewing Shipping Costs
To display the shipping cost previews on your page, use the PreviewShipments method of the Shipping object.
The PreviewShipments method creates the shipping cost previews by splitting the order into individual shipments, just as the Splitter component does in its shipping configuration. For more information about how shipment distinguishers are used to split shipments, see Using the Splitter to Create Multiple Shipments and Splitter.
The PreviewShipments method returns a SimpleList object of dictionaries, one for each shipment. Each shipment dictionary in turn contains a SimpleList object of dictionaries, each of which contains the shipping cost for using a particular shipping method.
To loop through all the shipping cost previews for all shipments, you might use code like the following:
Set oShip = Server.CreateObject("Commerce.Shipping")
ADistinguishers = Array("shipping_method_id", "shipping_address_id")
slShipments = oShip.PreviewShipments(dOrder, dContext, ADistinguishers)
For Each dShipment In slShipments
For Each dPreview In dShipment.Previews
' Inside the loop, you can get the preview
' information:
' dPreview("shipment_error") - the shipment error, if any
' dPreview("shipping_method_id") - the shipping method ID
' dPreview("shipping_method_name") - the shipping method name
' dPreview("description") - the shipping method description
' dPreview("_cy_shipping_total") - the shipping cost
Next
Next
See Also
Setting Up the Pipeline and Cache
Using the Splitter Component to Create Multiple Shipments
Adding Shipping Methods and Components