Anchor to section titled 'undefined'

priceRuleDelete
mutation
deprecated

Requires write_price_rules access scope.

Delete a price rule. Use discountCodeDelete instead.


Anchor to id
id
required

The ID of the price rule object.


Was this section helpful?

The ID price of the deleted price rule.

The list of errors that occurred from executing the mutation.

The shop of the deleted price rule.

The list of errors that occurred from executing the mutation. Use priceRuleUserErrors instead.


Was this section helpful?

Examples

Hide code
Copy
mutation priceRuleDelete($id: ID!) {
  priceRuleDelete(id: $id) {
    priceRuleUserErrors {
      field
      message
      code
    }
    deletedPriceRuleId
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation priceRuleDelete($id: ID!) { priceRuleDelete(id: $id) { priceRuleUserErrors { field message code } deletedPriceRuleId } }",
 "variables": {
    "id": "gid://shopify/PriceRule/1057371200"
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation priceRuleDelete($id: ID!) {
    priceRuleDelete(id: $id) {
      priceRuleUserErrors {
        field
        message
        code
      }
      deletedPriceRuleId
    }
  }`,
  {
    variables: {
      "id": "gid://shopify/PriceRule/1057371200"
    },
  },
);

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 priceRuleDelete($id: ID!) {
    priceRuleDelete(id: $id) {
      priceRuleUserErrors {
        field
        message
        code
      }
      deletedPriceRuleId
    }
  }
QUERY

variables = {
  "id": "gid://shopify/PriceRule/1057371200"
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation priceRuleDelete($id: ID!) {
      priceRuleDelete(id: $id) {
        priceRuleUserErrors {
          field
          message
          code
        }
        deletedPriceRuleId
      }
    }`,
    "variables": {
      "id": "gid://shopify/PriceRule/1057371200"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation priceRuleDelete($id: ID!) {
    priceRuleDelete(id: $id) {
      priceRuleUserErrors {
        field
        message
        code
      }
      deletedPriceRuleId
    }
  }
QUERY;

$variables = [
  "id" => "gid://shopify/PriceRule/1057371200",
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "id": "gid://shopify/PriceRule/1057371200"
}
Hide code
Response
JSON
{
  "priceRuleDelete": {
    "priceRuleUserErrors": [],
    "deletedPriceRuleId": "gid://shopify/PriceRule/1057371200"
  }
}