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
Tighten the whole-parcel allowance and localize a download failure
Damian Legawiec9cebd6b89a54
diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.jsonindex 429a4a6c31..b484e887af 100644--- a/packages/dashboard-core/src/locales/ar.json+++ b/packages/dashboard-core/src/locales/ar.json@@ -499,6 +499,7 @@"failed_to_update_staff": "فشل تحديث الموظف","failed_to_update_store": "فشل تحديث إعدادات المتجر","generic": "حدث خطأ ما",+ "label_download_failed": "تعذّر تنزيل بطاقة الشحن","network": "خطأ في الشبكة — يرجى المحاولة مجددًا","not_found": "غير موجود","required": "هذا الحقل مطلوب",diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.jsonindex 00acde6298..b42c382cdd 100644--- a/packages/dashboard-core/src/locales/de.json+++ b/packages/dashboard-core/src/locales/de.json@@ -499,6 +499,7 @@"failed_to_update_staff": "Mitarbeiter konnte nicht aktualisiert werden","failed_to_update_store": "Store-Einstellungen konnten nicht aktualisiert werden","generic": "Ein Fehler ist aufgetreten",+ "label_download_failed": "Das Etikett konnte nicht heruntergeladen werden","network": "Netzwerkfehler — bitte erneut versuchen","not_found": "Nicht gefunden","required": "Dieses Feld ist erforderlich",diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.jsonindex a6c30a69be..a51afa2d23 100644--- a/packages/dashboard-core/src/locales/en.json+++ b/packages/dashboard-core/src/locales/en.json@@ -501,6 +501,7 @@"failed_to_update_staff": "Failed to update staff","failed_to_update_store": "Failed to update store settings","generic": "Something went wrong",+ "label_download_failed": "Could not download the label","network": "Network error — please retry","not_found": "Not found","required": "This field is required",diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.jsonindex 4b9a32fb9e..5a640d6915 100644--- a/packages/dashboard-core/src/locales/fr.json+++ b/packages/dashboard-core/src/locales/fr.json@@ -499,6 +499,7 @@"failed_to_update_staff": "Échec de la mise à jour du personnel","failed_to_update_store": "Échec de la mise à jour des paramètres de la boutique","generic": "Une erreur s'est produite",+ "label_download_failed": "Impossible de télécharger l'étiquette","network": "Erreur réseau — veuillez réessayer","not_found": "Introuvable","required": "Ce champ est obligatoire",diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.jsonindex 5fd692b239..de4a91712b 100644--- a/packages/dashboard-core/src/locales/pl.json+++ b/packages/dashboard-core/src/locales/pl.json@@ -500,6 +500,7 @@"failed_to_update_staff": "Nie udało się zaktualizować personelu","failed_to_update_store": "Nie udało się zaktualizować ustawień sklepu","generic": "Coś poszło nie tak",+ "label_download_failed": "Nie udało się pobrać etykiety","network": "Błąd sieci — spróbuj ponownie","not_found": "Nie znaleziono","required": "To pole jest wymagane",diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.jsonindex 258c914be9..7a65287d47 100644--- a/packages/dashboard-core/src/locales/zh-CN.json+++ b/packages/dashboard-core/src/locales/zh-CN.json@@ -499,6 +499,7 @@"failed_to_update_staff": "更新员工失败","failed_to_update_store": "更新店铺设置失败","generic": "出错了",+ "label_download_failed": "无法下载标签","network": "网络错误 — 请重试","not_found": "未找到","required": "此字段为必填项",diff --git a/packages/dashboard-ui/src/spree/fulfill-items-form.tsx b/packages/dashboard-ui/src/spree/fulfill-items-form.tsxindex 0321d36958..30d2418f9f 100644--- a/packages/dashboard-ui/src/spree/fulfill-items-form.tsx+++ b/packages/dashboard-ui/src/spree/fulfill-items-form.tsx@@ -133,6 +133,7 @@ export function FulfillItemsForm({carrierOptions,onSubmit,onCancel,+ canShipWholeParcel = false,pending = false,}: {form: UseFormReturn<FulfillItemsValues>@@ -142,6 +143,16 @@ export function FulfillItemsForm({carrierOptions: Array<{ value: string; label: string }>onSubmit: (values: FulfillItemsValues) => void | Promise<void>onCancel: () => void+ /**+ * Whether the parcel can ship with nothing picked.+ *+ * True when it holds items that no row can address — the workflow reads an+ * empty selection as "everything", so blocking submit would leave such a+ * parcel unshippable. Never inferred from `rows` being empty here: that+ * cannot tell an unaddressable parcel from an empty one, and an empty+ * fulfillment must stay unsubmittable.+ */+ canShipWholeParcel?: booleanpending?: boolean}) {const { t } = useTranslation()@@ -154,10 +165,6 @@ export function FulfillItemsForm({)const totalAvailable = rows.reduce((sum, row) => sum + row.quantity, 0)const shipsEverything = totalSelected === totalAvailable- // A parcel whose items cannot be addressed by line item has nothing to pick- // from, but it still ships — the workflow reads an empty selection as- // "everything". Blocking submit would leave it unshippable.- const shipsWholeParcel = rows.length === 0return (<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col">@@ -262,7 +269,7 @@ export function FulfillItemsForm({<Buttontype="submit"size="sm"- disabled={(totalSelected === 0 && !shipsWholeParcel) || pending}+ disabled={(totalSelected === 0 && !canShipWholeParcel) || pending}>{pending ? t('admin.actions.saving') : t('admin.orders.fulfill.submit')}</Button>diff --git a/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsxindex 910701aa1f..7e8220c06b 100644--- a/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx+++ b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx@@ -48,6 +48,10 @@ export function FulfillmentFulfillForm({const idPrefix = `fulfill-${fulfillment.id}`const rows = fulfillableRows(fulfillmentItemRows(fulfillment, order.items ?? []))+ // The parcel holds units, but none of them can be named by line item — the+ // only case where shipping with nothing picked is right. An empty parcel+ // has nothing to ship and stays unsubmittable.+ const canShipWholeParcel = rows.length === 0 && (fulfillment.fulfillment_items?.length ?? 0) > 0const form = useForm<FulfillItemsFormValues>({resolver: zodResolver(fulfillItemsFormSchema),@@ -90,10 +94,10 @@ export function FulfillmentFulfillForm({const items = values.items.filter((item) => item.selected && item.quantity > 0).map((item) => ({ item_id: item.item_id, quantity: item.quantity }))- // Nothing addressable by line item means the whole parcel goes, which is- // what an omitted `items` asks for. Only a partial pick that came out- // empty is a no-op worth refusing.- if (items.length === 0 && rows.length > 0) return+ // An omitted `items` ships the whole parcel, which is only right when+ // nothing was addressable. A partial pick that came out empty, or an+ // empty parcel, is a no-op worth refusing.+ if (items.length === 0 && !canShipWholeParcel) return// Recomputed from the submitted values rather than a watched total, so the// branch is decided by exactly what is being sent.@@ -124,6 +128,7 @@ export function FulfillmentFulfillForm({carrierOptions={carrierOptions}onSubmit={onSubmit}onCancel={onDone}+ canShipWholeParcel={canShipWholeParcel}pending={fulfill.isPending}/>)diff --git a/packages/dashboard/src/components/spree/orders/shipping-label-row.tsx b/packages/dashboard/src/components/spree/orders/shipping-label-row.tsxindex f12fa65ec2..aa82d564bf 100644--- a/packages/dashboard/src/components/spree/orders/shipping-label-row.tsx+++ b/packages/dashboard/src/components/spree/orders/shipping-label-row.tsx@@ -61,11 +61,12 @@ export function ShippingLabelRow({`${label.tracking_number ?? 'label'}.${label.format ?? 'pdf'}`,getApiClient().downloadHeaders?.() ?? {},)- } catch (error) {- toastManager.add({- type: 'error',- title: error instanceof Error ? error.message : t('admin.errors.unexpected'),- })+ } catch {+ // Deliberately not the thrown message: `downloadFromApi` reports the+ // transport in English ("Download failed: 404"), which would land+ // untranslated in a localized panel and tells the merchant nothing they+ // can act on.+ toastManager.add({ type: 'error', title: t('admin.errors.label_download_failed') })}}diff --git a/packages/seller-dashboard/src/components/orders/fulfillment-fulfill-form.tsx b/packages/seller-dashboard/src/components/orders/fulfillment-fulfill-form.tsxindex dbcf3bf0e3..fd369a83aa 100644--- a/packages/seller-dashboard/src/components/orders/fulfillment-fulfill-form.tsx+++ b/packages/seller-dashboard/src/components/orders/fulfillment-fulfill-form.tsx@@ -48,6 +48,10 @@ export function FulfillmentFulfillForm({const idPrefix = `fulfill-${fulfillment.id}`const rows = fulfillableRows(fulfillmentItemRows(fulfillment, order.items ?? []))+ // The parcel holds units, but none of them can be named by line item — the+ // only case where shipping with nothing picked is right. An empty parcel+ // has nothing to ship and stays unsubmittable.+ const canShipWholeParcel = rows.length === 0 && (fulfillment.fulfillment_items?.length ?? 0) > 0const form = useForm<FulfillItemsFormValues>({resolver: zodResolver(fulfillItemsFormSchema),@@ -89,10 +93,10 @@ export function FulfillmentFulfillForm({const items = values.items.filter((item) => item.selected && item.quantity > 0).map((item) => ({ item_id: item.item_id, quantity: item.quantity }))- // Nothing addressable by line item means the whole parcel goes, which is- // what an omitted `items` asks for. Only a partial pick that came out- // empty is a no-op worth refusing.- if (items.length === 0 && rows.length > 0) return+ // An omitted `items` ships the whole parcel, which is only right when+ // nothing was addressable. A partial pick that came out empty, or an+ // empty parcel, is a no-op worth refusing.+ if (items.length === 0 && !canShipWholeParcel) returnconst everything = items.reduce((sum, item) => sum + item.quantity, 0) === totalAvailableconst tracking = values.tracking.trim()@@ -121,6 +125,7 @@ export function FulfillmentFulfillForm({carrierOptions={carrierOptions}onSubmit={onSubmit}onCancel={onDone}+ canShipWholeParcel={canShipWholeParcel}pending={fulfill.isPending}/>)diff --git a/packages/seller-dashboard/src/components/orders/shipping-label-row.tsx b/packages/seller-dashboard/src/components/orders/shipping-label-row.tsxindex 637f3ef5d3..36dc1ff970 100644--- a/packages/seller-dashboard/src/components/orders/shipping-label-row.tsx+++ b/packages/seller-dashboard/src/components/orders/shipping-label-row.tsx@@ -56,11 +56,12 @@ export function ShippingLabelRow({`${label.tracking_number ?? 'label'}.${label.format ?? 'pdf'}`,getApiClient().downloadHeaders?.() ?? {},)- } catch (error) {- toastManager.add({- type: 'error',- title: error instanceof Error ? error.message : t('admin.errors.unexpected'),- })+ } catch {+ // Deliberately not the thrown message: `downloadFromApi` reports the+ // transport in English ("Download failed: 404"), which would land+ // untranslated in a localized panel and tells the merchant nothing they+ // can act on.+ toastManager.add({ type: 'error', title: t('admin.errors.label_download_failed') })}}