Save Product
This page describes the request data identifiers and response structure required to create or update a product.
Data Identifier
{
"dataID": "SAVE_PRODUCT",
"seq": 340,
"product_code": "TS-TS01",
"name": "Cotton T-Shirt",
"product_type": "PHYSICAL",
"status": "ACTIVE",
"brand": "H:Dev+",
"summary": "100% soft cotton tee",
"description": "<p>180g cotton jersey</p>",
"currency": "KRW",
"base_price": 19000,
"list_price": 25000,
"category_sync": 1,
"category_seq": [2],
"category_default": 2,
"return_url": "/commerce/product/list"
}
| Key | Description |
|---|---|
| dataID | Data identifier SAVE_PRODUCT |
| seq | Product to update. Empty creates a new one. |
| product_code | Product code (1062 if duplicated) |
| name | Product name |
| product_type | Product type. Default PHYSICAL |
| status | DRAFT / ACTIVE / INACTIVE / ARCHIVED |
| brand | Brand |
| summary | One-line summary |
| description | Description HTML (sanitized on save) |
| currency | Currency code, e.g. KRW |
| base_price | Selling price |
| list_price | Regular price. Empty = none, 0 or more (422 if negative) |
| stock_flg | Track stock for a product without options 0 / 1 |
| category_sync | 1 replaces category links with category_seq[] |
| category_seq | Category numbers to link |
| category_default | Main category number |
| image | Images (replaces the image list when sent) |
| related_sync | 1 replaces related products with related_product_seq[] |
| related_product_seq | Related product numbers |
| custom_fields | Custom fields {key: value} |
| return_url | Where to go after saving. Echoed back. |
HTML
<form id="frm_save_product" method="post">
<input type="hidden" name="seq" value="340">
<input name="product_code" value="TS-TS01">
<input name="name" value="Cotton T-Shirt">
<select name="status"><option>DRAFT</option><option selected="">ACTIVE</option><option>INACTIVE</option><option>ARCHIVED</option></select>
<input type="number" name="base_price" value="19000">
<input type="number" name="list_price" value="25000">
<input type="hidden" name="category_sync" value="1">
<input type="checkbox" name="category_seq[]" value="2" checked="">
<input type="hidden" name="category_default" value="2">
<input type="hidden" name="return_url" value="/commerce/product/list">
<button type="submit" class="btn btn-primary">Save</button>
</form>
Response Result
{
"result": true,
"result_code": 200,
"seq": 340,
"return_url": "/commerce/product/list"
}
| Key | Description |
|---|---|
| result | Saved or not (true / false) |
| result_code | 200 saved, 1062 duplicate code |
| seq | Saved product number. 0 on failure |
| return_url | The return_url you sent |
- Create options separately after saving, with APPLY_OPTION_SET. Change stock with UPDATE_INVENTORY.
- Price: base_price is the selling price and list_price the regular price (null if none). With an option, price = base_price + the row's price_delta. Show a struck-through list price and discount only when list_price is greater.
- Product status is DRAFT, ACTIVE (on sale), INACTIVE (paused) or ARCHIVED. Storefront lists, widgets and orders accept ACTIVE only.
- Error codes — errors also come back as HTTP 200. Check result:false, then error_code (string) and error_message.
- 401 — Sign-in required (Unauthorized).
- 1062 — The code already exists. This one comes as result:false, result_code:1062, seq:0 with no error_code.
- 422 — Invalid input, e.g. Invalid list_price (negative regular price).
- 400 — A related product or inventory row does not belong to this product.
<script setup>
import { ref } from 'vue'
const form = ref({
seq: 340, product_code: 'TS-TS01', name: 'Cotton T-Shirt', product_type: 'PHYSICAL', status: 'ACTIVE',
brand: 'H:Dev+', summary: '100% soft cotton tee', currency: 'KRW', base_price: 19000, list_price: 25000
})
const categories = ref([2])
const msg = ref('')
async function save() {
const { output } = await useNuxtApp().$connector({
dataID: 'SAVE_PRODUCT', ...form.value,
category_sync: 1, category_seq: categories.value, category_default: categories.value[0],
return_url: '/commerce/product/list'
})
if (output.result) msg.value = `Saved #${output.seq}`
else if (output.result_code === 1062) msg.value = 'This product code is already in use.'
else msg.value = output.error_message // e.g. 422 Invalid list_price
}
</script>
<template>
<form class="card shadow-sm p-4" @submit.prevent="save">
<div class="row g-3">
<div class="col-md-4"><label class="form-label">Code</label><input class="form-control" v-model="form.product_code"></div>
<div class="col-md-8"><label class="form-label">Name</label><input class="form-control" v-model="form.name"></div>
<div class="col-md-4"><label class="form-label">Status</label>
<select class="form-select" v-model="form.status"><option>DRAFT</option><option>ACTIVE</option><option>INACTIVE</option><option>ARCHIVED</option></select></div>
<div class="col-md-4"><label class="form-label">Price</label><input type="number" min="0" class="form-control" v-model.number="form.base_price"></div>
<div class="col-md-4"><label class="form-label">Regular price (optional)</label><input type="number" min="0" class="form-control" v-model.number="form.list_price"></div>
</div>
<button class="btn btn-primary mt-3">Save</button>
<p class="mt-2">{{ msg }}</p>
</form>
</template>
<?php
$requestData = [
'dataID' => 'SAVE_PRODUCT',
'seq' => 340, // omit or 0 to create
'product_code' => 'TS-TS01',
'name' => 'Cotton T-Shirt',
'product_type' => 'PHYSICAL',
'status' => 'ACTIVE', // DRAFT | ACTIVE | INACTIVE | ARCHIVED
'currency' => 'KRW',
'base_price' => 19000, // selling price
'list_price' => 25000, // regular price, '' to clear
'category_sync' => 1, // replace category links with category_seq[]
'category_seq' => [2],
'category_default' => 2,
'return_url' => '/commerce/product/list',
];
$output = $connector->request($requestData);
if ($output['result']) {
header('Location: ' . $output['return_url']);
exit;
}
echo ($output['result_code'] ?? 0) === 1062 ? 'Duplicate product code' : htmlspecialchars($output['error_message'] ?? 'Save failed');
User Discussions
ADD- There are no posts yet.