Anchor to section titled 'undefined'

giftCardDisable
mutation
deprecated

Requires write_gift_cards access scope. Also: User needs gift_cards permission.

Disable a gift card. A disabled gift card cannot be used by a customer. A disabled gift card cannot be re-enabled. Use giftCardDeactivate instead.


Anchor to id
id
required

The ID of the gift card to disable.


Was this section helpful?

The disabled gift card.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation giftCardDisable($id: ID!) {
  giftCardDisable(id: $id) {
    userErrors {
      message
      field
    }
    giftCard {
      id
      enabled
    }
  }
}
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 giftCardDisable($id: ID!) { giftCardDisable(id: $id) { userErrors { message field } giftCard { id enabled } } }",
 "variables": {
    "id": "gid://shopify/GiftCard/63396415"
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation giftCardDisable($id: ID!) {
    giftCardDisable(id: $id) {
      userErrors {
        message
        field
      }
      giftCard {
        id
        enabled
      }
    }
  }`,
  {
    variables: {
      "id": "gid://shopify/GiftCard/63396415"
    },
  },
);

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 giftCardDisable($id: ID!) {
    giftCardDisable(id: $id) {
      userErrors {
        message
        field
      }
      giftCard {
        id
        enabled
      }
    }
  }
QUERY

variables = {
  "id": "gid://shopify/GiftCard/63396415"
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation giftCardDisable($id: ID!) {
      giftCardDisable(id: $id) {
        userErrors {
          message
          field
        }
        giftCard {
          id
          enabled
        }
      }
    }`,
    "variables": {
      "id": "gid://shopify/GiftCard/63396415"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation giftCardDisable($id: ID!) {
    giftCardDisable(id: $id) {
      userErrors {
        message
        field
      }
      giftCard {
        id
        enabled
      }
    }
  }
QUERY;

$variables = [
  "id" => "gid://shopify/GiftCard/63396415",
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "id": "gid://shopify/GiftCard/63396415"
}
Hide code
Response
JSON
{
  "giftCardDisable": {
    "userErrors": [],
    "giftCard": {
      "id": "gid://shopify/GiftCard/63396415",
      "enabled": false
    }
  }
}