public async Task<JsonResult> Add(string slug, int? q)
        {
            int quantity = q ?? 1;

            var customerId = GetCustomerId(HttpContext, Settings.AnonymousCookieId);

            var productModel = await _catalogService.GetProductAsync(Settings.StoreId, Settings.Culture, slug);

            if (productModel == null)
            {
                return Json(new { errorMessage = T("Product not found").Text });
            }

            var shoppingCartModel = await _shoppingCartService.GetShoppingCartAsync(Settings.StoreId, customerId);

            var shopModels = await _catalogService.GetShopsAsync();
            var shopModel = shopModels.FirstOrDefault(s => s.Id == Settings.StoreId);

            if (shoppingCartModel == null)
            {
                shoppingCartModel = new ShoppingCart();
                shoppingCartModel.Culture = Settings.Culture;
                shoppingCartModel.Currency = shopModel.Currency;
                shoppingCartModel.CustomerId = customerId;
                shoppingCartModel.StoreId = shopModel.Id;

                await _shoppingCartService.CreateShoppingCartAsync(shoppingCartModel);

                shoppingCartModel = await _shoppingCartService.GetShoppingCartAsync(Settings.StoreId, customerId);
            }

            shoppingCartModel.Add(productModel.ToLineItem(quantity, shopModel.Currency));

            await _shoppingCartService.UpdateShoppingCartAsync(shoppingCartModel);

            return Json(new { shoppingCart = shoppingCartModel });
        }
        public async Task UpdateShoppingCartAsync(ShoppingCart shoppingCart)
        {
            var shoppingCartModel = shoppingCart.ToApiModel();

            await _apiClient.CartClient.UpdateCurrentCartAsync(shoppingCartModel).ConfigureAwait(false);
        }
        public static ShoppingCart ToViewModel(this DataContracts.Cart.ShoppingCart shoppingCart)
        {
            var shoppingCartModel = new ShoppingCart();

            shoppingCartModel.Culture = shoppingCart.LanguageCode;
            shoppingCartModel.Currency = shoppingCart.Currency;
            shoppingCartModel.CustomerId = shoppingCart.CustomerId;
            shoppingCartModel.Id = shoppingCart.Id;

            foreach (var lineItem in shoppingCart.Items)
            {
                shoppingCartModel.LineItems.Add(lineItem.ToViewModel());
            }

            shoppingCartModel.StoreId = shoppingCart.StoreId;

            return shoppingCartModel;
        }