getObject(); /* @var $object kDBItem */ $engine = $this->Application->recallObject($object->GetDBField('ClassName')); /* @var $engine ShippingQuoteEngine */ $engine_fields = $engine->GetEngineFields(); $properties = $object->GetDBField('Properties'); $properties = $properties ? unserialize($properties) : Array (); // common fields for all shipping quote engines if ( $object->GetDBField('AccountPassword') != '' ) { // don't erase password by accident $engine_fields[] = 'AccountPassword'; } // save shipping quote specific fields foreach ($engine_fields as $engine_field) { $properties[$engine_field] = $object->GetDBField($engine_field); } $object->SetDBField('Properties', serialize($properties)); $cs_helper = $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */ $from_country = $this->Application->ConfigValue('Comm_Shipping_Country'); $has_states = strlen($from_country) == 3 ? $cs_helper->CountryHasStates($from_country) : false; $valid_address = $from_country && ($has_states && $this->Application->ConfigValue('Comm_Shipping_State') || !$has_states) && $this->Application->ConfigValue('Comm_Shipping_City') && $this->Application->ConfigValue('Comm_Shipping_ZIP'); if ( !function_exists('curl_init') ) { $object->SetError('Status', 'curl_not_present'); } elseif ( ($object->GetDBField('Status') == STATUS_ACTIVE) && !$valid_address ) { $object->SetError('Status', 'from_info_not_filled_in'); } } /** * Sets virtual fields from serialized properties array * * @param kEvent $event * @return void * @access protected */ protected function OnAfterItemLoad(kEvent $event) { parent::OnAfterItemLoad($event); $object = $event->getObject(); /* @var $object kDBItem */ $properties = $object->GetDBField('Properties'); if ( $properties ) { $object->SetDBFieldsFromHash(unserialize($properties)); } } /** * Deletes cached shipping quotes on any setting change * * @param kEvent $event * @return void * @access protected */ protected function OnAfterItemCreate(kEvent $event) { parent::OnAfterItemCreate($event); $this->_deleteQuoteCache(); } /** * Deletes cached shipping quotes on any setting change * * @param kEvent $event * @return void * @access protected */ protected function OnAfterItemUpdate(kEvent $event) { parent::OnAfterItemUpdate($event); $this->_deleteQuoteCache(); } /** * Deletes cached shipping quotes on any setting change * * @param kEvent $event * @return void * @access protected */ protected function OnAfterItemDelete(kEvent $event) { parent::OnAfterItemDelete($event); $this->_deleteQuoteCache(); } /** * Deletes cached shipping quotes * */ function _deleteQuoteCache() { $sql = 'DELETE FROM ' . TABLE_PREFIX . 'SystemCache WHERE VarName LIKE "ShippingQuotes%"'; $this->Conn->Query($sql); } }