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 the input variables you need, see below for available variables.
  3. Create the output variable to return the result back to OrderCentral.
  4. Add the necessary logic to the flow and assign the outcome to the Result output variable
  5. Go to Setup -> Custom Metadata Types -> Delivery Methods
  6. Add a new- or adjust the existing Delivery Method and set the type to Flow
  7. Copy the flow name created in Step 1 and past it in the Flow Name field.
Variable name Input/Output Type Class Name Required
products Input Apex-Defined welisacommerce__OrderProduct (Allow multiple values (collection)) No
shippingAddress Input Apex-Defined welisacommerce.Address No
subtotal Input Currency No
Result Output Apex-Defined welisacommerce.ShippingCalculationResult Yes

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