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
Keep carrier-priced delivery methods legible
Damian Legawiec1a14135c7b4c
diff --git a/packages/dashboard/src/components/spree/shipping/delivery-method-form.tsx b/packages/dashboard/src/components/spree/shipping/delivery-method-form.tsxindex 17e25627ca..a37db93aae 100644--- a/packages/dashboard/src/components/spree/shipping/delivery-method-form.tsx+++ b/packages/dashboard/src/components/spree/shipping/delivery-method-form.tsx@@ -401,6 +401,19 @@ function ProvidersCard({disabled: !provider.available,}))+ // A provider the registry no longer offers — an uninstalled gem, or a list+ // fetched before its integration was connected — would otherwise render as+ // its bare class name, since the trigger label comes from these options.+ if (rateProvider && !rateProviderOptions.some((option) => option.value === rateProvider)) {+ rateProviderOptions.push({+ value: rateProvider,+ label: t('admin.delivery_methods.provider_unavailable', {+ name: rateProvider.split('::').pop() ?? rateProvider,+ }),+ disabled: true,+ })+ }+// Every installed shipping integration that isn't connected yet, straight// from the integrations registry — a carrier gem is offered here even// before it registers a provider, so the merchant never has to discover@@ -558,10 +571,13 @@ function useSelectedRateProvider(const rateProvider = form.watch('rate_provider')const defaultRateProvider = rateProviders?.default ?? ''+ // Matched on type alone: a saved method keeps its provider even while the+ // integration is disconnected, and reading that as "no provider" would show+ // the method as calculator-priced and offer pricing that never applies.return useMemo(() =>(rateProviders?.data ?? []).find(- (provider) => provider.available && provider.type === (rateProvider || defaultRateProvider),+ (provider) => provider.type === (rateProvider || defaultRateProvider),),[rateProviders, rateProvider, defaultRateProvider],)diff --git a/packages/dashboard/src/hooks/use-integrations.ts b/packages/dashboard/src/hooks/use-integrations.tsindex e81e6954b9..27a4a04cbc 100644--- a/packages/dashboard/src/hooks/use-integrations.ts+++ b/packages/dashboard/src/hooks/use-integrations.ts@@ -24,11 +24,18 @@ export function useIntegrationTypes() {})}-/** Connects an integration type to the store. Activating verifies the connection server-side. */+/**+ * Connects an integration type to the store. Activating verifies the+ * connection server-side.+ *+ * Provider discovery is invalidated alongside: a carrier's rate and+ * fulfillment providers only become selectable once its integration is+ * connected, and those lists cache for half an hour.+ */export function useCreateIntegration() {return useResourceMutation<Integration, Error, IntegrationCreateParams>({mutationFn: (params) => adminClient.integrations.create(params),- invalidate: [['integrations']],+ invalidate: [['integrations'], ['delivery-methods']],successMessage: i18n.t('admin.integrations.messages.connected'),errorMessage: i18n.t('admin.errors.failed_to_create'),})@@ -38,7 +45,7 @@ export function useCreateIntegration() {export function useUpdateIntegration(id: string) {return useResourceMutation<Integration, Error, IntegrationUpdateParams>({mutationFn: (params) => adminClient.integrations.update(id, params),- invalidate: [['integrations']],+ invalidate: [['integrations'], ['delivery-methods']],successMessage: i18n.t('admin.integrations.messages.updated'),errorMessage: i18n.t('admin.errors.failed_to_update'),})@@ -48,7 +55,7 @@ export function useUpdateIntegration(id: string) {export function useDeleteIntegration() {return useResourceMutation<void, Error, string>({mutationFn: (id) => adminClient.integrations.delete(id),- invalidate: [['integrations']],+ invalidate: [['integrations'], ['delivery-methods']],successMessage: i18n.t('admin.integrations.messages.disconnected'),errorMessage: i18n.t('admin.errors.failed_to_delete'),})diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 7be4e39649..1e95cc86ce 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -517,6 +517,8 @@"amount_in_currency": "المبلغ بعملة {{currency}}","currency_amounts_help": "العملات المتروكة فارغة لا تُعرض لها طريقة التوصيل هذه."},+ "carrier_rates": "أسعار شركة الشحن",+ "provider_unavailable": "{{name}} (غير متاح)","provider_needs_connection": "اربط {{name}} لاستخدامه","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex b1d5581258..e31ba68299 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -517,6 +517,8 @@"amount_in_currency": "Betrag in {{currency}}","currency_amounts_help": "Währungen ohne Betrag wird diese Versandart nicht angeboten."},+ "carrier_rates": "Carrier-Tarife",+ "provider_unavailable": "{{name}} (nicht verfügbar)","provider_needs_connection": "{{name}} verbinden, um es zu nutzen","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 57f1a0bd6c..c38d09e4cd 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -517,6 +517,8 @@"amount_in_currency": "Amount in {{currency}}","currency_amounts_help": "Currencies left blank are not offered this delivery method."},+ "carrier_rates": "Carrier rates",+ "provider_unavailable": "{{name}} (unavailable)","provider_needs_connection": "Connect {{name}} to use it","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 2272ec21ab..19b82347fb 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -517,6 +517,8 @@"amount_in_currency": "Montant en {{currency}}","currency_amounts_help": "Les devises laissées vides ne se voient pas proposer cette méthode de livraison."},+ "carrier_rates": "Tarifs transporteur",+ "provider_unavailable": "{{name}} (indisponible)","provider_needs_connection": "Connectez {{name}} pour l’utiliser","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex b32e209e2e..852b97da9c 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -525,6 +525,8 @@"amount_in_currency": "Kwota w {{currency}}","currency_amounts_help": "Waluty bez kwoty nie mają oferowanej tej metody dostawy."},+ "carrier_rates": "Stawki przewoźnika",+ "provider_unavailable": "{{name}} (niedostępny)","provider_needs_connection": "Połącz {{name}}, aby użyć","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex 4f8aaa1e89..5f94828836 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -517,6 +517,8 @@"amount_in_currency": "{{currency}} 金额","currency_amounts_help": "未填写金额的币种将不会提供该配送方式。"},+ "carrier_rates": "承运商费率",+ "provider_unavailable": "{{name}}(不可用)","provider_needs_connection": "连接 {{name}} 后即可使用","rule_summary": {"separator": " · ",diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index.tsxindex a148420cdd..d5eb9aae4a 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index.tsx@@ -1011,6 +1011,7 @@ function MethodList({const deleteMutation = useDeleteDeliveryMethod()const { permissions } = usePermissions()const { data: rateProviders } = useDeliveryRateProviders()+ const defaultRateProvider = rateProviders?.default ?? ''async function handleDelete(method: DeliveryMethod) {const ok = await confirm({@@ -1040,10 +1041,16 @@ function MethodList({// A carrier quotes each shipment live, so there is no one price to// show — the carrier's name is the honest answer. Everything else is// priced up front: an amount, or free when there is none.- const carrierPriced = rateProvider?.uses_calculator === false+ //+ // A method carrying a rate provider absent from the registry (an+ // uninstalled gem, a disconnected integration) is still not+ // calculator-priced, and calling it free would be a lie about money.+ const carrierPriced = rateProvider+ ? rateProvider.uses_calculator === false+ : !!method.rate_provider && method.rate_provider !== defaultRateProviderconst amount = flatAmount(method.calculator_preferences)const price = carrierPriced- ? rateProvider.name+ ? (rateProvider?.name ?? t('admin.delivery_methods.carrier_rates')): amount === null || amount === 0? t('admin.delivery_methods.free'): formatAmount(amount, defaultCurrency, i18n.language)diff --git a/packages/dashboard/src/tables/delivery-profiles.tsx b/packages/dashboard/src/tables/delivery-profiles.tsxindex debdb47a86..68f4ec49b7 100644--- a/packages/dashboard/src/tables/delivery-profiles.tsx+++ b/packages/dashboard/src/tables/delivery-profiles.tsx@@ -5,7 +5,7 @@ import i18n from 'i18next'import { TruckIcon } from 'lucide-react'defineTable<DeliveryProfile>('delivery-profiles', {- title: i18n.t('admin.settings_nav.items.shipping'),+ title: i18n.t('admin.settings_nav.items.delivery_profiles'),searchParam: 'name_cont',searchPlaceholder: i18n.t('admin.delivery_profiles.search_placeholder'),defaultSort: { field: 'position', direction: 'asc' },