Getting Discount List

Function: admin_discount_get_list()

Purpose

The admin_discount_get_list() function retrieves a list of all discounts configured in the WebCommander system. It enables administrators to view current discount campaigns, including coupons, promotional offers, and automatic discounts. This function helps in managing and analyzing discount strategies by providing visibility into their configuration and status. It uses the WebCommander SDK to securely access the API and returns structured data about all available discounts. Debugging outputs are enabled to assist with testing and troubleshooting.

Parameters

This function does not require any input parameters.

Use Case

This function is useful for marketing managers, store admins, and support teams who need access to discount data for operational or strategic purposes. A store admin may use it to review all active discounts before launching a new campaign to avoid conflicts or duplication. Marketing teams can evaluate which promotions are currently running or expired to adjust their future plans.

Customer service representatives can also refer to this list to verify the terms of a coupon code a customer has inquired about. During seasonal sales, administrators can monitor and validate discount settings in real-time. This function supports transparency and consistency across teams managing pricing and promotion activities.

def admin_discount_get_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_discount.list()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

A successful response provides a list of discount records, each containing information such as discount ID, title, type (e.g., coupon or automatic), value, usage limits, active dates, and current status. This data helps teams understand what promotions are available, how they are structured, and whether they are currently active.

If the request fails due to authorization issues, internal errors, or network problems, the function captures and prints the error response, including a description of the failure, making it easier to debug and resolve.

