Business Categories Model

ActionMethodResourceDescription
Get allGET/business/:business_id/categoriesGet all categories with business_id .
GetGET/business/:business_id/categories/:category_idGet category with id business_id and category_id.
Create POST/business/:business_id/categoriesCreate a category with business_id.
Update POST/business/:business_id/categories/:category_idUpdate category with business_id and category_id.
Delete DELETE/business/:business_id/categories/:category_idDelete category with business_id and category_id.

The category model is composed of the following attributes:

AttributeTypeRequiredDescriptionWhereable
namestringno, required to create.The category's name.Yes
imagebase64 image, url image or File image.noThe category's image.No
rankintegernoThe category's rank.Yes
enabledbooleannoThe category's status.Yes
parent_category_idintegernoThe Parent category idYes

📘

Restrictions for POST, PUT and DELETE categories.

Business categories can only be created, updated or removed by user level 0 (Type: administrator) and Users level 2 (Type: Business Owner).

  • User type administrator can create, update or remove any business categories.
  • User type Business owner can create, update or remove only business categories related to his business

📘

Get response for business categories.

In general, there are no restrictions to obtain business categories, but there are two paths to obtain them, data obtained depends on the type of user:

  • Normal.
  • mode: dashboard

Therefore, depending on the mode and the type of user, the response will be obtained as shown below:

  • User type Administrator and mode:dashboard can obtain all business categories.
  • User type Business owner and mode:dashboard can obtain business categories related to his business.
  • Users type Customer can get all business categories bounded by the business they can get (Location, if delivery or pick up) and if categories are enabled for their request.

Subcategories

Now the ordering API can also group categories by placing an existing collation as a parent using the parent_category_id attribute. this feature is limited to 5 levels deep. Categories can have products and subcategories down to their deepest level as shown in the example.

{
    "error": false,
    "result": [
        {
            "id": 313,
            "business_id": 58,
            "name": "cat 1",
            "image": null,
            "rank": 1,
            "enabled": true,
            "external_id": null,
            "parent_category_id": null,
            "products": [
                {
                    "id": 1673,
                    "name": "pro3",
                    "price": 3,
                    "description": null,
                    "images": null,
                    "sku": null,
                    "category_id": 313,
                    "inventoried": false,
                    "quantity": 0,
                    "featured": false,
                    "enabled": true,
                    "upselling": false,
                    "in_offer": false,
                    "offer_price": null,
                    "rank": null,
                    "offer_rate": 0,
                    "offer_rate_type": 1,
                    "offer_include_options": true,
                    "external_id": null
                }
            ],
            "metafields": [],
            "subcategories": [
                {
                    "id": 314,
                    "business_id": 58,
                    "name": "cat 2",
                    "image": null,
                    "rank": 2,
                    "enabled": true,
                    "external_id": null,
                    "parent_category_id": 313,
                    "subcategories": [
                        {
                            "id": 315,
                            "business_id": 58,
                            "name": "cat 3",
                            "image": null,
                            "rank": 3,
                            "enabled": true,
                            "external_id": null,
                            "parent_category_id": 314,
                            "subcategories": [
                                {
                                    "id": 316,
                                    "business_id": 58,
                                    "name": "cat4",
                                    "image": null,
                                    "rank": 4,
                                    "enabled": true,
                                    "external_id": null,
                                    "parent_category_id": 315,
                                    "subcategories": [
                                        {
                                            "id": 317,
                                            "business_id": 58,
                                            "name": "cat4",
                                            "image": null,
                                            "rank": 5,
                                            "enabled": true,
                                            "external_id": null,
                                            "parent_category_id": 316,
                                            "subcategories": [
                                                {
                                                    "id": 318,
                                                    "business_id": 58,
                                                    "name": "cat4",
                                                    "image": null,
                                                    "rank": 6,
                                                    "enabled": true,
                                                    "external_id": null,
                                                    "parent_category_id": 317
                                                }
                                            ],
                                            "products": [],
                                            "metafields": []
                                        }
                                    ],
                                    "products": [],
                                    "metafields": []
                                }
                            ],
                            "products": [
                                {
                                    "id": 1671,
                                    "name": "pro1",
                                    "price": 1,
                                    "description": null,
                                    "images": null,
                                    "sku": null,
                                    "category_id": 315,
                                    "inventoried": false,
                                    "quantity": 0,
                                    "featured": false,
                                    "enabled": true,
                                    "upselling": false,
                                    "in_offer": false,
                                    "offer_price": null,
                                    "rank": null,
                                    "offer_rate": 0,
                                    "offer_rate_type": 1,
                                    "offer_include_options": true,
                                    "external_id": null
                                }
                            ],
                            "metafields": []
                        }
                    ],
                    "products": [
                        {
                            "id": 1672,
                            "name": "pro2",
                            "price": 2,
                            "description": null,
                            "images": null,
                            "sku": null,
                            "category_id": 314,
                            "inventoried": false,
                            "quantity": 0,
                            "featured": false,
                            "enabled": true,
                            "upselling": false,
                            "in_offer": false,
                            "offer_price": null,
                            "rank": null,
                            "offer_rate": 0,
                            "offer_rate_type": 1,
                            "offer_include_options": true,
                            "external_id": null
                        }
                    ],
                    "metafields": []
                }
            ]
        }
    ],
    "pagination": {
        "total": 1,
        "from": 1,
        "to": 1,
        "current_page": 1,
        "page_size": 1,
        "total_pages": 1,
        "fisrt_page": null,
        "back_page": null,
        "next_page": null,
        "last_page": null
    }
}

📘

Parent Category Level restriction

If the parent category that you want to assign as parent is at the maximum depth level, it cannot be used as parent category