Index: branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php =================================================================== diff -u -N -r13845 -r14089 --- branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php (.../shipping_quote_collector.php) (revision 13845) +++ branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php (.../shipping_quote_collector.php) (revision 14089) @@ -1,6 +1,6 @@ getEngineClasses(); @@ -46,7 +47,13 @@ /* @var $object ShippingQuoteEngine */ $new_shipping_types = $object->GetShippingQuotes($params); - $shipping_types = array_merge($shipping_types, $new_shipping_types); + + if (is_array($new_shipping_types)) { + $shipping_types = array_merge($shipping_types, $new_shipping_types); + } + else { + $quotes_valid = false; + } } uasort($shipping_types, Array(&$this, 'price_sort')); @@ -95,7 +102,9 @@ $shipping_types = $available_types; - $this->Application->setDBCache($cached_var_name, serialize($shipping_types), 24 * 3600); + if ($quotes_valid) { + $this->Application->setDBCache($cached_var_name, serialize($shipping_types), 24 * 3600); + } return $shipping_types; } @@ -136,6 +145,38 @@ return $classes; } + /** + * Returns shipping quote engine, that matches shipping type used in order + * + * @param Array $shipping_info + * @param int $package_num + * @return ShippingQuoteEngine + */ + function &GetClassByType($shipping_info, $package_num = 1) + { + if ( !$shipping_info || !array_key_exists($package_num, $shipping_info) ) { + return false; + } + + $classes = $this->getEngineClasses(); + $shipping_id = $shipping_info[$package_num]['ShippingId']; + + foreach ($classes as $class) { + $object =& $this->Application->recallObject($class); + /* @var $object ShippingQuoteEngine */ + + $shipping_types = $object->GetAvailableTypes(); + + foreach ($shipping_types as $index => $shipping_type) { + if ( preg_match('/^' . preg_quote($shipping_type['_Id'], '/') . '/', $shipping_id) ) { + return $class; + } + } + } + + return false; + } + function SortShippingTypes($elem1, $elem2) { if ($elem1['_Name'] == $elem2['_Name']) {