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; } /* - wont work, doesnt account for quantity which is in memory =/ ... if not for that, would do all the work itself.. SELECT SUM(c2.shipping_price) AS shipping_total FROM " . TABLE_CAT_ZONES . " c LEFT JOIN " . TABLE_CATEGORIES_TO_CAT_ZONES . " c2 ON (c2.cat_zone_id=c.cat_zone_id) WHERE c.cat_zone_name = '" . $zone . "' AND c2.products_id IN ('" . implode("', '", (array)$pids) . "') */ function get_actual_total_from_retarded_ass_zones($zone) { global $cart; $pids = array(); foreach($cart->get_products() as $product) if(!is_null($id = ($pos = strpos($product['id'], '{')) ? substr($product['id'], 0, $pos) : $product['id']) ) $pids[$id] = $product['quantity']; if(empty($pids)) return 0; $cat = tep_db_query(" SELECT DISTINCT c2.products_id, c2.shipping_price FROM " . TABLE_CAT_ZONES . " c LEFT JOIN " . TABLE_CATEGORIES_TO_CAT_ZONES . " c2 ON (c2.cat_zone_id=c.cat_zone_id) WHERE c.cat_zone_id = '" . (int)$zone . "' AND c2.products_id IN ('" . implode("', '", array_keys((array)$pids)) . "') ") or die(mysql_error()); for($t = 0;$re = tep_db_fetch_array($cat);) { foreach($pids as $id => $quantity) if($id == $re['products_id']) $t += $re['shipping_price'] * (empty($quantity) ? 1 : $quantity); } return sprintf('%.2f', empty($t) ? 0 : $t); }