+ return $price === false ? false : round($price, user_price_dec());
+}
+//----------------------------------------------------------------------------------------
+//
+// Get price for given item or kit.
+// When $std==true price is calculated as a sum of all included stock items,
+// otherwise all prices set for kits and items are accepted.
+//
+function get_kit_price($item_code, $currency, $sales_type_id, $factor=null,
+ $date=null, $std = false)
+{
+ $kit_price = 0.00;
+ if (!$std) {
+ $kit_price = get_price( $item_code, $currency, $sales_type_id,
+ $factor, $date);
+
+ if ($kit_price !== false) {
+ return $kit_price;
+ }
+ }
+ // no price for kit found, get total value of all items
+ $kit = get_item_kit($item_code);
+
+ while($item = db_fetch($kit)) {
+ if ($item['item_code'] != $item['stock_id']) {
+ // foreign/kit code
+ $kit_price += $item['quantity'] * get_kit_price( $item['stock_id'],
+ $currency, $sales_type_id, $factor, $date, $std);
+
+ } else {
+ // stock item
+ $kit_price += $item['quantity'] * get_price( $item['stock_id'],
+ $currency, $sales_type_id, $factor, $date);
+ }
+ }
+ return $kit_price;