DiscountsListDTO(
    discounts=[
        DiscountDataDTO(
            id="DISCOUNT_ID_1",
            name="DISCOUNT_NAME_1",
            type="DISCOUNT_TYPE_1",
            isActive="IS_ACTIVE_1",
            isSpecifyEndDate="IS_SPECIFY_END_DATE_1",
            startFrom="START_FROM_1",
            startTo="START_TO_1",
            detailsId="DETAILS_ID_1",
            details=DiscountDetailsDTO(
                amountType="AMOUNT_TYPE_1",
                singleAmountType="SINGLE_AMOUNT_TYPE_1",
                tiers=[],
                minimumQty="MINIMUM_QTY_1",
                singleAmount="SINGLE_AMOUNT_1",
                capAmount="CAP_AMOUNT_1",
                type="DISCOUNT_DETAILS_TYPE_1",
                applyTo="APPLY_TO_1",
                minimumQtyOn="MINIMUM_QTY_ON_1",
                maximumTime="MAXIMUM_TIME_1",
                zone="ZONE_1",
                minimumAmount="MINIMUM_AMOUNT_1",
                minimumAmountOn="MINIMUM_AMOUNT_ON_1",
                id="DETAILS_ID_1",
                shippingClass="SHIPPING_CLASS_1"
            ),
            isCouponCodeAutoGenerate="IS_AUTO_GENERATE_1",
            isApplyCouponCode="IS_APPLY_COUPON_1",
            isExcludeProductsOnSale="IS_EXCLUDE_ON_SALE_1",
            assoc="ASSOC_1",
            customerCoupons=[],
            coupon="COUPON_ID_1",
            defaultCouponCode="DEFAULT_COUPON_CODE_1",
            isMaximumUseTotal="IS_MAX_USE_TOTAL_1",
            isMaximumUseCustomer="IS_MAX_USE_CUSTOMER_1",
            isMaximumDiscountAllowed="IS_MAX_DISCOUNT_ALLOWED_1",
            maximumDiscountAllowedAmount="MAX_DISCOUNT_ALLOWED_AMOUNT_1",
            maximumUseCount="MAX_USE_COUNT_1",
            maximumUseCustomerCount="MAX_USE_CUSTOMER_COUNT_1",
            discountDetailsType="DISCOUNT_DETAILS_TYPE_1",
            isDisplayDiscountInformationProdDetail="DISPLAY_ON_PROD_DETAIL_1",
            isCreateUniqueCouponEachCustomer="IS_UNIQUE_COUPON_EACH_CUSTOMER_1",
            isDiscountUsedWithOtherDiscount="IS_USED_WITH_OTHERS_1",
            excludeProducts=[],
            displayTextCoupon="DISPLAY_TEXT_COUPON_1",
            displayTextPartialDiscountCondition="DISPLAY_TEXT_PARTIAL_CONDITION_1",
            displayTextCart="DISPLAY_TEXT_CART_1",
            isDisplayTextCoupon="IS_DISPLAY_TEXT_COUPON_1",
            isDisplayTextPartialDiscountCondition="IS_DISPLAY_TEXT_PARTIAL_CONDITION_1",
            isDisplayTextCart="IS_DISPLAY_TEXT_CART_1",
            isImportedCoupon="IS_IMPORTED_1",
            usage=[]
        ),
        DiscountDataDTO(
            id="DISCOUNT_ID_2",
            name="DISCOUNT_NAME_2",
            type="DISCOUNT_TYPE_2",
            isActive="IS_ACTIVE_2",
            isSpecifyEndDate="IS_SPECIFY_END_DATE_2",
            startFrom="START_FROM_2",
            startTo="START_TO_2",
            detailsId="DETAILS_ID_2",
            details=DiscountDetailsDTO(
                amountType="AMOUNT_TYPE_2",
                singleAmountType="SINGLE_AMOUNT_TYPE_2",
                tiers=[],
                minimumQty="MINIMUM_QTY_2",
                singleAmount="SINGLE_AMOUNT_2",
                capAmount="CAP_AMOUNT_2",
                type="DISCOUNT_DETAILS_TYPE_2",
                applyTo="APPLY_TO_2",
                minimumQtyOn="MINIMUM_QTY_ON_2",
                maximumTime="MAXIMUM_TIME_2",
                zone="ZONE_2",
                minimumAmount="MINIMUM_AMOUNT_2",
                minimumAmountOn="MINIMUM_AMOUNT_ON_2",
                id="DETAILS_ID_2",
                shippingClass="SHIPPING_CLASS_2"
            ),
            isCouponCodeAutoGenerate="IS_AUTO_GENERATE_2",
            isApplyCouponCode="IS_APPLY_COUPON_2",
            isExcludeProductsOnSale="IS_EXCLUDE_ON_SALE_2",
            assoc="ASSOC_2",
            customerCoupons=[],
            coupon="COUPON_ID_2",
            defaultCouponCode="DEFAULT_COUPON_CODE_2",
            isMaximumUseTotal="IS_MAX_USE_TOTAL_2",
            isMaximumUseCustomer="IS_MAX_USE_CUSTOMER_2",
            isMaximumDiscountAllowed="IS_MAX_DISCOUNT_ALLOWED_2",
            maximumDiscountAllowedAmount="MAX_DISCOUNT_ALLOWED_AMOUNT_2",
            maximumUseCount="MAX_USE_COUNT_2",
            maximumUseCustomerCount="MAX_USE_CUSTOMER_COUNT_2",
            discountDetailsType="DISCOUNT_DETAILS_TYPE_2",
            isDisplayDiscountInformationProdDetail="DISPLAY_ON_PROD_DETAIL_2",
            isCreateUniqueCouponEachCustomer="IS_UNIQUE_COUPON_EACH_CUSTOMER_2",
            isDiscountUsedWithOtherDiscount="IS_USED_WITH_OTHERS_2",
            excludeProducts=[],
            displayTextCoupon="DISPLAY_TEXT_COUPON_2",
            displayTextPartialDiscountCondition="DISPLAY_TEXT_PARTIAL_CONDITION_2",
            displayTextCart="DISPLAY_TEXT_CART_2",
            isDisplayTextCoupon="IS_DISPLAY_TEXT_COUPON_2",
            isDisplayTextPartialDiscountCondition="IS_DISPLAY_TEXT_PARTIAL_CONDITION_2",
            isDisplayTextCart="IS_DISPLAY_TEXT_CART_2",
            isImportedCoupon="IS_IMPORTED_2",
            usage=[]
        )
    ]
)

Getting specific Discount information

Function: admin_discount_get_info()

Purpose

The admin_discount_get_info() function is used to retrieve detailed information about a specific discount in the WebCommander system by its unique ID. This allows administrators to view the complete configuration of a discount, including its type, value, conditions, usage limits, validity period, and status. The function helps ensure accuracy in discount management and supports tasks like reviewing or modifying active promotions. It uses the WebCommander SDK to securely interact with the API, and debugging is enabled to assist with testing and diagnostics.

Parameters

Parameter
Type
Description
id
string
The unique identifier of the discount whose details are to be retrieved.

Use Case

This function is useful when an administrator or marketing manager needs to review the specifics of a discount campaign. For instance, before updating or duplicating a discount, an admin may call this function to check the current configuration. It can also be used to verify the conditions attached to a discount if a customer or support staff raises a query.

