protected AddToCartModel PrepareAddToCartModel(ProductOverviewModel product, ProductPrice productPrice, CartItemOverviewModel cartItem = null) { var model = new AddToCartModel(); model.ProductId = product.Id; model.AvailableForPreOrder = product.ShowPreOrderButton; if (product.Enabled == false) { return(model); } if (productPrice == null) { return(model); } if (productPrice.PriceExclTax <= 0M) { return(model); } if (productPrice.Enabled == false) { return(model); } if ((product.ProductEnforcedStockCount || product.BrandEnforcedStockCount) && productPrice.Stock <= 0) { return(model); } var maxQuantity = product.CalculateMaxQuantity(productPrice.Stock, productPrice.MaximumAllowedPurchaseQuantity); //allowed quantities if (maxQuantity > 0) { model.Visible = true; var increment = product.StepQuantity <= 0 ? 1 : product.StepQuantity; for (int i = product.StepQuantity; i <= maxQuantity; i = i + increment) { model.AllowedQuantities.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() }); } } return(model); }