/// <summary> /// Initializes the specified cart. /// </summary> /// <param name="cart">The cart.</param> public virtual void Initialize(Cart cart) { Assert.ArgumentNotNull(cart, "cart"); this.LineItemCount = ((CommerceCart)cart).LineItemCount; this.Total = ((CommerceTotal)cart.Total).Subtotal.ToCurrency(StorefrontManager.GetCustomerCurrency()); }
/// <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); }
/// <summary> /// Initializes this object based on the data contained in the provided cart. /// </summary> /// <param name="cart">The cart used to initialize this object.</param> public override void Initialize(Commerce.Entities.Carts.Cart cart, IProductResolver productResolver) { base.Initialize(cart, productResolver); CommerceCart commerceCart = cart as CommerceCart; if (commerceCart == null) { return; } if (commerceCart.OrderForms.Count > 0) { foreach (var promoCode in (commerceCart.OrderForms[0].PromoCodes ?? Enumerable.Empty <String>())) { this.PromoCodes.Add(promoCode); } } decimal totalSavings = 0; foreach (var lineitem in cart.Lines) { totalSavings += ((CommerceTotal)lineitem.Total).LineItemDiscountAmount; } this.Discount = totalSavings.ToCurrency(StorefrontManager.GetCustomerCurrency()); }
/// <summary> /// Initializes the specified renderings. /// </summary> /// <param name="renderings">The renderings.</param> /// <param name="confirmationId">The confirmation identifier.</param> /// <param name="order">The order.</param> public void Initialize(Rendering renderings, string confirmationId, CommerceOrder order) { base.Initialize(renderings); this.ConfirmationId = confirmationId; this.OrderStatus = StorefrontManager.GetOrderStatusName(order.Status); }
/// <summary> /// Sends the mail. /// </summary> /// <returns>True if the email was sent, false otherwise</returns> protected virtual bool SendMail() { MailMessage message = new MailMessage { From = new MailAddress(this._mailFrom), Body = this._mailBody, Subject = this._mailSubject, IsBodyHtml = true }; message.To.Add(this._mailTo); if (this._mailAttachmentFileName != null && File.Exists(this._mailAttachmentFileName)) { Attachment attachment = new Attachment(this._mailAttachmentFileName); message.Attachments.Add(attachment); } try { MainUtil.SendMail(message); string infoMessage = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.MailSentToMessage); Log.Info(Translate.Text(string.Format(CultureInfo.InvariantCulture, infoMessage, message.To, message.Subject)), "SendMailFromTemplate"); return(true); } catch (Exception e) { string errorMessage = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.CouldNotSendMailMessageError); Log.Error(Translate.Text(string.Format(CultureInfo.InvariantCulture, errorMessage, message.Subject, message.To)), e, "SendMailFromTemplate"); return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="WishListHeaderItemBaseJsonResult"/> class. /// </summary> /// <param name="header">The wish list header.</param> public WishListHeaderItemBaseJsonResult(WishListHeader header) { this.ExternalId = header.ExternalId; this.Name = header.Name; this.IsFavorite = header.IsFavorite; this.DetailsUrl = string.Concat(StorefrontManager.StorefrontUri("/accountmanagement/mywishlist"), "?id=", header.ExternalId); }
public JsonResult SubmitOrder(SubmitOrderInputModel inputModel) { try { Assert.ArgumentNotNull(inputModel, "inputModel"); var validationResult = new BaseJsonResult(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var response = this.OrderManager.SubmitVisitorOrder(CurrentStorefront, CurrentVisitorContext, inputModel); var result = new SubmitOrderBaseJsonResult(response.ServiceProviderResult); if (!response.ServiceProviderResult.Success || response.Result == null || response.ServiceProviderResult.CartWithErrors != null) { return(Json(result, JsonRequestBehavior.AllowGet)); } result.Initialize(string.Concat(StorefrontManager.StorefrontUri("checkout/OrderConfirmation"), "?confirmationId=", (response.Result.TrackingNumber))); return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception e) { CommerceLog.Current.Error("SubmitOrder", this, e); return(Json(new BaseJsonResult("SubmitOrder", e), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Initializes a new instance of the <see cref="OrderHeaderItemBaseJsonResult"/> class. /// </summary> /// <param name="header">The order header.</param> public OrderHeaderItemBaseJsonResult(OrderHeader header) { this.ExternalId = header.ExternalId; this.Status = header.Status; this.LastModified = ((CommerceOrderHeader)header).LastModified.ToDisplayedDate(); this.DetailsUrl = string.Concat(StorefrontManager.StorefrontUri("/accountmanagement/myorder"), "?id=", header.ExternalId); this.OrderId = header.ExternalId; }
/// <summary> /// Checks if the Tracker.Current object os null. /// </summary> /// <param name="tracker">The tracker.</param> /// <returns>In the context of the Runtime site, will trow a TrackingNotEnabledException; Otherwise null is returned /// in the context of the page editor.</returns> /// <exception cref="TrackingNotEnabledException">Tracker is null we are in the context of the runtime site.</exception> public static ITracker CheckForNull(this ITracker tracker) { if (tracker == null && !Sitecore.Context.PageMode.IsExperienceEditor) { throw new TrackingNotEnabledException(StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.TrackingNotEnabled)); } return(tracker); }
public JsonResult GetRequiredFieldMessage() { return(Json( new { RequiredFieldMessage = StorefrontManager.GetHtmlSystemMessage("RequiredFieldMessage").ToHtmlString() }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetCheckoutData() { try { var result = new CheckoutDataBaseJsonResult(); var response = this.CartManager.GetCurrentCart(CurrentStorefront, CurrentVisitorContext, true); if (response.ServiceProviderResult.Success && response.Result != null) { var cart = (CommerceCart)response.ServiceProviderResult.Cart; if (cart.Lines != null && cart.Lines.Any()) { result.Cart = new CSCartBaseJsonResult(response.ServiceProviderResult); result.Cart.Initialize(response.ServiceProviderResult.Cart); result.ShippingMethods = new List <ShippingMethod>(); result.CartLoyaltyCardNumber = cart.LoyaltyCardID; result.CurrencyCode = StorefrontManager.GetCustomerCurrency(); this.AddShippingOptionsToResult(result, cart); if (result.Success) { this.AddShippingMethodsToResult(result); if (result.Success) { this.GetAvailableCountries(result); if (result.Success) { this.GetPaymentOptions(result); if (result.Success) { this.GetPaymentMethods(result); if (result.Success) { this.GetPaymentClientToken(result); if (result.Success) { this.GetUserInfo(result); } } } } } } } } result.SetErrors(response.ServiceProviderResult); return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception e) { CommerceLog.Current.Error("GetCheckoutData", this, e); return(Json(new BaseJsonResult("GetCheckoutData", e), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Turns a decimal value into a currency string /// </summary> /// <param name="currency">The decimal object to act on</param> /// <param name="currencyCode">The currency code.</param> /// <returns> /// A decimal formatted as a string /// </returns> public static string ToCurrency(this decimal currency, string currencyCode) { CurrencyInformationModel currencyInfo = StorefrontManager.GetCurrencyInformation(currencyCode); NumberFormatInfo info = (NumberFormatInfo)CultureInfo.GetCultureInfo(currencyInfo.CurrencyNumberFormatCulture).NumberFormat.Clone(); info.CurrencySymbol = currencyInfo != null ? currencyInfo.Symbol : currencyCode; info.CurrencyPositivePattern = currencyInfo.SymbolPosition; return(currency.ToString("C", info)); }
public void UpdateMiniCart_ShoudReturn_TotalEqualsCartTotal(Database db) { _mocks.MockContexts(db); var expectedResult = ((CommerceTotal)Models.CommerceCartStub.Total) .Subtotal.ToCurrency(StorefrontManager.GetCustomerCurrency()); var result = _cartRepository.UpdateMiniCart(true); result.Total.Should().Be(expectedResult); }
public SubmitOrderBaseJsonResult SubmitOrder(SubmitOrderInputModel inputModel) { var response = this._orderManager.SubmitVisitorOrder(CurrentStorefront, CurrentVisitorContext, inputModel); var result = new SubmitOrderBaseJsonResult(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && response.Result != null && response.ServiceProviderResult.CartWithErrors == null) { result.Initialize(string.Concat(StorefrontManager.StorefrontUri("checkout/OrderConfirmation"), "?confirmationId=", (response.Result.TrackingNumber))); } return(result); }
public JsonResult GetStartCheckoutData() { return(Json(new { RequiredFieldMessage = StorefrontManager.GetHtmlSystemMessage("RequiredFieldMessage").ToHtmlString(), RequiredEmailMessage = StorefrontManager.GetHtmlSystemMessage("RequiredEmailMessage").ToHtmlString(), RequiredNumberMessage = StorefrontManager.GetHtmlSystemMessage("RequiredNumberMessage").ToHtmlString(), SelectDeliveryFirstMessage = StorefrontManager.GetHtmlSystemMessage("SelectDeliveryFirstMessage").ToHtmlString(), EmailMustMatchMessage = StorefrontManager.GetHtmlSystemMessage("EmailsMustMatchMessage").ToHtmlString(), MapKey = StorefrontManager.CurrentStorefront.GetMapKey() }, JsonRequestBehavior.AllowGet)); }
public ActionResult StartCheckout() { var cart = _checkoutRepository.GetCommerceCart(); if (cart.Lines == null || !cart.Lines.Any()) { var cartPageUrl = StorefrontManager.StorefrontUri("/shoppingcart"); return(Redirect(cartPageUrl)); } return(View("Checkout", new CartRenderingModel(cart))); }
/// <summary> /// Initializes the specified shipping method. /// </summary> /// <param name="shippingMethod">The shipping method.</param> public virtual void Initialize(ShippingMethod shippingMethod) { if (shippingMethod == null) { return; } this.ExternalId = shippingMethod.ExternalId; this.Description = StorefrontManager.GetShippingName(shippingMethod.Description); this.Name = shippingMethod.Name; this.ShippingOptionId = shippingMethod.ShippingOptionId; this.ShopName = shippingMethod.ShopName; }
public ActionResult StartCheckout() { var response = this.CartManager.GetCurrentCart(CurrentStorefront, CurrentVisitorContext, true); var cart = (CommerceCart)response.ServiceProviderResult.Cart; if (cart.Lines == null || !cart.Lines.Any()) { var cartPageUrl = StorefrontManager.StorefrontUri("/shoppingcart"); return(Redirect(cartPageUrl)); } return(View(this.CurrentRenderingView, new CartRenderingModel(cart))); }
/// <summary> /// Initializes the specified address. /// </summary> /// <param name="address">The address.</param> public virtual void Initialize(Party address) { Assert.ArgumentNotNull(address, "address"); this.ExternalId = address.ExternalId; this.Address1 = address.Address1; this.City = address.City; this.State = address.State; this.ZipPostalCode = address.ZipPostalCode; this.Country = address.Country; this.FullAddress = string.Concat(address.Address1, ", ", address.City, ", ", address.ZipPostalCode); this.DetailsUrl = string.Concat(StorefrontManager.StorefrontUri("/accountmanagement/addressbook"), "?id=", address.ExternalId); }
private void GetPaymentOptions(CheckoutDataBaseJsonResult result) { var response = this.PaymentManager.GetPaymentOptions(this.CurrentStorefront, this.CurrentVisitorContext); var paymentOptions = new List <PaymentOption>(); if (response.ServiceProviderResult.Success && response.Result != null) { paymentOptions = response.Result.ToList(); paymentOptions.ForEach(x => x.Name = StorefrontManager.GetPaymentName(x.Name)); } result.PaymentOptions = paymentOptions; result.SetErrors(response.ServiceProviderResult); }
/// <summary> /// Initializes the specified shipping option. /// </summary> /// <param name="shippingOption">The shipping option.</param> public virtual void Initialize(ShippingOption shippingOption) { if (shippingOption == null) { return; } this.ExternalId = shippingOption.ExternalId; this.Description = shippingOption.Description; this.Name = StorefrontManager.GetShippingName(shippingOption.Name); this.Description = shippingOption.Description; this.ShippingOptionType = shippingOption.ShippingOptionType; this.ShopName = shippingOption.ShopName; }
public CheckoutDataBaseJsonResult GetCheckoutData(User user) { var result = new CheckoutDataBaseJsonResult(); var response = this._cartManager.GetCurrentCart(CurrentStorefront, CurrentVisitorContext, true); if (response.ServiceProviderResult.Success && response.Result != null) { var cart = (CommerceCart)response.ServiceProviderResult.Cart; if (cart.Lines != null && cart.Lines.Any()) { result.Cart = new CSCartBaseJsonResult(response.ServiceProviderResult); result.Cart.Initialize(response.ServiceProviderResult.Cart, _productResolver); result.ShippingMethods = new List <ShippingMethod>(); result.CartLoyaltyCardNumber = cart.LoyaltyCardID; result.CurrencyCode = StorefrontManager.GetCustomerCurrency(); this.AddShippingOptionsToResult(result, cart); if (result.Success) { this.AddShippingMethodsToResult(result); if (result.Success) { this.GetAvailableCountries(result); if (result.Success) { this.GetPaymentOptions(result); if (result.Success) { this.GetPaymentMethods(result); if (result.Success) { this.GetUserInfo(result, user); } } } } } } } result.SetErrors(response.ServiceProviderResult); return(result); }
public ManagerResponse <UpdatePasswordResult, bool> ResetPassword(ForgotPasswordInputModel model) { Assert.ArgumentNotNull(this.CurrentStorefront, "storefront"); Assert.ArgumentNotNull(model, "inputModel"); var result = new UpdatePasswordResult { Success = true }; var getUserResponse = AccountManager.GetUser(model.Email); if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null) { result.Success = false; foreach (var systemMessage in getUserResponse.ServiceProviderResult.SystemMessages) { result.SystemMessages.Add(systemMessage); } } else { try { var userIpAddress = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : string.Empty; var provisionalPassword = Membership.Provider.ResetPassword(getUserResponse.Result.UserName, string.Empty); var mailUtil = new MailUtil(); var wasEmailSent = mailUtil.SendMail(model.Subject, model.Body, model.Email, this.CurrentStorefront.SenderEmailAddress, new object(), new object[] { userIpAddress, provisionalPassword }); if (!wasEmailSent) { var message = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.CouldNotSentEmailError); result.Success = false; result.SystemMessages.Add(new SystemMessage { Message = message }); } } catch (Exception e) { result.Success = false; result.SystemMessages.Add(new SystemMessage { Message = e.Message }); } } return(new ManagerResponse <UpdatePasswordResult, bool>(result, result.Success)); }
/// <summary> /// Initializes the specified gift card. /// </summary> /// <param name="giftCard">The gift card.</param> public virtual void Initialize(GiftCard giftCard) { Assert.ArgumentNotNull(giftCard, "giftCard"); var currencyCode = StorefrontManager.GetCustomerCurrency(); this.ExternalId = giftCard.ExternalId; this.Name = giftCard.Name; this.CustomerId = giftCard.CustomerId; this.ShopName = giftCard.ShopName; this.CurrencyCode = giftCard.CurrencyCode; this.Balance = giftCard.Balance; this.FormattedBalance = giftCard.Balance.ToCurrency(currencyCode); this.OriginalAmount = giftCard.OriginalAmount.ToCurrency(currencyCode); this.Description = giftCard.Description; }
/// <summary> /// Sets the errors. /// </summary> /// <param name="result">The result.</param> public void SetErrors(ServiceProviderResult result) { this.Success = result.Success; if (result.SystemMessages.Count <= 0) { return; } var errors = result.SystemMessages; foreach (var error in errors) { var message = StorefrontManager.GetSystemMessage(error.Message); this.Errors.Add(string.IsNullOrEmpty(message) ? error.Message : message); } }
/// <summary> /// Sends the mail. /// </summary> /// <param name="templateName">Name of the template.</param> /// <param name="toEmail">To email.</param> /// <param name="fromEmail">From email.</param> /// <param name="subjectParameters">The subject parameters.</param> /// <param name="bodyParameters">The body parameters.</param> /// <returns>True if the email was sent, false otherwise</returns> public virtual bool SendMail([NotNull] string templateName, [NotNull] string toEmail, [NotNull] string fromEmail, [NotNull] object subjectParameters, [NotNull] object[] bodyParameters) { Assert.ArgumentNotNull(templateName, "templateName"); Assert.ArgumentNotNull(toEmail, "toEmail"); Assert.ArgumentNotNull(fromEmail, "fromEmail"); Assert.ArgumentNotNull(subjectParameters, "subjectParameters"); Assert.ArgumentNotNull(bodyParameters, "bodyParameters"); Item mailTemplates = StorefrontManager.CurrentStorefront.GlobalItem.Children[StorefrontConstants.KnowItemNames.Mails]; if (mailTemplates == null) { return(false); } Item mailTemplate = mailTemplates.Children[templateName]; if (mailTemplate == null) { string message = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.CouldNotLoadTemplateMessageError); Log.Error(Translate.Text(string.Format(CultureInfo.InvariantCulture, message, templateName)), this); return(false); } var subjectField = mailTemplate.Fields[StorefrontConstants.KnownFieldNames.Subject]; if (subjectField == null) { string message = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.CouldNotFindEmailSubjectMessageError); Log.Error(Translate.Text(string.Format(CultureInfo.InvariantCulture, message, templateName)), this); return(false); } var bodyField = mailTemplate.Fields[StorefrontConstants.KnownFieldNames.Body]; if (bodyField == null) { string message = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.CouldNotFindEmailBodyMessageError); Log.Error(Translate.Text(string.Format(CultureInfo.InvariantCulture, message, templateName)), this); return(false); } var subject = string.Format(CultureInfo.InvariantCulture, subjectField.ToString(), subjectParameters); var body = string.Format(CultureInfo.InvariantCulture, bodyField.ToString(), bodyParameters); return(this.SendMail(toEmail, fromEmail, subject, body, string.Empty)); }
/// <summary> /// Initializes a new instance of the <see cref="WishListItemBaseJsonResult" /> class. /// </summary> /// <param name="line">The line.</param> /// <param name="wishListId">The wish list identifier.</param> public WishListItemBaseJsonResult(WishListLine line, string wishListId) { Assert.ArgumentNotNull(line, "line"); Assert.ArgumentNotNullOrEmpty(wishListId, "wishListId"); var product = (CommerceCartProduct)line.Product; var productItem = Sitecore.Reference.Storefront.SitecorePipelines.ProductItemResolver.ResolveCatalogItem(product.ProductId, product.ProductCatalog, true); var currencyCode = StorefrontManager.GetCustomerCurrency(); this.DisplayName = product.DisplayName; this.Color = product.Properties["Color"] as string; this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToString(Sitecore.Context.Language.CultureInfo); this.Quantity = line.Quantity.ToString(Sitecore.Context.Language.CultureInfo); this.LineTotal = line.Total.Amount.ToCurrency(currencyCode); this.ExternalLineId = line.ExternalId; this.ProductId = product.ProductId; this.VariantId = product.ProductVariantId; this.ProductCatalog = product.ProductCatalog; this.WishListId = wishListId; this.ProductUrl = product.ProductId.Equals(StorefrontManager.CurrentStorefront.GiftCardProductId, StringComparison.OrdinalIgnoreCase) ? StorefrontManager.StorefrontUri("/buygiftcard") : LinkManager.GetDynamicUrl(productItem); if (product.Price.Amount != 0M) { this.LinePrice = product.Price.Amount.ToCurrency(currencyCode); } var imageInfo = product.Properties["_product_Images"] as string; if (imageInfo != null) { var imageId = imageInfo.Split('|')[0]; MediaItem mediaItem = Sitecore.Context.Database.GetItem(imageId); this.Image = mediaItem.GetImageUrl(100, 100); } var giftCardAmount = line.GetPropertyValue("GiftCardAmount"); if (giftCardAmount != null) { decimal amount = System.Convert.ToDecimal(giftCardAmount, Sitecore.Context.Language.CultureInfo); this.GiftCardAmount = amount.ToCurrency(currencyCode); } }
/// <summary> /// Gets the payment methods. /// </summary> /// <param name="result">The result.</param> private void GetPaymentMethods(CheckoutDataBaseJsonResult result) { List <PaymentMethod> paymentMethodList = new List <PaymentMethod>(); var response = this.PaymentManager.GetPaymentMethods(this.CurrentStorefront, this.CurrentVisitorContext, new PaymentOption { PaymentOptionType = PaymentOptionType.PayCard }); if (response.ServiceProviderResult.Success) { paymentMethodList.AddRange(response.Result); paymentMethodList.ForEach(x => x.Description = StorefrontManager.GetPaymentName(x.Description)); } result.SetErrors(response.ServiceProviderResult); result.PaymentMethods = paymentMethodList; }
/// <summary> /// Turns a decimal value into a currency string /// </summary> /// <param name="currency">The decimal object to act on</param> /// <param name="currencyCode">The currency code.</param> /// <returns> /// A decimal formatted as a string /// </returns> public static string ToCurrency(this decimal currency, string currencyCode) { NumberFormatInfo info; CurrencyInformationModel currencyInfo = StorefrontManager.GetCurrencyInformation(currencyCode); if (currencyInfo != null) { info = (NumberFormatInfo)CultureInfo.GetCultureInfo(currencyInfo.CurrencyNumberFormatCulture).NumberFormat.Clone(); info.CurrencySymbol = currencyInfo != null ? currencyInfo.Symbol : currencyCode; info.CurrencyPositivePattern = currencyInfo.SymbolPosition; } else { info = (NumberFormatInfo)CultureInfo.GetCultureInfo(Sitecore.Context.Language.Name).NumberFormat.Clone(); } return(currency.ToString("C", info)); }
/// <summary> /// Initializes the specified stock infos. /// </summary> /// <param name="stockInfo">The stock information.</param> public virtual void Initialize(StockInformation stockInfo) { Assert.ArgumentNotNull(stockInfo, "stockInfo"); if (stockInfo == null || stockInfo.Status == null) { return; } this.ProductId = stockInfo.Product.ProductId; this.VariantId = string.IsNullOrEmpty(((CommerceInventoryProduct)stockInfo.Product).VariantId) ? string.Empty : ((CommerceInventoryProduct)stockInfo.Product).VariantId; this.Status = StorefrontManager.GetProductStockStatusName(stockInfo.Status); this.Count = stockInfo.Count < 0 ? 0 : stockInfo.Count; if (stockInfo.AvailabilityDate != null & stockInfo.AvailabilityDate.HasValue) { this.AvailabilityDate = stockInfo.AvailabilityDate.Value.ToDisplayedDate(); } }