public ActionResult Rendering()
        {
            var productView = new ProductCardRenderingViewModel();

            var database    = Sitecore.Context.Database;
            var productItem = database.GetItem(RenderingContext.Current.Rendering.Properties["productGuid"]);

            if (productItem == null)
            {
                return(null);
            }
            productView.DisplayName    = new HtmlString(FieldRenderer.Render(productItem, "Display Name"));
            productView.ThumbnailImage = new HtmlString(FieldRenderer.Render(productItem, "Thumbnail image"));

            var currentProduct = _productIndex.Find().Where(x => x.Guid == productItem.ID.Guid).SingleOrDefault();
            var category       = _catalogContext.CurrentCategory;

            productView.Url = _urlService.GetUrl(_catalogContext.CurrentCatalog,
                                                 _catalogContext.CurrentCategories.Append(_catalogContext.CurrentCategory).Compact()
                                                 , currentProduct);

            productView.ProductPriceRenderingViewModel =
                GetProductPriceRenderingViewModel(currentProduct, category, _catalogContext.CurrentCatalog);

            return(View(productView));
        }
Пример #2
0
        public ActionResult CalculatePrice(ProductCardRenderingViewModel priceCalculationDetails)
        {
            var product = _productRepository.Select(x => x.Sku == priceCalculationDetails.ProductSku && x.ParentProduct == null).FirstOrDefault();
            var catalog = _catalogLibraryInternal.GetCatalog(priceCalculationDetails.CatalogId);
            PriceCalculation priceCalculation = new PriceCalculation(product, catalog);

            var yourPrice = priceCalculation.YourPrice.Amount.ToString();
            var yourTax   = priceCalculation.YourTax.ToString();
            var discount  = priceCalculation.Discount.Amount.ToString();

            return(Json(new { YourPrice = yourPrice, Tax = yourTax, Discount = discount }));
        }
Пример #3
0
        public ActionResult CalculatePrice(ProductCardRenderingViewModel priceCalculationDetails)
        {
            var product = _productIndex.Find()
                          .Where(x => x.Sku == priceCalculationDetails.ProductSku && x.VariantSku == null).SingleOrDefault();

            string priceGroupName  = _catalogContext.CurrentPriceGroup.Name;
            string currencyIsoCode = _catalogContext.CurrentPriceGroup.CurrencyISOCode;

            var yourPrice = new Money(product.PricesInclTax[priceGroupName], currencyIsoCode).ToString();
            var yourTax   = new Money(product.Taxes[priceGroupName], currencyIsoCode).ToString();

            return(Json(new { YourPrice = yourPrice, Tax = yourTax, Discount = 0 }));
        }
        public ActionResult Rendering()
        {
            var productView = new ProductCardRenderingViewModel();

            var database    = Sitecore.Context.Database;
            var productItem = database.GetItem(RenderingContext.Current.Rendering.Properties["productGuid"]);

            if (productItem == null)
            {
                return(null);
            }
            productView.DisplayName    = new HtmlString(FieldRenderer.Render(productItem, "Display Name"));
            productView.ThumbnailImage = new HtmlString(FieldRenderer.Render(productItem, "Thumbnail image"));

            var currentProduct = _productRepository.SingleOrDefault(x => x.Guid == productItem.ID.Guid);
            var category       = _catalogContext.CurrentCategory;

            productView.Url = CatalogLibrary.GetNiceUrlForProduct(currentProduct, category);
            productView.ProductPriceRenderingViewModel = GetProductPriceRenderingViewModel(currentProduct, category, _catalogContext.CurrentCatalog);

            return(View(productView));
        }