/// <summary> /// Gets inventory for all of the variations for a given product /// </summary> /// <remarks> /// If none of the variations has stock, then 0 is returned. /// </remarks> /// <param name="content">The content.</param> /// <returns>The sum of all variation's stock</returns> public static decimal GetStock(this ProductContent content) { if (content == null) { return(0); } var varitions = content.GetVaritions(); if (varitions == null) { return(0); } decimal stock = 0; foreach (VariationContent varition in varitions) { stock += varition.GetStock(); } return(stock); }