/** * Returns the available delivery options based on the current country and region * for the order. * Must always return something! * @return DataList */ protected function liveOptions() { if (!self::$available_options) { $countryID = EcommerceCountry::get_country_id(); $regionID = EcommerceRegion::get_region_id(); $weight = $this->LiveTotalWeight(); $options = PickUpOrDeliveryModifierOptions::get(); if ($options->count()) { foreach ($options as $option) { //check countries if ($countryID) { $optionCountries = $option->AvailableInCountries(); //exclude if not found in country list if ($optionCountries->Count() > 0 && !$optionCountries->find('ID', $countryID)) { continue; } } //check regions if ($regionID) { $optionRegions = $option->AvailableInRegions(); //exclude if not found in region list if ($optionRegions->Count() > 0 && !$optionRegions->find('ID', $regionID)) { continue; } } $result[] = $option; } } if (!isset($result)) { $result[] = PickUpOrDeliveryModifierOptions::default_object(); } self::$available_options = new ArrayList($result); } return self::$available_options; }