I’m a bit stuck trying to use “before” restriction for my API input. Standard case is where I have e.g. 3 shipments per route (3 pickup locations and 3 dropoff locations).
And I’m trying to avoid cases where RouteXL would plan a same shipment’s dropoff before the pickup. So what I would need to do is set a “before” index for each dropoff location (I guess?).
But I’m creating locations array in foreach loop, something like that:
$locations = array();
foreach ($rows as $row) {
if ($location_type = "dropoff") {
$before_index = ???
}
$locations[] = array(
'name' => $row->location_id,
'lat' => $row->lat,
'lng' => $row->lng,
'servicetime' => $row->service_time,
'restrictions' => array(
'ready' => $row->ready_time_minutes,
'due' => $row->due_time_minutes,
'before' => $before_index
)
);
}
But as the locations array is created on-the-fly in the loop, the index might not yet be created when I need to add it as “before” value.
Would really appreciate if you could point me at the right direction.
Thank you in advance!