$propertyCollection = $order->getPropertyCollection();
foreach ($propertyCollection->getGroups() as $group)
{
foreach ($propertyCollection->getGroupProperties($group['ID']) as $property)
{
$p = $property->getProperty();
if($p["CODE"] == "LOCATION")
$property->setValue($location);
}
}