Use Custom Logic for Shipping Calculation
  • 05 Sep 2022
  • 1 Minute to read
  • Dark
    Light

Use Custom Logic for Shipping Calculation

  • Dark
    Light

Article Summary

When our standard shipping cost calculation options do not fulfill the needs there is the option to use flow for defining custom logic.

First create a new flow. In that flow two Apex-Defined variables available for input are required. 

  1. Products (type welisacommerce__OrderProduct)
  2. shippingAddress (type welisacommerce__Address)

Finally one Apex-Defined variable vailable for output is required

  • Result (type welisacommerce_ShippingCostCalculationResult) 

The result type (welisacommerce__ShippingCostCalculationResult) has the following properties:

  1. deliveryTime (Integer) - amount of days for expected delivery. If not set no expected delivery time will be displayed
  2. label (String) - If set the default label on the Delivery_Method__mdt will be overriden, if not set the default will be displayed
  3. totalAmount (Decimal) - total amount (without tax) applied as shipping cost

After saving and activating the flow copy the (technical) name of the flow and past it in the Flow Name field on the delivery method.