» Products Module Documentation

Getting all products

Function: get_product_list() &  admin_get_product_list()

Purpose

This function retrieves a list of products available for customers and administrators. The get_product_list() function is used to fetch products based on a customer’s access level, meaning some products may be restricted based on user type or permissions. On the other hand, admin_get_product_list() provides access to all products, regardless of restrictions, allowing administrators full control over inventory and visibility. This helps businesses manage product accessibility, control pricing strategies, and ensure restricted products are only available to authorized users. Additionally, it supports filtering, sorting, and pagination to efficiently navigate large product catalogs.

Parameters

This function does not require any input parameters.

Use Case

The get_product_list()  is used to browse and purchase available products for a customer, ensuring they only see items they are eligible to buy. Businesses can apply restrictions based on customer groups, scheduled availability, and password protection, making it ideal for exclusive sales or membership-based access. The admin_get_product_list() function allows administrators to manage all products, even those hidden from regular customers, ensuring smooth inventory tracking, bulk updates, and product lifecycle management. This separation helps maintain control over restricted products while allowing flexibility for different user types.

def get_product_list():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.product.list()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)
def admin_get_product_list():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_product.list()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

This function returns a list of products along with details such as pricing, stock availability, variations, metadata, and access restrictions. For regular customers, the response includes only products they are allowed to purchase, while administrators receive full product listings, including restricted and password-protected items. Each product contains information such as base price, sale price, stock levels, categories, variations, and SEO metadata to support e-commerce functionality. The response also supports pagination, ensuring efficient retrieval of product lists for large inventories.

