Create Price Rule
POST/openapi/2022-01/price_rules
Creates a new price rule for discounts or promotions on the store.
Request
- application/json
- Body
- Example
Body
- Array [
- ]
- Array [
- ]
price_rule object
Title of this price rule
Value for this discount , e.g. 50.25
Discount type, options: 1. fixed_amount for fixed amount of value to be reduced, 2. percentage for percentage of the value to be reduced
The usage limit, -1 means no limit
Redeem count limit for checkout: 0~999, 0 means only one redeem allowed, 999 means no limit
0The max usage per customer,-1 or 0 means no limit
Does this discount has prerequisite or not, 1 means yes, 0 means no
1The target products allowed of this discount, all means all products, entitled means only for the specific products
Target type of this discount, for example: line_item, shipping_line
line_itemDiscount started at
Discount ended at, -1 means no limit
Specify the target products allowed for the price rule. This field is required only when target_selection is entitled, e.g. [ "ac8ed089-55d9-4f58-a0f9-3dda4e4607cc", "0b76afba-e068-4bf6-85f5-660019f58488" ]
Specify the variants products allowed of the discount, e.g. [ "cea210d5-a419-4d4e-a17d-5bbd0bc4af76", "de2c55f5-c3e1-45e1-92f6-e65faf816ecc" ]
Specify the collections allowed of the discount, e.g. ["aa92c677-e5be-4cab-8e65-9ebc55b98240","e6152ca6-791b-4385-a9e1-49adb336b289"]
prerequisite_subtotal_range object[]
Prerequisite for the total amount of the money, for example: [ { "greater_than_or_equal_to": "10", "value": "1", "target_type": "", "target_data": [] } ] means total money must great than 10, then you could use the discount to reduce 1 dollar.
To specify the value which the price has to greater than or equal to.
The value used for the discount to apply, the reduction type is decided by value_type specified in Price Rule params
Target type
Target data
[]prerequisite_quantity_range object[]
Prerequisite for the total count of the products,e.g. [ { "greater_than_or_equal_to":"5", "value":"20", "target_type":"", "target_data":[] } ] means products count must great than 5, then you could use discount to reduce 20 dollars
To specify the value which the price has to greater than or equal to.
The value used for the discount to apply, the reduction type is decided by value_type specified in Price Rule params
Target type
Target data
[]{
"price_rule": {
"title": "string",
"value": 0,
"value_type": "string",
"usage_limit": 0,
"allocation_limit": 0,
"once_per_customer": 0,
"prerequisite": 1,
"target_selection": "string",
"target_type": "line_item",
"starts_at": "string",
"ends_at": "string",
"entitled_product_ids": [
"string"
],
"entitled_variant_ids": [
"string"
],
"entitled_collection_ids": [
"string"
],
"prerequisite_subtotal_range": [
{
"greater_than_or_equal_to": "string",
"value": "string",
"target_type": "string",
"target_data": [
"string"
]
}
],
"prerequisite_quantity_range": [
{
"greater_than_or_equal_to": "string",
"value": "string",
"target_type": "string",
"target_data": [
"string"
]
}
]
}
}
Responses
- 200
200
- application/json
- Schema
- Example
- Result
Schema
- Array [
- ]
price_rule object
2d7e416a-444f-4491-ae04-c50f47154140TITLE00percentage-10011allentitled2020-03-06 17:00:322020-03-12 15:29:4415834240001583942399prerequisite_quantity_range object[]
15{
"price_rule": {
"id": "2d7e416a-444f-4491-ae04-c50f47154140",
"title": "TITLE",
"value": 0,
"value_type": "percentage",
"usage_limit": "-1",
"times_used": "0",
"allocation_method": "",
"allocation_limit": "0",
"once_per_customer": "1",
"prerequisite": "1",
"customer_selection": "all",
"target_selection": "entitled",
"target_type": "",
"created_at": "2020-03-06 17:00:32",
"updated_at": "2020-03-12 15:29:44",
"starts_at": "1583424000",
"ends_at": "1583942399",
"entitled_product_ids": [
"cea210d5-a419-4d4e-a17d-5bbd0bc4af76"
],
"entitled_variant_ids": [
null
],
"prerequisite_quantity_range": [
{
"greater_than_or_equal_to": "1",
"value": "5",
"target_type": "",
"target_data": [
null
]
}
],
"prerequisite_subtotal_range": {}
}
}
{
"price_rule": {
"id": "2d7e416a-444f-4491-ae04-c50f47154140",
"title": "TITLE",
"value": 0,
"value_type": "percentage",
"usage_limit": "-1",
"times_used": "0",
"allocation_method": "",
"allocation_limit": "0",
"once_per_customer": "1",
"prerequisite": "1",
"customer_selection": "all",
"target_selection": "entitled",
"target_type": "",
"created_at": "2020-03-06 17:00:32",
"updated_at": "2020-03-12 15:29:44",
"starts_at": "1583424000",
"ends_at": "1583942399",
"entitled_product_ids": [
"cea210d5-a419-4d4e-a17d-5bbd0bc4af76",
"de2c55f5-c3e1-45e1-92f6-e65faf816ecc",
"47734e19-1b5c-468b-8695-31159d6d4478"
],
"entitled_variant_ids": [],
"prerequisite_quantity_range": [
{
"greater_than_or_equal_to": "1",
"value": "5",
"target_type": "",
"target_data": []
}
],
"prerequisite_subtotal_range": null
}
}