Anchor to section titled 'undefined'

discountAutomaticBulkDelete
mutation

Requires Apps must have write_discounts access scope.

Asynchronously delete automatic discounts in bulk if a search or saved_search_id 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.


The IDs of the automatic discounts to delete.

The ID of the saved search to use for filtering automatic discounts to delete.

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?

The asynchronous job removing the automatic discounts.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
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-07/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();

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)

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"
},
},
});

use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);

Hide code
Input variables
Copy
{
"search": "type:percentage status:expired"
}

Hide code
Response
JSON
{
"discountAutomaticBulkDelete": {
"job": {
"id": "gid://shopify/Job/11a6c2db-7d58-4a77-ac7b-7128dd68b8aa"
},
"userErrors": []
}
}