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"
}
KeyDescription
dataIDData identifier DELETE_CATEGORY
seqCategory to delete
force_flgY deletes the subtree too. Otherwise 409 when it has children
return_urlWhere 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"
}
KeyDescription
resultDeleted or not (true / false)
seqDeleted category number
return_urlThe 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

Delete category

Soft delete (delete_flg = 'Y'). Pass force_flg=Y to remove the whole subtree.

<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';