Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Match the terms columns to the table around them, and explain the terms

Damian Legawiecfae5190f1858
diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.json
index d90bebb132..8ff7979e41 100644
--- a/packages/dashboard-core/src/locales/ar.json
+++ b/packages/dashboard-core/src/locales/ar.json
@@ -1566,7 +1566,14 @@
},
"mixed": "مختلط",
"inherits": "الافتراضي",
- "default_help": "ينطبق على كل منتج في هذا الكتالوج، ما لم يحدد المنتج قيمه الخاصة في القائمة."
+ "default_help": "ينطبق على كل منتج في هذا الكتالوج، ما لم يحدد المنتج قيمه الخاصة في القائمة.",
+ "column_minimum": "الحد الأدنى",
+ "column_multiple": "المضاعف",
+ "help": {
+ "minimum": "أقل كمية يمكن للمشتري طلبها من منتج واحد. يُرفض الطلب الأقل منها مع ذكر أقرب الكميات الصالحة — ولا يتم التقريب أبدًا.",
+ "multiple": "مقدار الزيادة. مع مضاعف 24 يطلب المشتري 24 أو 48 أو 72 — وليس 30. تُحسب الزيادات من الحد الأدنى: بحد أدنى 50 وزيادة 24 يُسمح بـ 50 و74 و98.",
+ "order_minimum": "أقل قيمة يجب أن يبلغها الطلب بالكامل، بحساب المنتجات فقط — الشحن والضريبة لا يساهمان فيها. يرى المشترون كم ينقصهم أثناء التسوق، ويُرفض إتمام الشراء حتى يبلغوها."
+ }
}
}
}
diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.json
index ff8d53f855..ab40570f18 100644
--- a/packages/dashboard-core/src/locales/de.json
+++ b/packages/dashboard-core/src/locales/de.json
@@ -1561,7 +1561,14 @@
},
"mixed": "Gemischt",
"inherits": "Standard",
- "default_help": "Gilt für jedes Produkt in diesem Katalog, sofern ein Produkt in der Liste nichts Eigenes angibt."
+ "default_help": "Gilt für jedes Produkt in diesem Katalog, sofern ein Produkt in der Liste nichts Eigenes angibt.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Vielfaches",
+ "help": {
+ "minimum": "Die geringste Menge, die ein Käufer von einem Produkt bestellen darf. Eine kleinere Bestellung wird abgelehnt und nennt die nächstgelegenen gültigen Mengen — es wird nie aufgerundet.",
+ "multiple": "Die Schrittweite. Bei einem Vielfachen von 24 bestellt ein Käufer 24, 48 oder 72 — nie 30. Die Schritte zählen ab der Mindestmenge: bei Minimum 50 und Schritten von 24 sind 50, 74 und 98 erlaubt.",
+ "order_minimum": "Der Mindestwert einer gesamten Bestellung, nur Artikel — Versand und Steuern zählen nicht mit. Käufer sehen beim Einkaufen, wie viel noch fehlt, und der Checkout wird bis dahin abgelehnt."
+ }
}
}
}
diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.json
index a734440bd7..0566a4b20d 100644
--- a/packages/dashboard-core/src/locales/en.json
+++ b/packages/dashboard-core/src/locales/en.json
@@ -1563,7 +1563,14 @@
},
"mixed": "Mixed",
"inherits": "Default",
- "default_help": "Applies to every product in this catalog, unless a product states its own on the list."
+ "default_help": "Applies to every product in this catalog, unless a product states its own on the list.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Multiple",
+ "help": {
+ "minimum": "The least a buyer may order of one product. An order below it is refused with the nearest valid quantities named — nothing is ever rounded up for them.",
+ "multiple": "The step size. With a multiple of 24 a buyer orders 24, 48 or 72 — never 30. Steps count up from the minimum, so a minimum of 50 in steps of 24 allows 50, 74 and 98.",
+ "order_minimum": "The least a whole order must come to, counting items only — delivery and tax do not help reach it. Buyers see how far short they are while they shop, and checkout is refused until they reach it."
+ }
}
}
}
diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.json
index c65c059434..b90fd92e39 100644
--- a/packages/dashboard-core/src/locales/fr.json
+++ b/packages/dashboard-core/src/locales/fr.json
@@ -1561,7 +1561,14 @@
},
"mixed": "Variable",
"inherits": "Par défaut",
- "default_help": "S'applique à chaque produit de ce catalogue, sauf si un produit indique le sien dans la liste."
+ "default_help": "S'applique à chaque produit de ce catalogue, sauf si un produit indique le sien dans la liste.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Multiple",
+ "help": {
+ "minimum": "La plus petite quantité qu'un acheteur peut commander d'un produit. Une commande inférieure est refusée en indiquant les quantités valables les plus proches — rien n'est jamais arrondi.",
+ "multiple": "Le pas. Avec un multiple de 24, un acheteur commande 24, 48 ou 72 — jamais 30. Les paliers partent du minimum : un minimum de 50 par pas de 24 autorise 50, 74 et 98.",
+ "order_minimum": "Le montant minimal d'une commande entière, articles seuls — la livraison et la taxe n'y contribuent pas. Les acheteurs voient ce qu'il leur manque et la commande est refusée en dessous."
+ }
}
}
}
diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.json
index 7200daeccf..6cebe0eb35 100644
--- a/packages/dashboard-core/src/locales/pl.json
+++ b/packages/dashboard-core/src/locales/pl.json
@@ -1587,7 +1587,14 @@
},
"mixed": "Różne",
"inherits": "Domyślne",
- "default_help": "Dotyczy każdego produktu w tym katalogu, chyba że produkt na liście określi własne wartości."
+ "default_help": "Dotyczy każdego produktu w tym katalogu, chyba że produkt na liście określi własne wartości.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Wielokrotność",
+ "help": {
+ "minimum": "Najmniejsza ilość jednego produktu, jaką kupujący może zamówić. Mniejsze zamówienie jest odrzucane ze wskazaniem najbliższych prawidłowych ilości — nic nie jest zaokrąglane.",
+ "multiple": "Wielkość kroku. Przy wielokrotności 24 kupujący zamawia 24, 48 lub 72 — nigdy 30. Kroki liczone są od minimum: przy minimum 50 i kroku 24 dozwolone są 50, 74 i 98.",
+ "order_minimum": "Najniższa wartość całego zamówienia, liczone tylko produkty — dostawa i podatek się nie liczą. Kupujący widzą, ile brakuje, a złożenie zamówienia jest blokowane do osiągnięcia progu."
+ }
}
}
}
diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.json
index 05b0e462b9..b738793ff9 100644
--- a/packages/dashboard-core/src/locales/zh-CN.json
+++ b/packages/dashboard-core/src/locales/zh-CN.json
@@ -1560,7 +1560,14 @@
},
"mixed": "不一致",
"inherits": "默认",
- "default_help": "适用于本目录中的每个商品,除非某个商品在列表中另行设置。"
+ "default_help": "适用于本目录中的每个商品,除非某个商品在列表中另行设置。",
+ "column_minimum": "最小起订量",
+ "column_multiple": "订购倍数",
+ "help": {
+ "minimum": "买家单个商品可订购的最小数量。低于该数量的订单会被拒绝,并提示最接近的有效数量——系统绝不会自动向上取整。",
+ "multiple": "递增步长。倍数为 24 时,买家可订购 24、48 或 72——但不能是 30。步长从最小起订量开始计算:最小 50、步长 24 时,允许 50、74 和 98。",
+ "order_minimum": "整笔订单必须达到的最低金额,仅计算商品——运费和税费不计入。买家在选购时即可看到还差多少,未达到前无法结账。"
+ }
}
}
}
diff --git a/packages/dashboard/src/components/spree/catalog-terms-card.tsx b/packages/dashboard/src/components/spree/catalog-terms-card.tsx
index 15ac508136..7ab3eabff3 100644
--- a/packages/dashboard/src/components/spree/catalog-terms-card.tsx
+++ b/packages/dashboard/src/components/spree/catalog-terms-card.tsx
@@ -11,8 +11,13 @@ import {
FieldError,
FieldLabel,
Input,
+ TableCell,
+ TableHead,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from '@spree/dashboard-ui'
-import { PlusIcon, XIcon } from 'lucide-react'
+import { InfoIcon, PlusIcon, XIcon } from 'lucide-react'
import type { UseFormReturn } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import type {
@@ -21,6 +26,32 @@ import type {
StagedProductTerms,
} from '../../schemas/catalog'
+/**
+ * A term's explanation, on the label rather than under the field: these
+ * rules are easy to confuse with one another (an order multiple is a step
+ * size, not a divisor of the total) and a merchant setting one needs the
+ * distinction where they are reading, not in a paragraph below.
+ */
+function TermHelp({ text }: { text: string }) {
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ // A cursor-help affordance, not an action: it opens nothing and
+ // must not take a tab stop away from the field it describes.
+ tabIndex={-1}
+ className="cursor-help text-muted-foreground"
+ aria-hidden="true"
+ >
+ <InfoIcon className="size-3.5" />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">{text}</TooltipContent>
+ </Tooltip>
+ )
+}
+
/**
* How much buyers on this agreement must order: the catalog-wide default,
* and the least a whole order must come to in each currency.
@@ -52,8 +83,9 @@ export function CatalogTermsCard({
<CardContent className="flex flex-col gap-6">
<div className="grid grid-cols-2 gap-3">
<Field>
- <FieldLabel htmlFor="catalog-moq">
+ <FieldLabel htmlFor="catalog-moq" className="flex items-center gap-1.5">
{t('admin.fields.minimum_order_quantity.label')}
+ <TermHelp text={t('admin.catalogs.terms.help.minimum')} />
</FieldLabel>
<Input
id="catalog-moq"
@@ -71,8 +103,9 @@ export function CatalogTermsCard({
</Field>
<Field>
- <FieldLabel htmlFor="catalog-multiple">
+ <FieldLabel htmlFor="catalog-multiple" className="flex items-center gap-1.5">
{t('admin.fields.order_multiple.label')}
+ <TermHelp text={t('admin.catalogs.terms.help.multiple')} />
</FieldLabel>
<Input
id="catalog-multiple"
@@ -121,7 +154,10 @@ function OrderMinimums({
<section className="flex flex-col gap-3">
<div className="flex items-center justify-between">
<div>
- <h3 className="font-medium text-sm">{t('admin.catalogs.terms.minimums_title')}</h3>
+ <h3 className="flex items-center gap-1.5 font-medium text-sm">
+ {t('admin.catalogs.terms.minimums_title')}
+ <TermHelp text={t('admin.catalogs.terms.help.order_minimum')} />
+ </h3>
<p className="text-muted-foreground text-sm">
{t('admin.catalogs.terms.minimums_description')}
</p>
@@ -216,7 +252,19 @@ export function catalogTermColumns({
}: {
form: UseFormReturn<CatalogFormValues>
canEdit: boolean
- headers: { minimum: string; multiple: string; mixed: string; defaultHint: string }
+ headers: {
+ /** Short column heading. */
+ minimum: string
+ multiple: string
+ /** The full field name, kept as the input's accessible label. */
+ minimumLabel: string
+ multipleLabel: string
+ /** What the term means, shown from the column heading. */
+ minimumHelp: string
+ multipleHelp: string
+ mixed: string
+ defaultHint: string
+ }
}) {
const terms = form.watch('staged_terms') ?? {}
const catalogMinimum = form.watch('minimum_order_quantity')?.trim()
@@ -238,14 +286,23 @@ export function catalogTermColumns({
}
return {
+ // The shared table's own cells rather than hand-rolled ones: TableHead
+ // carries the header's rule and background, TableCell the row border, so
+ // raw elements read as a separate block that ignores the row hover.
headers: (
<>
- <th className="h-10 w-28 px-2 text-left align-middle font-medium text-muted-foreground text-xs">
- {headers.minimum}
- </th>
- <th className="h-10 w-28 px-2 text-left align-middle font-medium text-muted-foreground text-xs">
- {headers.multiple}
- </th>
+ <TableHead className="w-32">
+ <span className="flex items-center gap-1.5">
+ {headers.minimum}
+ <TermHelp text={headers.minimumHelp} />
+ </span>
+ </TableHead>
+ <TableHead className="w-32">
+ <span className="flex items-center gap-1.5">
+ {headers.multiple}
+ <TermHelp text={headers.multipleHelp} />
+ </span>
+ </TableHead>
</>
),
renderCells: (row: { id: string; pending?: 'added' | 'removed' }) => {
@@ -256,32 +313,32 @@ export function catalogTermColumns({
return (
<>
- <td className="px-2 py-1">
+ <TableCell>
<Input
type="number"
min={1}
step={1}
disabled={disabled}
- aria-label={headers.minimum}
+ aria-label={headers.minimumLabel}
placeholder={entry?.mixed ? headers.mixed : catalogMinimum || headers.defaultHint}
value={entry?.minimum_order_quantity ?? ''}
onChange={(event) => set(row.id, 'minimum_order_quantity', event.target.value)}
className="h-8"
/>
- </td>
- <td className="px-2 py-1">
+ </TableCell>
+ <TableCell>
<Input
type="number"
min={1}
step={1}
disabled={disabled}
- aria-label={headers.multiple}
+ aria-label={headers.multipleLabel}
placeholder={entry?.mixed ? headers.mixed : catalogMultiple || headers.defaultHint}
value={entry?.order_multiple ?? ''}
onChange={(event) => set(row.id, 'order_multiple', event.target.value)}
className="h-8"
/>
- </td>
+ </TableCell>
</>
)
},
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index e66109f3dc..22db8c54a0 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -172,7 +172,14 @@
},
"mixed": "مختلط",
"inherits": "الافتراضي",
- "default_help": "ينطبق على كل منتج في هذا الكتالوج، ما لم يحدد المنتج قيمه الخاصة في القائمة."
+ "default_help": "ينطبق على كل منتج في هذا الكتالوج، ما لم يحدد المنتج قيمه الخاصة في القائمة.",
+ "column_minimum": "الحد الأدنى",
+ "column_multiple": "المضاعف",
+ "help": {
+ "minimum": "أقل كمية يمكن للمشتري طلبها من منتج واحد. يُرفض الطلب الأقل منها مع ذكر أقرب الكميات الصالحة — ولا يتم التقريب أبدًا.",
+ "multiple": "مقدار الزيادة. مع مضاعف 24 يطلب المشتري 24 أو 48 أو 72 — وليس 30. تُحسب الزيادات من الحد الأدنى: بحد أدنى 50 وزيادة 24 يُسمح بـ 50 و74 و98.",
+ "order_minimum": "أقل قيمة يجب أن يبلغها الطلب بالكامل، بحساب المنتجات فقط — الشحن والضريبة لا يساهمان فيها. يرى المشترون كم ينقصهم أثناء التسوق، ويُرفض إتمام الشراء حتى يبلغوها."
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index e8c929cb2e..5863936538 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -172,7 +172,14 @@
},
"mixed": "Gemischt",
"inherits": "Standard",
- "default_help": "Gilt für jedes Produkt in diesem Katalog, sofern ein Produkt in der Liste nichts Eigenes angibt."
+ "default_help": "Gilt für jedes Produkt in diesem Katalog, sofern ein Produkt in der Liste nichts Eigenes angibt.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Vielfaches",
+ "help": {
+ "minimum": "Die geringste Menge, die ein Käufer von einem Produkt bestellen darf. Eine kleinere Bestellung wird abgelehnt und nennt die nächstgelegenen gültigen Mengen — es wird nie aufgerundet.",
+ "multiple": "Die Schrittweite. Bei einem Vielfachen von 24 bestellt ein Käufer 24, 48 oder 72 — nie 30. Die Schritte zählen ab der Mindestmenge: bei Minimum 50 und Schritten von 24 sind 50, 74 und 98 erlaubt.",
+ "order_minimum": "Der Mindestwert einer gesamten Bestellung, nur Artikel — Versand und Steuern zählen nicht mit. Käufer sehen beim Einkaufen, wie viel noch fehlt, und der Checkout wird bis dahin abgelehnt."
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index b8e2c69667..d54530301e 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -172,7 +172,14 @@
},
"mixed": "Mixed",
"inherits": "Default",
- "default_help": "Applies to every product in this catalog, unless a product states its own on the list."
+ "default_help": "Applies to every product in this catalog, unless a product states its own on the list.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Multiple",
+ "help": {
+ "minimum": "The least a buyer may order of one product. An order below it is refused with the nearest valid quantities named — nothing is ever rounded up for them.",
+ "multiple": "The step size. With a multiple of 24 a buyer orders 24, 48 or 72 — never 30. Steps count up from the minimum, so a minimum of 50 in steps of 24 allows 50, 74 and 98.",
+ "order_minimum": "The least a whole order must come to, counting items only — delivery and tax do not help reach it. Buyers see how far short they are while they shop, and checkout is refused until they reach it."
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index ac4fe36837..0dfaa4102e 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -172,7 +172,14 @@
},
"mixed": "Variable",
"inherits": "Par défaut",
- "default_help": "S'applique à chaque produit de ce catalogue, sauf si un produit indique le sien dans la liste."
+ "default_help": "S'applique à chaque produit de ce catalogue, sauf si un produit indique le sien dans la liste.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Multiple",
+ "help": {
+ "minimum": "La plus petite quantité qu'un acheteur peut commander d'un produit. Une commande inférieure est refusée en indiquant les quantités valables les plus proches — rien n'est jamais arrondi.",
+ "multiple": "Le pas. Avec un multiple de 24, un acheteur commande 24, 48 ou 72 — jamais 30. Les paliers partent du minimum : un minimum de 50 par pas de 24 autorise 50, 74 et 98.",
+ "order_minimum": "Le montant minimal d'une commande entière, articles seuls — la livraison et la taxe n'y contribuent pas. Les acheteurs voient ce qu'il leur manque et la commande est refusée en dessous."
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index b929701215..7279823de9 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -174,7 +174,14 @@
},
"mixed": "Różne",
"inherits": "Domyślne",
- "default_help": "Dotyczy każdego produktu w tym katalogu, chyba że produkt na liście określi własne wartości."
+ "default_help": "Dotyczy każdego produktu w tym katalogu, chyba że produkt na liście określi własne wartości.",
+ "column_minimum": "Minimum",
+ "column_multiple": "Wielokrotność",
+ "help": {
+ "minimum": "Najmniejsza ilość jednego produktu, jaką kupujący może zamówić. Mniejsze zamówienie jest odrzucane ze wskazaniem najbliższych prawidłowych ilości — nic nie jest zaokrąglane.",
+ "multiple": "Wielkość kroku. Przy wielokrotności 24 kupujący zamawia 24, 48 lub 72 — nigdy 30. Kroki liczone są od minimum: przy minimum 50 i kroku 24 dozwolone są 50, 74 i 98.",
+ "order_minimum": "Najniższa wartość całego zamówienia, liczone tylko produkty — dostawa i podatek się nie liczą. Kupujący widzą, ile brakuje, a złożenie zamówienia jest blokowane do osiągnięcia progu."
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index f660fb9726..779812bf61 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -172,7 +172,14 @@
},
"mixed": "不一致",
"inherits": "默认",
- "default_help": "适用于本目录中的每个商品,除非某个商品在列表中另行设置。"
+ "default_help": "适用于本目录中的每个商品,除非某个商品在列表中另行设置。",
+ "column_minimum": "最小起订量",
+ "column_multiple": "订购倍数",
+ "help": {
+ "minimum": "买家单个商品可订购的最小数量。低于该数量的订单会被拒绝,并提示最接近的有效数量——系统绝不会自动向上取整。",
+ "multiple": "递增步长。倍数为 24 时,买家可订购 24、48 或 72——但不能是 30。步长从最小起订量开始计算:最小 50、步长 24 时,允许 50、74 和 98。",
+ "order_minimum": "整笔订单必须达到的最低金额,仅计算商品——运费和税费不计入。买家在选购时即可看到还差多少,未达到前无法结账。"
+ }
}
},
"categories": {
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
index f859918b12..51913a23ee 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
@@ -242,8 +242,15 @@ function CatalogBody({ catalog }: { catalog: Catalog }) {
form,
canEdit,
headers: {
- minimum: t('admin.fields.minimum_order_quantity.label'),
- multiple: t('admin.fields.order_multiple.label'),
+ // Short column headers — the card's own title already
+ // says these are quantity terms. The full names stay as
+ // the inputs' accessible labels.
+ minimum: t('admin.catalogs.terms.column_minimum'),
+ multiple: t('admin.catalogs.terms.column_multiple'),
+ minimumLabel: t('admin.fields.minimum_order_quantity.label'),
+ multipleLabel: t('admin.fields.order_multiple.label'),
+ minimumHelp: t('admin.catalogs.terms.help.minimum'),
+ multipleHelp: t('admin.catalogs.terms.help.multiple'),
mixed: t('admin.catalogs.terms.mixed'),
defaultHint: t('admin.catalogs.terms.inherits'),
},