Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

831 B
Raw Blame
namespace Grand.Domain.Orders;

/// <summary>
///     Represents a shopping cart
/// </summary>
public static class ShoppingCartExtensions
{
    /// <summary>
    ///     Indicates whether the shopping cart requires shipping
    /// </summary>
    /// <param name="shoppingCart">Shopping cart</param>
    /// <returns>True if the shopping cart requires shipping; otherwise, false.</returns>
    public static bool RequiresShipping(this IList<ShoppingCartItem> shoppingCart)
    {
        return shoppingCart.Any(shoppingCartItem => shoppingCartItem.IsShipEnabled);
    }

    public static IEnumerable<ShoppingCartItem> LimitPerStore(this IEnumerable<ShoppingCartItem> cart,
        bool cartsSharedBetweenStores, string storeId)
    {
        return cartsSharedBetweenStores ? cart : cart.Where(x => x.StoreId == storeId);
    }
}