How do I add additional data (such as a date or file) to an order using the front-end api, which can also be viewed by an admin? #235
-
Hello, I want users to be able to add more information to an order, such as a file attachment or a memo/message. The swelljs docs explain that this is possible by updating the metadata of an order. This works, data can indeed be stored as metadata. await swell.cart.update({
metadata: {
memo: 'This is a test order',
},
}); However this metadata doesn't seem to be visible for admins in the order dashboard (https://MY_STORE.swell.store/admin/orders/ORDER_ID) Workaround using a PUT request.The next thing i tried was creating custom fields for an order and updating these, like this: Request: PUT https://MYSTORE.swell.store/api/cart/order/ORDER_ID Body: {
content : {
memo: "This is a test order"
}
} This however results in a 400 error with the following message: {code: "permission_error", message: "Permissions for cart must be defined in api.json"} It seems that updating the custom fields of an order is no good. So therefore my question:Is there a way to add additional data (such as texts, dates and files) to a swell order using the swell front-end api, in which it is also possible for an admin to see this data in the Swell order dashboard? (https://MY_STORE.swell.store/admin/orders/ORDER_ID) Thanks in advance 😄 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Is there a way to update the permissions so we can update the Custom Fields on an Order? |
Beta Was this translation helpful? Give feedback.
-
We just updated the permissions. So, we can add a file to an Order. Is there some default validation for files? We ofcourse don't want Users can upload scripts or big pdf files of 100MB or something. |
Beta Was this translation helpful? Give feedback.
-
@BramGerrits @leonkosterss you can also add custom fields to a model (data and content fields) and add permissions to access them via Frontend APIs (REST, Swell.js and GraphQL) - it is possible to add fields for read and write access (via |
Beta Was this translation helpful? Give feedback.
@BramGerrits @leonkosterss you can also add custom fields to a model (data and content fields) and add permissions to access them via Frontend APIs (REST, Swell.js and GraphQL) - it is possible to add fields for read and write access (via
input
). See https://developers.swell.is/guides/opening-content-permissions for more info.