This is a very clear solution !
So I tried this workaround, I have a question about it: to create an Order, do I need to create an OrderDetail first ??
I’m not sure about how to implement this, since I’ll create orders through a POST request on /orders. Should I do first a POST request on /order_details then ?
First, overwrite the order’s create() controller and define all that business logic there. Inside it you need to create the order-details first (because you need their IDs to refer them in the relation of order), then you create the order with a reference to order-details.
That way you will have a single controller that creates both: order-details and order. Now you can make a single POST request to /orders from your front-end.
There is something wrong. My client needs to be able, from the administrative panel, to check the orders her clients have paid so she can send them their product(s). Right now she has only the ids of OrderDetails in Orders in the admin panel. Should I use a component for this ?
Also when I think about it, I don’t need OrderDetails to be a Content-Type since I won’t do any request on it.
I just need a nested “details” (products and quantity for each one inside) in “orders”.
This is very basic normally, I don’t get why it’s that hard
Btw is it normal controller isn’t call (to check the body of Strapi’s requests for example) ? It only goes through my create(ctx) function while I use API requests, not directly Strapi. I would like to be able to have control on both (Strapi’s administrative panel and API requests). If it’s not the case, I guess I’ll have to duplicate the code ?
For those who would like to know, I created a simple repeatable component (as @sunnyson suggested) named “details” into my Order content-type and it worked pretty well !
This component has a “Order-Details” category, and inside there are:
product: relation with Products: Order has one Product