如何从我的网站在Kentico中创建新订单?

如何从我的网站在Kentico中创建新订单?,kentico,Kentico,我对Kentico完全陌生,我创建了一个电子商务网站,希望使用API创建订单。有人能告诉我应该使用哪种方法吗??,还想问是否有人试图在Sharepoint应用程序上显示kentico网站。创建订单稍微复杂一些,因为您需要获取客户、货币、发货地址、产品和其他可能相关的对象。一个简单的例子如下所示: // Gets the first customer whose last name is 'Smith' CustomerInfo customer = CustomerInfoProvider.Ge

我对Kentico完全陌生,我创建了一个电子商务网站,希望使用API创建订单。有人能告诉我应该使用哪种方法吗??,还想问是否有人试图在Sharepoint应用程序上显示kentico网站。

创建订单稍微复杂一些,因为您需要获取客户、货币、发货地址、产品和其他可能相关的对象。一个简单的例子如下所示:

// 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);
}
这是我真正建议您查看的内容,因为您可能会发现更多有用的示例


至于你的第二个问题,我不太清楚你在Sharepoint应用程序中显示Kentico是什么意思。Kentico是一个独立的ASP Web表单应用程序,需要在IIS上运行,并且不能单独嵌入Sharepoint中

非常方便的thnx Alotan其他问题请。。我找不到医生。如何从数据库中获取产品数据,所以我习惯于使用大量内部连接自行选择。。所以我想问的是他们获取产品数据及其附件和选项的另一种方法吗??感谢您的支持。嗨,我已经为您的第二个问题添加了答案,请随意查看