The following code contains the backend function for updating quantity in the Cart_WithService .ssp file:

function service(request,response) { // get incoming http parameter var quantity = request.getParameter('quantity'); nlapiLogExecution('DEBUG', 'quantity', quantity); // get active order in web container var order = nlapiGetWebContainer().getShoppingSession().getOrder(); // get the items out of the order var items = order.items; var orderItemId = items[0].orderitemid; nlapiLogExecution('DEBUG', 'order item id - line 1', orderItemId); var currentQuantityLine1 = items[0].quantity; nlapiLogExecution('DEBUG', 'order curr qty - line 1', currentQuantityLine1); var updatedItem = new Object(); updatedItem.orderitemid = orderItemId; updatedItem.quantity = quantity; order.updateItemQuantity(updatedItem); var itemsJSON = JSON.stringify(order.getItems()); // send items back out as JSON, response.setContentType('JSON'); response.writeLine(itemsJSON); }