2016-04-23 52 views
-2

对于Kentico我完全陌生,我创建了电子商务网站,并希望使用API​​来创建订单。任何人都可以告诉我我应该使用哪种方法??也想询问是否有人试图在Sharepoint应用程序上显示kentico网站。如何在我的网站上创建Kentico的新订单?

回答

2

创建订单是有点复杂,因为你需要得到客户,货币,送货地址,产品和其他可能与对象。一个简单的例子可以是这样的:

// Gets the first customer whose last name is 'Smith' 
CustomerInfo customer = CustomerInfoProvider.GetCustomers() 
              .WhereEquals("CustomerLastName", "Smith") 
              .FirstObject; 

// Prepares the order addresses 
OrderAddressInfo orderBillingAddress = null; 
OrderAddressInfo orderShippingAddress = null; 

// Gets the customer's address 
AddressInfo customerAddress = AddressInfoProvider.GetAddresses() 
                .WhereEquals("AddressCustomerID", customer.CustomerID) 
                .FirstObject; 

if (customerAddress != null) 
{ 
    // Gets the data from the customer's address 
    orderBillingAddress = OrderAddressInfoProvider.CreateOrderAddressInfo(customerAddress); 
    orderShippingAddress = OrderAddressInfoProvider.CreateOrderAddressInfo(customerAddress); 

    // Sets the order addresses 
    OrderAddressInfoProvider.SetAddressInfo(orderBillingAddress); 
    OrderAddressInfoProvider.SetAddressInfo(orderShippingAddress); 
} 

// Gets a status for the order 
OrderStatusInfo orderStatus = OrderStatusInfoProvider.GetOrderStatusInfo("NewStatus", SiteContext.CurrentSiteName); 

// Gets a currency for the order 
CurrencyInfo currency = CurrencyInfoProvider.GetCurrencyInfo("NewCurrency", SiteContext.CurrentSiteName); 

if ((customer != null) && (orderStatus != null) && (currency != null) && (orderBillingAddress != null)) 
{ 
    // Creates a new order object and sets its properties 
    OrderInfo newOrder = new OrderInfo 
    { 
     OrderInvoiceNumber = "1", 
     OrderBillingAddress = orderBillingAddress, 
     OrderShippingAddress = orderShippingAddress, 
     OrderTotalPrice = 200, 
     OrderTotalTax = 30, 
     OrderDate = DateTime.Now, 
     OrderStatusID = orderStatus.StatusID, 
     OrderCustomerID = customer.CustomerID, 
     OrderSiteID = SiteContext.CurrentSiteID, 
     OrderCurrencyID = currency.CurrencyID 
    }; 

    // Saves the order to the database 
    OrderInfoProvider.SetOrderInfo(newOrder); 
} 

这是从Kentico docs我真的建议检查出因为有许多你可能会发现有用的更多的例子服用。

关于你的第二个问题 - 我不太清楚你所说的在SharePoint应用程序中显示Kentico意思。 Kentico是一个独立的ASP Web表单应用程序需要在IIS上运行,并且不能由自己是在SharePoint嵌入式

+0

非常方便,很多日Thnx另一个 – Dii

+1

PLZ问题..我不能在文档找到。如何从数据库获取产品数据,所以我用我自己选择使用很多内部联接..所以我只想问是他们获取产品数据的另一种方法,它的附件和选项?感谢您的支持。 – Dii

+0

嗨,我已经加入回答你的第二个问题,以便随时检查出来[这里](http://stackoverflow.com/questions/36826799/creating-more-than-one-site-in-kentico/36833719# 36833719) – Enn

相关问题