> The index of all pages is at [llms.txt](https://developers.qliro.com/llms.txt). Add `.md` to any page URL for its Markdown.

# Update order (/qliro-checkout/checkout-features/update-order)

## Overview

After you create an order, you can update its order items with the update order request.

If the cart changes in the checkout, you must synchronize the order. Do this in the frontend by locking and unlocking the iframe. Follow these rules to keep the interface consistent:

* Always lock the checkout before you send any request to your server. Otherwise the customer can try to complete the purchase while the order is still synchronizing.
* Always compare the orders before you unlock the checkout. Otherwise multiple changes by the customer can interrupt the synchronization.

For the request and response parameters and the error codes, see UpdateOrder in the [API Reference](https://developers.qliro.com/api-reference/merchant/orders/update-order).

## How-to

**1. Customer updates shopping cart**

The customer updates the shopping cart.

**2. Lock the iframe**

Call `q1.lock()` to lock the frontend iframe and start the synchronization.

**3. Send update order request**

Send the update order request using `PUT /Orders/{id}`.

**4. Receive response**

Qliro sends a response.

**5. Verify order**

Call `q1.onOrderUpdated(function(order)...)`.

**6. Verify totals match**

Verify that the total amount of the order equals the total amount in the shopping cart.

**7. Unlock the iframe**

Call `q1.unlock()`.

![Update Order](<https://developers.qliro.com/assets/update-order-Baawae6d.webp>)

### lock()

Locks the Qliro Checkout frontend and disables user interaction.

```javascript
q1.lock()
```

### onOrderUpdated()

Starts the order synchronization towards the checkout frontend. Call q1.lock() first. Call q1.unlock() as soon as the orders match.

| Parameter | Type | Description | Required |
| :- | :- | :- | :- |
| callback | function | A function that takes an order (object) argument and calls unlock if the order is updated. | <Required /> |

**Implementation example**

```javascript
q1.onOrderUpdated(function (order) {
  // if order reflects the local cart, use q1.unlock()
  if (order.totalPrice === localCart.totalPrice) {
    // example of how the order can be verified
    q1.unlock()
  }
  // else, don't do anything
})
```

**Example of order argument passed to callback**

```json
{
  "totalPrice": 350,
  "orderItems": [
    {
      "merchantReference": "RedHat",
      "pricePerItemIncVat": 100,
      "quantity": 3
    },
    {
      "merchantReference": "BlackHat",
      "pricePerItemIncVat": 50,
      "quantity": 1
    }
  ]
}
```

### unlock()

Unlocks the Qliro Checkout frontend and enables user interaction.

```javascript
q1.unlock()
```

<Cards>
<Card title="Validate order" href="/qliro-checkout/checkout-features/validate-order">
Continue to Validate order
</Card>
</Cards>