Anchor to discountAutomaticBulkDeletediscount
discountAutomaticBulkDelete
mutation
Requires Apps must have access scope.
Asynchronously delete automatic discounts in bulk if a search
or argument is provided or if a
maximum discount threshold is reached (1,000). Otherwise, deletions will occur inline.
Warning: All automatic discounts will be deleted if a blank
search
argument is provided.
Anchor to Arguments
Arguments
- •
The IDs of the automatic discounts to delete.
- Anchor to savedSearchIdsaved•
Search Id The ID of the saved search to use for filtering automatic discounts to delete.
- Anchor to searchsearch•
The search query for filtering automatic discounts to delete.
For more information on the list of supported fields and search syntax, refer to the AutomaticDiscountNodes query section.
Was this section helpful?
Anchor to DiscountAutomaticBulkDeletePayload returnsDiscountAutomaticBulkDeletePayload returns
- •
The asynchronous job removing the automatic discounts.
- Anchor to userErrorsuser•
Errors [DiscountUser non-nullError!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Asynchronously delete automatic discounts in bulk using a search filter
- Using more than one targeting argument returns an error
- discountAutomaticBulkDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation discountAutomaticBulkDelete($search: String) {6 discountAutomaticBulkDelete(search: $search) {7 job {8 id9 }10 userErrors {11 code12 field13 message14 }15 }16 }`,17 {18 variables: {19 "search": "type:percentage status:expired"20 },21 },22);2324const data = await response.json();25
mutation discountAutomaticBulkDelete($search: String) {
discountAutomaticBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation discountAutomaticBulkDelete($search: String) { discountAutomaticBulkDelete(search: $search) { job { id } userErrors { code field message } } }",
"variables": {
"search": "type:percentage status:expired"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation discountAutomaticBulkDelete($search: String) {
discountAutomaticBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"search": "type:percentage status:expired"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation discountAutomaticBulkDelete($search: String) {
discountAutomaticBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"search": "type:percentage status:expired"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation discountAutomaticBulkDelete($search: String) {
discountAutomaticBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"search": "type:percentage status:expired"
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "search": "type:percentage status:expired"3}
Response
JSON1{2 "discountAutomaticBulkDelete": {3 "job": {4 "id": "gid://shopify/Job/11a6c2db-7d58-4a77-ac7b-7128dd68b8aa"5 },6 "userErrors": []7 }8}