Create Flow for Shipping Calculation

Prev Next

In order to create your own logic for calculating shipping costs for a specific set of products (shopping cart items) there is the ability to create a custom flow which. This custom flow has specific requirements from the OrderCentral side so that we can provide the flow with the product data and customer data for which the shipping costs should be generated.

  1. Create a flow
  2. Create three Apex-Defined variables
  3. Add the necessary logic to the flow and assign the outcome to the Result output variable
  4. Go to Setup -> Custom Metadata Types -> Delivery Methods
  5. Add a new- or adjust the existing Delivery Method and set the type to Flow
  6. Copy the flow name created in Step 1 and past it in the Flow Name field.
Variable name Input/Output Apex Type
products Input welisacommerce__OrderProduct (Allow multiple values (collection))
shippingAddress Input welisacommerce.Address
Result Output welisacommerce.ShippingCalculationResult

You can use the two input variables to base your calculation upon, they are not required if they will not be used. The Result output variable is required.

Type references

OrderProduct properties

Property Name Type Description
code String The Product2.ProductCode value
quantity Decimal The number of ordered products

Address properties

Property Name Type
street String
city String
postalCode String
state String
country String

ShippingCalculationResult properties

Property Name Type Description
totalAmount Decimal The total shipping cost amount before tax
deliveryTime Integer The expected delivery time in days. Zero or null will not be displayed in the ui
label String If set it will override the configured label on the Delivery Method