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.

Fix displaying cancelled orders on the storefront (#12511)

Łukasz Adamczyk129150cd20fe
diff --git a/core/app/models/spree/ability.rb b/core/app/models/spree/ability.rb
index 3aa75707eb..4f26ede840 100644
--- a/core/app/models/spree/ability.rb
+++ b/core/app/models/spree/ability.rb
@@ -58,6 +58,8 @@ module Spree
def apply_admin_permissions(user)
can :manage, :all
+ cannot :cancel, Spree::Order
+ can :cancel, Spree::Order, &:allow_cancel?
cannot [:edit, :update], Spree::RefundReason, mutable: false
cannot [:edit, :update], Spree::ReimbursementType, mutable: false
end
diff --git a/storefront/app/views/themes/default/spree/shared/_order_details.html.erb b/storefront/app/views/themes/default/spree/shared/_order_details.html.erb
index ae8c38aa29..f9b63ebe94 100644
--- a/storefront/app/views/themes/default/spree/shared/_order_details.html.erb
+++ b/storefront/app/views/themes/default/spree/shared/_order_details.html.erb
@@ -2,11 +2,13 @@
<% if order.order_refunded? || order.partially_refunded? %>
<div class="alert-warning mb-5 py-2 px-3">
- <% if order.gift_card %>
- <% key = "refund_action_required_message.order_#{shipments.shipped_but_canceled.any? ? 'refunded' : 'canceled'}.#{order.partially_refunded? ? 'partially' : 'fully'}" %>
+ <% i18n_key_suffix = "#{shipments.shipped_but_canceled.any? ? 'refunded' : 'canceled'}.#{order.partially_refunded? ? 'partially' : 'fully'}" %>
+
+ <% if order.respond_to?(:gift_card) && order.gift_card.present? %>
+ <% key = "storefront.refund_action_required_message.order_#{i18n_key_suffix}" %>
<%= Spree.t(key, customer_support_email: order.store.customer_support_email ) %>
<% else %>
- <% key = "refund_action_not_required_message.order_#{shipments.shipped_but_canceled.any? ? 'refunded' : 'canceled'}.#{order.partially_refunded? ? 'partially' : 'fully'}" %>
+ <% key = "storefront.refund_action_not_required_message.order_#{i18n_key_suffix}" %>
<%= Spree.t(key) %>
<% end %>
</div>
diff --git a/storefront/config/i18n-tasks.yml b/storefront/config/i18n-tasks.yml
index 636f960102..98ebf81dbd 100644
--- a/storefront/config/i18n-tasks.yml
+++ b/storefront/config/i18n-tasks.yml
@@ -143,12 +143,9 @@ search:
# - '{devise,simple_form}.*'
## Consider these keys used:
-# ignore_unused:
-# - 'activerecord.attributes.*'
-# - '{devise,kaminari,will_paginate}.*'
-# - 'simple_form.{yes,no}'
-# - 'simple_form.{placeholders,hints,labels}.*'
-# - 'simple_form.{error_notification,required}.:'
+ignore_unused:
+- 'spree.storefront.refund_action_not_required_message.*'
+- 'spree.storefront.refund_action_required_message.*'
## Exclude these keys from the `i18n-tasks eq-base' report:
# ignore_eq_base:
diff --git a/storefront/config/locales/en.yml b/storefront/config/locales/en.yml
index b18220efff..f1c4cd73e2 100644
--- a/storefront/config/locales/en.yml
+++ b/storefront/config/locales/en.yml
@@ -49,6 +49,20 @@ en:
description: Take control of your settings and tailor your experience according to your preferences. Customize your notifications to suit your needs.
join: Email me about new products, sales, and more. You can unsubscribe at any time.
status: You are currently %{status} to the newsletters.
+ refund_action_not_required_message:
+ order_canceled:
+ fully: This order has been canceled. No further action is required. You will receive a refund within couple business days.
+ partially: This order has been partially canceled. No further action is required. You will receive a refund within couple business days.
+ order_refunded:
+ fully: This order has been refunded. No further action is required. You will receive a refund within couple business days.
+ partially: This order has been partially refunded. No further action is required. You will receive a refund within couple business days.
+ refund_action_required_message:
+ order_canceled:
+ fully: This order has been canceled. The amount paid by the selected payment method will be refunded within couple business days. Please reach out to %{customer_support_email} to receive new voucher.
+ partially: This order has been partially canceled. The amount paid by the selected payment method will be refunded within couple business days. Please reach out to %{customer_support_email} to receive new voucher.
+ order_refunded:
+ fully: This order has been refunded. The amount paid by the selected payment method will be refunded within couple business days. Please reach out to %{customer_support_email} to receive new voucher.
+ partially: This order has been partially refunded. The amount paid by the selected payment method will be refunded within couple business days. Please reach out to %{customer_support_email} to receive new voucher.
variant_picker:
please_choose: Please choose %{option_type}
wished_items: