Delete Category
This page describes the request data identifiers and response structure required to delete a category (soft delete).
Data Identifier
{
"dataID": "DELETE_CATEGORY",
"seq": 3,
"force_flg": "N",
"return_url": "/commerce/category/list"
}
| Key | Description |
|---|---|
| dataID | Data identifier DELETE_CATEGORY |
| seq | Category to delete |
| force_flg | Y deletes the subtree too. Otherwise 409 when it has children |
| return_url | Where to go after deleting. Echoed back in the response. |
HTML
<form id="frm_delete_category">
<input type="hidden" name="seq" value="3">
<input type="checkbox" name="force_flg" value="Y"> Delete subtree
<input type="hidden" name="return_url" value="/commerce/category/list">
<button type="submit" class="btn btn-outline-danger">Delete</button>
</form>
Response Result
{
"result": true,
"seq": 3,
"return_url": "/commerce/category/list"
}
| Key | Description |
|---|---|
| result | Deleted or not (true / false) |
| seq | Deleted category number |
| return_url | The return_url you sent |
- This is a soft delete: the row stays but disappears from lists and trees. Product links (category assignments) are kept, so reassign them first if needed.
- Screen example: call without force_flg first. On 409, ask "Delete its sub-categories too?" and call again with force_flg=Y.
- Error codes — errors also come back as HTTP 200. Check result:false, then error_code (string) and error_message.
- 401 — Sign-in required (Unauthorized).
- 400 — seq is missing or invalid.
- 409 — The category has children. Call again with force_flg=Y.
Example
<script setup>
const seq = 3
async function remove() {
if (!confirm('Delete this category?')) return
// force_flg=Y soft-deletes the whole subtree; without it, a category with active children returns 409
const { output } = await useNuxtApp().$connector({ dataID: 'DELETE_CATEGORY', seq, force_flg: 'N', return_url: '/commerce/category/list' })
if (output.result) navigateTo('/commerce/category/list')
}
</script>
<template>
<div class="card border-danger shadow-sm">
<div class="card-body">
<h5 class="card-title text-danger">Delete category</h5>
<p class="text-secondary mb-3">Soft delete (delete_flg = 'Y'). Pass <code>force_flg=Y</code> to remove the whole subtree.</p>
<button class="btn btn-outline-danger" @click="remove">Delete #{{ seq }}</button>
</div>
</div>
</template>
<?php
$requestData = [
'dataID' => 'DELETE_CATEGORY',
'seq' => 3,
'force_flg' => 'N', // 'Y' -> soft-delete the entire subtree
'return_url' => '/commerce/category/list',
];
$output = $connector->request($requestData);
// A category that still has active children returns HTTP 409 unless force_flg = 'Y'.
echo $output['result'] ? 'Deleted #' . $output['seq'] : 'Delete failed';
Related Links
User Discussions
ADD- There are no posts yet.