ProductListResponseDTO(
    products=[
        ProductDataDTO(
            administrativeStatus=BOOLEAN,
            advanced={
                'advance_information': {
                    'global_trade_item_number': 'PRODUCT_GTIN',
                    'product_condition': 'NEW',
                    'loyality_points': 'LOYALTY_POINTS'
                },
                'webtool_disable_tracking': BOOLEAN,
                'meta_tags': [
                    {'name': 'Meta', 'value': 'META_VALUE', 'id': META_ID}
                ],
                'custom_information': {}
            },
            available=BOOLEAN,
            availableFor='AVAILABLE_FOR',
            availableFromDate='YYYY-MM-DDTHH:MM:SSZ',
            availableStock=AVAILABLE_STOCK,
            availableToDate='YYYY-MM-DDTHH:MM:SSZ',
            availableOnDateRange=BOOLEAN,
            availableOnWeekdays=ProductAvailableWeekdaysDataDTO(
                enabled=BOOLEAN,
                weekdays=[
                    WeekdaysDataDTO(day='DAY', startHour=0, startMinute=0, endHour=0, endMinute=0)
                ]
            ),
            basePrice=BASE_PRICE,
            costPrice=COST_PRICE,
            customClass='CUSTOM_CLASS',
            customProperties='',
            heading='HEADER',
            id=PRODUCT_ID,
            imageAndVideo=ProductMediaDTO(
                images=[
                    ImageDataDTO(
                        id=IMAGE_ID,
                        filename='IMAGE_FILENAME',
                        link='IMAGE_LINK',
                        thumbnail='IMAGE_THUMBNAIL'
                    )
                ],
                videos=[
                    VideoDataDTO(
                        id=VIDEO_ID,
                        filename='VIDEO_FILENAME',
                        link='VIDEO_LINK',
                        thumbnail='VIDEO_THUMBNAIL'
                    )
                ],
                specs=[
                    MediaDataDTO(
                        id=SPEC_ID,
                        filename='SPEC_FILENAME',
                        link='SPEC_LINK'
                    )
                ]
            ),
            isOnSale=BOOLEAN,
            name='PRODUCT_NAME',
            parents=[
                ParentDataDTO(id=PARENT_ID, name='PARENT_NAME', isInTrash=BOOLEAN, isParentInTrash=BOOLEAN, isDisposable=BOOLEAN),
                ParentDataDTO(id=PARENT_ID, name='PARENT_NAME', isInTrash=BOOLEAN, isParentInTrash=BOOLEAN, isDisposable=BOOLEAN)
            ],
            password='',
            passwordProtected=BOOLEAN,
            productPricingAndStock=ProductPricingAndStockDTO(
                availableStock=AVAILABLE_STOCK,
                enableCallForPrice=BOOLEAN,
                enableMultipleOrder=BOOLEAN,
                expectedToPay=BOOLEAN,
                expectedToPayPrice=EXPECTED_TO_PAY_PRICE,
                hidePrice=BOOLEAN,
                lowLevelStock=LOW_LEVEL_STOCK,
                maximumOrderQuantity=MAX_ORDER_QTY,
                minimumOrderQuantity=MIN_ORDER_QTY,
                multipleOrderQuantity=MULTIPLE_ORDER_QTY,
                onSale=BOOLEAN,
                onSalePrice=SALE_PRICE,
                onSalePriceType='SALE_PRICE_TYPE',
                restrictPriceFor='none',
                restrictPriceForExceptCustomers=[],
                restrictPurchaseFor='none',
                restrictPurchaseForSelectedCustomers=[],
                shippingProfile=ShippingProfileDataDTO(id=SHIPPING_ID, name='SHIPPING'),
                taxProfile=TaxProfileDataDTO(id=TAX_ID, name='TAX_NAME'),
                trackInventory=BOOLEAN
            ),
            productLayout=CommonStructureDTO(id=LAYOUT_ID, name='LAYOUT_NAME'),
            productSummary='PRODUCT_SUMMARY',
            productDescription='PRODUCT_DESCRIPTION',
            productPage={},
            productType='PRODUCT_TYPE',
            restrictPriceFor=None,
            restrictPurchaseFor=None,
            restrictForSelectedCustomers=[],
            relatedProducts=[
                RelatedOrSimilarProductDTO(id=RELATED_PRODUCT_ID, name='RELATED_PRODUCT_NAME', url='RELATED_PRODUCT_URL'),
                RelatedOrSimilarProductDTO(id=RELATED_PRODUCT_ID, name='RELATED_PRODUCT_NAME', url='RELATED_PRODUCT_URL')
            ],
            similarProducts=[
                RelatedOrSimilarProductDTO(id=SIMILAR_PRODUCT_ID, name='SIMILAR_PRODUCT_NAME', url='SIMILAR_PRODUCT_URL'),
                RelatedOrSimilarProductDTO(id=SIMILAR_PRODUCT_ID, name='SIMILAR_PRODUCT_NAME', url='SIMILAR_PRODUCT_URL')
            ],
            selectedCustomers=[],
            salePrice=SALE_PRICE,
            seoConfigs=[],
            sku='PRODUCT_SKU',
            summary=None,
            tags=[],
            url=None,
            videos=None
        )
    ],
    pagination=PaginationDTO(
        records=TOTAL_RECORDS,
        limit=PAGE_LIMIT,
        offset=OFFSET,
        nextPage='NEXT_PAGE_URL',
        previousPage=None
    )
)

Getting specific product info

Functions: get_product_info() & get_admin_product_info()

Purpose

This functions  retrieves detailed information about a specific product using its unique identifier. It provides essential data such as product name, price, description, stock availability, and other relevant metadata. Businesses can use this function to dynamically fetch product details for e-commerce platforms, inventory management systems, or customer queries. The get_admin_product_info() function is specifically designed for administrative users, allowing them to access extended product data, including internal attributes, supplier details, and restricted settings. By leveraging this function, businesses can ensure accurate and up-to-date product information is displayed, improving customer experience and operational efficiency. Administrators can use the admin version to manage and monitor product-related configurations without directly modifying the database. This function is essential for streamlining product data retrieval across different user roles, ensuring data consistency, and reducing errors in pricing, descriptions, or stock levels.

Parameters

Parameter
Type
Description
id
String
The unique identifier of the product.

Use Case

 This both functions get_product_info()get_admin_product_info() can be used when you need to fetch detailed product information for display, order processing, or inventory tracking. The admin version should be used for backend management purposes where additional product attributes are required.

