public string FormatOrderTokenString(Core.Domain.Orders.OrderItem item, string str) { var order = _orderService.GetOrderById(item.OrderId); var product = _productService.GetProductById(item.ProductId); var index = order.OrderItems.ToList().IndexOf(item); var result = str .Replace("<order_id>", order.Id.ToString()) .Replace("<order_guid>", order.OrderGuid.ToString()) .Replace("<store_id>", order.StoreId.ToString()) .Replace("<customer_id>", order.CustomerId.ToString()) .Replace("<affiliate_id>", order.AffiliateId.ToString()) .Replace("<product_id>", product.Id.ToString()) .Replace("<product_name>", product.Name ?? "") .Replace("<product_sku>", product.Sku ?? "") .Replace("<product_vendorId>", product.VendorId.ToString()) .Replace("<item_guid>", item.OrderItemGuid.ToString()) .Replace("<item_index>", index.ToString()) .Replace("<item_quantity>", item.Quantity.ToString()); foreach (var spec in product.ProductSpecificationAttributes) { var specName = spec.SpecificationAttributeOption.Name; var specValue = spec.CustomValue; result = result.Replace("<specattr_" + specName + ">", specValue); } result = result.Replace(" ", ""); return(result); }
public Nop.Core.Domain.Orders.OrderItem GetOrderItemById(int orderItemId, bool isLegacy) { if (!isLegacy) { Core.Domain.Orders.OrderItem orderItem = EngineContext.Current.Resolve <IOrderService>().GetOrderItemById(orderItemId); return(orderItem); } else { DBManager manager = new DBManager(_gbsOrderSettings.HOMConnectionString); Dictionary <string, Object> paramDicEx = new Dictionary <string, Object>(); paramDicEx.Add("@orderItemId", orderItemId); string select = "EXEC usp_getLegacyOrderItemForNOP @orderItemId"; //DataView orderResult = manager.GetParameterizedDataView(select, paramDicEx); string jsonResult = manager.GetParameterizedJsonString(select, paramDicEx); var legacyOrderItem = JsonConvert.DeserializeObject <LegacyOrderItem>(jsonResult); return(prepareLegacyOrderItem(legacyOrderItem)); } }