protected override void DoProcess(OrderPipelineArgs args) { var order = args.Order; var serviceOrder = new Services.Order { CustomerEmail = order.BuyerCustomerParty.Party.Contact.ElectronicMail, CustomerName = order.BuyerCustomerParty.Party.PartyName, Billing = ConvertAddress((Address)order.BuyerCustomerParty.Party.PostalAddress), Shipping = ConvertAddress((Address)order.DefaultDelivery.DeliveryParty.PostalAddress) }; var lines = new List <Services.OrderLine>(); foreach (var line in order.OrderLines) { var newLine = new Services.OrderLine { ProductId = line.LineItem.Item.Code, Price = line.LineItem.Price.PriceAmount.Value, Quantity = (uint)line.LineItem.Quantity }; lines.Add(newLine); } serviceOrder.OrderLines = lines.ToArray(); serviceOrder.Total = order.AnticipatedMonetaryTotal.TaxInclusiveAmount.Value; serviceOrder.TaxTotal = order.TaxTotal.TaxAmount.Value; var shippingCharges = order.AllowanceCharge.Cast <AllowanceCharge>().Where(x => x.ChargeIndicator && x.ShippingIndicator); serviceOrder.ShippingCost = shippingCharges.Sum(x => x.Amount.Value); var client = new Services.OrderServiceClient(); var id = client.CreateOrder(serviceOrder); Sitecore.Diagnostics.Log.Warn("Successfully exported order {0}".FormatWith(id), this); }
public void Process(OrderPipelineArgs args) { var order = args.Order; var serviceOrder = new Services.Order(); serviceOrder.CustomerEmail = order.CustomerInfo.Email; serviceOrder.CustomerName = order.CustomerInfo.BillingAddress.Name + " " + order.CustomerInfo.BillingAddress.Name2; serviceOrder.Billing = ConvertAddress((ActiveCommerce.Addresses.AddressInfo)order.CustomerInfo.BillingAddress); serviceOrder.Shipping = ConvertAddress((ActiveCommerce.Addresses.AddressInfo)order.CustomerInfo.ShippingAddress); var lines = new List <Services.OrderLine>(); foreach (var line in order.OrderLines) { var newLine = new Services.OrderLine(); newLine.ProductId = line.Product.Code; newLine.Price = line.Totals.PriceExVat; newLine.Quantity = line.Quantity; lines.Add(newLine); } serviceOrder.OrderLines = lines.ToArray(); serviceOrder.Total = order.Totals.TotalPriceIncVat; serviceOrder.TaxTotal = order.Totals.TotalVat; serviceOrder.ShippingCost = order.ShippingPrice; try { var client = new Services.OrderServiceClient(); var id = client.CreateOrder(serviceOrder); Sitecore.Diagnostics.Log.Warn("Successfully created order {0}".FormatWith(id), this); } catch (FaultException e) { Sitecore.Diagnostics.Log.Error("Error while sending order data. Error from server was: {0}".FormatWith(e.Message), e, this); args.AddMessage(e.Message); args.Order = null; } }