Пример #1
0
        /// <summary>
        /// Builds a <see cref="BasketLineItem"/>
        /// </summary>
        /// <param name="lineItem">
        /// The line item.
        /// </param>
        /// <returns>
        /// The <see cref="BasketLineItem"/>.
        /// </returns>
        public BasketLineItem Build(ILineItem lineItem)
        {
            var contentId = lineItem.ExtendedData.ContainsKey("umbracoContentId")
                                ? int.Parse(lineItem.ExtendedData["umbracoContentId"])
                                : 0;

            var productKey = lineItem.ExtendedData.GetProductKey();
            ProductModel product = null;
            if (!productKey.Equals(Guid.Empty))
            {
                var productContent = _merchello.TypedProductContent(productKey);  
                if (productContent != null) product = new ProductModel(productContent)
                                                          {
                                                              CurrentCustomer = _currentCustomer,
                                                              Currency = _currency
                                                          };
            }
            

            var basketLineItem = new BasketLineItem
                {
                    Key = lineItem.Key,
                    ContentId = contentId,
                    Name = lineItem.Name,
                    Sku = lineItem.Sku,
                    UnitPrice = lineItem.Price,
                    TotalPrice = lineItem.TotalPrice,
                    Quantity = lineItem.Quantity,
                    ExtendedData = lineItem.ExtendedData,
                    Product = product ?? this.HandleLegacyBazaarProductContent(contentId)
                };

            return basketLineItem;
        }
Пример #2
0
        public ActionResult RenderAddToBasket(ProductModel model)
        {
            var addItemModel = new AddItemModel()
            {
                Product = model.ProductData,
                ContentId = model.Id,
                BasketPageId = BazaarContentHelper.GetBasketContent().Id,
                ShowWishList = model.ShowWishList,
                WishListPageId = BazaarContentHelper.GetWishListContent().Id,
                Currency = model.Currency
            };

            return RenderAddItem(addItemModel);
        }
        public ActionResult RenderAddToBasket(ProductModel model)
        {
            var addItemModel = new AddItemModel()
            {
                Product = model.ProductData,
                ContentId = model.Id,
                BasketPageId = model.BasketPage.Id,
                ShowWishList = model.ShowWishList,
                WishListPageId = model.WishListPage.Id,
                Currency = model.Currency
            };

            return this.PartialView(model.ThemePartialViewPath("AddToCart"), addItemModel);
        }