Create Flow for Shipping Calculation
  • 15 Jun 2022
  • 1 Minute to read
  • Dark
    Light

Create Flow for Shipping Calculation

  • Dark
    Light

Article summary

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 nameInput/OutputApex Type
productsInputwelisacommerce__OrderProduct (Allow multiple values (collection))
shippingAddressInputwelisacommerce.Address
ResultOutputwelisacommerce.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 NameTypeDescription
codeStringThe Product2.ProductCode value
quantityDecimalThe number of ordered products

Address properties

Property NameType
streetString
cityString
postalCodeString
stateString
countryString

ShippingCalculationResult properties

Property NameTypeDescription
totalAmountDecimalThe total shipping cost amount before tax
deliveryTimeIntegerThe expected delivery time in days. Zero or null will not be displayed in the ui
labelStringIf set it will override the configured label on the Delivery Method