Esempio n. 1
0
        public Guid ExportOrder(ActiveCommerce.Orders.Order 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);
            return(id);
        }
Esempio n. 2
0
        public Guid ExportOrder(Order 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;

            var client = new Services.OrderServiceClient();
            var id     = client.CreateOrder(serviceOrder);

            Sitecore.Diagnostics.Log.Warn("Successfully exported order {0}".FormatWith(id), this);
            return(id);
        }