1. Home
  2. Ecommerce Rest Api
  3. WordPress WooCommerce
  4. Orders

Orders

Prerequisites

  • WooCommerce API Keys: You need Consumer Key and Consumer Secret.
  • Base URL: Replace https://yourstore.com with your actual WooCommerce store URL.
  • Authorization: Basic Auth with your Consumer Key and Consumer Secret.

Authorization Setup in Postman

  1. Go to the Authorization tab.
  2. Select Type: Basic Auth.
  3. Username: Enter your Consumer Key.
  4. Password: Enter your Consumer Secret.

1. List Orders

  • URL: https://yourstore.com/wp-json/wc/v3/orders
  • Method: GET
  • Headers:
    • Authorization: Basic Auth

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

2. Retrieve an Order

  • URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  • Method: GET
  • Headers:
    • Authorization: Basic Auth
  • Replace {id} with the actual order ID.

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

3. Create an Order

  • URL: https://yourstore.com/wp-json/wc/v3/orders
  • Method: POST
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with order data.

Example JSON Body:

{
  "payment_method": "bacs",
  "payment_method_title": "Direct Bank Transfer",
  "set_paid": true,
  "billing": {
    "first_name": "John",
    "last_name": "Doe",
    "address_1": "123 Main St",
    "city": "Anytown",
    "state": "CA",
    "postcode": "12345",
    "country": "US",
    "email": "john.doe@example.com",
    "phone": "(555) 555-5555"
  },
  "line_items": [
    {
      "product_id": 93,
      "quantity": 2
    }
  ]
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

4. Update an Order

  • URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  • Method: PUT
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with updated order data.
  • Replace {id} with the actual order ID.

Example JSON Body:

{
  "billing": {
    "first_name": "Jane",
    "last_name": "Doe",
    "address_1": "456 Another St",
    "city": "New City",
    "state": "NY",
    "postcode": "67890",
    "country": "US",
    "email": "jane.doe@example.com",
    "phone": "(555) 555-1234"
  }
}

Example in Postman:

  1. Set method to PUT.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

5. Delete an Order

  • URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  • Method: DELETE
  • Headers:
    • Authorization: Basic Auth
  • Replace {id} with the actual order ID.

Example in Postman:

  1. Set method to DELETE.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

6. Batch Update Orders

  • URL: https://yourstore.com/wp-json/wc/v3/orders/batch
  • Method: POST
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with batch operations.

Example JSON Body:

{
  "update": [
    {
      "id": 1,
      "billing": {
        "first_name": "Updated",
        "last_name": "Name"
      }
    },
    {
      "id": 2,
      "status": "completed"
    }
  ]
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/orders/batch
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

By following these instructions, you can test each WooCommerce orders endpoint in Postman. Each request should include the necessary Authorization header configured through Basic Auth with your Consumer Key and Consumer Secret.

How can we help?