Update order
Handle checkout updates.
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.
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().

lock()
Locks the Qliro Checkout frontend and disables user interaction.
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
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
{
"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.
q1.unlock()