API: 2023-07
Use graphql
Query
mutation discountAutomaticBxgyCreate($automaticBxgyDiscount: DiscountAutomaticBxgyInput!) { discountAutomaticBxgyCreate(automaticBxgyDiscount: $automaticBxgyDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticBxgy { id createdAt startsAt endsAt status summary title usesPerOrderLimit customerGets { items { ... on DiscountProducts { products(first: 2) { nodes { id } } } } value { ... on DiscountOnQuantity { quantity { quantity } } } } customerBuys { items { ... on AllDiscountItems { allItems } } value { ... on DiscountQuantity { quantity } } } } } } userErrors { field code message } } }
Variables
{
"automaticBxgyDiscount": {
"usesPerOrderLimit": "1",
"startsAt": "2023-06-08T04:52:53-04:00",
"title": "Minium 2tr get 1 A auto",
"customerGets": {
"value": {
"discountOnQuantity": {
"quantity": "2",
"effect": {
"percentage": 1.0
}
}
},
"items": {
"products": {
"productVariantsToAdd": ["gid://shopify/ProductVariant/45002547069218"]
}
}
},
"customerBuys": {
"value": {
"amount": "2000000"
},
"items": {
"all": true
}
}
}
}
Response
{
"data": {
"discountAutomaticBxgyCreate": {
"automaticDiscountNode": null,
"userErrors": [
{
"field": [
"automaticBxgyDiscount",
"customerBuys",
"items"
],
"code": "BLANK",
"message": "Items in 'customer buys' must be defined"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 22,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 990,
"restoreRate": 50.0
}
}
}
}