public static PromotionProductEntry ToPromotionItem(this LineItem lineItem)
        {
            var promoItem = new PromotionProductEntry();

            promoItem.InjectFrom(lineItem);

            promoItem.Discount   = (double)lineItem.DiscountTotal.Amount;
            promoItem.Price      = (double)lineItem.PlacedPrice.Amount;
            promoItem.Quantity   = lineItem.Quantity;
            promoItem.Variations = null; // TODO

            return(promoItem);
        }
Example #2
0
        public static PromotionProductEntry ToPromotionItem(this Product product)
        {
            var promoItem = new PromotionProductEntry();

            promoItem.InjectFrom(product);

            if (product.Price != null)
            {
                promoItem.Discount = new Money(product.Price.ActiveDiscount != null ? product.Price.ActiveDiscount.Amount.Amount : 0m, product.Price.Currency);
                promoItem.Price    = product.Price.SalePrice;
            }

            promoItem.ProductId  = product.Id;
            promoItem.Quantity   = 1;
            promoItem.Variations = product.Variations.Select(v => v.ToPromotionItem()).ToList();

            return(promoItem);
        }