本文整理汇总了C#中Nop.Core.Domain.Orders.Order.DeserializeCustomValues方法的典型用法代码示例。如果您正苦于以下问题:C# Order.DeserializeCustomValues方法的具体用法?C# Order.DeserializeCustomValues怎么用?C# Order.DeserializeCustomValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Orders.Order
的用法示例。
在下文中一共展示了Order.DeserializeCustomValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddOrderTokens
public virtual void AddOrderTokens(IList<Token> tokens, Order order, int languageId, int vendorId = 0)
{
tokens.Add(new Token("Order.OrderNumber", order.Id.ToString()));
tokens.Add(new Token("Order.CustomerFullName", string.Format("{0} {1}", order.BillingAddress.FirstName, order.BillingAddress.LastName)));
tokens.Add(new Token("Order.CustomerEmail", order.BillingAddress.Email));
tokens.Add(new Token("Order.BillingFirstName", order.BillingAddress.FirstName));
tokens.Add(new Token("Order.BillingLastName", order.BillingAddress.LastName));
tokens.Add(new Token("Order.BillingPhoneNumber", order.BillingAddress.PhoneNumber));
tokens.Add(new Token("Order.BillingEmail", order.BillingAddress.Email));
tokens.Add(new Token("Order.BillingFaxNumber", order.BillingAddress.FaxNumber));
tokens.Add(new Token("Order.BillingCompany", order.BillingAddress.Company));
tokens.Add(new Token("Order.BillingAddress1", order.BillingAddress.Address1));
tokens.Add(new Token("Order.BillingAddress2", order.BillingAddress.Address2));
tokens.Add(new Token("Order.BillingCity", order.BillingAddress.City));
tokens.Add(new Token("Order.BillingStateProvince", order.BillingAddress.StateProvince != null ? order.BillingAddress.StateProvince.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.BillingZipPostalCode", order.BillingAddress.ZipPostalCode));
tokens.Add(new Token("Order.BillingCountry", order.BillingAddress.Country != null ? order.BillingAddress.Country.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.BillingCustomAttributes", _addressAttributeFormatter.FormatAttributes(order.BillingAddress.CustomAttributes), true));
tokens.Add(new Token("Order.ShippingMethod", order.ShippingMethod));
tokens.Add(new Token("Order.ShippingFirstName", order.ShippingAddress != null ? order.ShippingAddress.FirstName : ""));
tokens.Add(new Token("Order.ShippingLastName", order.ShippingAddress != null ? order.ShippingAddress.LastName : ""));
tokens.Add(new Token("Order.ShippingPhoneNumber", order.ShippingAddress != null ? order.ShippingAddress.PhoneNumber : ""));
tokens.Add(new Token("Order.ShippingEmail", order.ShippingAddress != null ? order.ShippingAddress.Email : ""));
tokens.Add(new Token("Order.ShippingFaxNumber", order.ShippingAddress != null ? order.ShippingAddress.FaxNumber : ""));
tokens.Add(new Token("Order.ShippingCompany", order.ShippingAddress != null ? order.ShippingAddress.Company : ""));
tokens.Add(new Token("Order.ShippingAddress1", order.ShippingAddress != null ? order.ShippingAddress.Address1 : ""));
tokens.Add(new Token("Order.ShippingAddress2", order.ShippingAddress != null ? order.ShippingAddress.Address2 : ""));
tokens.Add(new Token("Order.ShippingCity", order.ShippingAddress != null ? order.ShippingAddress.City : ""));
tokens.Add(new Token("Order.ShippingStateProvince", order.ShippingAddress != null && order.ShippingAddress.StateProvince != null ? order.ShippingAddress.StateProvince.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.ShippingZipPostalCode", order.ShippingAddress != null ? order.ShippingAddress.ZipPostalCode : ""));
tokens.Add(new Token("Order.ShippingCountry", order.ShippingAddress != null && order.ShippingAddress.Country != null ? order.ShippingAddress.Country.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.ShippingCustomAttributes", _addressAttributeFormatter.FormatAttributes(order.ShippingAddress != null ? order.ShippingAddress.CustomAttributes : ""), true));
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);
var paymentMethodName = paymentMethod != null ? paymentMethod.GetLocalizedFriendlyName(_localizationService, _workContext.WorkingLanguage.Id) : order.PaymentMethodSystemName;
tokens.Add(new Token("Order.PaymentMethod", paymentMethodName));
tokens.Add(new Token("Order.VatNumber", order.VatNumber));
var sbCustomValues = new StringBuilder();
var customValues = order.DeserializeCustomValues();
if (customValues != null)
{
foreach (var item in customValues)
{
sbCustomValues.AppendFormat("{0}: {1}", HttpUtility.HtmlEncode(item.Key), HttpUtility.HtmlEncode(item.Value != null ? item.Value.ToString() : ""));
sbCustomValues.Append("<br />");
}
}
tokens.Add(new Token("Order.CustomValues", sbCustomValues.ToString(), true));
tokens.Add(new Token("Order.Product(s)", ProductListToHtmlTable(order, languageId, vendorId), true));
var language = _languageService.GetLanguageById(languageId);
if (language != null && !String.IsNullOrEmpty(language.LanguageCulture))
{
DateTime createdOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, TimeZoneInfo.Utc, _dateTimeHelper.GetCustomerTimeZone(order.Customer));
tokens.Add(new Token("Order.CreatedOn", createdOn.ToString("D", new CultureInfo(language.LanguageCulture))));
}
else
{
tokens.Add(new Token("Order.CreatedOn", order.CreatedOnUtc.ToString("D")));
}
//TODO add a method for getting URL (use routing because it handles all SEO friendly URLs)
tokens.Add(new Token("Order.OrderURLForCustomer", string.Format("{0}orderdetails/{1}", GetStoreUrl(order.StoreId), order.Id), true));
//event notification
_eventPublisher.EntityTokensAdded(order, tokens);
}
示例2: PrepareOrderDetailsModel
protected virtual OrderDetailsModel PrepareOrderDetailsModel(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
var model = new OrderDetailsModel();
model.Id = order.Id;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc);
model.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext);
model.IsReOrderAllowed = _orderSettings.IsReOrderAllowed;
model.IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order);
model.PdfInvoiceDisabled = _pdfSettings.DisablePdfInvoicesForPendingOrders && order.OrderStatus == OrderStatus.Pending;
//shipping info
model.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext);
if (order.ShippingStatus != ShippingStatus.ShippingNotRequired)
{
model.IsShippable = true;
model.PickUpInStore = order.PickUpInStore;
if (!order.PickUpInStore)
{
model.ShippingAddress.PrepareModel(
address: order.ShippingAddress,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
}
model.ShippingMethod = order.ShippingMethod;
//shipments (only already shipped)
var shipments = order.Shipments.Where(x => x.ShippedDateUtc.HasValue).OrderBy(x => x.CreatedOnUtc).ToList();
foreach (var shipment in shipments)
{
var shipmentModel = new OrderDetailsModel.ShipmentBriefModel
{
Id = shipment.Id,
TrackingNumber = shipment.TrackingNumber,
};
if (shipment.ShippedDateUtc.HasValue)
shipmentModel.ShippedDate = _dateTimeHelper.ConvertToUserTime(shipment.ShippedDateUtc.Value, DateTimeKind.Utc);
if (shipment.DeliveryDateUtc.HasValue)
shipmentModel.DeliveryDate = _dateTimeHelper.ConvertToUserTime(shipment.DeliveryDateUtc.Value, DateTimeKind.Utc);
model.Shipments.Add(shipmentModel);
}
}
//billing info
model.BillingAddress.PrepareModel(
address: order.BillingAddress,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
//VAT number
model.VatNumber = order.VatNumber;
//payment method
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);
model.PaymentMethod = paymentMethod != null ? paymentMethod.GetLocalizedFriendlyName(_localizationService, _workContext.WorkingLanguage.Id) : order.PaymentMethodSystemName;
model.PaymentMethodStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext);
model.CanRePostProcessPayment = _paymentService.CanRePostProcessPayment(order);
//custom values
model.CustomValues = order.DeserializeCustomValues();
//order subtotal
if (order.CustomerTaxDisplayType == TaxDisplayType.IncludingTax && !_taxSettings.ForceTaxExclusionFromOrderSubtotal)
{
//including tax
//order subtotal
var orderSubtotalInclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderSubtotalInclTax, order.CurrencyRate);
model.OrderSubtotal = _priceFormatter.FormatPrice(orderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
//discount (applied to order subtotal)
var orderSubTotalDiscountInclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderSubTotalDiscountInclTax, order.CurrencyRate);
if (orderSubTotalDiscountInclTaxInCustomerCurrency > decimal.Zero)
model.OrderSubTotalDiscount = _priceFormatter.FormatPrice(-orderSubTotalDiscountInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
}
else
{
//excluding tax
//order subtotal
var orderSubtotalExclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderSubtotalExclTax, order.CurrencyRate);
model.OrderSubtotal = _priceFormatter.FormatPrice(orderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, false);
//discount (applied to order subtotal)
var orderSubTotalDiscountExclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderSubTotalDiscountExclTax, order.CurrencyRate);
if (orderSubTotalDiscountExclTaxInCustomerCurrency > decimal.Zero)
model.OrderSubTotalDiscount = _priceFormatter.FormatPrice(-orderSubTotalDiscountExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, false);
}
if (order.CustomerTaxDisplayType == TaxDisplayType.IncludingTax)
{
//including tax
//order shipping
var orderShippingInclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderShippingInclTax, order.CurrencyRate);
model.OrderShipping = _priceFormatter.FormatShippingPrice(orderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
//payment method additional fee
var paymentMethodAdditionalFeeInclTaxInCustomerCurrency = _currencyService.ConvertCurrency(order.PaymentMethodAdditionalFeeInclTax, order.CurrencyRate);
if (paymentMethodAdditionalFeeInclTaxInCustomerCurrency > decimal.Zero)
//.........这里部分代码省略.........
示例3: PrepareOrderDetailsModel
protected virtual void PrepareOrderDetailsModel(OrderModel model, Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (model == null)
throw new ArgumentNullException("model");
model.Id = order.ID;
model.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext);
model.OrderStatusId = order.OrderStatusId;
model.OrderGuid = order.OrderGuid;
var store = _storeService.GetStoreById(order.StoreId);
model.StoreName = store != null ? store.Name : "Unknown";
model.CustomerId = order.CustomerId;
var customer = order.Customer;
model.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest");
model.CustomerIp = order.CustomerIp;
model.VatNumber = order.VatNumber;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc);
model.AllowCustomersToSelectTaxDisplayType = _taxSettings.AllowCustomersToSelectTaxDisplayType;
model.TaxDisplayType = _taxSettings.TaxDisplayType;
var affiliate = _affiliateService.GetAffiliateById(order.AffiliateId);
if (affiliate != null)
{
model.AffiliateId = affiliate.ID;
model.AffiliateName = affiliate.GetFullName();
}
//a vendor should have access only to his products
model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
//custom values
model.CustomValues = order.DeserializeCustomValues();
#region Order totals
var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
if (primaryStoreCurrency == null)
throw new Exception("Cannot load primary store currency");
//subtotal
model.OrderSubtotalInclTax = _priceFormatter.FormatPrice(order.OrderSubtotalInclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, true);
model.OrderSubtotalExclTax = _priceFormatter.FormatPrice(order.OrderSubtotalExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false);
model.OrderSubtotalInclTaxValue = order.OrderSubtotalInclTax;
model.OrderSubtotalExclTaxValue = order.OrderSubtotalExclTax;
//discount (applied to order subtotal)
string orderSubtotalDiscountInclTaxStr = _priceFormatter.FormatPrice(order.OrderSubTotalDiscountInclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, true);
string orderSubtotalDiscountExclTaxStr = _priceFormatter.FormatPrice(order.OrderSubTotalDiscountExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false);
if (order.OrderSubTotalDiscountInclTax > decimal.Zero)
model.OrderSubTotalDiscountInclTax = orderSubtotalDiscountInclTaxStr;
if (order.OrderSubTotalDiscountExclTax > decimal.Zero)
model.OrderSubTotalDiscountExclTax = orderSubtotalDiscountExclTaxStr;
model.OrderSubTotalDiscountInclTaxValue = order.OrderSubTotalDiscountInclTax;
model.OrderSubTotalDiscountExclTaxValue = order.OrderSubTotalDiscountExclTax;
//shipping
model.OrderShippingInclTax = _priceFormatter.FormatShippingPrice(order.OrderShippingInclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, true);
model.OrderShippingExclTax = _priceFormatter.FormatShippingPrice(order.OrderShippingExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false);
model.OrderShippingInclTaxValue = order.OrderShippingInclTax;
model.OrderShippingExclTaxValue = order.OrderShippingExclTax;
//payment method additional fee
if (order.PaymentMethodAdditionalFeeInclTax > decimal.Zero)
{
model.PaymentMethodAdditionalFeeInclTax = _priceFormatter.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, true);
model.PaymentMethodAdditionalFeeExclTax = _priceFormatter.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false);
}
model.PaymentMethodAdditionalFeeInclTaxValue = order.PaymentMethodAdditionalFeeInclTax;
model.PaymentMethodAdditionalFeeExclTaxValue = order.PaymentMethodAdditionalFeeExclTax;
//tax
model.Tax = _priceFormatter.FormatPrice(order.OrderTax, true, false);
SortedDictionary<decimal, decimal> taxRates = order.TaxRatesDictionary;
bool displayTaxRates = _taxSettings.DisplayTaxRates && taxRates.Count > 0;
bool displayTax = !displayTaxRates;
foreach (var tr in order.TaxRatesDictionary)
{
model.TaxRates.Add(new OrderModel.TaxRate
{
Rate = _priceFormatter.FormatTaxRate(tr.Key),
Value = _priceFormatter.FormatPrice(tr.Value, true, false),
});
}
model.DisplayTaxRates = displayTaxRates;
model.DisplayTax = displayTax;
model.TaxValue = order.OrderTax;
model.TaxRatesValue = order.TaxRates;
//discount
if (order.OrderDiscount > 0)
model.OrderTotalDiscount = _priceFormatter.FormatPrice(-order.OrderDiscount, true, false);
model.OrderTotalDiscountValue = order.OrderDiscount;
//gift cards
foreach (var gcuh in order.GiftCardUsageHistory)
{
model.GiftCards.Add(new OrderModel.GiftCard
{
//.........这里部分代码省略.........