Updating Order Items

Learn how to change a customer’s order by adding or removing order items or Changing Quantity

One way existing orders can be modified is by adding or removing the order items associated to the order. For example, a customer might want to add more items to their order or remove items they've already ordered from you.

Changing an order can change the status of an order. So you can prepare to handle this by subscribing your webhook endpoint to order.updated to get notified of any changes.

Adding line items to an order

Orders can be modified by adding new order item to the order without having the need to cancel or recreate the order:

# Retrieve the order:
curl --location --request GET https://lsapi-supplier-orders.lightspeedapp.com/orders/$ORDER_ID \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LIGHTSPEED_API_TOKEN'
  
# Add to the exisiting order by using the `id` above
curl --location --request POST https://lsapi-supplier-orders.lightspeedapp.com/orders/$ORDER_ID/items /
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LIGHTSPEED_API_TOKEN'
--data-raw '
  {
  "productID": "35ef9dea-f73d-11e9-80f3-d7e78880ed20",
  "quantity": 5,
  "cost": 2.50
  }
 '

Which will return an OrderItem:

{
    "id": "70fe43ed-4d1b-11ea-81e8-ba88c8889bb5",
    "productID": "35ef9dea-f73d-11e9-80f3-d7e78880ed20",
    "orderID": "70fe4392-4d1b-11ea-81e8-ba88c8889bb5",
    "status": "OrderItemOpened",
    "quantity": 5,
    "received": 0,
    "cost": 2.50,
    "totalCost": 12.5,
    "createdBy": "280981",
    "createdDate": "2020-02-11 22:11:24",
    "modifiedDate": "2020-02-11 22:11:24"
}

Removing order items to an order

Order items can also be removed without having the need to cancel or recreate the order. Begin by removing the order:

# Remove an order item
curl --location --request DELETE https://lsapi-supplier-orders.lightspeedappstg.com/orders/$ORDER_ID/items/$ORDER_ITEM_ID \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LIGHTSPEED_API_TOKEN'

By default, the removal takes effect immediately, however once a customer’s orders is canceled or completed, no further order items are can be created.


Changing Order Item Quantities

You can modify the information about an order's items without having to recreate the order. For instance, you may want to adjust the total quantity of an item being processed for Shipment

Orders can be modified by passing a payload containing only the fields you want to change.
Begin by calling the update order item endpoint:

# Modify the quantity of an order item
curl --location --request PUT https://lsapi-supplier-orders.lightspeedapp.com/orders/$ORDER_ID/items/ORDER_ITEM_ID /
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LIGHTSPEED_API_TOKEN'
--data-raw '
  {
    "quantity": 5
  }
 '