Product Category

Manage product category

List Product Categories

GET ‎https://<domain>/<api prefix>/<version>/commerce/product/list/categories/

This API endpoint will return a list of the product category (product-type)

Query Parameters

Headers

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <category_id>,
                "name": "<category_name>",
                "status": <status>,
                "has_inventory": <has_inventory_boolean>,
                "has_recurring": <has_recurring_boolean>,
                "has_variants": <has_variants_boolean>,
                "has_shippable": <has_shippable_boolean>,
                "has_discount": <has_discount_boolean>,
                "created": "<created_date>",
                "modified": "<modified_date>",
                "data": {
                    "tax": {
                        "method": "<method_name>",
                        "method_status": <status>
                    },
                    "afl_fees": {
                        "method": "<method_name>",
                        "method_status": <status>
                    },
                    ...
                },
                "slug": "<slug>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_link>,
        "next": "<next_page_link>"
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/categories/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/list/categories/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Create Product Category

Create a Product category (Product - Type).

  • First, Get the list of enabled product type method configuration through the below-provided endpoint.

  • Then Create product type through the post method.

Active Product Type Method Configurations

GET ‎https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/

This API endpoint will return enabled product type method configurations

Headers

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "EnabledProductTypeMethodConf": [
            {
                "method": "<method_name>",
                "weight": <weight>,
                "title": "<method_title>",
                "description": "<method_description>",
                "attr_slug": [],
                "disabled_status": <status>
            },
            ...
        ]
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Create Product Type

POST ‎https://<domain>/<api prefix>/<version>/commerce/product/create/category/

This API endpoint will create a product type.

Headers

Request Body

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

{
    "name": "<product-type-name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>",
        ...
    },
    "method": [
        "<method_name>",
        "<method_name>",
        ...
    ],
    "catalogue_ids": [
        <catalogue_id>,
        <catalogue_id>,
        ...
    ],
    "attr_grp_ids": [
        <attr_grp_ids>,
        <attr_grp_ids>,
        ...
    ]
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"name":"<method-name>","translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>],"attr_grp_ids":[<id>,<id>]})
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "name": "<method_name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>"
    },
    "method": [
        "<method_name>",
        "<method_name>"
    ],
    "catalogue_ids": [
        <id>,
        <id>
    ],
    "attr_grp_ids": [
        <id>,
        <id>
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Update Product Category

POST ‎https://<domain>/<api prefix>/<version>/commerce/product/update/category/

This API endpoint will update a product category.

Headers

Request Body

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

{    
    "ptype":<product_typ>,
    "name": "<product-type-name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>",
        ...
    },
    "method": [
        "<method_name>",
        "<method_name>",
        ...
    ],
    "catalogue_ids": [
        <catalogue_id>,
        <catalogue_id>,
        ...
    ],
    "attr_grp_ids": [
        <attr_grp_ids>,
        <attr_grp_ids>,
        ...
    ]
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"ptype":<product_type_id>,"name":"<name>","attr_grp_ids":[<id>,<id>],"translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "ptype":<product_type_id>,
    "name":"<name>",
    "attr_grp_ids":[
        <id>,
        <id>
    ],
    "translations": {
        "<language_code>":"<name>",
        "<language_code>":"<name>"
    },
    "method": [
        <method_name>",
        <method_name>"
    ],
     "catalogue_ids": [
        <id>,
        <id>         
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Delete Product Category

DELETE ‎https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>

This API endpoint will delete a product category

Query Parameters

Headers

​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Last updated