Fluent Commerce Logo
Docs
Sign In

CalculateLocationsDistances

Rule

Changed on:

19 Feb 2024

Overview

The calculates distances, in meters, from each to the delivery address based on the incoming longitude/latitude. Sends with attributes containing calculated distances.

Plugin NameOrder Reference Module
Namespace[[account.id]].order

The is the foundation for order-related implementations. It provides reference workflows for , and mixed baskets and those needed to build your own. Extensible by design, use this Module as a base to build a solution to your customers' needs.

UI Description

Calculates the distances from each location to the order delivery address. Sends event with attributes containing calculated distances.

Accepts

  • ORDER
  • FULFILMENT_OPTIONS

Actions

  • This rule forwards the input event with name eventName containing attributes with calculated distances.

Rule parameters

Parameter

Description

eventName

The name triggered by this

Event attributes

Parameter

Description

Data Type

Required?

locations

The map of locations objects with longitude and latitude properties.

Map

Required

longitude

The longitude in the request compared to the longitude in the property for calculate the distances of each .

Double

Required

latitude

The latitude in the request compared to the latitude in the property for calculate the distances of each .

Double

Required

Exceptions

This does not explicitly identify any exceptions.

Configuration example

1{
2  "name":"<ACCOUNTID>.order.CalculateLocationsDistances",
3  "props": {
4    "eventName":"UPDATE_ORDER"
5  }
6}

Detailed Technical Description

The calculates distances using the Great-Circle Distance (GCD) method. Essentially, it determines the shortest path between two points on the Earth's surface, akin to a straight line drawn on a globe. This method accounts for the Earth's curvature, providing precise measurements compared to simpler distance calculations.

The distance is calculated in meters for each , and the information is passed along in an to the next . The applied formula is the Haversine formula.

Version History

2023-08-03

v1.0.0

refers to