discountAutomaticBulkDelete
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.
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.
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.
- Asynchronously delete automatic discounts in bulk using a search filter
- Using more than one targeting argument returns an error
- discountAutomaticBulkDelete reference
Examples
mutation discountAutomaticBulkDelete($search: String) {
discountAutomaticBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/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)