### Get Products Summary (cURL) Source: https://getdokan.github.io/dokan This example shows how to retrieve a product summary from the Dokan API using the cURL command-line tool. It specifies the GET request, URL, and necessary authorization and cache control headers. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/products/summary \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ ``` -------------------------------- ### Get All Orders using cURL Command Line Source: https://getdokan.github.io/dokan This example demonstrates how to fetch all orders from the Dokan API using the cURL command-line tool. It specifies the GET request method, the API endpoint URL, and includes the required Authorization and Cache-Control headers. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/orders/ \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' ``` -------------------------------- ### Get All Stores using PHP, cURL, Python, JavaScript, Ruby Source: https://getdokan.github.io/dokan This section provides multiple ways to fetch all store details using the Dokan API. It includes examples for PHP cURL, raw cURL, Python http.client, JavaScript with jQuery AJAX, and Ruby Net::HTTP. These examples demonstrate how to make a GET request to the stores endpoint. ```php "http://dokan.test/wp-json/dokan/v1/stores", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ```curl curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/stores \ --header 'Cache-Control: no-cache' \ ``` ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,stores", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/stores", "method": "GET", "headers": { "Cache-Control": "no-cache", } } $.ajax(settings).done(function (response) { console.log(response); }); ``` ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/stores") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Store Reviews using PHP, cURL, Python, JavaScript, Ruby Source: https://getdokan.github.io/dokan This section provides multiple ways to fetch reviews for a specific store using the Dokan API. It includes examples for PHP cURL, raw cURL, Python http.client, JavaScript with jQuery AJAX, and Ruby Net::HTTP. These examples demonstrate how to make a GET request to the store reviews endpoint. ```php "http://dokan.test/wp-json/dokan/v1/stores/2/reviews", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ```curl curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/stores/2/reviews \ --header 'Cache-Control: no-cache' \ ``` ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,stores,21,reviews", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/stores/2/reviews", "method": "GET", "headers": { "Cache-Control": "no-cache", } } $.ajax(settings).done(function (response) { console.log(response); }); ``` ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/stores/2/reviews") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ``` -------------------------------- ### Fetch Top Selling Products Report (cURL) Source: https://getdokan.github.io/dokan This command-line example demonstrates how to fetch the top selling products report using cURL. It specifies the GET request method, the API endpoint URL, and includes the necessary Authorization and Cache-Control headers. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/reports/top_selling?start_date=2018-01-01 \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ ``` -------------------------------- ### Get Product Variations using Python http.client Source: https://getdokan.github.io/dokan This Python example utilizes the `http.client` module to make a GET request to the Dokan API for product variations. It sets up the connection, headers, and prints the decoded response. ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,products,72,variations", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get All Coupons using cURL Source: https://getdokan.github.io/dokan This command-line example demonstrates how to fetch all coupons from the Dokan API using cURL. It specifies the GET request method, the API endpoint URL, and includes the necessary authorization and cache-control headers. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/coupons/ \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' ``` -------------------------------- ### Get Products Summary (JavaScript) Source: https://getdokan.github.io/dokan This JavaScript example uses jQuery's AJAX method to fetch product summaries from the Dokan API. It configures the request with the correct URL, method, and headers, logging the response to the console. ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/products/summary", "method": "GET", "headers": { "Authorization": "Basic authorization_token", "Cache-Control": "no-cache", } } $.ajax(settings).done(function (response) { console.log(response); }); ``` -------------------------------- ### Get Store Products using Python http.client Source: https://getdokan.github.io/dokan Fetches store products using Python's built-in `http.client` module. This method establishes an HTTP connection and sends a GET request. It requires basic HTTP knowledge. ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,stores,21,products", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get Products Summary (Python) Source: https://getdokan.github.io/dokan This Python code snippet utilizes the `http.client` library to make a GET request to the Dokan API for product summaries. It includes setting up the connection, headers, and printing the decoded response. ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,products,summary", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Fetch Top Earners Report using cURL Command Line Source: https://getdokan.github.io/dokan This command-line example shows how to make a GET request to the Dokan API's top earners endpoint using cURL. It specifies the URL, the authorization token, and the cache-control header. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/reports/top_earners?start_date=2018-01-01 \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' ``` -------------------------------- ### Create Coupon via Dokan API (PHP, cURL, Python, JavaScript, Ruby) Source: https://getdokan.github.io/dokan These code snippets demonstrate how to create a new coupon using the Dokan API. They cover various programming languages and tools, including PHP with cURL, raw cURL requests, Python's http.client, JavaScript with jQuery's AJAX, and Ruby's Net::HTTP. All examples send a POST request to the /wp-json/dokan/v1/coupons/ endpoint with coupon details in JSON format. Ensure you have the necessary authorization token and the Dokan plugin installed and configured. ```php "http://dokan.test/wp-json/dokan/v1/coupons/?code=REST", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n \"code\": \"10off\",\n \"discount_type\": \"percent\",\n \"amount\": \"10\",\n \"product_ids\": [5611,72]\n}", CURLOPT_HTTPHEADER => array( "Authorization: Basic authorization_token", "Cache-Control: no-cache", "Content-Type: application/json", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ```curl curl --request POST \ --url 'http://dokan.test/wp-json/dokan/v1/coupons/?code=REST' \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ --header 'Content-Type: application/json' \ --data '{\n "code": "10off",\n "discount_type": "percent",\n "amount": "10",\n "product_ids": [5611,72]\n}' ``` ```python import http.client conn = http.client.HTTPConnection("localhost") payload = "{\n \"code\": \"10off\",\n \"discount_type\": \"percent\",\n \"amount\": \"10\",\n \"product_ids\": [5611,72]\n}" headers = { 'Content-Type': "application/json", 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("POST", "dokan,,wp-json,dokan,v1,coupons,", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/coupons/?code=REST", "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "Basic authorization_token", "Cache-Control": "no-cache", }, "processData": false, "data": "{\n \"code\": \"10off\",\n \"discount_type\": \"percent\",\n \"amount\": \"10\",\n \"product_ids\": [5611,72]\n}" } $.ajax(settings).done(function (response) { console.log(response); }); ``` ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/coupons/?code=REST") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request["Authorization"] = 'Basic authorization_token' request["Cache-Control"] = 'no-cache' request.body = "{\n \"code\": \"10off\",\n \"discount_type\": \"percent\",\n \"amount\": \"10\",\n \"product_ids\": [5611,72]\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get All Products via Dokan API (Python) Source: https://getdokan.github.io/dokan This Python script utilizes the `http.client` module to send a GET request to the Dokan API for retrieving products. It sets up the connection, headers, and then prints the decoded UTF-8 response. ```python import http.client conn = http.client.HTTPConnection("dokannew,test") headers = { 'Authorization': "Basic authorization_key", 'Cache-Control': "no-cache", } conn.request("GET", "wp-json,dokan,v1,products,", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get Order using cURL Command Line Source: https://getdokan.github.io/dokan This command-line snippet shows how to fetch order details using the cURL utility. It specifies the GET request, the API endpoint URL, and includes the necessary authorization and cache-control headers. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/orders/5616 \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' ``` -------------------------------- ### Create Product via Dokan API (Ruby) Source: https://getdokan.github.io/dokan This Ruby script initiates a POST request to the Dokan API for product creation using the `net/http` library. It sets up the URL and prepares the HTTP request object, with further implementation needed to add the payload and headers. ```ruby require 'uri' require 'net/http' url = URI("http://dokannew.test/wp-json/dokan/v1/products/") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) ``` -------------------------------- ### Get Products Summary (Ruby) Source: https://getdokan.github.io/dokan This Ruby script demonstrates how to retrieve product summaries from the Dokan API using the `net/http` and `uri` libraries. It constructs the URL, sets the necessary headers, and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/products/summary") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Authorization"] = 'Basic authorization_token' request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Pending Withdraws via cURL Command Source: https://getdokan.github.io/dokan This is a command-line example using cURL to retrieve pending withdraw requests from the Dokan API. It specifies the GET request method, the API endpoint URL, and includes the required Authorization and Cache-Control headers. ```bash curl --request GET \ --url 'http://dokan.test/wp-json/dokan/v1/withdraw/?status=pending' \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ ``` -------------------------------- ### Get Balance Details using Ruby Net::HTTP Source: https://getdokan.github.io/dokan This Ruby snippet demonstrates how to fetch balance details using the built-in `Net::HTTP` library. It constructs the URI, sets up the HTTP connection, and sends a GET request with appropriate headers. ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/withdraw/balance") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Authorization"] = 'Basic authorization_token' request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get All Products via Dokan API (cURL) Source: https://getdokan.github.io/dokan This command demonstrates how to fetch all products from the Dokan API using the cURL command-line tool. It specifies the GET method, the API endpoint URL, and includes necessary authorization and cache control headers. ```bash curl -X GET \ http://dokannew.test/wp-json/dokan/v1/products/ \ -H 'Authorization: Basic authorization_key' \ -H 'Cache-Control: no-cache' ``` -------------------------------- ### Get All Orders with Pagination (PHP) Source: https://getdokan.github.io/dokan This PHP script uses cURL to make a GET request to the Dokan API to retrieve orders with pagination. It handles potential cURL errors and outputs the JSON response. Ensure you have the cURL extension enabled in your PHP installation. ```php "http://dokan.test/wp-json/dokan/v1/orders/?per_page=1&page=2", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Authorization: Basic authorization_token", "Cache-Control: no-cache", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` -------------------------------- ### Get Single Store Info using PHP cURL Source: https://getdokan.github.io/dokan This snippet demonstrates how to retrieve single store information using PHP's cURL library. It makes a GET request to the Dokan API endpoint for a specific store ID. Ensure cURL is enabled in your PHP installation. ```php "http://dokan.test/wp-json/dokan/v1/stores/2", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` -------------------------------- ### POST /wp-json/dokan/v1/products/ Source: https://getdokan.github.io/dokan This endpoint allows you to create a new product in Dokan. You need to provide product details such as name, price, description, categories, and images in the request body. ```APIDOC ## POST /wp-json/dokan/v1/products/ ### Description Creates a new product for a vendor. ### Method POST ### Endpoint `/wp-json/dokan/v1/products/` ### Parameters #### Request Body - **name** (string) - Required - The name of the product. - **type** (string) - Optional - The type of the product (e.g., 'simple', 'variable'). Defaults to 'simple'. - **regular_price** (string) - Required - The regular price of the product. - **description** (string) - Optional - A detailed description of the product. - **short_description** (string) - Optional - A short description of the product. - **categories** (array) - Optional - An array of category objects, each with an `id` field. - **images** (array) - Optional - An array of image objects, each with `src` and `position` fields. ### Request Example ```json { "name": "MI 5S", "type": "simple", "regular_price": "299", "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", "categories": [ { "id": 48 } ], "images": [ { "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "position": 0 } ] } ``` ### Response #### Success Response (200) - **id** (integer) - The ID of the newly created product. - **name** (string) - The name of the product. - **slug** (string) - The slug of the product. - **permalink** (string) - The permalink to the product page. - **date_created** (string) - The date the product was created. - **date_modified** (string) - The date the product was last modified. - **status** (string) - The status of the product (e.g., 'publish'). - **type** (string) - The type of the product. - **description** (string) - The detailed description of the product. - **short_description** (string) - The short description of the product. - **price** (string) - The price of the product. - **regular_price** (string) - The regular price of the product. - **sale_price** (string) - The sale price of the product. - **price_html** (string) - The price displayed in HTML format. - **on_sale** (boolean) - Whether the product is on sale. - **purchasable** (boolean) - Whether the product is purchasable. - **total_sales** (integer) - The total number of sales for the product. - **virtual** (boolean) - Whether the product is virtual. - **downloadable** (boolean) - Whether the product is downloadable. - **download_limit** (integer) - The download limit for the product. - **download_expiry_days** (integer) - The download expiry days for the product. - **download_type** (string) - The download type for the product. - **download_label** (string) - The download label for the product. - **external_url** (string) - The external URL for the product. - **button_text** (string) - The button text for the product. - **tax_status** (string) - The tax status of the product. - **tax_class** (string) - The tax class of the product. - **manage_stock** (boolean) - Whether to manage stock for the product. - **stock_quantity** (integer) - The stock quantity of the product. - **backorders** (string) - The backorder status for the product. - **low_stock_amount** (integer) - The low stock amount for the product. - **sold_individually** (boolean) - Whether the product is sold individually. - **weight** (string) - The weight of the product. - **length** (string) - The length of the product. - **width** (string) - The width of the product. - **height** (string) - The height of the product. - **upsell_ids** (array) - An array of IDs for upsell products. - **cross_sell_ids** (array) - An array of IDs for cross-sell products. - **parent_id** (integer) - The ID of the parent product (for variations). - **reviews_allowed** (boolean) - Whether reviews are allowed for the product. - **purchase_note** (string) - The purchase note for the product. - **default_attributes** (array) - An array of default attributes for the product. - **attributes** (array) - An array of attributes for the product. - **grouped_products** (array) - An array of IDs for grouped products. - **menu_order** (integer) - The menu order of the product. - **price_html** (string) - The price displayed in HTML format. - **related_ids** (array) - An array of IDs for related products. - **meta_data** (array) - An array of meta data for the product. - **categories** (array) - An array of category objects. - **tags** (array) - An array of tag objects. - **images** (array) - An array of image objects. - **featured_src** (string) - The URL of the featured image. - **attributes_html** (string) - The attributes displayed in HTML format. - **reviews_enabled** (boolean) - Whether reviews are enabled for the product. - **average_rating** (string) - The average rating of the product. - **rating_count** (integer) - The number of ratings for the product. - **tips** (object) - Additional tips related to the product. - **vendor** (object) - Information about the vendor. #### Response Example ```json { "id": 123, "name": "MI 5S", "slug": "mi-5s", "permalink": "http://dokannew.test/product/mi-5s/", "date_created": "2023-10-27T10:00:00+00:00", "date_modified": "2023-10-27T10:00:00+00:00", "status": "publish", "type": "simple", "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", "price": "299", "regular_price": "299", "sale_price": "", "price_html": "$299.00", "on_sale": false, "purchasable": true, "total_sales": 0, "virtual": false, "downloadable": false, "download_limit": -1, "download_expiry_days": -1, "download_type": "standard", "download_label": "", "external_url": "", "button_text": "", "tax_status": "taxable", "tax_class": "", "manage_stock": false, "stock_quantity": null, "backorders": "no", "low_stock_amount": null, "sold_individually": false, "weight": "", "length": "", "width": "", "height": "", "upsell_ids": [], "cross_sell_ids": [], "parent_id": 0, "reviews_allowed": true, "purchase_note": "", "default_attributes": [], "attributes": [], "grouped_products": [], "menu_order": 0, "price_html": "$299.00", "related_ids": [], "meta_data": [], "categories": [ { "id": 48, "name": "Category Name", "slug": "category-name" } ], "tags": [], "images": [ { "id": 124, "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "thumbnail": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "position": 0 } ], "featured_src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "attributes_html": "", "reviews_enabled": true, "average_rating": "0.00", "rating_count": 0, "tips": {}, "vendor": { "id": 1, "name": "Vendor Name", "url": "http://dokannew.test/store/vendor-name/" } } ``` ``` -------------------------------- ### POST /wp-json/dokan/v1/products/ Source: https://getdokan.github.io/dokan This endpoint allows you to create a new product. You can specify various product properties such as name, price, description, categories, and images. ```APIDOC ## POST /wp-json/dokan/v1/products/ ### Description This endpoint helps you to create a new product. You can specify various product properties such as name, price, description, categories, and images. ### Method POST ### Endpoint http://dokan.test/wp-json/dokan/v1/products/ ### Parameters #### Query Parameters Accept all parameters for a product properties. #### Request Body - **name** (string) - Required - The name of the product. - **type** (string) - Optional - The type of the product (e.g., 'simple', 'variable'). Defaults to 'simple'. - **regular_price** (string) - Optional - The regular price of the product. - **description** (string) - Optional - A detailed description of the product. - **short_description** (string) - Optional - A short description of the product. - **categories** (array) - Optional - An array of category objects, each with an 'id'. - **id** (integer) - Required - The ID of the category. - **images** (array) - Optional - An array of image objects, each with 'src' and 'position'. - **src** (string) - Required - The URL of the image. - **position** (integer) - Optional - The display position of the image. ### Request Example ```json { "name": "MI 5S", "type": "simple", "regular_price": "299", "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", "categories": [ { "id": 48 } ], "images": [ { "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "position": 0 } ] } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the created product. - **name** (string) - The name of the product. - **slug** (string) - The slug for the product. - **permalink** (string) - The permalink to the product page. - **date_created** (string) - The date and time the product was created. - **date_modified** (string) - The date and time the product was last modified. - **type** (string) - The type of the product. - **status** (string) - The current status of the product (e.g., 'pending', 'publish'). - **description** (string) - The full description of the product. - **short_description** (string) - The short description of the product. - **price** (string) - The current price of the product. - **regular_price** (string) - The regular price of the product. - **categories** (array) - An array of category objects associated with the product. - **images** (array) - An array of image objects associated with the product. #### Response Example ```json { "id": 601, "name": "MI 5S", "slug": "", "post_author": "31", "permalink": "http://dokannew.test/?post_type=product&p=601", "date_created": "2018-02-15T11:13:14", "date_created_gmt": "2018-02-15T05:13:14", "date_modified": "2018-02-15T11:13:14", "date_modified_gmt": "2018-02-15T05:13:14", "type": "simple", "status": "pending", "featured": false, "catalog_visibility": "visible", "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", "sku": "", "price": "299", "regular_price": "299", "sale_price": "", "date_on_sale_from": null, "date_on_sale_from_gmt": null, "date_on_sale_to": null, "date_on_sale_to_gmt": null, "price_html": "299.00", "on_sale": false, "purchasable": true, "total_sales": 0, "virtual": false, "downloadable": false, "downloads": [], "download_limit": -1, "download_expiry": -1, "external_url": "", "button_text": "", "tax_status": "taxable", "tax_class": "", "manage_stock": false, "stock_quantity": null, "in_stock": true, "backorders": "no", "backorders_allowed": false, "backordered": false, "sold_individually": false, "weight": "", "dimensions": { "length": "", "width": "", "height": "" }, "shipping_required": true, "shipping_taxable": true, "shipping_class": "", "shipping_class_id": 0, "reviews_allowed": true, "average_rating": "0.00", "rating_count": 0, "related_ids": [], "upsell_ids": [], "cross_sell_ids": [], "parent_id": 0, "purchase_note": "", "categories": [ { "id": 48, "name": "Mobile", "slug": "mobile" } ], "tags": [], "images": [ { "id": 600, "date_created": "2018-02-15T11:13:13", "date_created_gmt": "2018-02-15T05:13:13", "date_modified": "2018-02-15T11:13:13", "date_modified_gmt": "2018-02-15T05:13:13", "src": "http://dokannew.test/wp-content/uploads/2018/02/T_2_front.jpg", "name": "T_2_front.jpg", "alt": "", "position": 0 } ], "attributes": [], "default_attributes": [], "variations": [], "grouped_products": [], "menu_order": 0, "meta_data": [] } ``` ``` -------------------------------- ### Get Single Coupon via HTTP Request Source: https://getdokan.github.io/dokan This snippet demonstrates how to retrieve a single coupon by its ID using an HTTP GET request to the Dokan API. It includes examples for PHP, cURL, Python, JavaScript (jQuery), and Ruby. Ensure you replace 'authorization_token' with your actual token and adjust the URL if necessary. ```php "http://dokan.test/wp-json/dokan/v1/coupons/5613", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTPHEADER => array( "Authorization: Basic authorization_token", "Cache-Control: no-cache", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ```curl curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/coupons/5613 \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ ``` ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,coupons,5613", headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/coupons/5613", "method": "GET", "headers": { "Authorization": "Basic authorization_token", "Cache-Control": "no-cache", }, "processData": false, "contentType": false, } $.ajax(settings).done(function (response) { console.log(response); }); ``` ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/coupons/5613") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["content-type"] = 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' request["Authorization"] = 'Basic authorization_token' request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ``` -------------------------------- ### Create Product via Dokan API (cURL) Source: https://getdokan.github.io/dokan This cURL command demonstrates how to create a product using the Dokan API. It specifies the POST request, URL, necessary headers (including authorization and content type), and the JSON payload containing product details. ```shell curl --request POST \ --url http://dokannew.test/wp-json/dokan/v1/products/ \ --header 'Authorization: Basic dmVuZG9yOnBhc3N3b3Jk' \ --header 'Cache-Control: no-cache' \ --header 'Content-Type: application/json' \ --header 'Postman-Token: 2518adad-8135-9904-9107-e62f39c4126f' \ --data '{ "name": "MI 5S", "type": "simple", "regular_price": "299", "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", "categories": [ { "id": 48 } ], "images": [ { "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", "position": 0 } ] }' ``` -------------------------------- ### Get Single Store Info using cURL command line Source: https://getdokan.github.io/dokan This snippet shows how to fetch single store information using the cURL command-line tool. It's a straightforward way to test the API endpoint directly from your terminal. This method requires cURL to be installed on your system. ```bash curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/stores/2 \ --header 'Cache-Control: no-cache' \ ``` -------------------------------- ### Get Orders Summary via API (PHP, cURL, Python, JavaScript, Ruby) Source: https://getdokan.github.io/dokan This snippet demonstrates how to retrieve a summary of orders from the Dokan API. It includes implementations in PHP using cURL, a direct cURL command, Python using http.client, JavaScript using jQuery's AJAX, and Ruby using Net::HTTP. All examples make a GET request to the specified API endpoint with authorization and cache control headers. The response is typically a JSON object containing counts of orders by status. ```php "http://dokan.test/wp-json/dokan/v1/orders/summary", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Authorization: Basic authorization_token", "Cache-Control: no-cache", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?> ``` ```curl curl --request GET \ --url http://dokan.test/wp-json/dokan/v1/orders/summary \ --header 'Authorization: Basic authorization_token' \ --header 'Cache-Control: no-cache' \ ``` ```python import http.client conn = http.client.HTTPConnection("localhost") headers = { 'Authorization': "Basic authorization_token", 'Cache-Control': "no-cache", } conn.request("GET", "dokan,,wp-json,dokan,v1,orders,summary", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```javascript var settings = { "async": true, "crossDomain": true, "url": "http://dokan.test/wp-json/dokan/v1/orders/summary", "method": "GET", "headers": { "Authorization": "Basic authorization_token", "Cache-Control": "no-cache", } } $.ajax(settings).done(function (response) { console.log(response); }); ``` ```ruby require 'uri' require 'net/http' url = URI("http://dokan.test/wp-json/dokan/v1/orders/summary") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Authorization"] = 'Basic authorization_token' request["Cache-Control"] = 'no-cache' response = http.request(request) puts response.read_body ```