UpdateQuantity.ss

Note:

For more information on SuiteScript 1.0, see SuiteScript 1.0 Guide.

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);   
} 

        

Related Topics

Sample_Cart.ssp
Cart_WithService.ssp
AddCartItem.ss
AddCustomerAddress.ss
Example .ss File Code that Accesses a NetSuite Record
ItemOption.ss
Known Issue with Internet Explorer and Plain Text Content
Sample SSP Application Code (SuiteScript 1.0)
SuiteScript 1.0 SSP Applications
Create and Use SSP Applications

General Notices