function updateCalculatedPrice(&$startingPrice)
 {
     $newPrice = -1;
     $fieldName = $this->owner->ClassName . "ID";
     $singleton = ComplexPriceObject::get()->first();
     if ($singleton) {
         // Check that ComplexPriceObject can be joined to this type of object
         if (!$singleton->hasField($fieldName)) {
             $ancestorArray = ClassInfo::ancestry($this->owner, true);
             foreach ($ancestorArray as $ancestor) {
                 $fieldName = $ancestor . "ID";
                 if ($singleton->hasField($fieldName)) {
                     break;
                 }
             }
         }
         // Load up the alternate prices for this product
         $prices = ComplexPriceObject::get()->filter(array($fieldName => $this->owner->ID, "NoLongerValid" => 0))->sort("NewPrice", "DESC");
         $memberGroupsArray = array();
         if ($prices->count()) {
             // Load up the groups for the current memeber, if any
             if ($member = Member::currentUser()) {
                 if ($memberGroupComponents = $member->getManyManyComponents('Groups')) {
                     if ($memberGroupComponents && $memberGroupComponents->count()) {
                         $memberGroupsArray = $memberGroupComponents->column("ID");
                         if (!is_array($memberGroupsArray)) {
                             $memberGroupsArray = array();
                         }
                     }
                 }
             }
             $countryID = EcommerceCountry::get_country_id();
             // Look at each price and see if it can be used
             foreach ($prices as $price) {
                 $priceCanBeUsed = true;
                 // Does it pass the group filter?
                 if ($priceGroupComponents = $price->getManyManyComponents('Groups')) {
                     if ($priceGroupComponents && $priceGroupComponents->count()) {
                         $priceCanBeUsed = false;
                         $priceGroupArray = $priceGroupComponents->column("ID");
                         if (!is_array($priceGroupArray)) {
                             $priceGroupArray = array();
                         }
                         $interSectionArray = array_intersect($priceGroupArray, $memberGroupsArray);
                         if (is_array($interSectionArray) && count($interSectionArray)) {
                             $priceCanBeUsed = true;
                         }
                     }
                 }
                 // Does it pass the country filter?
                 if ($priceCanBeUsed) {
                     if ($priceCountryComponents = $price->getManyManyComponents('EcommerceCountries')) {
                         if ($priceCountryComponents && $priceCountryComponents->count()) {
                             $priceCanBeUsed = false;
                             $priceCountryArray = $priceCountryComponents->column("ID");
                             if (!is_array($priceCountryArray)) {
                                 $priceCountryArray = array();
                             }
                             if ($countryID && in_array($countryID, $priceCountryArray)) {
                                 $priceCanBeUsed = true;
                             }
                         }
                     }
                 }
                 // Does it pass the date filter?
                 if ($priceCanBeUsed) {
                     $nowTS = strtotime("now");
                     if ($price->From) {
                         $priceCanBeUsed = false;
                         $fromTS = strtotime($price->From);
                         if ($fromTS && $fromTS < $nowTS) {
                             $priceCanBeUsed = true;
                         }
                     }
                 }
                 if ($priceCanBeUsed) {
                     if ($price->Until) {
                         $priceCanBeUsed = false;
                         $untilTS = strtotime($price->Until);
                         if ($untilTS && $untilTS > $nowTS) {
                             $priceCanBeUsed = true;
                         }
                     }
                 }
                 // If so, apply the price
                 if ($priceCanBeUsed) {
                     $newPrice = $price->getCalculatedPrice();
                 }
             }
         }
     }
     if ($newPrice > -1) {
         $startingPrice = $newPrice;
     }
     return $startingPrice;
 }