---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# CartJS :スコープ対象

# CartJS :スコープ対象 {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：24分

CartJS API は、ユーザーの買い物かごにアクセスできるようにするメソッドを提供します。

この API は `sn_sc` 名前空間で実行されます。CartJS API にアクセスするには、デフォルトで有効になっているサービスカタログスコープ付き API プラグイン (ID:com.glideapp.servicecatalog.scoped.api) が必要です。

## CartJS:CartJS(文字列 cartName) {#ariaid-title2}

現在ログインしているユーザーの定義済み買い物かごの名前で CartJS クラスのインスタンスを作成します。
{#r_CJSS-CartJS_S__table_zs3_bhy_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| カート名 | 文字列 | オプション。現在ログインしているユーザーの定義済み買い物かごの名前。 |
[表 : 1. パラメーター]

{#r_CJSS-CartJS_S__table_zs3_bhy_5z}  

    var cart = new sn_sc.CartJS(cart1);

## CartJS - addToCart(マップ要求) {#ariaid-title3}

カタログアイテムの要求を現在のカートに追加します。
{#r_CJSS-addToCart_M__table_ecz_zjy_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 要求 | マップ | カートに追加するカタログアイテムの詳細を含む JSON オブジェクト。 要求オブジェクトの構造は次のとおりです。 { 'sysparm_id': item_id, 'sysparm_quantity': item_quantity, 'variables':{ 'var_name': 'var_value', ... } } * item_id:カートに追加するアイテムのsys_id * item_quantity:追加するアイテムの数。デフォルト値は 1 です。 * var_name:質問の名前。 * var_value:回答の値 (表示値ではありません)。 {#r_CJSS-addToCart_M__ul_tdn_1ly_5z} |
[表 : 2. パラメーター]

{#r_CJSS-addToCart_M__table_ecz_zjy_5z} {#r_CJSS-addToCart_M__table_fcz_zjy_5z__entry__2}

| タイプ | 説明 |
|-|-|
| JSON | 現在の買い物かごの構造。 { 'subtotal': value, 'items':[ { itemName:'', quantity:'', price:'', recurring_price:'' } ...] } |
[表 : 3. 返される内容]

{#r_CJSS-addToCart_M__table_fcz_zjy_5z}  
この例では、買い物かごに複数のアイテムを追加する方法を示しています。`var cart = new sn_sc であることに注意してください。CartJS();`ループ内にあります。sn_sc に電話する必要があります `。CartJS()` を複数回呼び出して、カートに複数のアイテムを追加できるようにします。

    for (i = 0; i < 2; i++) { 
    var cart = new sn_sc.CartJS();
    var item =
    {
    'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',
    'sysparm_quantity': '1',
    'variables':{
    'carrier': 'at_and_t_mobility',
    'data_plan': '500MB',
    'duration': 'eighteen_months',
    'color': 'slate',
    'storage': 'sixtyfour' 
    }};
    var cartDetails = cart.addToCart(item);
    gs.info(JSON.stringify(cartDetails));
    }

出力

    //The cart after the first item is added
    {
      "cart_id": "c0f5828a1b476010593876a61a4bcb71",
      "subtotal": "$599.99",
      "items": [
        {
          "catalog_item_id": "0d08837237153000158bbfc8bcbe5d02",
          "quantity": "1",
          "localized_price": "$599.99",
          "price": "$599.99",
          "recurring_frequency": "Monthly",
          "localized_recurring_price": "$30.00",
          "recurring_price": "$29.00",
          "item_name": "Apple iPhone 5",
          "cart_item_id": "40f5828a1b476010593876a61a4bcb72"
        }
      ]
    }

    //The cart after the second item is added
    {
      "cart_id": "c0f5828a1b476010593876a61a4bcb71",
      "subtotal": "$1,199.98",
      "items": [
        {
          "catalog_item_id": "0d08837237153000158bbfc8bcbe5d02",
          "quantity": "1",
          "localized_price": "$599.99",
          "price": "$599.99",
          "recurring_frequency": "Monthly",
          "localized_recurring_price": "$30.00",
          "recurring_price": "$29.00",
          "item_name": "Apple iPhone 5",
          "cart_item_id": "40f5828a1b476010593876a61a4bcb72"
        },
        {
          "catalog_item_id": "0d08837237153000158bbfc8bcbe5d02",
          "quantity": "1",
          "localized_price": "$599.99",
          "price": "$599.99",
          "recurring_frequency": "Monthly",
          "localized_recurring_price": "$30.00",
          "recurring_price": "$29.00",
          "item_name": "Apple iPhone 5",
          "cart_item_id": "98f5828a1b476010593876a61a4bcb75"
        }
      ]
    }

## CartJS:canViewRF() {#ariaid-title4}

現在のユーザーが \[要求対象\] フィールドを編集するために必要なロールを持っているかどうかを指定します。
{#CJSS-canViewRF__table_jy1_pzt_qbb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 4. パラメーター]

{#CJSS-canViewRF__table_jy1_pzt_qbb} {#CJSS-canViewRF__table_ky1_pzt_qbb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | ユーザーが要求元フィールドを編集するために必要なロールを持っているかどうかを示すフラグ。 可能な値： * true:ユーザーに必要なロールがあります。 * false:必要なロールがユーザーにありません。 データタイプ：ブーリアン |
[表 : 5. 返される内容]

{#CJSS-canViewRF__table_ky1_pzt_qbb}  
このバックグラウンドスクリプトのコード例は、現在のユーザーが要求元フィールドの編集に必要なロールを持っているかどうかを確認する方法を示しています。

    gs.log(sn_sc.CartJS.canViewRF());

応答：

    true

## CartJS - checkoutCart() {#ariaid-title5}

カートのチェックアウトを実行します。2 ステップ精算が有効になっている場合は、注文サマリーを返します。2 ステップチェックアウトが無効になっている場合、買い物かごが送信され、生成された要求の詳細が返されます。
{#r_CJSS-checkoutCart__table_vqd_hsd_zz__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 6. パラメーター]

{#r_CJSS-checkoutCart__table_vqd_hsd_zz} {#r_CJSS-checkoutCart__table_wqd_hsd_zz__entry__2}

| タイプ | 説明 |
|-|-|
| JSON | 2 ステップ精算が有効になっている場合は、買い物かごのアイテムの概要が返されます。 { "subtotal_price":"", "subtotal_recurring_frequency":"", "delivery_address":"", "special_instructions":"", "total_title":"", "requested_for_user":"System Administrator", "requested_for":"6816f79cc0a8016401c5a33be04be441", "daily": ["frequency_subtotal":"", "items":[{}, {}, ...], ...], "monthly":["frequency_subtotal":"", "items":[{}, {}, ...], ...], "annually":["frequency_subtotal":"", "items":[{}, {}, ...], ...], "none":["frequency_subtotal":"", "items":[{}, {}, ...], ...], } 2 ステップチェックアウトが無効になっている場合: { 'request_id' : "sys_id of the generated request", "request_number" : "Number of the generated request" } |
[表 : 7. 返される内容]

{#r_CJSS-checkoutCart__table_wqd_hsd_zz}  

    var cart = new sn_sc.CartJS();
    var checkoutInfo = cart.checkoutCart();
    gs.info(checkoutInfo);

出力

    If two step checkout enabled:
    {"subtotal_price":"$2,748.49","subtotal_recurring_frequency":"","delivery_address":"","special_instructions":"","total_title":"Total","requested_for_user":"System Administrator","requested_for":"6816f79cc0a8016401c5a33be04be441","weekly":{"subtotal_price":"$399.50","subtotal_recurring_frequency":"Weekly","subtotal_recurring_price":"$0.00","total_title":"Total","items":[{"catalog_item_id":"e90a0f7237153000158bbfc8bcbe5d7f","variables":{},"quantity":"1","localized_price":"$399.50","price":"$399.50","recurring_frequency":"Weekly","localized_recurring_price":"$0.00","recurring_price":"$0.00","item_name":"Brother Network-Ready Color Laser Printer","cart_item_id":"f3f5c9b3c322320076173b0ac3d3ae00","delivery_time":"2 Days"}],"show_subtotal_price":"true","subtotal_title":"Subtotal"},"show_subtotal_price":"true","cart_id":"251c0562c326320076173b0ac3d3aeb4","subtotal_recurring_price":"$131.00","monthly":{"subtotal_price":"$849.99","subtotal_recurring_frequency":"Monthly","subtotal_recurring_price":"$31.00","total_title":"Total","items":[{"catalog_item_id":"d82ea08510247200964f77ffeec6c4ee","variables":{"Monthly data allowance":"500MB","Storage":"64GB","Color":"Space Gray","Is this a replacement for a lost or broken iPhone?":"No","What was the original phone number?":""},"quantity":"1","localized_price":"$799.99","price":"$849.99","recurring_frequency":"Monthly","localized_recurring_price":"$30.00","recurring_price":"$31.00","item_name":"Apple iPhone 6s Plus","cart_item_id":"18c509b3c322320076173b0ac3d3aef4","delivery_time":"2 Days"}],"show_subtotal_price":"true","subtotal_title":"Subtotal"},"yearly":{"subtotal_price":"$1,499.00","subtotal_recurring_frequency":"Annually","subtotal_recurring_price":"$100.00","total_title":"Total","items":[{"catalog_item_id":"774906834fbb4200086eeed18110c737","variables":{"Adobe Photoshop":"false","Adobe Acrobat":"false","Optional Software":"","Additional software requirements":"","Eclipse IDE":"true"},"quantity":"1","localized_price":"$1,499.00","price":"$1,499.00","recurring_frequency":"Annually","localized_recurring_price":"$100.00","recurring_price":"$100.00","item_name":"Developer Laptop (Mac)","cart_item_id":"6306c9b3c322320076173b0ac3d3ae89","delivery_time":"5 Days"}],"show_subtotal_price":"true","subtotal_title":"Subtotal"},"subtotal_title":"Subtotal"}
    If two step checkout disabled:
    {"request_number":"REQ0010001","request_id":"2f2789f3c322320076173b0ac3d3ae62"}

## CartJS:空 () {#ariaid-title6}

現在の買い物かごを削除します。
{#r_CJSS-empty__table_pzw_gjy_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 8. パラメーター]

{#r_CJSS-empty__table_pzw_gjy_5z} {#r_CJSS-empty__table_qzw_gjy_5z__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 9. 返される内容]

{#r_CJSS-empty__table_qzw_gjy_5z}  

    var cart = new sn_sc.CartJS();
          cart.empty();

## CartJS - getCartDetails() {#ariaid-title7}

買い物かごの詳細を返します。
{#CJSS-getCartDetails__table_kct_215_qbb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 10. パラメーター]

{#CJSS-getCartDetails__table_kct_215_qbb} {#CJSS-getCartDetails__table_lct_215_qbb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | 現在の買い物かごの詳細を指すオブジェクト。 |
[表 : 11. 返される内容]

{#CJSS-getCartDetails__table_lct_215_qbb}  
例：

    var cart=new sn_sc.CartJS();
    	console.log (cart.getCartDetails());

出力：

    delivery_address : "Brasilia,Brasil" 
            name : "DEFAULT" 
            requested_for : "62826bf03710200044e0bfc8bcbe5df1" 
            requested_for_display_name : "Abel Tuter" 
            special_instructions : "" 
            sys_id : "c2ac090087150300318d05a888cb0bd7" 

## CartJS:getCartID() {#ariaid-title8}

現在の買い物かごの ID を返します。
{#r_CJSS-getCartID__table_l4t_j3y_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 12. パラメーター]

{#r_CJSS-getCartID__table_l4t_j3y_5z} {#r_CJSS-getCartID__table_m4t_j3y_5z__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在の買い物かごのSys_id。 |
[表 : 13. 返される内容]

{#r_CJSS-getCartID__table_m4t_j3y_5z}  
現在の買い物かごのsys_idを返します。

    var cart = new sn_sc.CartJS();
    var cartId = cart.getCartID();
    gs.info(cartId);

出力

    039c516237b1300054b6a3549dbe5dfc

## CartJS - getCartItems() {#ariaid-title9}

現在の買い物かごにあるアイテムのレコードを含む GlideRecord オブジェクトを返します。
{#r_CJSS-getCartItems__table_c5z_53y_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 14. パラメーター]

{#r_CJSS-getCartItems__table_c5z_53y_5z} {#r_CJSS-getCartItems__table_d5z_53y_5z__entry__2}

| タイプ | 説明 |
|-|-|
| GlideRecord | 現在の買い物かご内のアイテムを説明するアイテム \[sc_cart_item\] テーブルのレコードとフィールドを含む GlideRecord オブジェクト。 |
[表 : 15. 返される内容]

{#r_CJSS-getCartItems__table_d5z_53y_5z}  
現在の買い物かご内のアイテムの数量とカタログアイテムフィールド値を返します。

    var cart = new sn_sc.CartJS();

    var cartItems = cart.getCartItems();
    while (cartItems.next()) {
      gs.info(cartItems.getElement('quantity').getDisplayValue()
      + " x "
      + cartItems.getElement('cat_item').getDisplayValue());
    }

出力


    1 x Apple iPhone 6s Plus
    1 x Apple iPhone 6s
    1 x Apple MacBook Pro 15"

## CartJS - getDeliveryAddress() {#ariaid-title10}

現在の買い物かごの配送先を返します。
{#r_CJSS-getDeliveryAddress__table_ns4_cny_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 16. パラメーター]

{#r_CJSS-getDeliveryAddress__table_ns4_cny_5z} {#r_CJSS-getDeliveryAddress__table_os4_cny_5z__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在の買い物かごの配送先。 |
[表 : 17. 返される内容]

{#r_CJSS-getDeliveryAddress__table_os4_cny_5z}  
現在の買い物かごの配送先を設定して返します。

    var cart = new sn_sc.CartJS();
    cart.setDeliveryAddress("Brasilia, Brasil");
    var deliveryAddress = cart.getDeliveryAddress();
    gs.info(deliveryAddress);

出力

    Brasilia, Brasil

## CartJS - getRequestedFor() {#ariaid-title11}

買い物かごが要求されているユーザーのsys_idを返します。
{#r_CJSS-getRequestedFor__table_wds_4ly_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 18. パラメーター]

{#r_CJSS-getRequestedFor__table_wds_4ly_5z} {#r_CJSS-getRequestedFor__table_xds_4ly_5z__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 買い物かごが要求されているユーザーレコードのSys_id。 テーブル： ユーザー \[sys_user\] |
[表 : 19. 返される内容]

{#r_CJSS-getRequestedFor__table_xds_4ly_5z}  
買い物かごに関連付けられているユーザー sys_idを返します。

    var cart = new sn_sc.CartJS();
    cart.setRequestedFor("039c516237b1300054b6a3549dbe5dfc")
    var userId = cart.getRequestedFor();
    gs.info(userId);

出力：

    039c516237b1300054b6a3549dbe5dfc

## CartJS - getRequestedForDisplayName() {#ariaid-title12}

現在の買い物かごが要求されているユーザーの名前を返します。
{#r_CJSS-getRequestedForDisplayName__table_y4j_dmy_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 20. パラメーター]

{#r_CJSS-getRequestedForDisplayName__table_y4j_dmy_5z} {#r_CJSS-getRequestedForDisplayName__table_z4j_dmy_5z__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在の買い物かごが要求されているユーザーの名前。 テーブル： ユーザー \[sys_user\] |
[表 : 21. 返される内容]

{#r_CJSS-getRequestedForDisplayName__table_z4j_dmy_5z}  
買い物かごに関連付けられているユーザーの名前を返します。

    var cart = new sn_sc.CartJS();
    var userName = cart.getRequestedForDisplayName();
    gs.info(userName);

出力：

    Abel Tuter

## CartJS:getSpecialInstructions() {#ariaid-title13}

現在の買い物かごの特別な指示を返します。
{#r_CJSS-getSpecialInstructions__table_mj2_5my_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 22. パラメーター]

{#r_CJSS-getSpecialInstructions__table_mj2_5my_5z} {#r_CJSS-getSpecialInstructions__table_nj2_5my_5z__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在の買い物かごに関する特別な指示。 |
[表 : 23. 返される内容]

{#r_CJSS-getSpecialInstructions__table_nj2_5my_5z}  
この例では、現在の買い物かごの特別な指示を設定および取得する方法を示します。

    var cart = new sn_sc.CartJS();
    cart.setSpecialInstructions("Delivery before 8 AM.");
    var specInstruction = cart.getSpecialInstructions();
    gs.info(specInstruction);

出力

    Delivery before 8 AM.

## CartJS - orderNow (マップ要求) {#ariaid-title14}

単一のアイテムを注文します。2 ステップチェックアウトが有効になっている場合、メソッドは指定されたアイテムをカートに追加し、カートのsys_idを返します。2 ステップ精算が無効になっている場合、このメソッドは指定されたアイテムの購入を完了し、生成された要求のsys_idを返します。
{#r_CJSS-orderNow_M__table_n4w_b4d_zz__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 要求 | マップ | 注文するカタログアイテムの詳細を含む JSON オブジェクト。 |
| request.delivery_address | 文字列 | アイテムの配送先の住所。 デフォルト:ユーザーの住所 |
| request.sysparm_id | 文字列 | 必須。購入するアイテムのsys_id。 |
| request.special_instructions | 文字列 | 注文を処理するときに従うべき指示。 |
| request.sysparm_quantity | 文字列 | 指定された購入アイテムの数量。 デフォルト値：1 |
| request.sysparm_requested_for | 文字列 | アイテムが要求されたユーザーのsys_id。 デフォルト:セッションユーザー |
| request.variables | アレイ | アイテムに関連付けられた質問と顧客の回答。 |
| request.variables.var_name | 文字列 | 質問の名前。 |
| request.variables.var_value | 文字列 | 関連する質問に対する顧客の回答。 |
[表 : 24. パラメーター]

{#r_CJSS-orderNow_M__table_n4w_b4d_zz} {#r_CJSS-orderNow_M__table_o4w_b4d_zz__entry__2}

| タイプ | 説明 |
|-|-|
| JSON キー/値ペア | 2 ステップチェックアウトが有効になっている場合の出力: { 'cart_id' : '<sys_id of the cart to which the items were added>' } 2 ステップチェックアウトが無効になっている場合の出力: { 'request_id' : '<sys_id of the generated request>', 'request_number' : '<Number of the generated request>' } |
[表 : 25. 返される内容]

{#r_CJSS-orderNow_M__table_o4w_b4d_zz}  


    var cart = new sn_sc.CartJS();
    var request =
    {
      'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',
      'sysparm_quantity': '1',
      'variables':{
        'carrier': 'at_and_t_mobility',
        'data_plan': '500MB',
        'duration': 'eighteen_months',
        'color': 'slate',
        'storage': 'sixtyfour'
      }
    }
    var cartDetails = cart.orderNow(request);
    gs.info(cartDetails);

出力


    // If two-step checkout is enabled:
    {"cart_id":"55384df3c322320076173b0ac3d3aec5"}

    // If two-step checkout is disabled:
    {"request_id":"4c690137c322320076173b0ac3d3ae03", "request_number": "REQ0010003"}

## CartJS - setDeliveryAddress(文字列アドレス) {#ariaid-title15}

現在の買い物かごの配送先を設定します。
{#r_CJSS-setDeliveryAddress_S__table_xjn_kny_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| address | 文字列 | 現在の買い物かごの配送先。 |
[表 : 26. パラメーター]

{#r_CJSS-setDeliveryAddress_S__table_xjn_kny_5z} {#r_CJSS-setDeliveryAddress_S__table_yjn_kny_5z__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 27. 返される内容]

{#r_CJSS-setDeliveryAddress_S__table_yjn_kny_5z}  


          var cart = new sn_sc.CartJS();
          cart.setDeliveryAddress("Brasilia, Brasil"); 
          
## CartJS - setRequestedFor(文字列 user) {#ariaid-title16}

買い物かごが要求されているユーザーのsys_userレコードにsys_idを設定します。
{#CJSS-setRequestedFor_S__table_rdc_gxt_qbb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| ユーザー | 文字列 | sys_id買い物かごが要求されているユーザーのsys_userレコードに設定されます。 |
[表 : 28. パラメーター]

{#CJSS-setRequestedFor_S__table_rdc_gxt_qbb} {#CJSS-setRequestedFor_S__table_sdc_gxt_qbb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 29. 返される内容]

{#CJSS-setRequestedFor_S__table_sdc_gxt_qbb}  


    var cart = new sn_sc.CartJS();
    cart.setRequestedFor("039c516237b1300054b6a3549dbe5dfc")

## CartJS:setSpecialInstructions(文字列 specialInstructions) {#ariaid-title17}

現在の買い物かごの特別な指示を設定します。
{#r_CJSS-setSpecialInstructions_S__table_iwt_5ny_5z__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 特別な指示 | 文字列 | 現在の買い物かごに関する特別な指示。 |
[表 : 30. パラメーター]

{#r_CJSS-setSpecialInstructions_S__table_iwt_5ny_5z} {#r_CJSS-setSpecialInstructions_S__table_jwt_5ny_5z__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 31. 返される内容]

{#r_CJSS-setSpecialInstructions_S__table_jwt_5ny_5z}  


          var cart = new sn_sc.CartJS();
          cart.setSpecialInstructions("Delivery before 8 AM."); 
       
## CartJS - submitOrder(マップ要求) {#ariaid-title18}

requestパラメーターから特別な指示、要求元、配送先を更新し、買い物かごのチェックアウトを実行します。この API を使用して、買い物かごの上記のパラメーターを変更し、同時に買い物かごのチェックアウトを実行します。request オブジェクトに欠落しているパラメーターにはデフォルト値が設定されます。
{#r_CJSS-submitOrder_M__table_ymx_brd_zz__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 要求 | マップ | 送信するカートの詳細を含む JSON オブジェクト。 { 'special_instructions': "String", 'requested_for': '"String", 'delivery_address': "String" } |
| request.special_instructions | 文字列 | 注文に含める特別な指示。 |
| request.requested_for | 文字列 | 注文が要求されているユーザーのSys_id。 デフォルト:現在のユーザー。 テーブル： ユーザー \[sys_user\] |
| request.delivery_address | 文字列 | 注文の配送先。 |
[表 : 32. パラメーター]

{#r_CJSS-submitOrder_M__table_ymx_brd_zz} {#r_CJSS-submitOrder_M__table_zmx_brd_zz__entry__2}

| タイプ | 説明 |
|-|-|
| JSON | 買い物かごの構造。 { 'request_id' : 'sys_id of the generated Request', 'request_number' : 'Number of the generated Request' } |
[表 : 33. 返される内容]

{#r_CJSS-submitOrder_M__table_zmx_brd_zz}  
次のコード例は、このメソッドを呼び出す方法を示しています。

    var cart = new sn_sc.CartJS();
    var request =
    {
      'special_instructions' : 'Delivery only in working hours',
      'requested_for' : '62826bf03710200044e0bfc8bcbe5df1',
      'delivery_address' : "Brasilia, Brasil",
    };
    var requestDetails = cart.submitOrder(request);
    gs.info(JSON.stringify(requestDetails));

出力：

    {"request_id":"6eed229047801200e0ef563dbb9a71c2", "request_number": "REQ0000001"}

## CartJS - updateItem(マップ要求、文字列 cart_item_id) {#ariaid-title19}

買い物かごのアイテムを更新します。
{#r_CJSS-updateItem_M_S__table_zvx_npd_zz__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 要求 | マップ | 更新するカタログアイテムの詳細を含む JSON オブジェクト。 要求オブジェクトの構造は次のとおりです。 { 'sysparm_quantity' : item_quantity, 'sysparm_requested_for' : requested_for, 'variables' : { 'var_name' : 'var_value', ... } } * item_quantity:追加するアイテムの数。デフォルト値は 1 です。 * var_name:質問の名前。 * var_value:回答の値 (表示値ではありません)。 {#r_CJSS-updateItem_M_S__ul_agy_ypd_zz} |
| cart_item_id | 文字列 | 変更する買い物かごアイテムのsys_id。 |
[表 : 34. パラメーター]

{#r_CJSS-updateItem_M_S__table_zvx_npd_zz} {#r_CJSS-updateItem_M_S__table_awx_npd_zz__entry__2}

| タイプ | 説明 |
|-|-|
| JSON | 買い物かごの詳細。 { 'subtotal': value, 'items':[ { itemName:'', quantity:'', price:'', recurring_price:'' } ...], ... } |
[表 : 35. 返される内容]

{#r_CJSS-updateItem_M_S__table_awx_npd_zz}  

    var cart = new sn_sc.CartJS();
    var request =
    {
      'sysparm_quantity': '1',
      'variables':{
        'carrier': 'at_and_t_mobility',
        'data_plan': '500MB',
        'duration': 'eighteen_months',
        'color': 'slate',
        'storage': 'sixtyfour'
      }
    };
    var cart_item_id = "4d69b672c322320076173b0ac3d3ae79";
    var cartDetails = cart.updateItem(request, cart_item_id);
    gs.info(cartDetails);

出力


    { "cart_id":"35ec9e8947a13200e0ef563dbb9a7109", "items":[ { "cart_item_id":"35ec9e8947a13200e0ef563dbb9a710a", "catalog_item_id":"0d08837237153000158bbfc8bcbe5d02", "item_name":"Apple iPhone 5", "localized_price":"$799.99", "localized_recurring_price":"$30.00", "price":"$799.99", "quantity":"1", "recurring_frequency":"Monthly", "recurring_price":"$29.00" } ] "subtotal":"$799.99" }


