1. Home
  2. Ecommerce Rest Api
  3. WordPress WooCommerce
  4. Product Attributes

Product Attributes

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 Attributes

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

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes
  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 Attribute

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

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes/{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 Attribute

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

Example JSON Body:

{
  "name": "Size",
  "slug": "size",
  "type": "select",
  "order_by": "menu_order",
  "has_archives": true,
  "options": [
    "Small",
    "Medium",
    "Large"
  ]
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes
  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 Attribute

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

Example JSON Body:

{
  "name": "Size Updated",
  "options": [
    "Small",
    "Medium",
    "Large",
    "Extra Large"
  ]
}

Example in Postman:

  1. Set method to PUT.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes/{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 Attribute

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

Example in Postman:

  1. Set method to DELETE.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes/{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 Attributes

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

Example JSON Body:

{
  "update": [
    {
      "id": 1,
      "name": "Size Updated"
    },
    {
      "id": 2,
      "name": "Color Updated"
    }
  ]
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/products/attributes/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 attributes endpoint in Postman. Each request should include the necessary Authorization header configured through Basic Auth with your Consumer Key and Consumer Secret. Adjust the {id} parameter with the actual attribute ID you intend to work with for retrieving, updating, or deleting operations. Adjust the base URL and endpoint as needed based on your WooCommerce store setup and the specific attributes you want to manage.

How can we help?