Migrated from Redmine #1286 | Author: Thomas Luzat
Status: New | Priority: Normal | Created: 2024-09-24
We create bookings, which include products and service add-ons, through the API.
We noticed that at least one such order was missing most products and service add-ons that were ordered, though. The company is bludeluxe, the order code is 2qecmbc3l. The invoice is showing the the booking, 4 products and 1 service add-on, but the booking itself only contains one of the products. It is unclear, when the products/add-ons went missing.
The order has been modified only once after creation and that was when updating its fields through the API as described below. I feel that a bug with the PUT update could have caused only one product to remain in the order. We did not notice this behavior with other orders for which the same code ran.
Our steps for updating the fields, which happened at 02:57 for this order:
- Fetch the order data using the REST API (GET /admin/bookings/ID); in our code:
const data = await restClient(`/admin/bookings/${booking.id}`)
- Update the additional_fields in the returned data:
const update = {
...data,
additional_fields: [
...(data.additional_fields ?? []),
{ field: '4a3033d0df3143fb06285431a6dd6dd6', value: 'INFLUENCER:DONE' },
],
}
- PUT all the data to /admin/bookings/ID
await restClient(`/admin/bookings/${booking.id}`, 'PUT', update)
This generally works (except that users do get an update mail, which we do not really want).
Attached are two screenshots:
- One from the calendar view where the edit history and only one product is shown
- Another one, which shows the invoice with all products and add-ons
Given that the edit history only shows one change, I think that fetching the data using REST and PUTting it back caused all items but the first to be removed. Are products in a different format for the GET/PUT requests?
From what I can tell, the GET request ( API documentation | SimplyBook.me Online Scheduling ) should return a products field with type array|Booking_DetailedProductQtyEntity (which links to the description of ProductQtyEntity). The PUT request ( API documentation | SimplyBook.me Online Scheduling ) seems to require a products field with type array|ProductQtyEntity, which is probably the same, that is an array of objects with product_id and qty fields?
In general, it would be nice to be able to edit orders without having to fetch the order data first. Also, I’m generally just PUTting an AdminBookingDetailsEntity even though a AdminBookingBuildEntity is requested, but the additional fields seem to be gracefully ignored.