def get_product_info():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.product.info(id="PRODUCT_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)
def get_admin_product_info():
    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_product.info(id="PRODUCT_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

A response object containing detailed product information such as product name, SKU, price, stock status, description, and images. The admin version provides additional fields, including supplier details, internal notes, and restricted attributes.

ProductResponseDTO(
    status="STATUS",
    product=ProductDataDTO(
        administrativeStatus=True,
        advanced=AdvancedDTO(
            advance_information=AdvanceInformationDTO(
                global_trade_item_number="GLOBAL_TRADE_ITEM_NUMBER",
                product_condition="PRODUCT_CONDITION",
                loyality_points="LOYALITY_POINTS"
            ),
            webtool_disable_tracking="WEBTOOL_DISABLE_TRACKING",
            meta_tags=[
                MetaTagDTO(
                    name="META_NAME_1",
                    value="META_VALUE_1",
                    id="META_ID_1"
                ),
                MetaTagDTO(
                    name="META_NAME_2",
                    value="META_VALUE_2",
                    id="META_ID_2"
                )
            ],
            custom_information="CUSTOM_INFORMATION"
        ),
        available=True,
        availableFor="AVAILABLE_FOR",
        availableFromDate="AVAILABLE_FROM_DATE",
        availableStock="AVAILABLE_STOCK",
        availableToDate="AVAILABLE_TO_DATE",
        availableOnDateRange=True,
        availableOnWeekdays=ProductAvailableWeekdaysDataDTO(
            enabled=True,
            weekdays=[
                WeekdaysDataDTO(
                    day="DAY_1",
                    startHour="START_HOUR_1",
                    startMinute="START_MINUTE_1",
                    endHour="END_HOUR_1",
                    endMinute="END_MINUTE_1"
                ),
                WeekdaysDataDTO(
                    day="DAY_2",
                    startHour="START_HOUR_2",
                    startMinute="START_MINUTE_2",
                    endHour="END_HOUR_2",
                    endMinute="END_MINUTE_2"
                ),
                WeekdaysDataDTO(
                    day="DAY_3",
                    startHour="START_HOUR_3",
                    startMinute="START_MINUTE_3",
                    endHour="END_HOUR_3",
                    endMinute="END_MINUTE_3"
                )
            ]
        ),
        basePrice="BASE_PRICE",
        costPrice="COST_PRICE",
        customClass="CUSTOM_CLASS",
        customProperties="CUSTOM_PROPERTIES",
        heading="HEADING",
        id="PRODUCT_ID",
        imageAndVideo=ProductMediaDTO(
            images=[
                ImageDataDTO(
                    id="IMAGE_ID",
                    filename="IMAGE_FILENAME",
                    link="IMAGE_LINK",
                    thumbnail="IMAGE_THUMBNAIL"
                )
            ],
            videos=[
                VideoDataDTO(
                    id="VIDEO_ID",
                    filename="VIDEO_FILENAME",
                    link="VIDEO_LINK",
                    thumbnail="VIDEO_THUMBNAIL"
                )
            ],
            specs=[
                MediaDataDTO(
                    id="MEDIA_ID",
                    filename="MEDIA_FILENAME",
                    link="MEDIA_LINK"
                )
            ]
        ),
        isOnSale=True,
        name="PRODUCT_NAME",
        parents=[
            ParentDataDTO(
                id="PARENT_ID_1",
                name="PARENT_NAME_1",
                isInTrash=False,
                isParentInTrash=False,
                isDisposable=False
            ),
            ParentDataDTO(
                id="PARENT_ID_2",
                name="PARENT_NAME_2",
                isInTrash=False,
                isParentInTrash=False,
                isDisposable=False
            )
        ],
        password="PASSWORD",
        passwordProtected=False,
        productPricingAndStock=ProductPricingAndStockDTO(
            availableStock="AVAILABLE_STOCK",
            enableCallForPrice=True,
            enableMultipleOrder=True,
            expectedToPay=False,
            expectedToPayPrice="EXPECTED_TO_PAY_PRICE",
            hidePrice=False,
            lowLevelStock="LOW_LEVEL_STOCK",
            maximumOrderQuantity="MAXIMUM_ORDER_QUANTITY",
            minimumOrderQuantity="MINIMUM_ORDER_QUANTITY",
            multipleOrderQuantity="MULTIPLE_ORDER_QUANTITY",
            onSale=True,
            onSalePrice="ON_SALE_PRICE",
            onSalePriceType="ON_SALE_PRICE_TYPE",
            restrictPriceFor="RESTRICT_PRICE_FOR",
            restrictPriceForExceptCustomers=["RESTRICT_CUSTOMER_1", "RESTRICT_CUSTOMER_2"],
            restrictPurchaseFor="RESTRICT_PURCHASE_FOR",
            restrictPurchaseForSelectedCustomers=["SELECTED_CUSTOMER_1", "SELECTED_CUSTOMER_2"],
            shippingProfile=ShippingProfileDataDTO(
                id="SHIPPING_PROFILE_ID",
                name="SHIPPING_PROFILE_NAME"
            ),
            taxProfile=TaxProfileDataDTO(
                id="TAX_PROFILE_ID",
                name="TAX_PROFILE_NAME"
            ),
            trackInventory=False
        ),
        productLayout=CommonStructureDTO(
            id="LAYOUT_ID",
            name="LAYOUT_NAME"
        ),
        productSummary="PRODUCT_SUMMARY",
        productDescription="PRODUCT_DESCRIPTION",
        productPage={},
        productType="PRODUCT_TYPE",
        restrictPriceFor="RESTRICT_PRICE_FOR",
        restrictPurchaseFor="RESTRICT_PURCHASE_FOR",
        restrictForSelectedCustomers=["SELECTED_CUSTOMER_1", "SELECTED_CUSTOMER_2"],
        relatedProducts=[
            RelatedOrSimilarProductDTO(
                id="RELATED_PRODUCT_ID_1",
                name="RELATED_PRODUCT_NAME_1",
                url="RELATED_PRODUCT_URL_1"
            ),
            RelatedOrSimilarProductDTO(
                id="RELATED_PRODUCT_ID_2",
                name="RELATED_PRODUCT_NAME_2",
                url="RELATED_PRODUCT_URL_2"
            ),
            RelatedOrSimilarProductDTO(
                id="RELATED_PRODUCT_ID_3",
                name="RELATED_PRODUCT_NAME_3",
                url="RELATED_PRODUCT_URL_3"
            )
        ],
        similarProducts=[
            RelatedOrSimilarProductDTO(
                id="SIMILAR_PRODUCT_ID_1",
                name="SIMILAR_PRODUCT_NAME_1",
                url="SIMILAR_PRODUCT_URL_1"
            ),
            RelatedOrSimilarProductDTO(
                id="SIMILAR_PRODUCT_ID_2",
                name="SIMILAR_PRODUCT_NAME_2",
                url="SIMILAR_PRODUCT_URL_2"
            ),
            RelatedOrSimilarProductDTO(
                id="SIMILAR_PRODUCT_ID_3",
                name="SIMILAR_PRODUCT_NAME_3",
                url="SIMILAR_PRODUCT_URL_3"
            )
        ],
        selectedCustomers=["SELECTED_CUSTOMER_ID_1"],
        salePrice="SALE_PRICE",
        seoConfigs=[],
        sku="SKU",
        summary="SUMMARY",
        tags=["TAG1", "TAG2"],
        url="PRODUCT_URL",
        videos="PRODUCT_VIDEOS"
    )
)

Getting products count

Function: get_product_count() & admin_get_product_count()

Purpose

Retrieves the total number of products available. For get_product_count(), it returns the count for customers, groups, or anonymous users based on their access, whereas admin_get_product_count() provides the full count for all products accessible by the admin.

Parameters

This function does not require any input parameters.

Use Case

The get_product_count()  function is used to get an idea of how many products are available to customers in the store, ensuring they see only items they can purchase. Administrators use admin_get_product_count() for inventory management, tracking total product numbers, including hidden or restricted items. This distinction is useful for managing special promotions, private sales, or exclusive memberships where not all products should be publicly accessible

def get_product_count():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.product.count()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)
def admin_get_product_count():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_product.count()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response returns the number of products available. For get_product_count(), this number represents only the products the current customer can access. In contrast, admin_get_product_count() provides the total number of products in the system, including restricted items. This helps businesses understand inventory size from both a customer and administrative perspective.

CountResponseDTO(count=TOTAL_PRODUCT_COUNT)

Getting product settings

Function: get_product_settings()

Purpose

This function get_product_settings() retrieves global product settings that define how products behave within the system. It provides essential configurations such as pricing rules, stock management settings, tax policies, display preferences, and other operational parameters. Businesses can use this function to dynamically adjust product behavior, ensuring consistency in pricing, stock control, and visibility settings across their platform. It helps developers, administrators, and system integrators access predefined product rules without manually checking configurations in the database. By leveraging this function, businesses can streamline product management, reduce errors, and ensure compliance with pricing and tax regulations. This is particularly useful for multi-channel e-commerce platforms, inventory systems, and custom storefronts that rely on system-wide product configurations.

Parameters

No input parameters are required for this function.

Use Case

This function get_product_settings() when you need to retrieve system-wide product settings for pricing, inventory control, tax policies, and display configurations. It is particularly useful for ensuring that all products adhere to a consistent set of rules across different parts of the system.

def get_product_settings():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.product.settings()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

A response object containing global product settings, including pricing configurations, stock control rules, tax settings, and display preferences. These settings define how products function within the system and affect pricing, availability, and presentation.

ProductSettingsDataDTO(
    labelForCallForPrice="Call for Price",
    labelForExpectToPay="Expect to Pay",
    labelForBasePrice="Today's Price",
    addToCart="true",
    variationOptionView="flat"
)

Getting Product Variations

Function: admin_get_product_variation()

Purpose

This function retrieves detailed information about the variations of a specific product. It is designed for administrative use, allowing administrators to access and manage product variations, including their types, options, and available combinations. This function is beneficial for managing complex products with multiple variations, such as different colors, sizes, or other customizable attributes.

Parameters

Parameter
Type
Description
id
String
The unique identifier of the product for which variations are being retrieved.

Use Case

This function is used when administrators need to fetch detailed information about the variations of a product. It is particularly useful in scenarios where products have multiple customizable options, such as configurable products with different colors, sizes, or materials. It is also helpful for managing tiered pricing or inventory tracking for each variation. Additionally, this function can be used to dynamically display product variations on the frontend or update inventory details in the backend.

def admin_get_product_variation():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_product.product_variations(id="PRODUCT_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response provides detailed information about the product variations, including the variation model, types, options, and available combinations. Each variation includes SKU, pricing, stock levels, images, videos, and tax information.

ProductVariationResponseDTO(
    product=ProductVariationDataDTO(
        productId=PRODUCT_ID,
        productVariation=ProductVariationDTO(
            variationModel='VARIATION_MODEL',
            types=[
                VariationTypeDTO(
                    id=VARIATION_TYPE_ID,
                    name='VARIATION_TYPE_NAME',
                    standard='VARIATION_STANDARD',
                    options=[
                        VariationOptionDTO(
                            id=VARIATION_OPTION_ID,
                            label='VARIATION_OPTION_LABEL',
                            value='VARIATION_OPTION_VALUE',
                            default=VARIATION_OPTION_DEFAULT
                        ),
                        VariationOptionDTO(
                            id=VARIATION_OPTION_ID,
                            label='VARIATION_OPTION_LABEL',
                            value='VARIATION_OPTION_VALUE',
                            default=VARIATION_OPTION_DEFAULT
                        )
                    ],
                    role=None,
                    isDisposable=None
                )
            ],
            availableCombinations=[
                AvailableCombinationDTO(
                    options=[
                        CombinationOptionDTO(
                            id=COMBINATION_OPTION_ID,
                            index=COMBINATION_OPTION_INDEX,
                            type=[
                                CombinationVariationTypeDTO(
                                    id=COMBINATION_VARIATION_TYPE_ID,
                                    name='COMBINATION_VARIATION_TYPE_NAME',
                                    standard='COMBINATION_VARIATION_STANDARD',
                                    role=None,
                                    isDisposable=COMBINATION_VARIATION_IS_DISPOSABLE
                                )
                            ],
                            label='COMBINATION_OPTION_LABEL',
                            value='COMBINATION_OPTION_VALUE',
                            colorHasSwatch=COLOR_HAS_SWATCH,
                            colorSwatchValue='COLOR_SWATCH_VALUE',
                            imageBaseUrl='IMAGE_BASE_URL'
                        )
                    ],
                    details=VariationDetailsDTO(
                        variationId=VARIATION_ID,
                        productName='PRODUCT_NAME',
                        sku='PRODUCT_SKU',
                        customSku=None,
                        urls=ProductVariationUrlsDTO(
                            url='PRODUCT_URL',
                            productUrl='PRODUCT_FULL_URL'
                        ),
                        url=None,
                        productUrl=None,
                        metaTags=[],
                        isInventoryEnabled=IS_INVENTORY_ENABLED,
                        availableStock=AVAILABLE_STOCK,
                        lowStockLevel=LOW_STOCK_LEVEL,
                        spec=None,
                        isMultipleOrderQuantity=IS_MULTIPLE_ORDER_QUANTITY,
                        isOnSale=IS_ON_SALE,
                        isExpectToPay=IS_EXPECT_TO_PAY,
                        isCallForPriceEnabled=IS_CALL_FOR_PRICE_ENABLED,
                        isNew=IS_NEW,
                        onSaleAmountType='ON_SALE_AMOUNT_TYPE',
                        title=None,
                        heading='PRODUCT_HEADING',
                        summary='PRODUCT_SUMMARY',
                        description='PRODUCT_DESCRIPTION',
                        model='PRODUCT_MODEL',
                        productCondition='PRODUCT_CONDITION',
                        basePrice=BASE_PRICE,
                        costPrice=COST_PRICE,
                        salePrice=SALE_PRICE,
                        expectToPayPrice=EXPECT_TO_PAY_PRICE,
                        weight='PRODUCT_WEIGHT',
                        height='PRODUCT_HEIGHT',
                        length='PRODUCT_LENGTH',
                        width='PRODUCT_WIDTH',
                        displayPrice=None,
                        previousPrice=None,
                        minOrderQuantity=MIN_ORDER_QUANTITY,
                        maxOrderQuantity=MAX_ORDER_QUANTITY,
                        multipleOfOrderQuantity=MULTIPLE_OF_ORDER_QUANTITY,
                        supportedMaxOrderQuantity=SUPPORTED_MAX_ORDER_QUANTITY,
                        images=[
                            ImageDataDTO(
                                id=IMAGE_ID,
                                filename=None,
                                link=None,
                                thumbnail='IMAGE_THUMBNAIL_URL',
                                url='IMAGE_URL'
                            )
                        ],
                        videos=[
                            VideoDataDTO(
                                id=VIDEO_ID,
                                filename='VIDEO_FILENAME',
                                link='VIDEO_LINK',
                                thumbnail='VIDEO_THUMBNAIL'
                            )
                        ],
                        specs=[
                            MediaDataDTO(
                                id=SPEC_ID,
                                filename='SPEC_FILENAME',
                                link='SPEC_LINK'
                            )
                        ],
                        tax=TAX_AMOUNT,
                        taxMessage='TAX_MESSAGE',
                        priceAndStock=VariationPriceAndStockDTO(
                            trackInventory=TRACK_INVENTORY,
                            availableStock=AVAILABLE_STOCK,
                            lowLevelStock=LOW_LEVEL_STOCK,
                            minimumOrderQuantity=MINIMUM_ORDER_QUANTITY,
                            maximumOrderQuantity=MAXIMUM_ORDER_QUANTITY,
                            supportedMaxOrderQuantity=SUPPORTED_MAX_ORDER_QUANTITY,
                            enableMultipleOrder=ENABLE_MULTIPLE_ORDER,
                            multipleOrderQuantity=MULTIPLE_ORDER_QUANTITY,
                            onSale=ON_SALE,
                            soldOut=SOLD_OUT,
                            soldOutLabel=None,
                            onSalePriceType='ON_SALE_PRICE_TYPE',
                            onSalePrice=ON_SALE_PRICE,
                            expectedToPay=EXPECTED_TO_PAY,
                            expectedToPayPrice=EXPECTED_TO_PAY_PRICE,
                            enableCallForPrice=ENABLE_CALL_FOR_PRICE,
                            hidePrice=HIDE_PRICE
                        )
                    )
                )
            ]
        )
    )
)

Adjusting Product Inventory

Function: adjust_inventory_product()

Purpose

This function allows administrators to adjust the inventory details of a specific product. It updates key inventory-related fields such as available stock, low stock level, minimum and maximum order quantities, and inventory tracking settings. This function is essential for maintaining accurate inventory levels and ensuring that product availability is correctly reflected in the system.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the product whose inventory is being adjusted.
trackInventoryBooleanIndicates whether inventory tracking is enabled for the product.
availableStockStringThe updated available stock level for the product.
lowLevelStockStringThe threshold at which the product is considered low in stock.
minimumOrderQuantityStringThe minimum quantity that can be ordered for the product.
maximumOrderQuantityStringThe maximum quantity that can be ordered for the product.

Use Case

This function is used when administrators need to update the inventory details of a product. It is particularly useful in scenarios such as restocking products, setting low stock alerts, or adjusting order quantity limits. For example, if a product’s stock level changes due to a new shipment, this function can be used to update the available stock. Similarly, if the business wants to enforce minimum or maximum order quantities, this function can be used to set those limits.

def adjust_inventory_product():
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        product_data = ProductInventoryCreateDTO(
            product=ProductInventoryDTO(
                productPricingAndStock=ProductInventoryPricingAndStockDTO(
                    trackInventory=BOOLEAN,
                    availableStock="AVAILABLE_STOCK",
                    lowLevelStock="LOW_LEVEL_STOCK",
                    minimumOrderQuantity="MINIMUM_ORDER_QUANTITY",
                    maximumOrderQuantity="MAXIMUM_ORDER_QUANTITY"
                )
            )
        )
        response = webcommander_sdk.admin_product.adjust_inventory(id="PRODUCT_ID", request_data=product_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response confirms whether the inventory update was successful. It returns a status and message indicating the result of the operation.

CommonMessageDTO(
    status='success',
    message='Inventory has been updated successfully'
)

Creating Product Images

Function: create_product_image()

Purpose

This function enables administrators to upload and associate multiple images with a specific product. It supports uploading images in base64 encoded format and automatically generates thumbnail versions. The function is essential for managing product media assets, allowing for visual representation of products in the e-commerce platform.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the product receiving the images
filenameStringImage file name with extension.
base64StringBase64 format of the image for upload.

Use Case

This function is used when administrators need to add new product images or update existing ones. Typical scenarios include adding product photos after initial creation, replacing outdated images, or enhancing product listings with additional visual content. The function handles multiple images in a single request, making it efficient for bulk uploads. The system automatically processes the images, storing the originals and generating optimized thumbnails for different display contexts.

def create_product_image():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        image1 = MediaAssetDTO(filename="IMAGE.jpg",
                               base64="BASE64_FORMAT_IMAGE")
        image2 = MediaAssetDTO(filename="IMAGE.jpg",
                               base64="BASE64_FORMAT_IMAGE")
        image_collection = ProductMediaCollectionDTO(images=[image1, image2], videos=[])
        media_bundle = ProductMediaBundleDTO(imageAndVideo=image_collection)
        payload = ProductImageAndVideoRequestDTO(product=media_bundle)

        response = webcommander_sdk.admin_product.create_image(id="58", request_data=payload)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response returns details of all successfully uploaded media assets, including image URLs for the original and thumbnail versions, unique identifiers for each uploaded asset, and confirmation of video and spec files if included.

ProductImageAndVideoResponseDTO(
    product=ProductMediaDTO(
        images=[
            ImageDataDTO(
                id=IMAGE_ID_1,
                filename='IMAGE_FILENAME_1',
                link='IMAGE_LINK_1',
                thumbnail='IMAGE_THUMBNAIL_1',
                url=None
            ),
            ImageDataDTO(
                id=IMAGE_ID_2,
                filename='IMAGE_FILENAME_2',
                link='IMAGE_LINK_2',
                thumbnail='IMAGE_THUMBNAIL_2',
                url=None
            )
        ],
        videos=[
            VideoDataDTO(
                id=VIDEO_ID,
                filename='VIDEO_FILENAME',
                link='VIDEO_LINK',
                thumbnail='VIDEO_THUMBNAIL'
            )
        ],
        specs=[
            MediaDataDTO(
                id=SPEC_ID,
                filename='SPEC_FILENAME',
                link='SPEC_LINK'
            )
        ]
    )
)

Deleting Product Images

Function: delete_product_image()

Purpose

This function allows administrators to remove specific images associated with a product. It permanently deletes the image from both the original and thumbnail storage locations. This function is essential for maintaining accurate product media by removing outdated, incorrect, or unwanted images while preserving other media assets associated with the product.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the product containing the image to be deleted.
image_idStringThe unique identifier of the specific image to be removed.

Use Case

This function is used when administrators need to remove individual product images while keeping the product record intact. Common scenarios include deleting incorrect product photos, removing outdated images after product updates, or cleaning up duplicate images. The function targets specific images without affecting other media assets (videos, specifications files) or product information, making it precise for media management operations.

def delete_product_image():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_product.image_delete(id="PRODUCT_ID", image_id="IMAGE_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns None with a 204 No Content status upon successful deletion, indicating the image was removed without returning any data.

Adding Product Reviews

Function: add_product_review()

Purpose

This function enables adding customer reviews to products, including textual feedback, star ratings, and supporting media attachments. It supports adding multiple reviews in a single request and automatically associates them with the specified product. This functionality helps maintain authentic customer feedback and enhances product credibility.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the product receiving the reviews
nameStringName of the customer who is providing the review.
emailStringEmail of the customer.
reviewStringReview of the product.
filenameStringImage file name with extension.
base64StringBase64 format of the image for upload.
ratingStringRating of the product.

Use Case

This function adds or imports customer reviews for products manually. Typical scenarios include migrating reviews from another system, adding verified purchase reviews, or importing professional product evaluations. The function handles multiple reviews in batch operations and supports media attachments for visual verification or demonstration of product use. It's particularly valuable for seeding initial reviews on new products or maintaining review quality standards.

def add_product_review():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True
    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        product_review_data = ProductReviewCreateDTO(
            product=ProductReviewDTO(
                reviews=[
                    ProductReviewDataDTO(
                        name="CUSTOMER_NAME",
                        email="CUSTOMER_EMAIL",
                        review="PRODUCT_REVIEW",
                        file=[
                            MediaAssetDTO(
                                filename="IMAGE.jpg",
                                base64="BASE64_IMAGE"
                            )
                        ],
                        rating=PRODUCT_RATING
                    )
                ]
            )
        )
        response = webcommander_sdk.admin_product.add_review(id="PRODUCT_ID", request_data=
                                                             product_review_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The response returns the successfully created review data, with system-generated identifiers and processed media references. The response confirms all review elements were properly stored.

ProductReviewCreateDTO(
    product=ProductReviewDTO(
        reviews=[
            ProductReviewDataDTO(
                id="REVIEW_ID",
                name='CUSTOMER_NAME',
                email='CUSTOMER_EMAIL',
                review='PRODUCT_REVIEW_TEXT',
                file=[
                    MediaAssetDTO(
                        id=MEDIA_ASSET_ID,
                        filename='MEDIA_FILENAME',
                        thumbnail='MEDIA_THUMBNAIL'
                    )
                ],
                rating=RATING_VALUE
            )
        ]
    )
)