def admin_discount_get_info():
    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_discount.info(id="DISCOUNT_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

A successful response provides complete details of the requested discount, including its ID, title, description, type (e.g. coupon or automatic), value and value type, applicable products or categories, activation period, and current status. This data helps administrators understand and manage the discount effectively.

DiscountInfoDTO(
    discount=DiscountDataDTO(
        id="DISCOUNT_ID",
        name="DISCOUNT_NAME",
        type="DISCOUNT_TYPE",
        isActive="IS_ACTIVE",
        isSpecifyEndDate="IS_SPECIFY_END_DATE",
        startFrom="START_FROM",
        startTo="START_TO",
        detailsId="DETAILS_ID",
        details=DiscountDetailsDTO(
            amountType="AMOUNT_TYPE",
            singleAmountType="SINGLE_AMOUNT_TYPE",
            tiers=[],
            minimumQty="MINIMUM_QTY",
            singleAmount="SINGLE_AMOUNT",
            capAmount="CAP_AMOUNT",
            type="DISCOUNT_DETAIL_TYPE",
            applyTo="APPLY_TO",
            minimumQtyOn="MINIMUM_QTY_ON",
            maximumTime="MAXIMUM_TIME",
            zone="ZONE",
            minimumAmount="MINIMUM_AMOUNT",
            minimumAmountOn="MINIMUM_AMOUNT_ON",
            id="DETAILS_ID",
            shippingClass="SHIPPING_CLASS"
        ),
        isCouponCodeAutoGenerate="IS_AUTO_GENERATE",
        isApplyCouponCode="IS_APPLY_COUPON",
        isExcludeProductsOnSale="IS_EXCLUDE_ON_SALE",
        assoc="ASSOC_ID",
        customerCoupons=[],
        coupon="COUPON_ID",
        defaultCouponCode="DEFAULT_COUPON_CODE",
        isMaximumUseTotal="IS_MAX_USE_TOTAL",
        isMaximumUseCustomer="IS_MAX_USE_CUSTOMER",
        isMaximumDiscountAllowed="IS_MAX_DISCOUNT_ALLOWED",
        maximumDiscountAllowedAmount="MAX_DISCOUNT_ALLOWED_AMOUNT",
        maximumUseCount="MAX_USE_COUNT",
        maximumUseCustomerCount="MAX_USE_CUSTOMER_COUNT",
        discountDetailsType="DISCOUNT_DETAILS_TYPE",
        isDisplayDiscountInformationProdDetail="DISPLAY_ON_PROD_DETAIL",
        isCreateUniqueCouponEachCustomer="IS_UNIQUE_COUPON_EACH_CUSTOMER",
        isDiscountUsedWithOtherDiscount="IS_USED_WITH_OTHERS",
        excludeProducts=[],
        displayTextCoupon="DISPLAY_TEXT_COUPON",
        displayTextPartialDiscountCondition="DISPLAY_TEXT_PARTIAL_CONDITION",
        displayTextCart="DISPLAY_TEXT_CART",
        isDisplayTextCoupon="IS_DISPLAY_TEXT_COUPON",
        isDisplayTextPartialDiscountCondition="IS_DISPLAY_TEXT_PARTIAL_CONDITION",
        isDisplayTextCart="IS_DISPLAY_TEXT_CART",
        isImportedCoupon="IS_IMPORTED",
        usage=[]
    )
)

Delete Discount Profile

Function: admin_discount_delete()

Purpose

The admin_discount_delete()function is used to permanently delete a specific discount from the WebCommander system using its unique ID. It is intended for administrative use when a discount is no longer valid, needed, or was created in error. This helps maintain a clean and accurate list of active promotions and ensures outdated or conflicting discounts do not remain in the system. The function securely executes an API call through the WebCommander SDK, and debugging is enabled to provide visibility into the request and response for testing and audit purposes.

Parameters

Parameter
Type
Description
id
string
The unique identifier of the discount to be deleted.

Use Case

This function is useful when an administrator needs to remove a discount campaign that has expired, is incorrect, or conflicts with current promotions. For example, after a limited-time offer has ended, the associated discount can be deleted to prevent misuse. If a duplicate or incorrectly configured discount was added, this function allows for its immediate removal to preserve system accuracy.

It also helps ensure customers and staff are only presented with valid discounts during checkout or promotional activities. Deleting unused or inactive discounts also contributes to better performance and organization of marketing assets in the system.

def admin_discount_delete():
    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_discount.delete(id="DISCOUNT_ID")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

If the discount is successfully deleted, the response confirms the removal. The discount is no longer available in the system and cannot be applied to future transactions. If the provided ID does not exist or the discount is linked to active orders or constraints that prevent deletion, an error is returned.

Request was successful, but there is no content to display.