Getting All Categories
Function: admin_categories_get_list()
Purpose
The admin_categories_get_list()
function is designed to retrieve a list of all product categories available in the system. This function helps to fetch detailed information about each category, including their names, URLs, images, and associated products.
Parameters
This function does not require any input parameters.
Use Case
Use this function when you need to display or manage categories in your application, such as building category navigation menus, managing category hierarchies, or reviewing category details for administrative purposes.
def admin_categories_get_list():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = webcommander_sdk.admin_categories.list()
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a ShippingRatesListResponseDTO
, which contains a list of ShippingRateDTO
objects. Each object includes detailed information about a shipping rate, such as its ID, name, policy type, conditions, and timestamps.
CategoriesListResponseDTO(
categories=[
CategoryDTO(
id=PLACEHOLDER_CATEGORY_ID,
name="PLACEHOLDER_CATEGORY_NAME",
sku="PLACEHOLDER_CATEGORY_SKU",
title="PLACEHOLDER_TITLE",
heading="PLACEHOLDER_HEADING",
url="PLACEHOLDER_URL",
available=True,
visible=None,
parentCategory=CategoryReferenceDTO(
id=None,
name=None,
isInTrash=None,
isParentInTrash=None,
isDisposable=None
),
layout=LayoutDTO(id=None, name=None),
productPage=LayoutDTO(id=None, name=None),
productLayout=LayoutDTO(id=None, name=None),
availableOnDateRange=False,
availableFromDate="",
availableToDate="",
availableFor="PLACEHOLDER_AUDIENCE",
selectedCategories=[],
passwordProtected=False,
password="",
imageUrl="PLACEHOLDER_IMAGE_URL",
backgroundImageUrl=None,
summary="PLACEHOLDER_SUMMARY",
description="PLACEHOLDER_DESCRIPTION",
products=[
ProductDTO(id=PLACEHOLDER_PRODUCT_ID, name="PLACEHOLDER_PRODUCT_NAME")
],
shippingProfile={},
taxProfile={},
disableTracking=False,
seoConfigs=[],
transactionNo=None,
isDisposable=False,
isInTrash=False,
isParentInTrash=False,
createdBy=CreatedByDTO(id=None, name=None),
createdOn="PLACEHOLDER_CREATED_ON",
updatedOn="PLACEHOLDER_UPDATED_ON"
)
],
pagination=PaginationDTO(
records=PLACEHOLDER_TOTAL_RECORDS,
limit=PLACEHOLDER_LIMIT,
offset=PLACEHOLDER_OFFSET,
nextPage=None,
previousPage=None
)
)
Getting a Specific Category
Functions: admin_categories_get_details()
Purpose
The admin_categories_get_details()
function is designed to retrieve the details of a specific category using its unique identifier. This function helps to fetch comprehensive information about the selected category, including metadata, associated products, and configuration settings
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the category. |
Use Case
Use this function when you need to display or validate the details of a particular category in your system. It's especially useful for administrative dashboards or during integration testing to ensure the category data is accurate and complete.
def admin_categories_get_details():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
id = 'CATEGORY_ID'
response = webcommander_sdk.admin_categories.details(id=id)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns detailed information of the specified category, wrapped in a response DTO. The response includes attributes such as the category name, URL, availability status, parent category reference, associated products, and timestamps for creation and last update.
CategoriesDetailsResponseDTO(
category=CategoryDTO(
id=PLACEHOLDER_CATEGORY_ID,
name='PLACEHOLDER_CATEGORY_NAME',
sku='PLACEHOLDER_CATEGORY_SKU',
title='PLACEHOLDER_CATEGORY_TITLE',
heading='PLACEHOLDER_CATEGORY_HEADING',
url='PLACEHOLDER_CATEGORY_URL',
available=True,
visible=None,
parentCategory=CategoryReferenceDTO(
id=None,
name=None,
isInTrash=None,
isParentInTrash=None,
isDisposable=None
),
layout=LayoutDTO(id=None, name=None),
productPage=LayoutDTO(id=None, name=None),
productLayout=LayoutDTO(id=None, name=None),
availableOnDateRange=False,
availableFromDate='PLACEHOLDER_FROM_DATE',
availableToDate='PLACEHOLDER_TO_DATE',
availableFor='PLACEHOLDER_AVAILABILITY_SCOPE',
selectedCategories=[],
passwordProtected=False,
password='',
imageUrl='PLACEHOLDER_IMAGE_URL',
backgroundImageUrl=None,
summary='PLACEHOLDER_SUMMARY',
description='PLACEHOLDER_DESCRIPTION',
products=[
ProductDTO(id=PLACEHOLDER_PRODUCT_ID_1, name='PLACEHOLDER_PRODUCT_NAME_1'),
ProductDTO(id=PLACEHOLDER_PRODUCT_ID_2, name='PLACEHOLDER_PRODUCT_NAME_2')
],
shippingProfile={},
taxProfile={},
disableTracking=False,
seoConfigs=[],
transactionNo=None,
isDisposable=False,
isInTrash=True,
isParentInTrash=False,
createdBy=CreatedByDTO(id=None, name=None),
createdOn='PLACEHOLDER_CREATED_ON',
updatedOn='PLACEHOLDER_UPDATED_ON'
)
)
Creating Specific Category
Function: admin_create_categories()
Purpose
The admin_create_categories()
function is designed to create a new category in the system. It allows defining various properties of the category, such as name, title, parent category, availability, SEO configurations, images, and analytics settings. This function enables administrators to dynamically manage and expand their product catalog by adding new categories.
Parameters
Parameters | Type | Description |
---|---|---|
name | String | The name of the category. |
title | String | The title of the category. |
heading | String | The heading text displayed for the category. |
available | Boolean | Whether the category is available. |
categoryAvailable | Boolean | Whether the category is available on the storefront. |
parentCategory.id | String | ID of the parent category. |
parentCategory.name | String | Name of the parent category. |
productPage.id | String | ID of the product page. |
productLayout.id | String | ID of the product layout. |
availability.onDateRange | Boolean | Whether availability is limited to a date range. |
availability.fromDate | String | Start date for availability. |
availability.toDate | String | End date for availability. |
availabilityDetails.availableFor | String | Availability audience type. |
availabilityDetails.selectedCustomers | Array of String | List of selected customer IDs. |
availabilityDetails.restrictSelectedCustomers | Boolean | Whether to restrict to selected customers only. |
protectionDetails.codeProtected | Boolean | Whether category is protected by code. |
protectionDetails.codeToProtect | String | Code required to access the category. |
images.url | String | URL of the main image. |
images.baseUrl | String | Base URL for the image. |
images.thumbUrl | String | Thumbnail image URL. |
images.backgroundImage | String | Background image URL (if any). |
summary | String | Short summary of the category. |
description | String | Full description of the category. |
productSorting | String | Sorting preference for products. |
disableTracking | Boolean | Whether to disable tracking for the category. |
loyaltyPoints | Integer | Loyalty points associated with the category. |
seoConfigurations.url | String | SEO-friendly URL. |
seoConfigurations.overwriteSeoSettings | Boolean | Whether to override default SEO settings. |
seoConfigurations.seoTitle | String | SEO title tag. |
seoConfigurations.seoDescription | String | SEO meta description. |
seoConfigurations.searchEngineIndexing | Boolean | Whether search engines can index the page. |
seoConfigurations.canonicalUrl.enable | Boolean | Enable canonical URL. |
seoConfigurations.canonicalUrl.url | Array of String | List of canonical URLs. |
additionalMetaInfo.enable | Boolean | Whether to enable additional meta info. |
analytics.defaultProductListingConfigurations | Boolean | Use default analytics settings. |
analytics.thirdPartyAnalytics.enable | Boolean | |
analytics.thirdPartyAnalytics.trackEvent.enable | Boolean | Enable tracking for specific events. |
analytics.thirdPartyAnalytics.trackEvent.events | Dictionary | Dictionary of events and their boolean values. |
analytics.seoCustomCode.enable | Boolean | Enable custom SEO code injection. |
analytics.seoCustomCode.customCodeInHeader | String | Custom HTML/JS code for the header. |
analytics.seoCustomCode.customCodeInFooter | String | Custom HTML/JS code for the footer. |
Use Case
Use this function when you want to create a new category for organizing products in the system. It is useful for scenarios like launching a new product line, structuring the catalog with subcategories, or adding promotional categories. You can specify all the relevant category details, including availability settings, meta information, and SEO data to improve the discoverability of the category.
def admin_create_categories():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
request_data = CategoryDataDTO(
name="PLACEHOLDER_CATEGORY_NAME",
title="PLACEHOLDER_TITLE",
heading="PLACEHOLDER_HEADING",
available=True,
categoryAvailable=True,
parentCategory=ParentCategoryDTO(
id="PLACEHOLDER_PARENT_CATEGORY_ID",
name="PLACEHOLDER_PARENT_CATEGORY_NAME"
),
productPage=PageDTO(
id="PLACEHOLDER_PRODUCT_PAGE_ID"
),
productLayout=PageDTO(
id="PLACEHOLDER_PRODUCT_LAYOUT_ID"
),
availability=AvailabilityDTO(
onDateRange=True,
fromDate="PLACEHOLDER_FROM_DATE",
toDate="PLACEHOLDER_TO_DATE"
),
availabilityDetails=AvailabilityDetailsDTO(
availableFor="PLACEHOLDER_AVAILABLE_FOR",
selectedCustomers=["PLACEHOLDER_CUSTOMER_ID"],
restrictSelectedCustomers=True
),
protectionDetails=ProtectionDetailsDTO(
codeProtected=True,
codeToProtect="PLACEHOLDER_PROTECTION_CODE"
),
images=ImagesDTO(
url="PLACEHOLDER_IMAGE_URL",
baseUrl="PLACEHOLDER_BASE_URL",
thumbUrl="PLACEHOLDER_THUMB_URL",
backgroundImage=None
),
summary="PLACEHOLDER_SUMMARY",
description="PLACEHOLDER_DESCRIPTION",
products=[
ProductDTO(id="PLACEHOLDER_PRODUCT_ID")
],
productSorting="PLACEHOLDER_PRODUCT_SORTING",
disableTracking=False,
loyaltyPoints=0,
seoConfigurations=SEOConfigurationsDTO(
url="PLACEHOLDER_SEO_URL",
overwriteSeoSettings=False,
seoTitle="PLACEHOLDER_SEO_TITLE",
seoDescription="PLACEHOLDER_SEO_DESCRIPTION",
searchEngineIndexing=False,
canonicalUrl=CanonicalUrlDTO(
enable=True,
url=["PLACEHOLDER_CANONICAL_URL_1", "PLACEHOLDER_CANONICAL_URL_2"]
)
),
additionalMetaInfo=AdditionalMetaInfoDTO(
enable=True,
metaInfo=[
MetaInfoDTO(tagName="PLACEHOLDER_TAG_NAME", tagContent="PLACEHOLDER_TAG_CONTENT"),
MetaInfoDTO(name="PLACEHOLDER_META_NAME", value="PLACEHOLDER_META_VALUE")
]
),
analytics=AnalyticsDTO(
defaultProductListingConfigurations=False,
thirdPartyAnalytics=ThirdPartyAnalyticsDTO(
enable=True,
platform="PLACEHOLDER_ANALYTICS_PLATFORM",
enableGoogleAnalytics=True,
googleAnalysis="PLACEHOLDER_GOOGLE_ANALYSIS",
googleAdsConversionId="PLACEHOLDER_CONVERSION_ID",
googleAdsConversionLabel="PLACEHOLDER_CONVERSION_LABEL",
debugMode=True,
facebookPixelId="PLACEHOLDER_FACEBOOK_PIXEL_ID",
trackEvent=TrackEventsDTO(
enable=True,
events={
"add_to_cart": True,
"view_item": False,
"view_item_list": True,
"begin_checkout": False,
"purchase": True,
"remove_from_cart": False,
"view_cart": True,
"add_payment_info": True,
"add_shipping_info": False,
"add_to_wish_list": True
}
)
),
seoCustomCode=SEOCustomCodeDTO(
enable=True,
customCodeInHeader="PLACEHOLDER_CUSTOM_HEADER_CODE",
customCodeInFooter="PLACEHOLDER_CUSTOM_FOOTER_CODE"
)
)
)
response = webcommander_sdk.admin_categories.create_categories(request_data=request_data)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns the details of the newly created category, including the CATEGORY_ID, CATEGORY_NAME, CATEGORY_URL, visibility status, parent category details, layout configurations, availability information, and timestamps for creation and updates.
CategoriesDetailsResponseDTO(
category=CategoryDTO(
id=PLACEHOLDER_CATEGORY_ID,
name="PLACEHOLDER_CATEGORY_NAME",
sku="PLACEHOLDER_CATEGORY_SKU",
title="PLACEHOLDER_TITLE",
heading="PLACEHOLDER_HEADING",
url="PLACEHOLDER_CATEGORY_URL",
available=True,
visible=True,
parentCategory=CategoryReferenceDTO(
id=PLACEHOLDER_PARENT_CATEGORY_ID,
name="PLACEHOLDER_PARENT_CATEGORY_NAME",
isInTrash=False,
isParentInTrash=False,
isDisposable=False
),
layout=LayoutDTO(id=None, name=None),
productPage=LayoutDTO(id="PLACEHOLDER_PRODUCT_PAGE_ID", name="PLACEHOLDER_PRODUCT_PAGE_NAME"),
productLayout=LayoutDTO(id="PLACEHOLDER_PRODUCT_LAYOUT_ID", name="PLACEHOLDER_PRODUCT_LAYOUT_NAME"),
availableOnDateRange=False,
availableFromDate="",
availableToDate="",
availableFor="PLACEHOLDER_AVAILABLE_FOR",
selectedCategories=[],
passwordProtected=False,
password="",
imageUrl=None,
backgroundImageUrl=None,
summary="PLACEHOLDER_SUMMARY",
description="PLACEHOLDER_DESCRIPTION",
products={},
shippingProfile={},
taxProfile={},
disableTracking=False,
seoConfigs=[],
transactionNo=None,
isDisposable=False,
isInTrash=False,
isParentInTrash=False,
createdBy=CreatedByDTO(id="PLACEHOLDER_CREATED_BY_ID", name="PLACEHOLDER_CREATED_BY_NAME"),
createdOn="PLACEHOLDER_CREATED_ON",
updatedOn="PLACEHOLDER_UPDATED_ON"
)
)
Updating a Specific Category
Function: admin_update_categories()
Purpose
The admin_update_categories
function is used to update an existing category's details in the system. It allows modification of various attributes such as category name, URL, availability, SEO configurations, analytics, and associated products, providing comprehensive control over category management.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | ID of the category to update. |
request_data | CategoryDataDTO | Object containing all category update data. |
name | String | Category name. |
url | String | URL for the category. |
title | String | Display title of the category. |
heading | String | Heading for the category section. |
available | Boolean | Category availability. |
categoryAvailable | Boolean | Whether the category is active on the site. |
parentCategory | ParentCategoryDTO | Parent category details. |
productPage | PageDTO | Associated product page. |
productLayout | PageDTO | Layout used for displaying products. |
availability | AvailabilityDTO | Date-based availability configuration. |
availabilityDetails | AvailabilityDetailsDTO | Customer-specific availability rules. |
protectionDetails | ProtectionDetailsDTO | Access protection via code. |
images | ImagesDTO | Category image configuration. |
summary | String | Short summary of the category. |
description | String | Full HTML/text description. |
products | List[ProductDTO] | List of product IDs assigned to the category. |
productSorting | String | Sorting preference of products. |
disableTracking | Boolean | Disable analytics tracking for this category. |
loyaltyPoints | Integer | Points assigned for purchases in this category. |
seoConfigurations | SEOConfigurationsDTO | SEO metadata. |
additionalMetaInfo | AdditionalMetaInfoDTO | Extra meta tags for SEO. |
analytics | AnalyticsDTO | Analytics settings including Google & Facebook pixel. |
Use Case
Use this function when you need to make changes to an existing category — for example, updating the category name, adjusting its visibility, setting availability dates, adding or removing products, configuring SEO metadata, or integrating third-party analytics. This is particularly useful for keeping the category structure and data up to date with business needs.
def admin_update_categories():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
request_data = CategoryDataDTO(
name="PLACEHOLDER_CATEGORY_NAME",
url="PLACEHOLDER_CATEGORY_URL",
title="PLACEHOLDER_CATEGORY_TITLE",
heading="PLACEHOLDER_CATEGORY_HEADING",
available=True,
categoryAvailable=True,
parentCategory=ParentCategoryDTO(
id="PLACEHOLDER_PARENT_CATEGORY_ID",
name="PLACEHOLDER_PARENT_CATEGORY_NAME"
),
productPage=PageDTO(
id="PLACEHOLDER_PRODUCT_PAGE_ID"
),
productLayout=PageDTO(
id="PLACEHOLDER_PRODUCT_LAYOUT_ID"
),
availability=AvailabilityDTO(
onDateRange=True,
fromDate="PLACEHOLDER_FROM_DATE",
toDate="PLACEHOLDER_TO_DATE"
),
availabilityDetails=AvailabilityDetailsDTO(
availableFor="PLACEHOLDER_AVAILABLE_FOR",
selectedCustomers=["PLACEHOLDER_CUSTOMER_ID"],
restrictSelectedCustomers=True
),
protectionDetails=ProtectionDetailsDTO(
codeProtected=True,
codeToProtect="PLACEHOLDER_PROTECTION_CODE"
),
images=ImagesDTO(
url="PLACEHOLDER_IMAGE_URL",
baseUrl="PLACEHOLDER_IMAGE_BASE_URL",
thumbUrl="PLACEHOLDER_THUMB_URL",
backgroundImage=None
),
summary="PLACEHOLDER_SUMMARY",
description="PLACEHOLDER_DESCRIPTION",
products=[
ProductDTO(id="PLACEHOLDER_PRODUCT_ID")
],
productSorting="PLACEHOLDER_PRODUCT_SORTING",
disableTracking=False,
loyaltyPoints=0,
seoConfigurations=SEOConfigurationsDTO(
url="PLACEHOLDER_SEO_URL",
overwriteSeoSettings=False,
seoTitle="PLACEHOLDER_SEO_TITLE",
seoDescription="PLACEHOLDER_SEO_DESCRIPTION",
searchEngineIndexing=False,
canonicalUrl=CanonicalUrlDTO(
enable=True,
url=["PLACEHOLDER_CANONICAL_URL_1", "PLACEHOLDER_CANONICAL_URL_2"]
)
),
additionalMetaInfo=AdditionalMetaInfoDTO(
enable=True,
metaInfo=[
MetaInfoDTO(tagName="meta", tagContent="PLACEHOLDER_META_CONTENT"),
MetaInfoDTO(name="meta2", value="PLACEHOLDER_META_CONTENT_2")
]
),
analytics=AnalyticsDTO(
defaultProductListingConfigurations=False,
thirdPartyAnalytics=ThirdPartyAnalyticsDTO(
enable=True,
platform="PLACEHOLDER_PLATFORM",
enableGoogleAnalytics=True,
googleAnalysis="PLACEHOLDER_GOOGLE_ANALYSIS",
googleAdsConversionId="PLACEHOLDER_CONVERSION_ID",
googleAdsConversionLabel="PLACEHOLDER_CONVERSION_LABEL",
debugMode=True,
facebookPixelId="PLACEHOLDER_PIXEL_ID",
trackEvent=TrackEventsDTO(
enable=True,
events={
"add_to_cart": True,
"view_item": False,
"view_item_list": True,
"begin_checkout": False,
"purchase": True,
"remove_from_cart": False,
"view_cart": True,
"add_payment_info": True,
"add_shipping_info": False,
"add_to_wish_list": True
}
)
),
seoCustomCode=SEOCustomCodeDTO(
enable=True,
customCodeInHeader="PLACEHOLDER_HEADER_CODE",
customCodeInFooter="PLACEHOLDER_FOOTER_CODE"
)
)
)
id = "PLACEHOLDER_CATEGORY_ID"
response = webcommander_sdk.admin_categories.update_categories(id=id, request_data=request_data)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns an updated category response object, which contains the latest details of the modified category, including IDs, names, descriptions, availability status, associated products, SEO configurations, and timestamps for creation and updates.
CategoriesDetailsResponseDTO(
category=CategoryDTO(
id=PLACEHOLDER_CATEGORY_ID,
name="PLACEHOLDER_CATEGORY_NAME",
sku="PLACEHOLDER_CATEGORY_SKU",
title="PLACEHOLDER_CATEGORY_TITLE",
heading="PLACEHOLDER_CATEGORY_HEADING",
url="PLACEHOLDER_CATEGORY_URL",
available=True,
visible=True,
parentCategory=CategoryReferenceDTO(
id=PLACEHOLDER_PARENT_CATEGORY_ID,
name="PLACEHOLDER_PARENT_CATEGORY_NAME",
isInTrash=False,
isParentInTrash=False,
isDisposable=False
),
layout=LayoutDTO(
id=None,
name=None
),
productPage=LayoutDTO(
id=PLACEHOLDER_PRODUCT_PAGE_ID,
name="PLACEHOLDER_PRODUCT_PAGE_NAME"
),
productLayout=LayoutDTO(
id=PLACEHOLDER_PRODUCT_LAYOUT_ID,
name="PLACEHOLDER_PRODUCT_LAYOUT_NAME"
),
availableOnDateRange=False,
availableFromDate="",
availableToDate="",
availableFor="everyone",
selectedCategories=[],
passwordProtected=False,
password="",
imageUrl=None,
backgroundImageUrl=None,
summary="PLACEHOLDER_SUMMARY",
description="PLACEHOLDER_DESCRIPTION",
products={},
shippingProfile={},
taxProfile={},
disableTracking=False,
seoConfigs=[],
transactionNo=None,
isDisposable=False,
isInTrash=False,
isParentInTrash=False,
createdBy=CreatedByDTO(
id=PLACEHOLDER_USER_ID,
name="PLACEHOLDER_USER_NAME"
),
createdOn="PLACEHOLDER_CREATED_ON",
updatedOn="PLACEHOLDER_UPDATED_ON"
)
)
Deleting a Category
Function: admin_delete_categories()
Purpose
The admin_delete_categories
function is used to delete an existing category by its unique identifier. This function helps in maintaining the relevance and accuracy of category listings by allowing the removal of outdated or incorrect categories.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The unique identifier of the category to be deleted. |
Use Case
Use this function when you need to permanently remove a category from the system. This is particularly useful when categories are deprecated, merged, or created in error, ensuring that only valid and current categories remain in your catalog.
def admin_delete_categories():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
id = "PLACEHOLDER_CATEGORY_ID"
response = webcommander_sdk.admin_categories.delete_categories(id=id)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a success message indicating that the category has been successfully deleted.