Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | |||||
function MakeOrder(&$object, $dry_run = false) | function MakeOrder(&$object, $dry_run = false) | ||||
{ | { | ||||
return Array (); | return Array (); | ||||
} | } | ||||
/** | /** | ||||
* Loads properties of shipping quote engine | * Loads properties of shipping quote engine | ||||
* | * | ||||
* @return void | |||||
*/ | */ | ||||
function initProperties() | protected function initProperties() | ||||
{ | { | ||||
$sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge | $cache_key = 'shipping_quote_engines_data[%SqeSerial%]'; | ||||
$cache_value = $this->Application->getCache($cache_key); | |||||
if ( $cache_value === false ) { | |||||
$this->Conn->nextQueryCachable = true; | |||||
$sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge, LOWER(ClassName) AS SQEKey | |||||
FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . ' | ||||
WHERE LOWER(ClassName) = ' . $this->Conn->qstr( strtolower( get_class($this) ) ); | WHERE Status = ' . STATUS_ACTIVE; | ||||
$data = $this->Conn->GetRow($sql); | $cache_value = $this->Conn->Query($sql, 'SQEKey'); | ||||
foreach ( $cache_value as $sqe_key => $sqe_data ) { | |||||
$properties = $sqe_data['Properties'] ? unserialize($sqe_data['Properties']) : array(); | |||||
$properties['FlatSurcharge'] = $sqe_data['FlatSurcharge']; | |||||
$properties['PercentSurcharge'] = $sqe_data['PercentSurcharge']; | |||||
$cache_value[$sqe_key]['Properties'] = $properties; | |||||
unset($cache_value[$sqe_key]['FlatSurcharge'], $cache_value[$sqe_key]['PercentSurcharge']); | |||||
} | |||||
if (is_array($data)) { | $this->Application->setCache($cache_key, $cache_value); | ||||
$properties = $data['Properties'] ? unserialize($data['Properties']) : Array (); | } | ||||
$properties['FlatSurcharge'] = $data['FlatSurcharge']; | |||||
$properties['PercentSurcharge'] = $data['PercentSurcharge']; | $sqe_key = strtolower(get_class($this)); | ||||
$this->properties = $properties; | if ( array_key_exists($sqe_key, $cache_value) ) { | ||||
$this->properties = $cache_value[$sqe_key]['Properties']; | |||||
} | } | ||||
else { | else { | ||||
$this->properties = Array (); | $this->properties = array(); | ||||
} | } | ||||
} | } | ||||
} | |||||
No newline at end of file | } |