{"size": 714, "ext": "js", "max_stars_repo_path": "client/js/components/Products/Utilities.js", "max_stars_repo_name": "SlateRobotics/slate-website", "max_stars_repo_stars_event_min_datetime": "2019-08-03T16:55:04.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-04T04:26:46.000Z", "max_issues_repo_path": "client/js/components/Products/Utilities.js", "max_issues_repo_name": "SlateRobotics/slate-website", "max_issues_repo_issues_event_min_datetime": "2020-04-30T00:06:42.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-30T00:06:42.000Z", "max_forks_repo_path": "client/js/components/Products/Utilities.js", "max_forks_repo_name": "SlateRobotics/slate-website", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 25.5, "max_line_length": 61, "alphanum_fraction": 0.5518207283}
module.exports = {
  CalculateTotal: function (product, config) {
    if (!product || !config) { return; }
    var total = product.basePrice;
    for (var i = 0; i < product.config.length; i++) {
      var productConfig = product.config[i];

      var orderConfig;
      for (var j = 0; j < config.length; j++) {
        if (config[j].name == productConfig.name) {
          orderConfig = config[j];
        }
      }

      var configItem;
      for (var j = 0; j < productConfig.items.length; j++) {
        if (productConfig.items[j].id == orderConfig.value) {
          configItem = productConfig.items[j];
        }
      }

      if (configItem) { total += configItem.price; }
    }

    return total;
  }
}
