Getting All Shipping Rules
Function: admin_shipping_rules_get_list()
Purpose
The admin_shipping_rules_get_list
function retrieves a list of all available shipping rules. This helps to fetch the complete set of shipping rules along with their associated zones, policies, and metadata.
Parameters
This function does not require any input parameters.
Use Case
Use this function when you need to retrieve and display all shipping rules. For example, it can be used to audit existing shipping rules, map rules to specific shipping profiles, or validate the rules currently applied to various shipping policies.
def admin_shipping_rules_get_list_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:
response = webcommander_sdk.admin_shipping_rules.list()
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a ShippingRulesListResponseDTO
object containing a list of ShippingRuleDTO
objects. Each ShippingRuleDTO
includes details such as the rule ID, name, associated shipping policy, shipping class, linked zones, description, creation date, and update date. The response also contains pagination details for handling large datasets.
ShippingRulesListResponseDTO(
shippingRules=[
ShippingRuleDTO(
id=PLACEHOLDER_RULE_ID,
name="PLACEHOLDER_RULE_NAME",
shippingPolicy=ShippingPolicyDTO(
id=PLACEHOLDER_POLICY_ID,
name="PLACEHOLDER_POLICY_NAME"
),
shippingClass=None,
zones=[
ShippingZoneDTO(
id=PLACEHOLDER_ZONE_ID,
name="PLACEHOLDER_ZONE_NAME"
)
],
description="PLACEHOLDER_DESCRIPTION",
createdAt="PLACEHOLDER_CREATED_AT",
updatedAt="PLACEHOLDER_UPDATED_AT"
)
],
pagination=PaginationDTO(
records=PLACEHOLDER_TOTAL_RECORDS,
limit=PLACEHOLDER_LIMIT,
offset=PLACEHOLDER_OFFSET,
nextPage="PLACEHOLDER_NEXT_PAGE",
previousPage="PLACEHOLDER_PREVIOUS_PAGE"
)
)
Getting Specific Shipping Rules
Functions: admin_shipping_rules_get_details()
Purpose
The admin_shipping_rules_get_details
function retrieves detailed information about a specific shipping rule. This allows you to access the full configuration and metadata for a particular shipping rule by providing its unique identifier.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the product. |
Use Case
Use this function when you need to fetch the detailed information for a specific shipping rule. This can be helpful for auditing, editing, or verifying rule configurations, including associated zones, policies, and descriptions.
def admin_shipping_rules_get_details_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:
id = 'PLACEHOLDER_RULE_ID'
response = webcommander_sdk.admin_shipping_rules.details(id=id)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a ShippingRulesDetailsResponseDTO
object containing a ShippingRuleDTO
. This object provides details such as the rule ID, name, associated shipping policy, shipping class, zones, description, and timestamps for creation and last update.
ShippingRulesDetailsResponseDTO(
shippingRule=ShippingRuleDTO(
id=PLACEHOLDER_RULE_ID,
name="PLACEHOLDER_RULE_NAME",
shippingPolicy=ShippingPolicyDTO(
id=PLACEHOLDER_POLICY_ID,
name="PLACEHOLDER_POLICY_NAME"
),
shippingClass=None,
zones=[
ShippingZoneDTO(
id=PLACEHOLDER_ZONE_ID,
name="PLACEHOLDER_ZONE_NAME"
)
],
description="PLACEHOLDER_DESCRIPTION",
createdAt="PLACEHOLDER_CREATED_AT",
updatedAt="PLACEHOLDER_UPDATED_AT"
)
)
Creating Specific Shipping Rules
Functions: admin_create_shipping_rules()
Purpose
The admin_create_shipping_rules
function is designed to create a new shipping rule. This allows you to define the rule's properties, including its name, type, class, description, and whether to use an existing rule or create a new one.
Parameters
Parameter | Type | Description |
---|---|---|
name | String | The unique name of the tax profiles. |
Use Case
Use this function when you need to create a new shipping rule in the system. This is helpful when setting up new shipping configurations, customizing delivery methods, or copying existing rules for modification.
def admin_create_shipping_rules_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 = ShippingRuleRequestDTO(
shippingRule=ShippingRuleRequestDataDTO(
type=ShippingRuleTypeDTO(
create=False,
useExisting=True
),
apply=ShippingRuleOptionDTO(
type="enum",
choices=["PLACEHOLDER_APPLY_CHOICE_1", "PLACEHOLDER_APPLY_CHOICE_2"],
value="PLACEHOLDER_APPLY_VALUE"
),
rule=ShippingRuleOptionDTO(
type="enum",
choices=["PLACEHOLDER_RULE_CHOICE_1", "PLACEHOLDER_RULE_CHOICE_2"],
value="PLACEHOLDER_RULE_VALUE"
),
name="PLACEHOLDER_RULE_NAME",
className=ShippingRuleOptionDTO(
type="enum",
choices=["PLACEHOLDER_CLASS_CHOICE_1", "PLACEHOLDER_CLASS_CHOICE_2"],
value="PLACEHOLDER_CLASS_VALUE"
),
description="PLACEHOLDER_DESCRIPTION"
)
)
response = webcommander_sdk.admin_shipping_rules.create_shipping_profiles(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 ShippingRulesDetailsResponseDTO
object containing a ShippingRuleDTO
. This object provides details about the newly created shipping rule, including its ID, name, associated policy, shipping class, zones, description, and timestamps for creation and last update.
ShippingRulesDetailsResponseDTO(
shippingRule=ShippingRuleDTO(
id=PLACEHOLDER_RULE_ID,
name="PLACEHOLDER_RULE_NAME",
shippingPolicy=ShippingPolicyDTO(
id=PLACEHOLDER_POLICY_ID,
name="PLACEHOLDER_POLICY_NAME"
),
shippingClass=ShippingClassDTO(
id=PLACEHOLDER_CLASS_ID,
name="PLACEHOLDER_CLASS_NAME"
),
zones=[
ShippingZoneDTO(
id=PLACEHOLDER_ZONE_ID,
name="PLACEHOLDER_ZONE_NAME"
)
],
description="PLACEHOLDER_DESCRIPTION",
createdAt="PLACEHOLDER_CREATED_AT",
updatedAt="PLACEHOLDER_UPDATED_AT"
)
)
Updating Specific Shipping Rules
Functions: admin_update_shipping_rules()
Purpose
The admin_update_shipping_rules
function updates the details of an existing shipping rule. This allows modification of key attributes such as the rule name, class, application method, and description.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the tax profiles. |
Use Case
Use this function when you need to update the properties of a shipping rule. This is helpful for adjusting existing shipping policies, changing rule names, or updating the shipping class to meet new business requirements.
def admin_update_shipping_rules_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 = ShippingRuleUpdateRequestDTO(
shippingRule=ShippingRuleUpdateRequestDataDTO(
apply="PLACEHOLDER_APPLY_VALUE",
rule="PLACEHOLDER_RULE_VALUE",
name="PLACEHOLDER_RULE_NAME",
className="PLACEHOLDER_CLASS_NAME",
description="PLACEHOLDER_DESCRIPTION"
)
)
id = "PLACEHOLDER_RULE_ID"
response = webcommander_sdk.admin_shipping_rules.update_shipping_profiles(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 a ShippingRulesDetailsResponseDTO
object containing a ShippingRuleDTO
. This object provides updated information about the shipping rule, including its ID, name, associated policy, shipping class, zones, description, and timestamps for creation and last update.
ShippingRulesDetailsResponseDTO(
shippingRule=ShippingRuleDTO(
id=PLACEHOLDER_RULE_ID,
name="PLACEHOLDER_RULE_NAME",
shippingPolicy=ShippingPolicyDTO(
id=PLACEHOLDER_POLICY_ID,
name="PLACEHOLDER_POLICY_NAME"
),
shippingClass=ShippingClassDTO(
id=PLACEHOLDER_CLASS_ID,
name="PLACEHOLDER_CLASS_NAME"
),
zones=[
ShippingZoneDTO(
id=PLACEHOLDER_ZONE_ID,
name="PLACEHOLDER_ZONE_NAME"
)
],
description="PLACEHOLDER_DESCRIPTION",
createdAt="PLACEHOLDER_CREATED_AT",
updatedAt="PLACEHOLDER_UPDATED_AT"
)
)
Deleting a Shipping Rules
Function: admin_delete_shipping_rules()
Purpose
The admin_delete_shipping_rules
function deletes an existing shipping rule by its unique identifier. This allows the removal of obsolete or incorrect shipping rules from the system.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The unique identifier of the blog post to be deleted. |
Use Case
Use this function when you need to permanently delete a shipping rule. This is useful for cleaning up outdated rules, removing duplicate entries, or managing policy changes.
def admin_delete_shipping_rules_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:
id = "PLACEHOLDER_RULE_ID"
response = webcommander_sdk.admin_shipping_rules.delete_shipping_rules(id=id)
print(response)
except WCException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
Response
The function returns a simple success message confirming the deletion of the specified shipping rule. No additional data is provided in the response.