k.commerce.settings
Global e-commerce settings.
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
KScript API (k.api.get / k.api.post), server-side <script env="server"> | Configure store settings in Kooboo backend under E-commerce -> Settings | Inspect default currency/weight units, enabled payment channels, loyalty earning/redemption rules, mail server config, and webhooks |
k.commerce.settings exposes read-only access to site-level e-commerce configuration including currency rates, payment methods, loyalty point rules, custom/extension fields, email templates, and webhooks.
Quick Start
k.api.get(() => {
const s = k.commerce.settings
return {
currencyCode: s.currencyCode,
currencySymbol: s.currencySymbol,
weightUnit: s.weightUnit,
payments: s.payments,
currencies: s.currencies
}
})Quick Reference
| Method / Property | Description | Returns |
|---|---|---|
currencyCode | Default currency code (such as "CNY") | string |
currencySymbol | Default currency symbol (such as "CN¥") | string |
currencies | Site-configured multi-currency exchange list | CurrencyConfig[] |
weightUnit | Default product weight unit (such as "kg") | string |
payments | Enabled payment provider names | string[] |
earnPoint | Point-earning rules configuration | EarnPointSettings |
redeemPoint | Point-redemption rules configuration | RedeemPointSettings |
productCustomFields | Custom field definitions for products | CustomField[] |
categoryCustomFields | Custom field definitions for categories | CustomField[] |
orderExtensionFields | Custom extension field definitions for orders | ExtensionField[] |
hideAttributes | Whether product attributes are hidden in backend UI | boolean |
hideVariants | Whether product variants are hidden in backend UI | boolean |
productDigitalItemRequired | Whether digital products require at least one digital delivery item | boolean |
mailServerType | Mail server type ("kooboo" or "custom") | string |
koobooEmailAddress | Built-in Kooboo sender email address | string |
customMailServer | Custom SMTP mail server settings (null when unconfigured; contains credentials, do not return raw to clients) | MailServer | null |
enableEmailNotification | Whether email notifications are enabled | boolean |
emailNotifications | Configured email notification templates | EmailNotification[] |
enableWebhook | Whether event webhooks are enabled | boolean |
webhooks | Configured webhook endpoints | Webhook[] |
webhookSecret | Webhook signing secret (server-side verification only; never expose to clients) | string |
currencyCode
Read-only property returning the site default currency code. No parameters.
Type: string (such as "CNY").
k.api.get(() => {
return k.commerce.settings.currencyCode
})currencySymbol
Read-only property returning the site default currency symbol. No parameters.
Type: string (such as "CN¥").
k.api.get(() => {
return k.commerce.settings.currencySymbol
})currencies
Read-only property returning the multi-currency configuration list for the site. No parameters.
Type: CurrencyConfig[].
k.api.get(() => {
return k.commerce.settings.currencies
})categoryCustomFields
Read-only property returning the category custom field configuration. No parameters.
Type: CustomField[].
k.api.get(() => {
return k.commerce.settings.categoryCustomFields
})productDigitalItemRequired
Read-only property indicating whether digital products require at least one digital delivery item. No parameters.
Type: boolean.
k.api.get(() => {
return k.commerce.settings.productDigitalItemRequired
})weightUnit
Read-only property returning the default weight unit. No parameters.
Type: string (such as "kg").
k.api.get(() => {
return k.commerce.settings.weightUnit
})payments
Read-only property returning the list of enabled payment methods. No parameters.
Type: string[].
k.api.get(() => {
return k.commerce.settings.payments
})earnPoint
Read-only property returning loyalty point-earning configuration. No parameters.
Type: EarnPointSettings.
k.api.get(() => {
return k.commerce.settings.earnPoint
})redeemPoint
Read-only property returning loyalty point-redemption rules. No parameters.
Type: RedeemPointSettings.
k.api.get(() => {
return k.commerce.settings.redeemPoint
})orderExtensionFields
Read-only property returning order extension field definitions. No parameters.
Type: ExtensionField[].
k.api.get(() => {
return k.commerce.settings.orderExtensionFields
})productCustomFields
Read-only property returning product custom field definitions. No parameters.
Type: CustomField[].
k.api.get(() => {
return k.commerce.settings.productCustomFields
})hideAttributes
Read-only property indicating whether product attributes are hidden. No parameters.
Type: boolean.
k.api.get(() => {
return k.commerce.settings.hideAttributes
})hideVariants
Read-only property indicating whether product variants are hidden. No parameters.
Type: boolean.
k.api.get(() => {
return k.commerce.settings.hideVariants
})customMailServer
Read-only property returning custom SMTP mail server configuration. No parameters; returns null when unconfigured.
Security Warning
customMailServer contains plaintext SMTP credentials (userName and password). Never return the raw customMailServer object from public endpoints; redact credentials and expose only connection status or non-sensitive fields such as server, port, ssl, and from.
Type: MailServer | null.
k.api.get(() => {
const mail = k.commerce.settings.customMailServer
if (!mail) {
return { configured: false }
}
// Redact sensitive credentials; never return userName or password to clients
return {
configured: true,
server: mail.server,
port: mail.port,
ssl: mail.ssl,
from: mail.from
}
})mailServerType
Read-only property returning the configured mail server type. No parameters.
Type: "kooboo" | "custom" (string).
k.api.get(() => {
return k.commerce.settings.mailServerType
})koobooEmailAddress
Read-only property returning the Kooboo sender email address. No parameters.
Type: string.
k.api.get(() => {
return k.commerce.settings.koobooEmailAddress
})enableEmailNotification
Read-only property indicating whether email notifications are enabled. No parameters.
Type: boolean.
k.api.get(() => {
return k.commerce.settings.enableEmailNotification
})emailNotifications
Read-only property returning the configured email notification templates. No parameters.
Type: EmailNotification[].
k.api.get(() => {
return k.commerce.settings.emailNotifications
})enableWebhook
Read-only property indicating whether webhooks are enabled. No parameters.
Type: boolean.
k.api.get(() => {
return k.commerce.settings.enableWebhook
})webhooks
Read-only property returning configured webhook definitions. No parameters.
Type: Webhook[].
k.api.get(() => {
return k.commerce.settings.webhooks
})webhookSecret
Read-only property returning the webhook signing secret. No parameters.
Security Warning
webhookSecret is used to sign and verify Kooboo commerce webhook requests (X-Kooboo-Hmac-SHA256). Never return this secret from unauthenticated k.api.get endpoints or expose it to clients; keep its usage strictly server-side.
Type: string.
k.api.post(() => {
// Use webhookSecret only on the server to verify incoming webhook signatures; never return it
const secret = k.commerce.settings.webhookSecret
const signature = k.request.headers.get('X-Kooboo-Hmac-SHA256')
const rawBody = k.request.body || ''
const expected = k.security.sha256(rawBody + secret)
if (!signature || signature.toLowerCase() !== expected) {
k.response.statusCode(401)
return { verified: false }
}
return { verified: true }
})Structures
Settings property
k.commerce.settings returns the full e-commerce configuration object:
| Property | Description | Type |
|---|---|---|
currencyCode | Default currency code | string |
currencySymbol | Default currency symbol | string |
currencies | Multi-currency exchange configs | CurrencyConfig[] |
weightUnit | Weight unit | string |
earnPoint | Point-earning rules config | EarnPointSettings |
redeemPoint | Point-redemption rules config | RedeemPointSettings |
payments | Enabled payment method names | string[] |
productCustomFields | Product custom fields | CustomField[] |
categoryCustomFields | Category custom fields | CustomField[] |
orderExtensionFields | Order extension fields | ExtensionField[] |
enableEmailNotification | Whether email notifications are enabled | boolean |
customMailServer | Custom SMTP mail server config | MailServer | null |
koobooEmailAddress | Kooboo sender email address | string |
mailServerType | Mail server type | string |
emailNotifications | Email notification templates | EmailNotification[] |
enableWebhook | Whether webhooks are enabled | boolean |
webhooks | Webhook endpoints | Webhook[] |
webhookSecret | Webhook signing secret | string |
hideAttributes | Whether product attributes are hidden | boolean |
hideVariants | Whether product variants are hidden | boolean |
productDigitalItemRequired | Whether digital products require a digital item | boolean |
EarnPointSettings Property
| Property | Description | Type |
|---|---|---|
activeDurationUnit | Point expiration duration unit | string |
activeDuration | Point expiration duration value | number |
orderEarnRules | Order point-earning rules | OrderEarnPointsRule[] |
loginEarnRules | Login point-earning rules | LoginEarnPointsRule[] |
RedeemPointSettings Property
| Property | Description | Type |
|---|---|---|
exchangeRate | Redemption exchange rate | number |
orderRedeemRules | Order point-redemption rules | OrderRedeemPointsRule[] |
OrderEarnPointsRule Property
| Property | Description | Type |
|---|---|---|
value | Points earned value | number |
isPercent | Whether calculated as percentage of order amount | boolean |
description | Rule description | string |
condition | Rule condition | Condition |
LoginEarnPointsRule Property
| Property | Description | Type |
|---|---|---|
value | Points earned value | number |
durationUnit | Login reward cycle unit (once per Day/Week/Month/Year) | string |
description | Rule description | string |
condition | Rule condition | Condition |
OrderRedeemPointsRule Property
| Property | Description | Type |
|---|---|---|
value | Redeemed points value | number |
isPercent | Whether calculated as percentage of order amount | boolean |
description | Rule description | string |
condition | Rule condition | Condition |
Condition property
| Property | Description | Type |
|---|---|---|
isAny | Whether any condition item suffices | boolean |
items | List of condition items | ConditionItem[] |
ConditionItem Property
| Property | Description | Type |
|---|---|---|
option | Condition option | string |
method | Condition comparison method | string |
value | Condition target value | string |
ExtensionField Property
| Property | Description | Type |
|---|---|---|
name | Field name | string |
displayName | Display name | string |
type | Field type | string |
editable | Whether editable | boolean |
exportable | Whether exportable | boolean |
filterable | Whether filterable | boolean |
isSelection | Whether selection-based | boolean |
Webhook properties
| Property | Description | Type |
|---|---|---|
event | Trigger event name | string |
url | Webhook target URL | string |
EmailNotification Property
| Property | Description | Type |
|---|---|---|
id | Notification ID | string |
event | Trigger event name | string |
subjectTemplate | Email subject template | string |
bodyTemplate | Email body template | string |
sendToCustomer | Whether sent to customers | boolean |
sendToAddresses | Recipient address list | string[] |
CurrencyConfig Property
| Property | Description | Type |
|---|---|---|
code | Currency code | string |
symbol | Currency symbol | string |
exchangeRate | Exchange rate | number |
autoUpdate | Whether exchange rate updates automatically | boolean |
MailServer Properties
| Property | Description | Type |
|---|---|---|
server | SMTP server host | string |
port | Port number | number |
ssl | Whether SSL is enabled | boolean |
from | Sender email address | string |
userName | Username | string |
password | Password | string |
TypeScript Definitions
interface Settings {
currencyCode: string;
currencySymbol: string;
currencies: Kooboo.Sites.Commerce.Entities.CurrencyConfig[];
weightUnit: string;
earnPoint: Kooboo.Sites.Commerce.RewardPoints.EarnPointSettings;
redeemPoint: Kooboo.Sites.Commerce.RewardPoints.RedeemPointSettings;
payments: string[];
productCustomFields: Kooboo.Sites.Commerce.CustomData.CustomField[];
categoryCustomFields: Kooboo.Sites.Commerce.CustomData.CustomField[];
orderExtensionFields: Kooboo.Sites.Commerce.Entities.ExtensionField[];
enableEmailNotification: boolean;
customMailServer: Kooboo.Mail.Models.SmtpSetting | null;
koobooEmailAddress: string;
mailServerType: string;
emailNotifications: Kooboo.Sites.Commerce.Notification.EmailNotification[];
enableWebhook: boolean;
webhooks: Kooboo.Sites.Commerce.Notification.Webhook[];
webhookSecret: string;
hideAttributes: boolean;
hideVariants: boolean;
productDigitalItemRequired: boolean;
}Related Docs
- k.commerce - E-commerce module overview
- currency - Currency lookups
- shipping - Shipping management (references
MailServerconfig) - order - Order management
- cart - Shopping cart