productDisable
Required scope: edit_products
Transition a product to DISABLED status, temporarily hiding it and preventing it from being used in new orders. A disabled product can be re-enabled with productActivate.
Mutation
graphql
mutation ProductDisable($id: String!) {
productDisable(id: $id) {
id
status
}
}Arguments
| Argument | Type | Description |
|---|---|---|
id | String! | The product UUID to disable |
Example
Variables
json
{
"id": "prod_456"
}Response
json
{
"data": {
"productDisable": {
"id": "prod_456",
"status": "DISABLED"
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation ProductDisable($id: String!) { productDisable(id: $id) { id status } }",
"variables": {
"id": "prod_456"
}
}'js
async function disableProduct(accessToken, productId) {
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation ProductDisable($id: String!) {
productDisable(id: $id) {
id
status
}
}
`,
variables: { id: productId },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.productDisable;
}
// Usage
const product = await disableProduct(accessToken, 'prod_456');python
import requests
def disable_product(access_token, product_id):
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
},
json={
'query': '''
mutation ProductDisable($id: String!) {
productDisable(id: $id) {
id
status
}
}
''',
'variables': {'id': product_id},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['productDisable']
# Usage
product = disable_product(access_token, 'prod_456')php
function disableProduct(string $accessToken, string $productId): array
{
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'query' => '
mutation ProductDisable($id: String!) {
productDisable(id: $id) {
id
status
}
}
',
'variables' => ['id' => $productId],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['productDisable'];
}
// Usage
$product = disableProduct($accessToken, 'prod_456');go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func disableProduct(accessToken, productID string) (map[string]interface{}, error) {
query := `
mutation ProductDisable($id: String!) {
productDisable(id: $id) {
id
status
}
}
`
body, _ := json.Marshal(map[string]interface{}{
"query": query,
"variables": map[string]interface{}{"id": productID},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
if errs, ok := result["errors"]; ok {
return nil, fmt.Errorf("graphql error: %v", errs)
}
data := result["data"].(map[string]interface{})
return data["productDisable"].(map[string]interface{}), nil
}