updateSalesOrderItems mutation
updateSalesOrderItems is a GraphQL mutation of the Chameleoon MAX API. Send it as POST https://max-api.chameleoon.sk/api/v1/graphql with your API key, see Chameleoon MAX.
Updates the order's items and charges to match the external source's current ones. Call it when items, quantities, prices or charges change in the external source after the order was placed.
Send all of the order's items and charges as the external source has them now, priced as for
createSalesOrder, together with the total. MAX matches them to the order as
follows:
- Items match lines by each item's
externalId, as the order was created with it. The ids belong to the external source's order that this order was placed as. When you name the order by its MAXid, that is the external order the MAX order holds. - Charges match by
kindandcode, or bykindandnamewhen a charge has no code.
Before packing, MAX applies the change. It adds a new item at your price, removes an item you no longer send, and changes a quantity, price or charge. It leaves alone any line or charge that the external source never sent.
In the following cases MAX keeps its own items and opens a SHOP_CHANGE_* exception on the
order, with your items in the exception's data.
| Outcome | Blocks the order | When |
|---|---|---|
WARNING | No | The order has shipped, or a consignment has a label without cash on delivery. |
UNMAPPED | Yes | A new item matches no product in MAX. |
CONFLICT | Yes | A user changed the items in MAX. |
NEEDS_REVIEW | Yes | A consignment is packed or has a label. |
REFUSED | Yes | MAX refused a step part way through, or the currency cannot change (see Currency). |
After the change, MAX compares expectedTotal with the order's total (TOTAL_MISMATCH).
Money paid above the new total gives the warning SHOP_ORDER_OVERPAID.
Currency
Send currencyCode when the external source restates the order's currency, for example after it
read its own document in the wrong currency. MAX changes the currency together with your prices,
and only while the order merely waits:
- the warehouse has not started on it: every consignment is open, not being picked and not claimed by a packer, and there is no shipment or shipment draft;
- no payment or refund is recorded on it;
- no user changed its items in MAX;
- MAX did not convert its prices under a VAT regime;
- its price list, if any, is in the new currency.
Otherwise MAX keeps the order as it is and opens the blocking exception SHOP_CHANGE_CURRENCY
with the outcome REFUSED. After the order has shipped, or once another order was merged into
it, the change is a warning only (SHOP_CHANGE_AFTER_SHIPPING, SHOP_CHANGE_CONFLICT). If a later step is refused after MAX took the currency, the
exception SHOP_CHANGE_REFUSED says so; send the items again, or a user in MAX takes them from
the exception.
Permissions
Requires the order.write and order.read permissions.
Repeated calls
A repeat changes nothing and returns UNCHANGED.
Errors
VALIDATIONwhen an item is invalid by the rules ofcreateSalesOrderor has noexternalId.VALIDATIONwhen you name the order byidand it holds orders from several external sources. Name it bysourceandexternalIdinstead.CONFLICTwhen the order is cancelled or merged.CONFLICTwithextensions.reasonITEMS_SYNC_IN_PROGRESSwhen another change of the order's items is being applied. Send the request again shortly.NOT_FOUNDwhen the order does not exist or your API key cannot see it.
An error whose path runs below this field does not mean the call failed: the items were processed, so do not retry. See
Mutation.
Costs 1 point plus 1 per item and 1 per charge, plus its selection.
Arguments
ref:SalesOrderRefInput!· requiredinput:SalesOrderItemsInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.