Exemple #1
0
        private void RepriceItemsForUser(Order order)
        {
            foreach (var li in order.Items)
            {
                if (!li.IsUserSuppliedPrice && !li.IsGiftCard)
                {
                    var price = _app.PriceProduct(li.ProductId, order.UserID, li.SelectionData);

                    // Null check because if the item isn't in the catalog
                    // we will get back a null user specific price.
                    //
                    // In the future it may be a good idea to add an option
                    // allowing merchant to select if they would like to allow
                    // items not in the catalog to exist in carts or if we should
                    // just remove items from the cart with a warning here.
                    if (price == null)
                    {
                        continue;
                    }

                    li.BasePricePerItem = price.BasePrice;

                    foreach (var discount in price.DiscountDetails)
                    {
                        li.DiscountDetails.Add(new DiscountDetail
                        {
                            Amount       = discount.Amount * li.Quantity,
                            Description  = discount.Description,
                            DiscountType = PromotionType.Sale
                        });
                    }
                }
            }
        }
        /// <summary>
        ///     Set parameter values with provided product object
        /// </summary>
        /// <param name="p">Product information.</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public SingleProductViewModel(Product p, HotcakesApplication hccApp)
        {
            if (p == null)
            {
                throw new ArgumentNullException("Product");
            }
            if (hccApp == null)
            {
                throw new ArgumentNullException("HotcakesApplication");
            }

            UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales);
            Item      = p;

            ProductLink = UrlRewriter.BuildUrlForProduct(p);
            ImageUrls   = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, p);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp);

#pragma warning disable 0612, 0618
            ImageUrl = DiskStorage.ProductImageUrlSmall(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.IsCurrentRequestSecure());

            OriginalImageUrl = DiskStorage.ProductImageUrlOriginal(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
#pragma warning restore 0612, 0618
        }
Exemple #3
0
        public SingleProductJsonModel(Product product, HotcakesApplication app)
        {
            ProductLink   = UrlRewriter.BuildUrlForProduct(product);
            ProductName   = product.ProductName;
            ImageSmallUrl = DiskStorage.ProductImageUrlSmall(app, product.Bvin, product.ImageFileSmall,
                                                             app.IsCurrentRequestSecure());
            ImageSmallAltText = product.ImageFileSmallAlternateText;
            ProductSku        = product.Sku;
            Bvin = product.Bvin;

            var up = app.PriceProduct(product, app.CurrentCustomer, null, app.CurrentlyActiveSales);

            UserPrice = up.DisplayPrice();
        }
Exemple #4
0
        /// <summary>
        ///     Set parameter values with provided product object
        /// </summary>
        /// <param name="p">Product information.</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public SingleProductViewModel(Product p, HotcakesApplication hccApp)
        {
            if (p == null)
            {
                throw new ArgumentNullException("Product");
            }
            if (hccApp == null)
            {
                throw new ArgumentNullException("HotcakesApplication");
            }

            UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales);
            Item      = p;

            ProductLink          = UrlRewriter.BuildUrlForProduct(p);
            ProductAddToCartLink = UrlRewriter.BuildUrlForProductAddToCart(p);
            ImageUrls            = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, p);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp);
        }