コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CartLineBaseJsonResult"/> class.
        /// </summary>
        /// <param name="line">The line.</param>
        public CartLineBaseJsonResult(CustomCommerceCartLine line)
        {
            this.DiscountOfferNames = new List <string>();

            var product     = (CommerceCartProduct)line.Product;
            var productItem = ProductItemResolver.ResolveCatalogItem(product.ProductId, product.ProductCatalog, true);

            if (line.Images.Count > 0)
            {
                this.Image = line.Images[0].GetImageUrl(100, 100);
            }

            var userCurrency = StorefrontManager.GetCustomerCurrency();

            this.DisplayName        = product.DisplayName;
            this.Color              = product.Properties["Color"] as string;
            this.LineDiscount       = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToCurrency(this.GetCurrencyCode(userCurrency, ((CommerceTotal)line.Total).CurrencyCode));
            this.Quantity           = line.Quantity.ToString(Context.Language.CultureInfo);
            this.LinePrice          = product.Price.Amount.ToCurrency(this.GetCurrencyCode(userCurrency, product.Price.CurrencyCode));
            this.LineTotal          = line.Total.Amount.ToCurrency(this.GetCurrencyCode(userCurrency, line.Total.CurrencyCode));
            this.ExternalCartLineId = StringUtility.RemoveCurlyBrackets(line.ExternalCartLineId);
            this.ProductUrl         = product.ProductId.Equals(StorefrontManager.CurrentStorefront.GiftCardProductId, StringComparison.OrdinalIgnoreCase)
                ? StorefrontManager.StorefrontUri("/buygiftcard")
                : LinkManager.GetDynamicUrl(productItem);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AXCartLineBaseJsonResult"/> class.
 /// </summary>
 /// <param name="line">The line.</param>
 public AXCartLineBaseJsonResult(CustomCommerceCartLine line)
     : base(line)
 {
     if (!string.IsNullOrWhiteSpace(line.Properties["OfferNames"] as string))
     {
         this.DiscountOfferNames.Add(line.Properties["OfferNames"] as string);
     }
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AXCartLineBaseJsonResult"/> class.
 /// </summary>
 /// <param name="line">The line.</param>
 public AXCartLineBaseJsonResult(CustomCommerceCartLine line)
     : base(line)
 {
     if (!string.IsNullOrWhiteSpace(line.Properties["OfferNames"] as string))
     {
         this.DiscountOfferNames.Add(line.Properties["OfferNames"] as string);
     }
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSCartLineBaseJsonResult"/> class.
 /// </summary>
 /// <param name="line">The line.</param>
 public CSCartLineBaseJsonResult(CustomCommerceCartLine line)
     : base(line)
 {
     if (line.Adjustments.Count > 0)
     {
         foreach (var adjustment in line.Adjustments)
         {
             this.DiscountOfferNames.Add(adjustment.Description);
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSCartLineBaseJsonResult"/> class.
 /// </summary>
 /// <param name="line">The line.</param>
 public CSCartLineBaseJsonResult(CustomCommerceCartLine line)
     : base(line)
 {
     if (line.Adjustments.Count > 0)
     {
         foreach (var adjustment in line.Adjustments)
         {
             this.DiscountOfferNames.Add(adjustment.Description);
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CartLineBaseJsonResult"/> class.
        /// </summary>
        /// <param name="line">The line.</param>
        public CartLineBaseJsonResult(CustomCommerceCartLine line)
        {
            this.DiscountOfferNames = new List<string>();

            var product = (CommerceCartProduct)line.Product;
            var productItem = ProductItemResolver.ResolveCatalogItem(product.ProductId, product.ProductCatalog, true);

            if (line.Images.Count > 0)
            {
                this.Image = line.Images[0].GetImageUrl(100, 100);
            }

            this.DisplayName = product.DisplayName;
            this.Color = product.Properties["Color"] as string;
            this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToCurrency(StorefrontConstants.Settings.DefaultCurrencyCode);
            this.Quantity = line.Quantity.ToString(Context.Language.CultureInfo);
            this.LinePrice = product.Price.Amount.ToCurrency(StorefrontConstants.Settings.DefaultCurrencyCode);
            this.LineTotal = line.Total.Amount.ToCurrency(StorefrontConstants.Settings.DefaultCurrencyCode);
            this.ExternalCartLineId = StringUtility.RemoveCurlyBrackets(line.ExternalCartLineId);
            this.ProductUrl = product.ProductId.Equals(StorefrontManager.CurrentStorefront.GiftCardProductId, StringComparison.OrdinalIgnoreCase)
                ? StorefrontManager.StorefrontUri("/buygiftcard")
                : LinkManager.GetDynamicUrl(productItem);
        }