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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix: Clarify promotion item total operators (#15053)
Chiu22c36c081fbd
diff --git a/packages/dashboard/e2e/promotions.spec.ts b/packages/dashboard/e2e/promotions.spec.tsindex a2b503f435..acff048286 100644--- a/packages/dashboard/e2e/promotions.spec.ts+++ b/packages/dashboard/e2e/promotions.spec.ts@@ -450,7 +450,7 @@ test.describe('promotions', () => {// Money goes to the API as an exact decimal string; each value must read// back as typed after the promotion is saved and reloaded.- test('keeps a flat rate amount and an item total minimum exactly', async ({ page }) => {+ test('keeps item total comparisons and exact amounts after reload', async ({ page }) => {const creds = await login(page)await gotoIndex(page, PROMOTIONS_PATH(creds.store_id), CTA)@@ -458,7 +458,29 @@ test.describe('promotions', () => {await startNewPromotion(page, creds.store_id, name)await pickRule(page, /^item total\b/i)- await page.getByRole('dialog').locator('#preference-amount_min').fill('50.25')+ const ruleDialog = page.getByRole('dialog')+ await ruleDialog.locator('#preference-amount_min').fill('50.25')+ await ruleDialog.locator('#preference-amount_max').fill('250.75')++ const minimumComparison = ruleDialog.locator('#preference-operator_min')+ await minimumComparison.click()+ await page+ .getByRole('option', { name: /greater than or equal to \(includes the minimum\)/i })+ .click()+ await expect(minimumComparison).toContainText(/greater than or equal to/i)++ const maximumComparison = ruleDialog.locator('#preference-operator_max')+ await maximumComparison.click()+ await page+ .getByRole('option', { name: /less than or equal to \(includes the maximum\)/i })+ .click()+ await expect(maximumComparison).toContainText(/less than or equal to/i)++ await expect(ruleDialog.getByText(/^minimum comparison$/i)).toBeVisible()+ await expect(ruleDialog.getByText(/^maximum comparison$/i)).toBeVisible()+ await expect(+ ruleDialog.getByText(/for free shipping on item totals of 150 or more/i),+ ).toBeVisible()await saveEditor(page)await pickAction(page, /^create whole-order adjustment\b/i)@@ -486,9 +508,19 @@ test.describe('promotions', () => {.getByRole('button').first().click()- await expect(page.getByRole('dialog').locator('#preference-amount_min')).toHaveValue('50.25', {+ const savedRuleDialog = page.getByRole('dialog')+ await expect(savedRuleDialog.locator('#preference-amount_min')).toHaveValue('50.25', {timeout: 5_000,})+ await expect(savedRuleDialog.locator('#preference-amount_max')).toHaveValue('250.75')+ await expect(savedRuleDialog.locator('#preference-operator_min')).toContainText(+ /greater than or equal to/i,+ )+ await expect(savedRuleDialog.locator('#preference-operator_max')).toContainText(+ /less than or equal to/i,+ )+ await expect(savedRuleDialog.getByText(/^minimum comparison$/i)).toBeVisible()+ await expect(savedRuleDialog.getByText(/^maximum comparison$/i)).toBeVisible()})test('keeps a flat percent discount exactly', async ({ page }) => {diff --git a/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx b/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsxindex d6119e3cd5..55d3015f8a 100644--- a/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx+++ b/packages/dashboard/src/components/spree/promotion-editors/promotion-form.tsx@@ -1052,10 +1052,38 @@ function RuleEditSheet({function DefaultRuleEditor({ draft, onSave, onClose }: PromotionRuleEditorContext) {const { t } = useTranslation()- const [values, setValues] = useState<Record<string, unknown>>(draft.preferences ?? {})+ const [values, setValues] = useState<Record<string, unknown>>(() => {+ const preferences = draft.preferences ?? {}+ if (draft.type !== 'item_total') return preferences++ return {+ ...preferences,+ operator_min: preferences.operator_min === 'gte' ? 'gte' : 'gt',+ operator_max: preferences.operator_max === 'lte' ? 'lte' : 'lt',+ }+ })const { data: typesData } = usePromotionRuleTypes()const schema = typesData?.data.find((type) => type.type === draft.type)?.schema- const hasPreferences = Object.keys(schema?.properties ?? {}).length > 0+ const ruleSchema =+ draft.type === 'item_total' && schema+ ? {+ ...schema,+ properties: {+ ...schema.properties,+ operator_min: {+ ...(schema.properties.operator_min ?? { type: 'string' }),+ default: 'gt',+ enum: ['gt', 'gte'],+ },+ operator_max: {+ ...(schema.properties.operator_max ?? { type: 'string' }),+ default: 'lt',+ enum: ['lt', 'lte'],+ },+ },+ }+ : schema+ const hasPreferences = Object.keys(ruleSchema?.properties ?? {}).length > 0function handleSave() {onSave({ ...draft, preferences: values })@@ -1070,7 +1098,7 @@ function DefaultRuleEditor({ draft, onSave, onClose }: PromotionRuleEditorContexsaveLabel={hasPreferences ? undefined : t('admin.actions.add')}>{hasPreferences ? (- <PreferencesForm schema={schema} values={values} onChange={setValues} />+ <PreferencesForm schema={ruleSchema} values={values} onChange={setValues} />) : (<p className="text-sm text-muted-foreground">{t('admin.promotions.rule_edit.no_options')}diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 83fff64c27..e077ab0eac 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -4751,7 +4751,23 @@"terms_url": "رابط الشروط","terms_url_description": "نسخة منشورة اختيارية من الشروط نفسها، تُفتح في علامة تبويب جديدة.","webhook_secret": "مفتاح توقيع الويب هوك",- "webhook_secret_description": "السر الذي ضبطته على ويب هوك EasyPost. بدونه تُرفض تحديثات شركة الشحن."+ "webhook_secret_description": "السر الذي ضبطته على ويب هوك EasyPost. بدونه تُرفض تحديثات شركة الشحن.",+ "operator_max": "مقارنة الحد الأقصى",+ "operator_max_description": "اختر ما إذا كان الطلب الذي يساوي الحد الأقصى مؤهلًا.",+ "operator_max_options": {+ "lt": "أقل من (باستثناء الحد الأقصى)",+ "lte": "أقل من أو يساوي (مع الحد الأقصى)"+ },+ "operator_min": "مقارنة الحد الأدنى",+ "operator_min_description": "مثال: للشحن المجاني للطلبات بقيمة 150 أو أكثر، أدخل 150 في الحد الأدنى لإجمالي المنتجات واختر «أكبر من أو يساوي».",+ "operator_min_options": {+ "gt": "أكبر من (باستثناء الحد الأدنى)",+ "gte": "أكبر من أو يساوي (مع الحد الأدنى)"+ },+ "amount_min": "الحد الأدنى لإجمالي المنتجات",+ "amount_min_description": "يجب أن يصل إجمالي منتجات الطلب إلى هذا المبلغ حتى يستوفي الشرط.",+ "amount_max": "الحد الأقصى لإجمالي المنتجات",+ "amount_max_description": "حد أعلى اختياري. اتركه فارغًا لعدم تحديد حد أقصى."},"product_types": {"add_cta": "إضافة نوع منتج",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex d77621624f..43de6c7a47 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -4719,7 +4719,23 @@"terms_url": "URL der Bedingungen","terms_url_description": "Optionale veröffentlichte Fassung derselben Bedingungen, öffnet in einem neuen Tab.","webhook_secret": "Webhook-Signaturschlüssel",- "webhook_secret_description": "Das Geheimnis, das Sie im EasyPost-Webhook festgelegt haben. Ohne es werden Carrier-Updates abgelehnt."+ "webhook_secret_description": "Das Geheimnis, das Sie im EasyPost-Webhook festgelegt haben. Ohne es werden Carrier-Updates abgelehnt.",+ "operator_max": "Vergleich des Höchstbetrags",+ "operator_max_description": "Wählen Sie, ob eine Bestellung genau am Höchstbetrag noch berechtigt ist.",+ "operator_max_options": {+ "lt": "Kleiner als (Höchstbetrag ausgeschlossen)",+ "lte": "Kleiner oder gleich (Höchstbetrag eingeschlossen)"+ },+ "operator_min": "Vergleich des Mindestbetrags",+ "operator_min_description": "Beispiel: Für kostenlosen Versand ab 150 setzen Sie den Mindestwarenwert auf 150 und wählen „Größer oder gleich“.",+ "operator_min_options": {+ "gt": "Größer als (Mindestbetrag ausgeschlossen)",+ "gte": "Größer oder gleich (Mindestbetrag eingeschlossen)"+ },+ "amount_min": "Mindestwarenwert",+ "amount_min_description": "Der Warenwert der Bestellung muss diesen Betrag erreichen, damit die Bestellung berechtigt ist.",+ "amount_max": "Höchstwarenwert",+ "amount_max_description": "Optionale Obergrenze. Leer lassen, wenn es kein Maximum gibt."},"product_types": {"add_cta": "Produkttyp hinzufügen",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 3597489aca..52c9f286a3 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -4719,7 +4719,23 @@"terms_url": "Terms URL","terms_url_description": "Optional published copy of the same terms, opened in a new tab.","webhook_secret": "Webhook signing secret",- "webhook_secret_description": "The secret you set on the EasyPost webhook. Carrier updates are refused without it."+ "webhook_secret_description": "The secret you set on the EasyPost webhook. Carrier updates are refused without it.",+ "operator_max": "Maximum comparison",+ "operator_max_description": "Choose whether an order exactly at Amount Max qualifies.",+ "operator_max_options": {+ "lt": "Less than (excludes the maximum)",+ "lte": "Less than or equal to (includes the maximum)"+ },+ "operator_min": "Minimum comparison",+ "operator_min_description": "Example: for free shipping on item totals of 150 or more, set Minimum item total to 150 and choose “Greater than or equal to.”",+ "operator_min_options": {+ "gt": "Greater than (excludes the minimum)",+ "gte": "Greater than or equal to (includes the minimum)"+ },+ "amount_min": "Minimum item total",+ "amount_min_description": "The order item total must reach this amount to qualify.",+ "amount_max": "Maximum item total",+ "amount_max_description": "Optional upper limit. Leave blank for no maximum."},"product_types": {"add_cta": "Add product type",diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.jsonindex fcb7e73501..78639d4fb5 100644--- a/packages/dashboard/src/locales/es.json+++ b/packages/dashboard/src/locales/es.json@@ -4606,7 +4606,23 @@"terms_url": "URL de las condiciones","terms_url_description": "Copia publicada opcional de las mismas condiciones, que se abre en una pestaña nueva.","webhook_secret": "Secreto de firma del webhook",- "webhook_secret_description": "El secreto que configuraste en el webhook de EasyPost. Sin él se rechazan las actualizaciones del transportista."+ "webhook_secret_description": "El secreto que configuraste en el webhook de EasyPost. Sin él se rechazan las actualizaciones del transportista.",+ "operator_max": "Comparación del importe máximo",+ "operator_max_description": "Elige si un pedido que alcanza exactamente el importe máximo cumple la condición.",+ "operator_max_options": {+ "lt": "Menor que (excluye el máximo)",+ "lte": "Menor o igual que (incluye el máximo)"+ },+ "operator_min": "Comparación del importe mínimo",+ "operator_min_description": "Ejemplo: para envío gratis desde 150, indica 150 como importe mínimo de productos y elige “Mayor o igual que”.",+ "operator_min_options": {+ "gt": "Mayor que (excluye el mínimo)",+ "gte": "Mayor o igual que (incluye el mínimo)"+ },+ "amount_min": "Importe mínimo de productos",+ "amount_min_description": "El importe de los productos del pedido debe alcanzar esta cantidad para cumplir la condición.",+ "amount_max": "Importe máximo de productos",+ "amount_max_description": "Límite superior opcional. Déjalo en blanco para no establecer un máximo."},"categories": {"add_cta": "Nueva categoría",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 167f5249d4..7c8f045106 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -4720,7 +4720,23 @@"terms_url": "URL des conditions","terms_url_description": "Copie publiée facultative des mêmes conditions, ouverte dans un nouvel onglet.","webhook_secret": "Clé de signature du webhook",- "webhook_secret_description": "Le secret défini sur le webhook EasyPost. Sans lui, les mises à jour du transporteur sont refusées."+ "webhook_secret_description": "Le secret défini sur le webhook EasyPost. Sans lui, les mises à jour du transporteur sont refusées.",+ "operator_max": "Comparaison du montant maximal",+ "operator_max_description": "Choisissez si une commande égale au montant maximal est admissible.",+ "operator_max_options": {+ "lt": "Inférieur à (plafond exclu)",+ "lte": "Inférieur ou égal à (plafond inclus)"+ },+ "operator_min": "Comparaison du montant minimal",+ "operator_min_description": "Exemple : pour la livraison gratuite dès 150, indiquez 150 comme montant minimum des articles et choisissez « Supérieur ou égal à ».",+ "operator_min_options": {+ "gt": "Supérieur à (minimum exclu)",+ "gte": "Supérieur ou égal à (minimum inclus)"+ },+ "amount_min": "Montant minimum des articles",+ "amount_min_description": "Le montant des articles de la commande doit atteindre ce seuil pour remplir la condition.",+ "amount_max": "Montant maximum des articles",+ "amount_max_description": "Limite supérieure facultative. Laissez vide pour ne pas fixer de maximum."},"product_types": {"add_cta": "Ajouter un type de produit",diff --git a/packages/dashboard/src/locales/ja.json b/packages/dashboard/src/locales/ja.jsonindex 3469b1b382..243fc8bb5f 100644--- a/packages/dashboard/src/locales/ja.json+++ b/packages/dashboard/src/locales/ja.json@@ -4719,7 +4719,23 @@"terms_url": "規約の URL","terms_url_description": "同じ規約を公開したもの(任意)。新しいタブで開きます。","webhook_secret": "Webhook の署名用の秘密",- "webhook_secret_description": "EasyPost の Webhook に設定した秘密です。これがないと運送会社からの更新を受け付けません。"+ "webhook_secret_description": "EasyPost の Webhook に設定した秘密です。これがないと運送会社からの更新を受け付けません。",+ "operator_max": "上限金額の比較方法",+ "operator_max_description": "注文金額が上限金額と同じ場合に対象にするか選びます。",+ "operator_max_options": {+ "lt": "未満(上限を含まない)",+ "lte": "以下(上限を含む)"+ },+ "operator_min": "下限金額の比較方法",+ "operator_min_description": "例:150以上で送料無料にする場合、商品合計の最低額に150を入力して「以上」を選びます。",+ "operator_min_options": {+ "gt": "より大きい(下限を含まない)",+ "gte": "以上(下限を含む)"+ },+ "amount_min": "商品合計の最低額",+ "amount_min_description": "条件を満たすには、注文の商品合計がこの金額に達する必要があります。",+ "amount_max": "商品合計の最高額",+ "amount_max_description": "任意の上限です。上限を設けない場合は空欄にします。"},"product_types": {"add_cta": "商品タイプを追加",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex 363830617b..bdc0e7d8ed 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -4775,7 +4775,23 @@"terms_url": "Adres URL regulaminu","terms_url_description": "Opcjonalna opublikowana kopia tego samego regulaminu, otwierana w nowej karcie.","webhook_secret": "Sekret podpisu webhooka",- "webhook_secret_description": "Sekret ustawiony na webhooku EasyPost. Bez niego aktualizacje od przewoźnika są odrzucane."+ "webhook_secret_description": "Sekret ustawiony na webhooku EasyPost. Bez niego aktualizacje od przewoźnika są odrzucane.",+ "operator_max": "Porównanie kwoty maksymalnej",+ "operator_max_description": "Wybierz, czy zamówienie równe kwocie maksymalnej spełnia warunek.",+ "operator_max_options": {+ "lt": "Mniej niż (bez kwoty maksymalnej)",+ "lte": "Mniej niż lub równo (z kwotą maksymalną)"+ },+ "operator_min": "Porównanie kwoty minimalnej",+ "operator_min_description": "Przykład: aby zapewnić darmową dostawę od 150, wpisz 150 jako minimalną wartość produktów i wybierz „Większe niż lub równe”.",+ "operator_min_options": {+ "gt": "Więcej niż (bez kwoty minimalnej)",+ "gte": "Więcej niż lub równo (z kwotą minimalną)"+ },+ "amount_min": "Minimalna wartość produktów",+ "amount_min_description": "Wartość produktów w zamówieniu musi osiągnąć tę kwotę, aby spełnić warunek.",+ "amount_max": "Maksymalna wartość produktów",+ "amount_max_description": "Opcjonalny limit górny. Pozostaw puste, aby nie ustawiać maksimum."},"product_types": {"add_cta": "Dodaj typ produktu",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex b78a8b2488..f4b28b59d5 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -4708,7 +4708,23 @@"terms_url": "条款链接","terms_url_description": "同一条款的可选已发布副本,在新标签页中打开。","webhook_secret": "Webhook 签名密钥",- "webhook_secret_description": "您在 EasyPost webhook 上设置的密钥。缺少它,承运商更新将被拒绝。"+ "webhook_secret_description": "您在 EasyPost webhook 上设置的密钥。缺少它,承运商更新将被拒绝。",+ "operator_max": "最高金额比较方式",+ "operator_max_description": "订单金额刚好等于最高金额时,决定是否仍符合条件。",+ "operator_max_options": {+ "lt": "小于(不含最高金额)",+ "lte": "小于或等于(含最高金额)"+ },+ "operator_min": "最低金额比较方式",+ "operator_min_description": "例如满 150 包邮:最低商品总额填 150,并选择“大于或等于”。",+ "operator_min_options": {+ "gt": "大于(不含最低金额)",+ "gte": "大于或等于(含最低金额)"+ },+ "amount_min": "最低商品总额",+ "amount_min_description": "订单中的商品金额需要达到此金额,优惠才符合条件。",+ "amount_max": "最高商品总额",+ "amount_max_description": "可选。留空表示不设最高金额。"},"product_types": {"add_cta": "添加商品类型",