+ if ($factor == 0) return false; // auto price calculations off
+
+ $base_id = get_base_sales_type();
+ if ($base_id <= 0) return 0; // auto price calculations off
+
+ $home_curr = get_company_currency();
+
+ // get all prices which we can use to guess the price.
+ // alternative is make up to 2 additional sql queries
+ $sql = "SELECT price, curr_abrev, sales_type_id
+ FROM ".TB_PREF."prices
+ WHERE stock_id = '" . $stock_id . "' "
+ ." AND (sales_type_id = " . $sales_type_id
+ ." OR sales_type_id = " . $base_id.")"
+ ." AND (curr_abrev = '$currency'"
+ ." OR curr_abrev = '$home_curr')";
+
+ $result = db_query($sql, $msg);
+
+ $prices = array();
+ while($myrow = db_fetch($result))