Servigistics InService 自訂 > 自訂系統整合 > 購物參數自訂 > 使用購物參數
  
使用購物參數
購物參數可用來決定自訂定價委派中的定價與供貨狀況,也可傳遞至外部商務系統。這些參數在請求標題中設定,且可以在使用 SCRequestContextUtility.getShoppingParameters() API 的委派中擷取。此 API 會傳回 SCFieldList,其將購物參數清單表示為 SCField 概念模型。
當訂購購物車時,如果其中任何一個購物參數的內部名稱與 SCEOrder 物件之可變屬性的內部名稱相符,系統會將其儲存。此訂購物件將可在 CommerceDelegate 中找到,以用於進一步的訂購處理。
自訂勾點也已新增至 delivery\app\services\cartsService.js 中的用戶端,以允許將訂購功能自訂為使用購物參數。
/**
* This is a customization hook that allows specifying a function that performs
* order a cart.
* This function is used in cartDetails.
* The custom function should take the following arguments:
*
* 1) cart object the order operation is performed on
*
* 2) orderItem object containing the cart items included in the order
*
* 3) onSuccess is a function that takes as input a single argument "data"
* which is a json object parsed from the reponse. If this callback
* is not specified then the globally configured order cart success d.
* callback is use
*
* 4) onFailure is a function that takes as input a single argument "errorObject".
* This error object is the same that you would get from $http. It may have an
* "errorCode" attribute, and it may have a populated "response" attribute.
* If this callback is not specified then the globally configured order cart
* failure callback is used.
*
*/
cartsServiceProvider.setOrderCart = function (fn) {
if (typeof fn !== "function") {
throw new Error("Do not call setOrderCart without a function.");
}
orderCart = fn;
};
欲使用此自訂勾點,應以如下方式在 customizations.jsafter() 方法內執行組態:
/**
* This function is called near the very end of main.js, after InService has
* initialized itself, and just before angular.bootstrap() is called.
*
* Use this function for config customizations.
*/
after: function () {
module.config(function (cartsServiceProvider) {
cartsServiceProvider.setOrderCart(function (orderItem, cart,
onSuccess, onFailure) {
// do custom logic here
});
});
}