2016-04-23 9 views
-2

Kenticoに全く新しいです。私はEコマースサイトを作成し、APIを使用して注文を作成したいと考えています。どの方法で私がどのような方法を使うべきか教えてくれますか?また、誰かがSharepointアプリケーションでkenticoウェブサイトを表示しようとしたかどうか尋ねたいと思っています。私のサイトからKenticoで新しい注文を作成するには?

答えて

2

注文の作成は、お客様、通貨、配送先住所、商品などの関連性のあるオブジェクトを取得する必要があるため、少し複雑です。簡単な例は次のようになります。

これは、私は本当にあなたが有用見つけるかもしれない多くのより多くの例があるので、チェックアウトすることをお勧めします Kentico docsから取られた
// 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); 
} 

あなたの2番目の質問としては、SharepointアプリケーションにKenticoを表示することがどういう意味なのかよく分かりません。 Kenticoは、IIS上で実行する必要があり、単独ではに組み込まれたスタンドアロンのASP Webフォームアプリケーションです.Sharepointにはが埋め込まれています。

+0

非常に便利なthnxの多く – Dii

+1

別の質問plz ..私は文書で見つけることができません。どのようにDBから製品データを取得するために私は内側のジョイントの多くを使用して自分自身でそれを選択するために使用..私はちょうどその製品データを取得する彼らの別のアプローチであり、添付ファイルとオプションですか?あなたの支援に感謝。 – Dii

+0

こんにちは、私はあなたの2番目の質問への回答を追加しましたので、それをチェックしてください[ここ](http://stackoverflow.com/questions/36826799/creating-more-than-one-site-in-kentico/36833719# 36833719) – Enn