The Create Order endpoint initiates a new sales transaction for a given product. The authenticated user supplies the quantity to buy, color/size variant selections, and full customer shipping details. The server validates available stock, computes the order total using the discounted price when applicable, assigns a unique order code (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery/llms.txt
Use this file to discover all available pages before exploring further.
codeSale), and saves the sale with an initial status of Pendiente (Awaiting payment). If a matching sale already exists for the same user, color, and size combination, the order is updated rather than duplicated.
Endpoint
Authentication
Requires a valid user Token in the request headers.Path Parameters
The MongoDB ObjectId of the product being purchased.
Request Body
Quantity of the product to purchase. Must be greater than
0 and must not exceed the product’s current stock (minCant).The selected color variant(s). Accepts a JSON array of
{ label, value } objects or a comma-separated string. Each entry is validated against the catalog’s available color values.The selected size variant(s). Accepts a JSON array of
{ label, value } objects or a comma-separated string. Each entry is validated against the catalog’s available size values.Shirt cut/style. Corresponds to one of the product’s defined shirt types (e.g.,
"Regular Fit", "Overside", "Hoodie").Customer shipping and identification details.
Pricing Logic
- If the product has a
priceDiscountvalue set, that price is used as the unit price. - Otherwise, the standard
pricefield is used. total = unitPrice × cantBuy