コード例 #1
0
        public static int CurrentCartId(this HttpContextBase context)
        {
            var email = context.CurrentCustomerEmail();

            if (!String.IsNullOrWhiteSpace(email))
            {
                return(Site.Current.Commerce().ShoppingCarts.GetCartIdByCustomer(email));
            }

            var sessionId = EngineContext.Current.Resolve <IShoppingCartSessionIdProvider>().GetCurrentSessionId(true);

            return(Site.Current.Commerce().ShoppingCarts.GetCartIdBySessionId(sessionId));
        }