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: Cancelling a dispatched order refused without saying why
Łukasz Adamczyk6ba8d101bee7
diff --git a/spree/core/app/workflows/spree/orders/cancel.rb b/spree/core/app/workflows/spree/orders/cancel.rbindex 0fa749e59e..bfbb31b938 100644--- a/spree/core/app/workflows/spree/orders/cancel.rb+++ b/spree/core/app/workflows/spree/orders/cancel.rb@@ -71,7 +71,10 @@ module Spreeprivatedef ensure_cancellable- failure(order) unless order.allow_cancel?+ return if order.allow_cancel?++ order.errors.add(:base, :not_cancellable, message: Spree.t('errors.messages.not_cancellable'))+ failure(order)end# An ordinary order settles at the gateway, which returns the wholediff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.ymlindex f420258cea..e308d276a2 100644--- a/spree/core/config/locales/en.yml+++ b/spree/core/config/locales/en.yml@@ -652,7 +652,6 @@ en:not_saved:one: '1 error prohibited this %{resource} from being saved:'other: "%{count} errors prohibited this %{resource} from being saved:"- refund_amount_requires_shared_payment: can only be set when the payment is shared across a split checkoutseeded_report_read_only: is a built-in report and cannot be changed — save a copy insteadnumber:currency:@@ -1081,6 +1080,7 @@ en:must_be_greater_than_min_amount: must be greater than or equal to the minimummust_be_origin_only: must be an origin (scheme and host) without path, query, or fragmentno_pickup_point_provider: this delivery method has no pickup point provider configured+ not_cancellable: cannot be canceled once its goods have been dispatchedoidc_account_not_provisioned: This account is not authorized for this store. Ask an administrator for an invitation.oidc_authentication_failed: We could not sign you in with this provider. Please try again.oidc_missing_code: The identity provider did not return an authorization code.@@ -1092,6 +1092,7 @@ en:rate_provider_requires_shipping: "%{provider} quotes shipments, so this method must ship to an address"rate_provider_unavailable: is not available for this store — connect its integration firstreceived_exceeds_expected: cannot be more than the %{expected} expected+ refund_amount_requires_shared_payment: can only be set when the payment is shared across a split checkoutsame_as_inviter: cannot be the same as the inviterseller_delivery_method_not_shareable: only the marketplace's own delivery methods can be shared with sellersseller_delivery_method_provider: a seller's delivery method prices its own rates and is fulfilled by hand — carrier accounts belong to the marketplacediff --git a/spree/core/spec/workflows/spree/orders/cancel_spec.rb b/spree/core/spec/workflows/spree/orders/cancel_spec.rbindex 6659785668..6548e7a8bc 100644--- a/spree/core/spec/workflows/spree/orders/cancel_spec.rb+++ b/spree/core/spec/workflows/spree/orders/cancel_spec.rb@@ -68,6 +68,19 @@ module Spreeendend+ context 'an order whose goods have gone out' do+ let(:order) { create(:completed_order_with_totals) }++ before { order.update_columns(fulfillment_status: 'fulfilled') }++ it { expect(result).to be_failure }++ it 'says why it refused' do+ expect(result.error.value.full_messages.join).+ to include(Spree.t('errors.messages.not_cancellable'))+ end+ end+context 'incomplete order' dolet(:order) { create(:order_with_totals) }