put https://{subdomain}.myshoplaza.com/openapi/2022-01/price_rules/
Requires
price_rules
access scope. More access scope
The Update Price Rule API allows for the modification of an existing price rule by specifying its ID and the new parameters.
This API is especially useful for:
- Updating discounts or offers applied to products.
- Modifying the conditions or scope of a specific price rule.
- Adjusting the effective duration of price rules.
Request Parameters
Public Request Parameters
Path Parameters
Field | Type | Required | Example | Description |
---|---|---|---|---|
price_rule_id | string | Yes | 91f9a466-7c8c-46e7-9774-64874a641534 | Price rule ID. |
Body Parameters
Field | Type | Required | Example | Description |
---|---|---|---|---|
title | string | Yes | "Discount Rule Title" | Title of this price rule. |
value | double | Yes | 50.25 | Value for this discount. |
value_type | string | Yes | "fixed_amount" | Discount type. Options: fixed_amount for a fixed discount, or percentage for a percentage discount. |
usage_limit | int32 | No | -1 | The usage limit. -1 means no limit. |
allocation_limit | int32 | No | 0 | Redeem count limit per checkout: 0 means only one redeem allowed, 999 means no limit. |
once_per_customer | int32 | No | 1 | Maximum usage per customer. -1 or 0 means no limit. |
prerequisite | int32 | No | 1 | Indicates if this discount has prerequisites. 1 means yes, 0 means no. |
target_selection | string | Yes | "entitled" | Target products allowed for this discount. Options: all for all products, entitled for specific products. |
target_type | string | No | "line_item" | Target type of this discount. |
starts_at | string | Yes | "2024-12-01T00:00:00Z" | Start time of the discount. |
ends_at | string | Yes | "2024-12-31T23:59:59Z" | End time of the discount. |
entitled_product_ids | array[string] | No | ["ce21d85-a419-4d4e-a17d-5bddbc4ab7f6", "de2c55f5-3c81-45e1-9276-e65faf816ecc"] | Specifies the product IDs allowed for the price rule. Required only when target_selection is entitled . |
entitled_variant_ids | array[string] | No | ["ce21d85-a419-4d4e-a17d-5bddbc4ab7f6"] | Specifies the product variant IDs allowed for the price rule. |
prerequisite_subtotal_range | array[object] | No | [{"greater_than_or_equal_to":"100","value":"10"}] | Prerequisite for total amount in the cart. |
prerequisite_subtotal_range.greater_than_or_equal_to | string | Yes | "100" | Specifies the minimum total cart amount required. |
prerequisite_subtotal_range.value | string | Yes | "10" | Value used for discount application. |
prerequisite_subtotal_range.target_type | string | No | "" | Specifies the type of target the rule applies to. |
prerequisite_subtotal_range.target_data | array[string] | No | [] | Specifies IDs of specific target items for the rule. |
prerequisite_quantity_range | array[object] | No | [{"greater_than_or_equal_to":"5","value":"20"}] | Prerequisite for total quantity of products in the cart. |
prerequisite_quantity_range.greater_than_or_equal_to | string | Yes | "5" | Specifies the minimum total product quantity required. |
prerequisite_quantity_range.value | string | Yes | "20" | Value used for discount application. |
prerequisite_quantity_range.target_type | string | No | "" | Specifies the type of target the rule applies to. |
prerequisite_quantity_range.target_data | array[string] | No | [] | Specifies IDs of specific target items for the rule. |
Response Explanation
Public Response Parameters
Successful Response
Field | Type | Description | Example |
---|---|---|---|
price_rule | object | Object containing details about the created price rule. | See fields below. |
price_rule.id | string | Unique identifier of the price rule. | "2d7e416a-444f-4491-ae04-c50f47154140" |
price_rule.title | string | Title of this price rule. | "Buy 2 Get 1 Free" |
price_rule.value | double | Value of the discount. | 10.5 |
price_rule.value_type | string | Type of the discount value. Options: percentage , fixed_amount . | "fixed_amount" |
price_rule.usage_limit | string | Maximum number of times the discount can be used. -1 means no limit. | "100" |
price_rule.times_used | string | Number of times the discount has been used. | "5" |
price_rule.allocation_method | string | Allocation method for the discount. | "each" |
price_rule.allocation_limit | string | Redeem count limit per checkout. 0 means no limit. | "1" |
price_rule.once_per_customer | string | Indicates if the discount can be used only once per customer. "1" means yes. | "0" |
price_rule.prerequisite | string | Indicates if the discount has prerequisites. "1" means yes. | "1" |
price_rule.customer_selection | string | Specifies the customer selection for the discount. | "specific" |
price_rule.target_selection | string | Specifies the target product selection for the discount. | "entitled" |
price_rule.target_type | string | Specifies the type of target for the discount. | "line_item" |
price_rule.created_at | string | Timestamp of when the price rule was created. | "2024-12-19 10:00:00" |
price_rule.updated_at | string | Timestamp of when the price rule was last updated. | "2024-12-20 12:00:00" |
price_rule.starts_at | string | Start time of the discount (Unix timestamp). | "1700000000" |
price_rule.ends_at | string | End time of the discount (Unix timestamp). | "1700500000" |
price_rule.entitled_product_ids | array[string] | List of product IDs entitled for the discount. | ["product-1", "product-2", "product-3"] |
price_rule.entitled_variant_ids | array[string] | List of product variant IDs entitled for the discount. | ["variant-1", "variant-2"] |
price_rule.prerequisite_quantity_range | array[object] | Prerequisite for total product quantity in the cart. | See fields below. |
price_rule.prerequisite_quantity_range.greater_than_or_equal_to | string | Minimum quantity of products required to apply the discount. | "3" |
price_rule.prerequisite_quantity_range.value | string | Value used for discount application. | "15" |
price_rule.prerequisite_quantity_range.target_type | string | Specifies the type of target for the discount. | "line_item" |
price_rule.prerequisite_quantity_range.target_data | array[string] | List of target data IDs for the discount rule. | ["target-1", "target-2"] |
price_rule.prerequisite_subtotal_range | array[object] | Prerequisite for total cart amount. | See fields below. |
price_rule.prerequisite_subtotal_range.greater_than_or_equal_to | string | Minimum subtotal amount required to apply the discount. | "100" |
price_rule.prerequisite_subtotal_range.value | string | Discount value applied when subtotal condition is met. | "20" |
price_rule.prerequisite_subtotal_range.target_type | string | Specifies the type of target for the discount. | "line_item" |
price_rule.prerequisite_subtotal_range.target_data | array[string] | List of target data IDs for the subtotal discount rule. | ["subtotal-target-1"] |
Error Response
Error responses in the API can be represented using two different fields: errors
and error
. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.
Field | Type | Example | Description |
---|---|---|---|
errors | Array | [ "invalid line_item id"] | A list of errors encountered during the request processing. |
Field | Type | Example | Description |
---|---|---|---|
error | String | "store is not active" | Indicates an error encountered during the process |
Error Detail
Status Code | Message | Possible Reason | Example Response |
---|---|---|---|
400 | Bad Request | Invalid input format or request structure (e.g., missing required fields or incorrect data types). | Bad Request |
Unauthorized | The request is missing valid authentication credentials or the credentials provided are invalid. | Unauthorized | |
404 | Not Found | The id provided is not existed. | "Not found" |