1. Home
  2. Ecommerce Rest Api
  3. WordPress WooCommerce
  4. Install WordPress & Woocommerce

Install WordPress & Woocommerce

Setting Up WooCommerce:

  • Install WordPress: First, set up a WordPress site.
  • Install WooCommerce: Install the WooCommerce plugin on your WordPress site.
  • Configure WooCommerce: Set up your store settings, including products, payment gateways, shipping methods, etc.

Using WooCommerce REST API:

  • Enable REST API: WooCommerce REST API is enabled by default. You can manage API keys from the WordPress admin panel (WooCommerce > Settings > Advanced > REST API).
  • Generate API Keys: Create API keys with the necessary permissions (read/write) for the endpoints you plan to use.

To interact with the WooCommerce REST API for managing products, you will need to make HTTP requests using tools like Postman. Below is a detailed tutorial for each endpoint, following the structure you provided.

Step-by-Step Guide to Set Up Authorization in Postman

Prerequisites

  1. WooCommerce API Keys: You need the Consumer Key and Consumer Secret, which you can generate from your WooCommerce store’s admin panel.

1. Obtain WooCommerce API Keys

  1. Log in to your WooCommerce admin panel.
  2. Navigate to WooCommerce > Settings > Advanced > REST API.
  3. Click Add Key.
  4. Enter a description, choose a user with appropriate permissions, and set permissions to Read/Write.
  5. Click Generate API Key.
  6. Note down the Consumer Key and Consumer Secret.

Step-by-Step Configuration in Postman

  1. Open Postman: Launch Postman and create a new request.
  2. Set Method: Choose the appropriate HTTP method (GET, POST, PUT, DELETE) based on the API endpoint you are testing.
  3. Enter URL: Input the URL for the WooCommerce REST API endpoint.

Configuring Authorization Header

  1. Go to Authorization Tab: Click on the Authorization tab in Postman.
  2. Set Type: Select Basic Auth from the dropdown.
  3. Enter API Keys:
    • Username: Enter your Consumer Key.
    • Password: Enter your Consumer Secret.

Postman will automatically encode these credentials and add the appropriate Authorization header to your request.

Example Requests

Example: List Products

URL: https://yourstore.com/wp-json/wc/v3/products

  • Method: GET
  • Authorization: Basic Auth (use your Consumer Key and Consumer Secret)
  1. Open Postman and create a new GET request.
  2. Enter the URL: https://yourstore.com/wp-json/wc/v3/products
  3. Go to the Authorization tab:
    • Type: Basic Auth
    • Username: Consumer Key
    • Password: Consumer Secret
  4. Send the request.

Example: Create a Product

URL: https://yourstore.com/wp-json/wc/v3/products

  • Method: POST
  • Authorization: Basic Auth (use your Consumer Key and Consumer Secret)
  • Body: JSON

JSON Body:

{
  "name": "Sample Product",
  "type": "simple",
  "regular_price": "19.99",
  "description": "This is a sample product",
  "categories": [
    {
      "id": 9
    }
  ]
}
  1. Open Postman and create a new POST request.
  2. Enter the URL: https://yourstore.com/wp-json/wc/v3/products
  3. Go to the Authorization tab:
    • Type: Basic Auth
    • Username: Consumer Key
    • Password: Consumer Secret
  4. Go to the Body tab:
    • Select raw and JSON from the dropdown.
    • Paste the JSON body provided above.
  5. Send the request.

By following these steps, you should be able to successfully interact with the WooCommerce REST API using Postman for all the endpoints listed. Each request should include the necessary Authorization header configured through Basic Auth in Postman.

How can we help?