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

How to create new order in Kentico from my site?

我是 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);
}

这是从 Kentico docs 中摘录的,我真的建议您查看一下,因为还有更多您可能会觉得有用的示例。

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