Configuring Order Drafts - Fabric

Order Drafts Overview

This feature in Carts API enables the cart to be transformed into a schema ready for submission to the Order Management System (OMS), representing the order draft stage before the order is officially created. At this stage, the cart contains all necessary data, including items, fulfillment details, fees, taxes, and payment information. This transformation ensures that the cart aligns with OMS requirements, allowing for final review and confirmation of the order before proceeding to fulfillment.

Prerequisites

There are two types of prerequisites, depending on your cart configurations. One of the following prerequisites must be completed sequentially to configure an order draft.

Prerequisites where cart configurations are set to BLOCK

"configuration": {
    "order": {
        "validate": {
            "paymentsRemaining": "BLOCK",
            "taxRemaining": "BLOCK",
            "invalidItem": "BLOCK",
            "itemOutOfStock": "BLOCK"
        }
    }
}

Prerequisites

  1. Create a cart.
  2. Add item to the cart.
  3. Add taxes to the resources in the cart.
  4. Add payments to the cart, ensuring they match the cart total.
  5. Ensure that the items added to the cart are valid and in stock.

Prerequisites where cart configurations are set to NONE

Prerequisites

  1. Create a cart.
  2. Add item to the cart.

Order Drafts Initialization

The order draft captures a snapshot of the cart, which can then be converted into an order. The ability to create an order draft is controlled by cart configurations. Cart offers users the flexibility to prevent order draft creation if:

Cart Configuration

Examples

Creating an Order Draft to Send to OMS

Use the create an order draft endpoint to create an order draft and send it to OMS as in the following example:

curl --location '{{orchestrator_domain}}/carts/{{cartId}}/order-draft' \
--header 'x-fabric-tenant-id: {tenantId}' \
--header 'x-fabric-request-id: {{requestId}}' \
--header 'x-fabric-channel-id: {{channelId}}' \
--header 'Authorization: {authToken}' \
--header 'Content-Type: application/json' \
--data '{
    "orderNumber": "W0013"
}'

Response

{
    "order": {
        "number": "W0013",
        "currency": "USD",
        "createdAt": "2024-06-24T09:22:40.979+00:00",
        "attributes": {}
    },
    "cartId": "39ea2154-7160-4feb-ae42-1506223efd95",
    "attributes": {
        "name": "cart test",
        "description": "This cart is created by cart v2 service"
    },
    "customerContext": {
        "id": "C01",
        "segments": [
            {
                "name": "membership",
                "value": ["premium"]
            },
            {
                "name": "customer-type",
                "value": ["high"]
            }
        ],
        "attributes": {
            "returnRate": "high",
            "city": "london",
            "type": "regular"
        }
    },
    "status": "ACTIVE",
    "state": [...],
    "price": {...},
    "promotions": {...},
    "fees": {...},
    "adjustments": {...},
    "addresses": {...},
    "lineItems": {...},
    "summary": {...},
    "fulfillments": {...},
    "coupons": [...],
    "appliedCoupons": [...],
    "notAppliedCoupons": [],
    "payments": {...},
    "channelId": "12",
    "updatedAt": "2024-06-24T09:22:40.907Z",
    "createdAt": "2024-06-24T09:07:37.140Z",
    "errors": []
}