{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":969,"path":"api-reference/server-api-reference/c_CartJSScoped.md","title":"CartJS - Scoped","bundle":null,"doc_type":null,"release":"australia","body":"\n# CartJS- Scoped\n\nThe CartJS API provides methods that enable you to access a user's shopping cart.\n\nThis API runs in the `sn_sc` namespace. The Service Catalog Scoped API plugin \\(ID: com.glideapp.servicecatalog.scoped.api\\) that is enabled by default is required to access the CartJS API.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## CartJS - CartJS\\(String cartName\\)\n\nCreates an instance of the CartJS class with the name of a defined cart for the user who is currently logged in.\n\n|Name|Type|Description|\n|----|----|-----------|\n|cartName|String|Optional. Name of a defined cart for the user who is currently logged in.|\n\n```\nvar cart = new sn_sc.CartJS(cart1);\n```\n\n## CartJS - addToCart\\(Map request\\)\n\nAdds the request for a catalog item to the current cart.\n\n<table id=\"table_ecz_zjy_5z\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nrequest\n\n</td><td>\n\nMap\n\n</td><td>\n\nA JSON object that contains the details of the catalog item to be added to the cart.The structure of the request object is:\n\n ```\n{\n'sysparm_id': item_id,\n'sysparm_quantity': item_quantity,\n'variables':{\n'var_name': 'var_value',\n...\n}\n}\n```\n\n -   item\\_id: sys\\_id of the item to be added to the cart\n-   item\\_quantity: Number of items to be added. Default value is 1.\n-   var\\_name: Name of the question.\n-   var\\_value: Value of the answer \\(Not the display value\\).\n\n</td></tr></tbody>\n</table><table id=\"table_fcz_zjy_5z\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nJSON\n\n</td><td>\n\nStructure of the current cart.```\n{\n'subtotal': value,\n'items':[\n{\nitemName:'',\nquantity:'', \nprice:'', \nrecurring_price:''\n} ...]\n}\n```\n\n</td></tr></tbody>\n</table>This example shows how you can add multiple items to the cart. Note that `var cart = new sn_sc.CartJS();` is inside the loop. You must call `sn_sc.CartJS()` multiple times to be able to add multiple items to the cart.\n\n```\nfor (i = 0; i < 2; i++) { \nvar cart = new sn_sc.CartJS();\nvar item =\n{\n'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',\n'sysparm_quantity': '1',\n'variables':{\n'carrier': 'at_and_t_mobility',\n'data_plan': '500MB',\n'duration': 'eighteen_months',\n'color': 'slate',\n'storage': 'sixtyfour' \n}};\nvar cartDetails = cart.addToCart(item);\ngs.info(JSON.stringify(cartDetails));\n}\n```\n\nOutput\n\n```\n//The cart after the first item is added\n{\n  \"cart_id\": \"c0f5828a1b476010593876a61a4bcb71\",\n  \"subtotal\": \"$599.99\",\n  \"items\": [\n    {\n      \"catalog_item_id\": \"0d08837237153000158bbfc8bcbe5d02\",\n      \"quantity\": \"1\",\n      \"localized_price\": \"$599.99\",\n      \"price\": \"$599.99\",\n      \"recurring_frequency\": \"Monthly\",\n      \"localized_recurring_price\": \"$30.00\",\n      \"recurring_price\": \"$29.00\",\n      \"item_name\": \"Apple iPhone 5\",\n      \"cart_item_id\": \"40f5828a1b476010593876a61a4bcb72\"\n    }\n  ]\n}\n\n//The cart after the second item is added\n{\n  \"cart_id\": \"c0f5828a1b476010593876a61a4bcb71\",\n  \"subtotal\": \"$1,199.98\",\n  \"items\": [\n    {\n      \"catalog_item_id\": \"0d08837237153000158bbfc8bcbe5d02\",\n      \"quantity\": \"1\",\n      \"localized_price\": \"$599.99\",\n      \"price\": \"$599.99\",\n      \"recurring_frequency\": \"Monthly\",\n      \"localized_recurring_price\": \"$30.00\",\n      \"recurring_price\": \"$29.00\",\n      \"item_name\": \"Apple iPhone 5\",\n      \"cart_item_id\": \"40f5828a1b476010593876a61a4bcb72\"\n    },\n    {\n      \"catalog_item_id\": \"0d08837237153000158bbfc8bcbe5d02\",\n      \"quantity\": \"1\",\n      \"localized_price\": \"$599.99\",\n      \"price\": \"$599.99\",\n      \"recurring_frequency\": \"Monthly\",\n      \"localized_recurring_price\": \"$30.00\",\n      \"recurring_price\": \"$29.00\",\n      \"item_name\": \"Apple iPhone 5\",\n      \"cart_item_id\": \"98f5828a1b476010593876a61a4bcb75\"\n    }\n  ]\n}\n```\n\n## CartJS - canViewRF\\(\\)\n\nSpecifies if the current user has the required role to edit the **Request for** field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_ky1_pzt_qbb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user has the required role to edit the requested for field.Possible values:\n\n-   true: User has the required role.\n-   false: User does not have the required role.\n\nData type: Boolean\n\n</td></tr></tbody>\n</table>This background script code example shows how to check if the current user has the role needed to edit the requested for field.\n\n```\ngs.log(sn_sc.CartJS.canViewRF());\n```\n\nResponse:\n\n```\ntrue\n```\n\n## CartJS - checkoutCart\\(\\)\n\nPerforms the cart checkout. If the two-step checkout is enabled, returns the order summary. If the two-step checkout is disabled, the cart is submitted and details of the generated request are returned.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_wqd_hsd_zz\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nJSON\n\n</td><td>\n\nIf the two-step checkout is enabled, the summary of the items in the cart is returned.```\n{ \"subtotal_price\":\"\",\n  \"subtotal_recurring_frequency\":\"\",\n  \"delivery_address\":\"\",\n  \"special_instructions\":\"\",\n  \"total_title\":\"\",\n  \"requested_for_user\":\"System Administrator\",\n  \"requested_for\":\"6816f79cc0a8016401c5a33be04be441\",\n  \"daily\": [\"frequency_subtotal\":\"\", \"items\":[{}, {}, ...], …],\n  \"monthly\":[\"frequency_subtotal\":\"\", \"items\":[{}, {}, ...], …],\n  \"annually\":[\"frequency_subtotal\":\"\", \"items\":[{}, {}, ...], …],\n  \"none\":[\"frequency_subtotal\":\"\", \"items\":[{}, {}, ...], …],\n}\n```\n\n If the two-step checkout is disabled:\n\n```\n{\n  'request_id' : \"sys_id of the generated request\",\n  \"request_number\" : \"Number of the generated request\"\n}\n```\n\n</td></tr></tbody>\n</table>```\nvar cart = new sn_sc.CartJS();\nvar checkoutInfo = cart.checkoutCart();\ngs.info(checkoutInfo);\n\n```\n\nOutput\n\n```\nIf two step checkout enabled:\n{\"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\"}\nIf two step checkout disabled:\n{\"request_number\":\"REQ0010001\",\"request_id\":\"2f2789f3c322320076173b0ac3d3ae62\"}\n\n```\n\n## CartJS - empty\\(\\)\n\nDeletes the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar cart = new sn_sc.CartJS();\n      cart.empty();\n```\n\n## CartJS - getCartDetails\\(\\)\n\nReturns the cart details.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Object|Object pointing to the current cart details.|\n\nExample:\n\n```\nvar cart=new sn_sc.CartJS();\n\tconsole.log (cart.getCartDetails());\n```\n\nOutput:\n\n```\ndelivery_address : \"Brasilia,Brasil\" \n        name : \"DEFAULT\" \n        requested_for : \"62826bf03710200044e0bfc8bcbe5df1\" \n        requested_for_display_name : \"Abel Tuter\" \n        special_instructions : \"\" \n        sys_id : \"c2ac090087150300318d05a888cb0bd7\" \n\n```\n\n## CartJS - getCartID\\(\\)\n\nReturns the ID of the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id for the current cart.|\n\nReturns the sys\\_id of the current cart.\n\n```\nvar cart = new sn_sc.CartJS();\nvar cartId = cart.getCartID();\ngs.info(cartId);\n```\n\nOutput\n\n```\n039c516237b1300054b6a3549dbe5dfc\n```\n\n## CartJS - getCartItems\\(\\)\n\nReturns a GlideRecord object containing records for items in the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideRecord|GlideRecord object including records and fields from the Item \\[sc\\_cart\\_item\\] table that describe an item in the current cart.|\n\nReturns quantity and Catalog Item field values for items in the current cart.\n\n```\nvar cart = new sn_sc.CartJS();\n\nvar cartItems = cart.getCartItems();\nwhile (cartItems.next()) {\n  gs.info(cartItems.getElement('quantity').getDisplayValue()\n  + \" x \"\n  + cartItems.getElement('cat_item').getDisplayValue());\n}\n```\n\nOutput\n\n```\n\n1 x Apple iPhone 6s Plus\n1 x Apple iPhone 6s\n1 x Apple MacBook Pro 15\"\n```\n\n## CartJS - getDeliveryAddress\\(\\)\n\nReturns the delivery address for the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Delivery address for the current cart.|\n\nSets and then returns the delivery address for the current cart.\n\n```\nvar cart = new sn_sc.CartJS();\ncart.setDeliveryAddress(\"Brasilia, Brasil\");\nvar deliveryAddress = cart.getDeliveryAddress();\ngs.info(deliveryAddress);\n```\n\nOutput\n\n```\nBrasilia, Brasil\n```\n\n## CartJS - getRequestedFor\\(\\)\n\nReturns the sys\\_id of the user for whom the cart is requested.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_xds_4ly_5z\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nSys\\_id of the user record for whom the cart is requested.Table: User \\[sys\\_user\\]\n\n</td></tr></tbody>\n</table>Returns the user sys\\_id associated with the cart.\n\n```\nvar cart = new sn_sc.CartJS();\ncart.setRequestedFor(\"039c516237b1300054b6a3549dbe5dfc\")\nvar userId = cart.getRequestedFor();\ngs.info(userId);\n```\n\nOutput:\n\n```\n039c516237b1300054b6a3549dbe5dfc\n```\n\n## CartJS - getRequestedForDisplayName\\(\\)\n\nReturns the name of the user for whom the current cart is requested.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_z4j_dmy_5z\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nName of the user for whom the current cart is requested.Table: User \\[sys\\_user\\]\n\n</td></tr></tbody>\n</table>Returns the name of the user associated with the cart.\n\n```\nvar cart = new sn_sc.CartJS();\nvar userName = cart.getRequestedForDisplayName();\ngs.info(userName);\n```\n\nOutput:\n\n```\nAbel Tuter\n```\n\n## CartJS - getSpecialInstructions\\(\\)\n\nReturns the special instructions for the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Special instructions for the current cart.|\n\nThis example shows how to set and retrieve the special instructions for the current cart.\n\n```\nvar cart = new sn_sc.CartJS();\ncart.setSpecialInstructions(\"Delivery before 8 AM.\");\nvar specInstruction = cart.getSpecialInstructions();\ngs.info(specInstruction);\n```\n\nOutput\n\n```\nDelivery before 8 AM.\n```\n\n## CartJS - orderNow\\(Map request\\)\n\nOrders a single item. If two-step checkout is enabled, the method adds the specified item to the cart and returns the sys\\_id of the cart. If two-step checkout is disabled, the method completes the purchase of the specified item and returns the sys\\_id of the generated request.\n\n<table id=\"table_n4w_b4d_zz\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nrequest\n\n</td><td>\n\nMap\n\n</td><td>\n\nJSON object that contains details of the catalog item to order.\n\n</td></tr><tr><td>\n\nrequest.delivery\\_address\n\n</td><td>\n\nString\n\n</td><td>\n\nAddress to which to deliver the items.Default: Address of user\n\n</td></tr><tr><td>\n\nrequest.sysparm\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nRequired. The sys\\_id of the item to purchase.\n\n</td></tr><tr><td>\n\nrequest.special\\_instructions\n\n</td><td>\n\nString\n\n</td><td>\n\nInstructions to follow when processing the order.\n\n</td></tr><tr><td>\n\nrequest.sysparm\\_quantity\n\n</td><td>\n\nString\n\n</td><td>\n\nQuantity of the specified item to purchase.Default: 1\n\n</td></tr><tr><td>\n\nrequest.sysparm\\_requested\\_for\n\n</td><td>\n\nString\n\n</td><td>\n\nThe sys\\_id of the user for whom the item is requested.Default: Session user\n\n</td></tr><tr><td>\n\nrequest.variables\n\n</td><td>\n\nArray\n\n</td><td>\n\nQuestions and customer answers associated with the item.\n\n</td></tr><tr><td>\n\nrequest.variables.var\\_name\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the question.\n\n</td></tr><tr><td>\n\nrequest.variables.var\\_value\n\n</td><td>\n\nString\n\n</td><td>\n\nCustomer's response to the associated question.\n\n</td></tr></tbody>\n</table><table id=\"table_o4w_b4d_zz\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nJSON key/value pairs\n\n</td><td>\n\nOutput if two-step checkout is enabled:```\n{\n  'cart_id' : '<sys_id of the cart to which the items were added>'\n}\n```\n\n Output if two-step checkout is disabled:\n\n ```\n{\n  'request_id' : '<sys_id of the generated request>',\n  'request_number' : '<Number of the generated request>'\n}\n```\n\n</td></tr></tbody>\n</table>```\n\nvar cart = new sn_sc.CartJS();\nvar request =\n{\n  'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',\n  'sysparm_quantity': '1',\n  'variables':{\n    'carrier': 'at_and_t_mobility',\n    'data_plan': '500MB',\n    'duration': 'eighteen_months',\n    'color': 'slate',\n    'storage': 'sixtyfour'\n  }\n}\nvar cartDetails = cart.orderNow(request);\ngs.info(cartDetails);\n```\n\nOutput\n\n```\n\n// If two-step checkout is enabled:\n{\"cart_id\":\"55384df3c322320076173b0ac3d3aec5\"}\n\n// If two-step checkout is disabled:\n{\"request_id\":\"4c690137c322320076173b0ac3d3ae03\", \"request_number\": \"REQ0010003\"}\n```\n\n## CartJS - setDeliveryAddress\\(String address\\)\n\nSets the delivery address for the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|address|String|Delivery address for the current cart.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n\n      var cart = new sn_sc.CartJS();\n      cart.setDeliveryAddress(\"Brasilia, Brasil\"); \n      \n```\n\n## CartJS - setRequestedFor\\(String user\\)\n\nSets the sys\\_id in the sys\\_user record of the user for whom the cart is requested.\n\n|Name|Type|Description|\n|----|----|-----------|\n|user|String|sys\\_id to be set in the sys\\_user record of the user for whom the cart is requested.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n\nvar cart = new sn_sc.CartJS();\ncart.setRequestedFor(\"039c516237b1300054b6a3549dbe5dfc\")\n\n```\n\n## CartJS - setSpecialInstructions\\(String specialInstructions\\)\n\nSets the special instructions for the current cart.\n\n|Name|Type|Description|\n|----|----|-----------|\n|specialInstructions|String|Special instructions for the current cart.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n\n      var cart = new sn_sc.CartJS();\n      cart.setSpecialInstructions(\"Delivery before 8 AM.\"); \n   \n```\n\n## CartJS - submitOrder\\(Map request\\)\n\nUpdates special instructions, requested for, and delivery address from the **request** parameter and performs the cart checkout. Use this API to modify the mentioned parameters of the cart and perform the cart checkout simultaneously. Missing parameters in the **request** object will have their default value.\n\n<table id=\"table_ymx_brd_zz\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nrequest\n\n</td><td>\n\nMap\n\n</td><td>\n\nJSON object that contains details of the cart to be submitted. ```\n{\n  'special_instructions': \"String\",\n  'requested_for': '\"String\",\n  'delivery_address': \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nrequest.special\\_instructions\n\n</td><td>\n\nString\n\n</td><td>\n\nSpecial instructions to include with the order.\n\n</td></tr><tr><td>\n\nrequest.requested\\_for\n\n</td><td>\n\nString\n\n</td><td>\n\nSys\\_id of the user who the order is requested for.Default: The current user.\n\nTable: User \\[sys\\_user\\]\n\n</td></tr><tr><td>\n\nrequest.delivery\\_address\n\n</td><td>\n\nString\n\n</td><td>\n\nDelivery address for the order.\n\n</td></tr></tbody>\n</table><table id=\"table_zmx_brd_zz\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nJSON\n\n</td><td>\n\nStructure of the cart.```\n{\n  'request_id' : 'sys_id of the generated Request',\n  'request_number' : 'Number of the generated Request'\n}\n```\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar cart = new sn_sc.CartJS();\nvar request =\n{\n  'special_instructions' : 'Delivery only in working hours',\n  'requested_for' : '62826bf03710200044e0bfc8bcbe5df1',\n  'delivery_address' : \"Brasilia, Brasil\",\n};\nvar requestDetails = cart.submitOrder(request);\ngs.info(JSON.stringify(requestDetails));\n```\n\nOutput:\n\n```\n{\"request_id\":\"6eed229047801200e0ef563dbb9a71c2\", \"request_number\": \"REQ0000001\"}\n```\n\n## CartJS - updateItem\\(Map request, String cart\\_item\\_id\\)\n\nUpdates an item in the cart.\n\n<table id=\"table_zvx_npd_zz\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nrequest\n\n</td><td>\n\nMap\n\n</td><td>\n\nA JSON object that contains details of the catalog item to be updated.The structure of the request object is:\n\n ```\n{\n    'sysparm_quantity' : item_quantity,\n  'sysparm_requested_for' : requested_for,\n  'variables' : {\n    'var_name' : 'var_value',\n    ...\n  }\n}\n```\n\n -   item\\_quantity: Number of items to be added. Default value is 1.\n-   var\\_name: Name of the question.\n-   var\\_value: Value of the answer \\(Not the display value\\).\n\n</td></tr><tr><td>\n\ncart\\_item\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nsys\\_id of the cart item to be modified.\n\n</td></tr></tbody>\n</table><table id=\"table_awx_npd_zz\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nJSON\n\n</td><td>\n\nDetails of the cart.```\n{\n  'subtotal': value,\n  'items':[\n    {\n    itemName:'',\n    quantity:'',\n    price:'',\n    recurring_price:''\n    }\n    ...],\n  ...\n}\n```\n\n</td></tr></tbody>\n</table>```\nvar cart = new sn_sc.CartJS();\nvar request =\n{\n  'sysparm_quantity': '1',\n  'variables':{\n    'carrier': 'at_and_t_mobility',\n    'data_plan': '500MB',\n    'duration': 'eighteen_months',\n    'color': 'slate',\n    'storage': 'sixtyfour'\n  }\n};\nvar cart_item_id = \"4d69b672c322320076173b0ac3d3ae79\";\nvar cartDetails = cart.updateItem(request, cart_item_id);\ngs.info(cartDetails);\n\n```\n\nOutput\n\n```\n\n{ \"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\" }\n```\n\n"}}