function tep_get_active_zone_total($zone, $mode) { global $cart; $products_array = $cart->get_products(); $key_array = array(); $total = 0; $catzone_query = tep_db_query("select c2cz.categories_id, c2cz.products_id, c2cz.shipping_price from " . TABLE_CAT_ZONES . " cz left join " . TABLE_CATEGORIES_TO_CAT_ZONES . " c2cz on (c2cz.cat_zone_id=cz.cat_zone_id) where cz.cat_zone_id = '" . (int)$zone . "'"); while( $catzone = tep_db_fetch_array($catzone_query) ) { if( !$catzone['categories_id'] && !$catzone['products_id'] ) { return $catzone['shipping_price']*count($products_array); } if( !$catzone['products_id'] ) { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$catzone['categories_id'] . "'"); while($products = tep_db_fetch_array($products_query) ) { $key_array[$products['products_id']] = $products['products_id']; } } else { $key_array[$catzone['products_id']] = $catzone['shipping_price']; } } $check_array = array_keys($key_array); foreach( $products_array as $key=>$val) { $check = in_array((int)$val['id'], $check_array); if( $check ) { $total += $key_array[(int)$val['id']]*$val['quantity']; } } return $total; }