Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. private OrderInfo CreateOrderInfo(CustomerInfo customerInfo, AddressInfo billingAddress, AddressInfo shippingAddress, ShippingOptionInfo shippingOptionInfo, PaymentOptionInfo paymentOptionInfo)
  2.         {
  3.  
  4.             var orderInfo = new OrderInfo
  5.             {
  6.                 OrderCustomerID = customerInfo.CustomerID,
  7.  
  8.                 OrderDate = DateTime.Now,
  9.  
  10.                 OrderShippingAddress = billingAddress,
  11.                 OrderBillingAddress = shippingAddress,
  12.  
  13.                 OrderSiteID = SiteContext.CurrentSiteID,
  14.                 OrderStatusID = 1,
  15.  
  16.                 OrderCouponCode = ShoppingCart.ShoppingCartCouponCode,
  17.  
  18.                 OrderTotalPrice = ShoppingCart.TotalPrice,
  19.                 OrderTotalPriceInMainCurrency = ShoppingCart.TotalPriceInMainCurrency,
  20.  
  21.                 OrderTotalShipping = ShoppingCart.TotalShipping,
  22.                 OrderTotalShippingInMainCurrency = ShoppingCart.TotalShippingInMainCurrency,
  23.  
  24.                 OrderTotalTax = ShoppingCart.TotalTax,
  25.                 OrderTotalTaxInMainCurrency = ShoppingCart.TotalTaxInMainCurrency,
  26.  
  27.                 OrderShippingOptionID = shippingOptionInfo != null ? shippingOptionInfo.ShippingOptionID : 0,
  28.                 OrderPaymentOptionID = paymentOptionInfo != null ? paymentOptionInfo.PaymentOptionID : 0,
  29.  
  30.  
  31.                 OrderCurrencyID = CurrencyInfoProvider.GetMainCurrency(SiteContext.CurrentSiteID).CurrencyID
  32.             };
  33.  
  34.  
  35.             // Apply any discount codes
  36.             if (!string.IsNullOrEmpty(ShoppingCart.ShoppingCartCouponCode))
  37.             {
  38.                 var coupon = DiscountCouponInfoProvider.GetDiscountCouponInfo(ShoppingCart.ShoppingCartCouponCode, SiteContext.CurrentSiteName);
  39.  
  40.                 if (coupon != null)
  41.                 {
  42.                     orderInfo.OrderDiscountCouponID = coupon.DiscountCouponID;
  43.                     ShoppingCart.Order.OrderCouponCode = orderInfo.OrderCouponCode;
  44.                     ShoppingCart.Order.OrderTotalDiscountInMainCurrency = ShoppingCart.OrderDiscountInMainCurrency;
  45.  
  46.                 }
  47.             }
  48.  
  49.  
  50.             orderInfo.Insert();
  51.  
  52.             ShoppingCart.Order = orderInfo;
  53.  
  54.             foreach (var item in ShoppingCart.CartItems)
  55.             {
  56.                 var orderItemInfo = new OrderItemInfo
  57.                 {
  58.                     OrderItemUnitPrice = item.UnitPrice,
  59.                     OrderItemUnitCount = item.CartItemUnits,
  60.                     OrderItemText = item.CartItemText,
  61.                     OrderItemSKU = item.SKU,
  62.                     OrderItemOrderID = orderInfo.OrderID,
  63.                     OrderItemUnitTotalTaxInMainCurrency = item.UnitTotalTaxInMainCurrency,
  64.  
  65.                 };
  66.  
  67.                 orderItemInfo.Insert();
  68.             }
  69.  
  70.             return orderInfo;
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement