pixiUpdateOrder
Updates shipping costs, ship date, shop note, voucher, address remarks and payment type of an existing open order.
Updates selected header data of an existing order. The order is found by OrderNr or OrderNrExternal.
Validation steps (each returns an Error row and stops):
- At least one of
OrderNrorOrderNrExternalmust be given. - The order is looked up with
OrderNr = @OrderNr OR OrderNrExternal = @OrderNrExternal(first match). If none is found, an error is returned. VoucherIDandVoucherAmountmust be given together.- The voucher must not be used on order lines of another order.
- If
PaymentTypeis given, it must exist as aCodein thePaymentstable. - The order must still be editable: the overall order state, calculated from the order lines, must be
OPENorHOLD. In addition, the number of non-final order lines that already have invoice lines must be lower than the number of lines that are neither final nor in statusMINorFUS.
Update:
- Parameters that are left out keep the current values of the order.
ShipCostsis applied to the net shipping costs forB2Borders and to the gross shipping costs forB2Corders.ShipDatereplaces the ship date. The value1900-01-01clears it toNULL.ShopNoteandAddressRemarksreplace the stored texts.- All other header fields, such as gift message, shipping instructions, ship vendor, CCP merchant,
ccpPayID, Verfahren/Product/Extras and order type, are passed through unchanged. - The actual update is done by the internal procedure
Pixi_UpdateOrder. It setsUpdateDateto the current time. - If the shipping costs change and no voucher or discount applies, the
ShipCostof the order lines is updated as well. - If a voucher is given, it is created in
Voucherif it does not exist yet. Otherwise its amount is updated. The voucher ID is then written to all order lines. - If
PaymentTypeis given, it is written toAPaymentof the order's address (AddrRef).
On success, a Success row is returned.
Notes
VoucherAmountis passed throughNULLIF(@VoucherAmount, ''). Because''converts to0formoney, an amount of0is treated as not provided. PassingVoucherIDwith amount0therefore returnsVoucherID provided without VoucherAmount.- An empty
VoucherIDis treated as not provided. - If both
OrderNrandOrderNrExternalare given and match different orders, an arbitrary one of them is updated (TOP (1)withoutORDER BY). - In the does not exist error, the message is built by string concatenation. If one of the two identifiers is
NULL, theMessagecolumn isNULL. Pixi_UpdateOrderruns in its own transaction and catches its own errors. It logs them vialog.InsertErrorand does not re-raise them, so the outer error handler may not see them. ASuccessrow can therefore be returned even if the inner update was rolled back.log.InsertErroris not attached.- The
Addressesupdate for the payment type happens after the inner transaction and outside of it. - If the order has no CCP merchant, the inner procedure may set one based on the setting
DefaultCCPMerchant. - If
ccpPayIDisNULLon an open order, it is stored as an empty string. ShopNoteis declared asvarchar(max). Characters outside the database code page are lost, even though the target column isnvarchar.- Reads in the validation part use
NOLOCK; the inner procedure usesUPDLOCKonOrderHeaderandOrderlines.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
OrderNr
|
int | NULL |
Pixi order number. Either this or Example: |
OrderNrExternal
|
varchar(50) string |
NULL |
External (shop) order number. Used if Example: |
ShipCosts
|
money decimal |
NULL |
New shipping costs (net for Example: |
ShipDate
|
datetime dateTime |
NULL |
New ship date. If omitted, the current value is kept; Example: |
ShopNote
|
varchar(max) string |
NULL |
Note received from the shop with this order (shop comment). If omitted, the current note is kept. Example: |
VoucherID
|
varchar(50) string |
NULL |
Voucher ID. Must be given together with Example: |
VoucherAmount
|
money decimal |
NULL |
Amount covered by the voucher. Requires Example: |
PaymentType
|
varchar(1) string |
NULL |
Payment type code; must exist in Example: |
AddressRemarks
|
varchar(255) string |
NULL |
New address remarks of the order. If omitted, the current value is kept. Example: |
Result set 1 · Always (one row, success or error)
Status row describing the result of the call.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(7) string |
|
Message
Nullable |
varchar(max) string |
Result or error text. |
Response example
<SqlRowSet1>
<row>
<Status>Success</Status>
<Message>Order with OrderNr: 100234 was updated.</Message>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| Error | Parameter OrderNr/OrderNrExternal is mandatory parameter and needs to be provided. | Neither `OrderNr` nor a non-empty `OrderNrExternal` was passed. |
| Error | Order with OrderNr: {OrderNr} ({OrderNrExternal}) does not exist. | No order matches the given number. If one identifier is NULL, the message itself is NULL. |
| Error | VoucherAmount provided without VoucherID. | `VoucherAmount` was given but `VoucherID` is missing or empty. |
| Error | VoucherID provided without VoucherAmount. | `VoucherID` was given without `VoucherAmount` (or with amount 0). |
| Error | Voucher {VoucherID} already used in other orderlines. | The voucher is already assigned to order lines of another order. |
| Error | Payment type {PaymentType} does not exist. | The given payment type code is not in `Payments`. |
| Error | Order with OrderNr: {OrderNr} ({OrderNrExternal}) can not be updated anymore. | The order is not `OPEN`/`HOLD`, or all remaining open lines are already invoiced. |
| Error | Unexpected error: {ERROR_MESSAGE} | An unexpected SQL error occurred during the update. |
POST https://apigateway.descartes.com/tms/pixi/
Content-Type: text/xml; charset=utf-8
Authorization: Basic BASE64(USERNAME:PASSWORD)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiUpdateOrder>
<!-- <OrderNr>100234</OrderNr> -->
<!-- <OrderNrExternal>SHOP-2024-001234</OrderNrExternal> -->
<!-- <ShipCosts>4.95</ShipCosts> -->
<!-- <ShipDate>2024-05-20T00:00:00</ShipDate> -->
<!-- <ShopNote>Bitte vor 12 Uhr liefern</ShopNote> -->
<!-- <VoucherID>SUMMER10</VoucherID> -->
<!-- <VoucherAmount>10.00</VoucherAmount> -->
<!-- <PaymentType>V</PaymentType> -->
<!-- <AddressRemarks>Hinterhaus, 2. OG</AddressRemarks> -->
</ns1:pixiUpdateOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
curl -X POST 'https://apigateway.descartes.com/tms/pixi/' \
--user 'USERNAME:PASSWORD' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data-binary @- <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiUpdateOrder>
<!-- <OrderNr>100234</OrderNr> -->
<!-- <OrderNrExternal>SHOP-2024-001234</OrderNrExternal> -->
<!-- <ShipCosts>4.95</ShipCosts> -->
<!-- <ShipDate>2024-05-20T00:00:00</ShipDate> -->
<!-- <ShopNote>Bitte vor 12 Uhr liefern</ShopNote> -->
<!-- <VoucherID>SUMMER10</VoucherID> -->
<!-- <VoucherAmount>10.00</VoucherAmount> -->
<!-- <PaymentType>V</PaymentType> -->
<!-- <AddressRemarks>Hinterhaus, 2. OG</AddressRemarks> -->
</ns1:pixiUpdateOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML
<?php
$soapClient = new SoapClient(null, [
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'https://apigateway.descartes.com/tms/pixi/',
'uri' => 'https://apigateway.descartes.com/tms/pixi/',
]);
$arguments = [
// 'OrderNr' => '100234',
// 'OrderNrExternal' => 'SHOP-2024-001234',
// 'ShipCosts' => '4.95',
// 'ShipDate' => '2024-05-20T00:00:00',
// 'ShopNote' => 'Bitte vor 12 Uhr liefern',
// 'VoucherID' => 'SUMMER10',
// 'VoucherAmount' => '10.00',
// 'PaymentType' => 'V',
// 'AddressRemarks' => 'Hinterhaus, 2. OG',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiUpdateOrder', $soapArguments);
- SQL object:
- dbo.pipiUpdateOrder