Logotype
For developers
By Qliro
Select search filters:
0
0
/
/
Update order
Handle checkout updates.
Overview
Once an order is created, you can update the order items by using the update order request.
If the cart is updated in checkout the order needs to be synchronized. This is done in the front end by locking and unlocking the Iframe. There are a few important points to consider for the interface to be consistent.
  • Always lock the checkout before making any requests to your server. Otherwise, the customer can interact with the checkout and try to complete the purchase while the order is still being synchronized.
  • Always make a proper order comparison before unlocking the checkout. Otherwise, the synchronization could be interrupted if the customer makes multiple changes to the order.
For details on the request/response parameters as well as error codes, please continue to UpdateOrder in the API reference.
How-to
  1. Customer updates the shopping cart.
  2. Call q1.lock() to lock the frontend iframe and enable the synchronizing process.
  3. Send the update order request using PUT /Orders/{id}.
  4. Qliro sends a response.
  5. Call q1.onOrderUpdated(function(order)…)).
  6. Verify that the total amount of the order = total amount in the shopping cart.
  7. Call q1.unlock().

lock()
Lock the Qliro Checkout front end and disable user interaction.
 
Implementation example
1
q1.lock()
 
onOrderUpdated()
Requires q1.lock() to have been called first. Initiates the order sync process towards the checkout front end. Should call q1.unlock() as soon as the orders match.
 
Implementation
Arguments
Parameter Type Description Mandatory
callback function A function that takes an order (object) argument and calls unlock if the order is updated. Yes
 
 
Implementation example
1
2
3
4
5
6
7
8
q1.onOrderUpdated(function (order) {
// if order reflects the local cart, use q1.unlock()
if (order.totalPrice === localCart.totalPrice) {
// exampel of how the order can be verified
q1.unlock()
}
// else, don't do anything
})
 
 
 
Example of order argument passed to isUpdated
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
  "totalPrice": 350,
  "orderItems": [
    {
      "merchantReference": "RedHat",
      "pricePerItemIncVat": 100,
      "quantity": 3
    },
    {
      "merchantReference": "BlackHat",
      "pricePerItemIncVat": 50,
      "quantity": 1
    }
  ]
}
 
unlock()
Unlock the Qliro Checkout front end and enable user interaction.
 
Implementation example
1
q1.unlock()
icon corner-down-right-dark
Next up is Validate order