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.
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 a 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.
Add a New Discount
Function: admin_discount_create()
Purpose
The admin_discount_create()
function is designed to create a new discount entry in the system. It allows configuring various properties of the discount, including the discount amount, usage limits, coupon code behavior, and product/customer applicability.
Parameters
This function does not require any input parameters.
Use Case
The function can be used when you want to programmatically add a discount to your platform. It is useful for setting up promotional offers, customer-specific discounts, or time-bound discount campaigns with detailed configuration options.
def admin_discount_create():
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:
discount_data = DiscountCreateDataDTO(
name="PLACEHOLDER_NAME",
isActive="PLACEHOLDER_IS_ACTIVE",
startDate="PLACEHOLDER_START_DATE",
isSpecifyEndDate="PLACEHOLDER_IS_SPECIFY_END_DATE",
endDate="PLACEHOLDER_END_DATE",
type="PLACEHOLDER_TYPE",
isExcludeProductsOnSale=PLACEHOLDER_IS_EXCLUDE_PRODUCTS_ON_SALE,
isUsedWithOtherDiscounts=PLACEHOLDER_IS_USED_WITH_OTHER_DISCOUNTS,
isMaximumUseLimit="PLACEHOLDER_IS_MAXIMUM_USE_LIMIT",
maximumUseLimit="PLACEHOLDER_MAXIMUM_USE_LIMIT",
isMaximumUseLimitByCustomer="PLACEHOLDER_IS_MAXIMUM_USE_LIMIT_BY_CUSTOMER",
maximumUseLimitByCustomer="PLACEHOLDER_MAXIMUM_USE_LIMIT_BY_CUSTOMER",
isMaximumDiscountAllowed="PLACEHOLDER_IS_MAXIMUM_DISCOUNT_ALLOWED",
maximumDiscountAllowed="PLACEHOLDER_MAXIMUM_DISCOUNT_ALLOWED",
isApplyCouponCode="PLACEHOLDER_IS_APPLY_COUPON_CODE",
isCouponCodeAutoGenerated="PLACEHOLDER_IS_COUPON_CODE_AUTO_GENERATED",
defaultCouponCode="PLACEHOLDER_DEFAULT_COUPON_CODE",
isUniqueCouponCode=PLACEHOLDER_IS_UNIQUE_COUPON_CODE,
uniqueCouponCode=PLACEHOLDER_UNIQUE_COUPON_CODE,
isAppliedToAllCustomer="PLACEHOLDER_IS_APPLIED_TO_ALL_CUSTOMER",
customers=[],
isAppliedToAllProducts="PLACEHOLDER_IS_APPLIED_TO_ALL_PRODUCTS",
products=[],
discountDetailsType="PLACEHOLDER_DISCOUNT_DETAILS_TYPE",
amountDetails=DiscountAmountDetailsDTO(
applyTo="PLACEHOLDER_APPLY_TO",
type="PLACEHOLDER_TYPE",
singleAmount=PLACEHOLDER_SINGLE_AMOUNT,
singleAmountType="PLACEHOLDER_SINGLE_AMOUNT_TYPE"
)
)
response = webcommander_sdk.admin_discount.create(request_data=discount_data)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a DiscountInfoDTO
containing the full details of the newly created discount, such as discount ID, name, type, coupon configuration, applicable products/customers, and discount amount details.
DiscountInfoDTO(
discount=DiscountDataDTO(
id=PLACEHOLDER_ID,
name="PLACEHOLDER_NAME",
type="PLACEHOLDER_TYPE",
isActive=PLACEHOLDER_IS_ACTIVE,
isSpecifyEndDate=PLACEHOLDER_IS_SPECIFY_END_DATE,
startFrom="PLACEHOLDER_START_FROM",
startTo="PLACEHOLDER_START_TO",
detailsId=PLACEHOLDER_DETAILS_ID,
details=DiscountDetailsDTO(
amountType="PLACEHOLDER_AMOUNT_TYPE",
singleAmountType="PLACEHOLDER_SINGLE_AMOUNT_TYPE",
tiers=[],
minimumQty=PLACEHOLDER_MINIMUM_QTY,
singleAmount=PLACEHOLDER_SINGLE_AMOUNT,
capAmount=PLACEHOLDER_CAP_AMOUNT,
type="PLACEHOLDER_DETAILS_TYPE",
applyTo="PLACEHOLDER_APPLY_TO",
minimumQtyOn="PLACEHOLDER_MINIMUM_QTY_ON",
maximumTime="PLACEHOLDER_MAXIMUM_TIME",
zone="PLACEHOLDER_ZONE",
minimumAmount="PLACEHOLDER_MINIMUM_AMOUNT",
minimumAmountOn="PLACEHOLDER_MINIMUM_AMOUNT_ON",
id=PLACEHOLDER_DETAIL_ID,
shippingClass="PLACEHOLDER_SHIPPING_CLASS"
),
isCouponCodeAutoGenerate=PLACEHOLDER_IS_COUPON_CODE_AUTO_GENERATE,
isApplyCouponCode=PLACEHOLDER_IS_APPLY_COUPON_CODE,
isExcludeProductsOnSale=PLACEHOLDER_IS_EXCLUDE_PRODUCTS_ON_SALE,
assoc=PLACEHOLDER_ASSOC,
customerCoupons=[],
coupon=PLACEHOLDER_COUPON_ID,
defaultCouponCode="PLACEHOLDER_DEFAULT_COUPON_CODE",
isMaximumUseTotal=PLACEHOLDER_IS_MAXIMUM_USE_TOTAL,
isMaximumUseCustomer=PLACEHOLDER_IS_MAXIMUM_USE_CUSTOMER,
isMaximumDiscountAllowed=PLACEHOLDER_IS_MAXIMUM_DISCOUNT_ALLOWED,
maximumDiscountAllowedAmount=PLACEHOLDER_MAXIMUM_DISCOUNT_ALLOWED_AMOUNT,
maximumUseCount=PLACEHOLDER_MAXIMUM_USE_COUNT,
maximumUseCustomerCount=PLACEHOLDER_MAXIMUM_USE_CUSTOMER_COUNT,
discountDetailsType="PLACEHOLDER_DISCOUNT_DETAILS_TYPE",
isDisplayDiscountInformationProdDetail=PLACEHOLDER_IS_DISPLAY_DISCOUNT_INFORMATION_PROD_DETAIL,
isCreateUniqueCouponEachCustomer=PLACEHOLDER_IS_CREATE_UNIQUE_COUPON_EACH_CUSTOMER,
isDiscountUsedWithOtherDiscount=PLACEHOLDER_IS_DISCOUNT_USED_WITH_OTHER_DISCOUNT,
excludeProducts=[],
displayTextCoupon="PLACEHOLDER_DISPLAY_TEXT_COUPON",
displayTextPartialDiscountCondition="PLACEHOLDER_DISPLAY_TEXT_PARTIAL_DISCOUNT_CONDITION",
displayTextCart="PLACEHOLDER_DISPLAY_TEXT_CART",
isDisplayTextCoupon=PLACEHOLDER_IS_DISPLAY_TEXT_COUPON,
isDisplayTextPartialDiscountCondition=PLACEHOLDER_IS_DISPLAY_TEXT_PARTIAL_DISCOUNT_CONDITION,
isDisplayTextCart=PLACEHOLDER_IS_DISPLAY_TEXT_CART,
isImportedCoupon=PLACEHOLDER_IS_IMPORTED_COUPON,
usage=[]
)
)
Updating Specific Discount Profile Coupons
Functions: admin_create_discount_profile_coupons()
Purpose
The admin_create_discount_profile_coupons()
function is used to generate a specified number of discount coupon codes for an existing discount profile.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the tax profiles. |
Use Case
This function can be used when you need to create a batch of new discount codes under a specific discount profile, for promotions, marketing campaigns, or special sales events.
def admin_create_discount_profile_coupons():
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 = DiscountProfileCouponsRequestDTO(requestedCodes="PLACEHOLDER_REQUESTED_CODES")
discount_profile_id = PLACEHOLDER_DISCOUNT_PROFILE_ID
response = webcommander_sdk.admin_discount.create_discount_profile_coupons(discount_profile_id=discount_profile_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.
DiscountProfilesCouponsResponseDTO(
status="PLACEHOLDER_STATUS",
message="PLACEHOLDER_MESSAGE",
codes=[
"PLACEHOLDER_CODE_1",
"PLACEHOLDER_CODE_2",
"PLACEHOLDER_CODE_3",
"PLACEHOLDER_CODE_4",
"PLACEHOLDER_CODE_5"
]
)
Updating Specific Discount Profile
Functions: admin_discount_update()
Purpose
The admin_discount_update()
function is used to update the configuration of an existing discount in the system by providing updated discount details such as name, validity dates, usage limits, coupon code settings, and discount application rules.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the tax profiles. |
Use Case
This function can be used when you want to modify an existing discount’s settings—such as activating or deactivating it, changing how it’s applied (e.g., by customer or product), adjusting the amount or type of discount, or updating coupon code rules for an ongoing promotion.
def admin_discount_update_test():
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:
discount_data = DiscountCreateDataDTO(
name="PLACEHOLDER_DISCOUNT_NAME",
isActive="PLACEHOLDER_IS_ACTIVE",
startDate="PLACEHOLDER_START_DATE",
isSpecifyEndDate="PLACEHOLDER_IS_SPECIFY_END_DATE",
endDate="PLACEHOLDER_END_DATE",
type="PLACEHOLDER_DISCOUNT_TYPE",
isExcludeProductsOnSale=PLACEHOLDER_IS_EXCLUDE_PRODUCTS_ON_SALE,
isUsedWithOtherDiscounts=PLACEHOLDER_IS_USED_WITH_OTHER_DISCOUNTS,
isMaximumUseLimit="PLACEHOLDER_IS_MAX_USE_LIMIT",
maximumUseLimit="PLACEHOLDER_MAX_USE_LIMIT",
isMaximumUseLimitByCustomer="PLACEHOLDER_IS_MAX_USE_LIMIT_BY_CUSTOMER",
maximumUseLimitByCustomer="PLACEHOLDER_MAX_USE_LIMIT_BY_CUSTOMER",
isMaximumDiscountAllowed="PLACEHOLDER_IS_MAX_DISCOUNT_ALLOWED",
maximumDiscountAllowed="PLACEHOLDER_MAX_DISCOUNT_ALLOWED",
isApplyCouponCode="PLACEHOLDER_IS_APPLY_COUPON_CODE",
isCouponCodeAutoGenerated="PLACEHOLDER_IS_COUPON_AUTO_GENERATED",
defaultCouponCode="PLACEHOLDER_DEFAULT_COUPON_CODE",
isUniqueCouponCode=PLACEHOLDER_IS_UNIQUE_COUPON_CODE,
uniqueCouponCode=PLACEHOLDER_UNIQUE_COUPON_CODE,
isAppliedToAllCustomer="PLACEHOLDER_IS_APPLIED_TO_ALL_CUSTOMERS",
customers=[],
isAppliedToAllProducts="PLACEHOLDER_IS_APPLIED_TO_ALL_PRODUCTS",
products=[],
discountDetailsType="PLACEHOLDER_DISCOUNT_DETAILS_TYPE",
amountDetails=DiscountAmountDetailsDTO(
applyTo="PLACEHOLDER_APPLY_TO",
type="PLACEHOLDER_AMOUNT_TYPE",
singleAmount=PLACEHOLDER_SINGLE_AMOUNT,
singleAmountType="PLACEHOLDER_AMOUNT_VALUE_TYPE"
)
)
response = webcommander_sdk.admin_discount.update(id="PLACEHOLDER_DISCOUNT_ID", request_data=discount_data)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a DiscountInfoDTO
object containing the updated details of the discount, including its type, activity status, conditions, usage limits, coupon settings, and associated configurations.
DiscountInfoDTO(
discount=DiscountDataDTO(
id=PLACEHOLDER_DISCOUNT_ID,
name="PLACEHOLDER_DISCOUNT_NAME",
type="PLACEHOLDER_DISCOUNT_TYPE",
isActive=True,
isSpecifyEndDate=True,
startFrom="PLACEHOLDER_START_FROM",
startTo="PLACEHOLDER_END_TO",
detailsId=PLACEHOLDER_DETAILS_ID,
details=DiscountDetailsDTO(
singleAmount=PLACEHOLDER_SINGLE_AMOUNT,
type="PLACEHOLDER_AMOUNT_TYPE",
singleAmountType="PLACEHOLDER_AMOUNT_VALUE_TYPE",
applyTo="PLACEHOLDER_APPLY_TO",
id=PLACEHOLDER_DETAILS_ID
),
defaultCouponCode="PLACEHOLDER_DEFAULT_COUPON_CODE",
isApplyCouponCode=True,
isMaximumUseTotal=True,
isMaximumUseCustomer=True,
isMaximumDiscountAllowed=True,
maximumDiscountAllowedAmount=PLACEHOLDER_MAX_DISCOUNT_ALLOWED,
maximumUseCount=PLACEHOLDER_MAX_USE_LIMIT,
maximumUseCustomerCount=PLACEHOLDER_MAX_USE_LIMIT_BY_CUSTOMER
)
)
Assigning Discount Coupons
Function: admin_assign_discount_profile_coupons()
Purpose
The admin_assign_discount_profile_coupons()
function is used to assign an existing discount coupon code to a specific customer by email.
Parameters
This function does not require any input parameters.
Use Case
Use this function when a generated discount code needs to be explicitly linked to a customer, typically for targeted promotions or user-specific benefits.
def admin_assign_discount_profile_coupons_test():
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 = DiscountProfileCouponAssignRequestDTO(
code="PLACEHOLDER_COUPON_CODE",
email="PLACEHOLDER_CUSTOMER_EMAIL"
)
response = webcommander_sdk.admin_discount.assign_discount_profile_coupons(request_data=request_data)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a DiscountProfilesCouponsResponseDTO
containing a status
, a message
indicating the result of the assignment, and optionally the assigned codes
(which may be None
if not returned).
DiscountProfilesCouponsResponseDTO(
status="PLACEHOLDER_STATUS",
message="PLACEHOLDER_ASSIGNMENT_MESSAGE",
codes=None
)